babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310
  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/Maths/math.scalar" {
  496. /**
  497. * Scalar computation library
  498. */
  499. export class Scalar {
  500. /**
  501. * Two pi constants convenient for computation.
  502. */
  503. static TwoPi: number;
  504. /**
  505. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  506. * @param a number
  507. * @param b number
  508. * @param epsilon (default = 1.401298E-45)
  509. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  510. */
  511. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  512. /**
  513. * Returns a string : the upper case translation of the number i to hexadecimal.
  514. * @param i number
  515. * @returns the upper case translation of the number i to hexadecimal.
  516. */
  517. static ToHex(i: number): string;
  518. /**
  519. * Returns -1 if value is negative and +1 is value is positive.
  520. * @param value the value
  521. * @returns the value itself if it's equal to zero.
  522. */
  523. static Sign(value: number): number;
  524. /**
  525. * Returns the value itself if it's between min and max.
  526. * Returns min if the value is lower than min.
  527. * Returns max if the value is greater than max.
  528. * @param value the value to clmap
  529. * @param min the min value to clamp to (default: 0)
  530. * @param max the max value to clamp to (default: 1)
  531. * @returns the clamped value
  532. */
  533. static Clamp(value: number, min?: number, max?: number): number;
  534. /**
  535. * the log2 of value.
  536. * @param value the value to compute log2 of
  537. * @returns the log2 of value.
  538. */
  539. static Log2(value: number): number;
  540. /**
  541. * Loops the value, so that it is never larger than length and never smaller than 0.
  542. *
  543. * This is similar to the modulo operator but it works with floating point numbers.
  544. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  545. * With t = 5 and length = 2.5, the result would be 0.0.
  546. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  547. * @param value the value
  548. * @param length the length
  549. * @returns the looped value
  550. */
  551. static Repeat(value: number, length: number): number;
  552. /**
  553. * Normalize the value between 0.0 and 1.0 using min and max values
  554. * @param value value to normalize
  555. * @param min max to normalize between
  556. * @param max min to normalize between
  557. * @returns the normalized value
  558. */
  559. static Normalize(value: number, min: number, max: number): number;
  560. /**
  561. * Denormalize the value from 0.0 and 1.0 using min and max values
  562. * @param normalized value to denormalize
  563. * @param min max to denormalize between
  564. * @param max min to denormalize between
  565. * @returns the denormalized value
  566. */
  567. static Denormalize(normalized: number, min: number, max: number): number;
  568. /**
  569. * Calculates the shortest difference between two given angles given in degrees.
  570. * @param current current angle in degrees
  571. * @param target target angle in degrees
  572. * @returns the delta
  573. */
  574. static DeltaAngle(current: number, target: number): number;
  575. /**
  576. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  577. * @param tx value
  578. * @param length length
  579. * @returns The returned value will move back and forth between 0 and length
  580. */
  581. static PingPong(tx: number, length: number): number;
  582. /**
  583. * Interpolates between min and max with smoothing at the limits.
  584. *
  585. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  586. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  587. * @param from from
  588. * @param to to
  589. * @param tx value
  590. * @returns the smooth stepped value
  591. */
  592. static SmoothStep(from: number, to: number, tx: number): number;
  593. /**
  594. * Moves a value current towards target.
  595. *
  596. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  597. * Negative values of maxDelta pushes the value away from target.
  598. * @param current current value
  599. * @param target target value
  600. * @param maxDelta max distance to move
  601. * @returns resulting value
  602. */
  603. static MoveTowards(current: number, target: number, maxDelta: number): number;
  604. /**
  605. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  606. *
  607. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  608. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  609. * @param current current value
  610. * @param target target value
  611. * @param maxDelta max distance to move
  612. * @returns resulting angle
  613. */
  614. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  615. /**
  616. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  617. * @param start start value
  618. * @param end target value
  619. * @param amount amount to lerp between
  620. * @returns the lerped value
  621. */
  622. static Lerp(start: number, end: number, amount: number): number;
  623. /**
  624. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  625. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  626. * @param start start value
  627. * @param end target value
  628. * @param amount amount to lerp between
  629. * @returns the lerped value
  630. */
  631. static LerpAngle(start: number, end: number, amount: number): number;
  632. /**
  633. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  634. * @param a start value
  635. * @param b target value
  636. * @param value value between a and b
  637. * @returns the inverseLerp value
  638. */
  639. static InverseLerp(a: number, b: number, value: number): number;
  640. /**
  641. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  642. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  643. * @param value1 spline value
  644. * @param tangent1 spline value
  645. * @param value2 spline value
  646. * @param tangent2 spline value
  647. * @param amount input value
  648. * @returns hermite result
  649. */
  650. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  651. /**
  652. * Returns a random float number between and min and max values
  653. * @param min min value of random
  654. * @param max max value of random
  655. * @returns random value
  656. */
  657. static RandomRange(min: number, max: number): number;
  658. /**
  659. * This function returns percentage of a number in a given range.
  660. *
  661. * RangeToPercent(40,20,60) will return 0.5 (50%)
  662. * RangeToPercent(34,0,100) will return 0.34 (34%)
  663. * @param number to convert to percentage
  664. * @param min min range
  665. * @param max max range
  666. * @returns the percentage
  667. */
  668. static RangeToPercent(number: number, min: number, max: number): number;
  669. /**
  670. * This function returns number that corresponds to the percentage in a given range.
  671. *
  672. * PercentToRange(0.34,0,100) will return 34.
  673. * @param percent to convert to number
  674. * @param min min range
  675. * @param max max range
  676. * @returns the number
  677. */
  678. static PercentToRange(percent: number, min: number, max: number): number;
  679. /**
  680. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  681. * @param angle The angle to normalize in radian.
  682. * @return The converted angle.
  683. */
  684. static NormalizeRadians(angle: number): number;
  685. }
  686. }
  687. declare module "babylonjs/Maths/math.constants" {
  688. /**
  689. * Constant used to convert a value to gamma space
  690. * @ignorenaming
  691. */
  692. export const ToGammaSpace: number;
  693. /**
  694. * Constant used to convert a value to linear space
  695. * @ignorenaming
  696. */
  697. export const ToLinearSpace = 2.2;
  698. /**
  699. * Constant used to define the minimal number value in Babylon.js
  700. * @ignorenaming
  701. */
  702. let Epsilon: number;
  703. export { Epsilon };
  704. }
  705. declare module "babylonjs/Maths/math.viewport" {
  706. /**
  707. * Class used to represent a viewport on screen
  708. */
  709. export class Viewport {
  710. /** viewport left coordinate */
  711. x: number;
  712. /** viewport top coordinate */
  713. y: number;
  714. /**viewport width */
  715. width: number;
  716. /** viewport height */
  717. height: number;
  718. /**
  719. * Creates a Viewport object located at (x, y) and sized (width, height)
  720. * @param x defines viewport left coordinate
  721. * @param y defines viewport top coordinate
  722. * @param width defines the viewport width
  723. * @param height defines the viewport height
  724. */
  725. constructor(
  726. /** viewport left coordinate */
  727. x: number,
  728. /** viewport top coordinate */
  729. y: number,
  730. /**viewport width */
  731. width: number,
  732. /** viewport height */
  733. height: number);
  734. /**
  735. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  736. * @param renderWidth defines the rendering width
  737. * @param renderHeight defines the rendering height
  738. * @returns a new Viewport
  739. */
  740. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  741. /**
  742. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  743. * @param renderWidth defines the rendering width
  744. * @param renderHeight defines the rendering height
  745. * @param ref defines the target viewport
  746. * @returns the current viewport
  747. */
  748. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  749. /**
  750. * Returns a new Viewport copied from the current one
  751. * @returns a new Viewport
  752. */
  753. clone(): Viewport;
  754. }
  755. }
  756. declare module "babylonjs/Misc/arrayTools" {
  757. /**
  758. * Class containing a set of static utilities functions for arrays.
  759. */
  760. export class ArrayTools {
  761. /**
  762. * Returns an array of the given size filled with element built from the given constructor and the paramters
  763. * @param size the number of element to construct and put in the array
  764. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  765. * @returns a new array filled with new objects
  766. */
  767. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  768. }
  769. }
  770. declare module "babylonjs/Maths/math.like" {
  771. import { float, int, DeepImmutable } from "babylonjs/types";
  772. /**
  773. * @hidden
  774. */
  775. export interface IColor4Like {
  776. r: float;
  777. g: float;
  778. b: float;
  779. a: float;
  780. }
  781. /**
  782. * @hidden
  783. */
  784. export interface IColor3Like {
  785. r: float;
  786. g: float;
  787. b: float;
  788. }
  789. /**
  790. * @hidden
  791. */
  792. export interface IVector4Like {
  793. x: float;
  794. y: float;
  795. z: float;
  796. w: float;
  797. }
  798. /**
  799. * @hidden
  800. */
  801. export interface IVector3Like {
  802. x: float;
  803. y: float;
  804. z: float;
  805. }
  806. /**
  807. * @hidden
  808. */
  809. export interface IVector2Like {
  810. x: float;
  811. y: float;
  812. }
  813. /**
  814. * @hidden
  815. */
  816. export interface IMatrixLike {
  817. toArray(): DeepImmutable<Float32Array>;
  818. updateFlag: int;
  819. }
  820. /**
  821. * @hidden
  822. */
  823. export interface IViewportLike {
  824. x: float;
  825. y: float;
  826. width: float;
  827. height: float;
  828. }
  829. /**
  830. * @hidden
  831. */
  832. export interface IPlaneLike {
  833. normal: IVector3Like;
  834. d: float;
  835. normalize(): void;
  836. }
  837. }
  838. declare module "babylonjs/Maths/math.vector" {
  839. import { Viewport } from "babylonjs/Maths/math.viewport";
  840. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  841. import { IPlaneLike } from "babylonjs/Maths/math.like";
  842. /**
  843. * Class representing a vector containing 2 coordinates
  844. */
  845. export class Vector2 {
  846. /** defines the first coordinate */
  847. x: number;
  848. /** defines the second coordinate */
  849. y: number;
  850. /**
  851. * Creates a new Vector2 from the given x and y coordinates
  852. * @param x defines the first coordinate
  853. * @param y defines the second coordinate
  854. */
  855. constructor(
  856. /** defines the first coordinate */
  857. x?: number,
  858. /** defines the second coordinate */
  859. y?: number);
  860. /**
  861. * Gets a string with the Vector2 coordinates
  862. * @returns a string with the Vector2 coordinates
  863. */
  864. toString(): string;
  865. /**
  866. * Gets class name
  867. * @returns the string "Vector2"
  868. */
  869. getClassName(): string;
  870. /**
  871. * Gets current vector hash code
  872. * @returns the Vector2 hash code as a number
  873. */
  874. getHashCode(): number;
  875. /**
  876. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  877. * @param array defines the source array
  878. * @param index defines the offset in source array
  879. * @returns the current Vector2
  880. */
  881. toArray(array: FloatArray, index?: number): Vector2;
  882. /**
  883. * Copy the current vector to an array
  884. * @returns a new array with 2 elements: the Vector2 coordinates.
  885. */
  886. asArray(): number[];
  887. /**
  888. * Sets the Vector2 coordinates with the given Vector2 coordinates
  889. * @param source defines the source Vector2
  890. * @returns the current updated Vector2
  891. */
  892. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  893. /**
  894. * Sets the Vector2 coordinates with the given floats
  895. * @param x defines the first coordinate
  896. * @param y defines the second coordinate
  897. * @returns the current updated Vector2
  898. */
  899. copyFromFloats(x: number, y: number): Vector2;
  900. /**
  901. * Sets the Vector2 coordinates with the given floats
  902. * @param x defines the first coordinate
  903. * @param y defines the second coordinate
  904. * @returns the current updated Vector2
  905. */
  906. set(x: number, y: number): Vector2;
  907. /**
  908. * Add another vector with the current one
  909. * @param otherVector defines the other vector
  910. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  911. */
  912. add(otherVector: DeepImmutable<Vector2>): Vector2;
  913. /**
  914. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  915. * @param otherVector defines the other vector
  916. * @param result defines the target vector
  917. * @returns the unmodified current Vector2
  918. */
  919. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  920. /**
  921. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  922. * @param otherVector defines the other vector
  923. * @returns the current updated Vector2
  924. */
  925. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  926. /**
  927. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  928. * @param otherVector defines the other vector
  929. * @returns a new Vector2
  930. */
  931. addVector3(otherVector: Vector3): Vector2;
  932. /**
  933. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. subtract(otherVector: Vector2): Vector2;
  938. /**
  939. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  940. * @param otherVector defines the other vector
  941. * @param result defines the target vector
  942. * @returns the unmodified current Vector2
  943. */
  944. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  945. /**
  946. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns the current updated Vector2
  949. */
  950. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Multiplies in place the current Vector2 coordinates by the given ones
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  959. * @param otherVector defines the other vector
  960. * @returns a new Vector2
  961. */
  962. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @param result defines the target vector
  967. * @returns the unmodified current Vector2
  968. */
  969. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  970. /**
  971. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  972. * @param x defines the first coordinate
  973. * @param y defines the second coordinate
  974. * @returns a new Vector2
  975. */
  976. multiplyByFloats(x: number, y: number): Vector2;
  977. /**
  978. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  979. * @param otherVector defines the other vector
  980. * @returns a new Vector2
  981. */
  982. divide(otherVector: Vector2): Vector2;
  983. /**
  984. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @param result defines the target vector
  987. * @returns the unmodified current Vector2
  988. */
  989. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  990. /**
  991. * Divides the current Vector2 coordinates by the given ones
  992. * @param otherVector defines the other vector
  993. * @returns the current updated Vector2
  994. */
  995. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  996. /**
  997. * Gets a new Vector2 with current Vector2 negated coordinates
  998. * @returns a new Vector2
  999. */
  1000. negate(): Vector2;
  1001. /**
  1002. * Multiply the Vector2 coordinates by scale
  1003. * @param scale defines the scaling factor
  1004. * @returns the current updated Vector2
  1005. */
  1006. scaleInPlace(scale: number): Vector2;
  1007. /**
  1008. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1009. * @param scale defines the scaling factor
  1010. * @returns a new Vector2
  1011. */
  1012. scale(scale: number): Vector2;
  1013. /**
  1014. * Scale the current Vector2 values by a factor to a given Vector2
  1015. * @param scale defines the scale factor
  1016. * @param result defines the Vector2 object where to store the result
  1017. * @returns the unmodified current Vector2
  1018. */
  1019. scaleToRef(scale: number, result: Vector2): Vector2;
  1020. /**
  1021. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1022. * @param scale defines the scale factor
  1023. * @param result defines the Vector2 object where to store the result
  1024. * @returns the unmodified current Vector2
  1025. */
  1026. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1027. /**
  1028. * Gets a boolean if two vectors are equals
  1029. * @param otherVector defines the other vector
  1030. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1031. */
  1032. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1033. /**
  1034. * Gets a boolean if two vectors are equals (using an epsilon value)
  1035. * @param otherVector defines the other vector
  1036. * @param epsilon defines the minimal distance to consider equality
  1037. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1038. */
  1039. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1040. /**
  1041. * Gets a new Vector2 from current Vector2 floored values
  1042. * @returns a new Vector2
  1043. */
  1044. floor(): Vector2;
  1045. /**
  1046. * Gets a new Vector2 from current Vector2 floored values
  1047. * @returns a new Vector2
  1048. */
  1049. fract(): Vector2;
  1050. /**
  1051. * Gets the length of the vector
  1052. * @returns the vector length (float)
  1053. */
  1054. length(): number;
  1055. /**
  1056. * Gets the vector squared length
  1057. * @returns the vector squared length (float)
  1058. */
  1059. lengthSquared(): number;
  1060. /**
  1061. * Normalize the vector
  1062. * @returns the current updated Vector2
  1063. */
  1064. normalize(): Vector2;
  1065. /**
  1066. * Gets a new Vector2 copied from the Vector2
  1067. * @returns a new Vector2
  1068. */
  1069. clone(): Vector2;
  1070. /**
  1071. * Gets a new Vector2(0, 0)
  1072. * @returns a new Vector2
  1073. */
  1074. static Zero(): Vector2;
  1075. /**
  1076. * Gets a new Vector2(1, 1)
  1077. * @returns a new Vector2
  1078. */
  1079. static One(): Vector2;
  1080. /**
  1081. * Gets a new Vector2 set from the given index element of the given array
  1082. * @param array defines the data source
  1083. * @param offset defines the offset in the data source
  1084. * @returns a new Vector2
  1085. */
  1086. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1087. /**
  1088. * Sets "result" from the given index element of the given array
  1089. * @param array defines the data source
  1090. * @param offset defines the offset in the data source
  1091. * @param result defines the target vector
  1092. */
  1093. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1094. /**
  1095. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1096. * @param value1 defines 1st point of control
  1097. * @param value2 defines 2nd point of control
  1098. * @param value3 defines 3rd point of control
  1099. * @param value4 defines 4th point of control
  1100. * @param amount defines the interpolation factor
  1101. * @returns a new Vector2
  1102. */
  1103. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1104. /**
  1105. * 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".
  1106. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1107. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1108. * @param value defines the value to clamp
  1109. * @param min defines the lower limit
  1110. * @param max defines the upper limit
  1111. * @returns a new Vector2
  1112. */
  1113. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1116. * @param value1 defines the 1st control point
  1117. * @param tangent1 defines the outgoing tangent
  1118. * @param value2 defines the 2nd control point
  1119. * @param tangent2 defines the incoming tangent
  1120. * @param amount defines the interpolation factor
  1121. * @returns a new Vector2
  1122. */
  1123. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1124. /**
  1125. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1126. * @param start defines the start vector
  1127. * @param end defines the end vector
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Gets the dot product of the vector "left" and the vector "right"
  1134. * @param left defines first vector
  1135. * @param right defines second vector
  1136. * @returns the dot product (float)
  1137. */
  1138. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1139. /**
  1140. * Returns a new Vector2 equal to the normalized given vector
  1141. * @param vector defines the vector to normalize
  1142. * @returns a new Vector2
  1143. */
  1144. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1145. /**
  1146. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1147. * @param left defines 1st vector
  1148. * @param right defines 2nd vector
  1149. * @returns a new Vector2
  1150. */
  1151. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1152. /**
  1153. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1154. * @param left defines 1st vector
  1155. * @param right defines 2nd vector
  1156. * @returns a new Vector2
  1157. */
  1158. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1159. /**
  1160. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1161. * @param vector defines the vector to transform
  1162. * @param transformation defines the matrix to apply
  1163. * @returns a new Vector2
  1164. */
  1165. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1166. /**
  1167. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1168. * @param vector defines the vector to transform
  1169. * @param transformation defines the matrix to apply
  1170. * @param result defines the target vector
  1171. */
  1172. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1173. /**
  1174. * Determines if a given vector is included in a triangle
  1175. * @param p defines the vector to test
  1176. * @param p0 defines 1st triangle point
  1177. * @param p1 defines 2nd triangle point
  1178. * @param p2 defines 3rd triangle point
  1179. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1180. */
  1181. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1182. /**
  1183. * Gets the distance between the vectors "value1" and "value2"
  1184. * @param value1 defines first vector
  1185. * @param value2 defines second vector
  1186. * @returns the distance between vectors
  1187. */
  1188. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1189. /**
  1190. * Returns the squared distance between the vectors "value1" and "value2"
  1191. * @param value1 defines first vector
  1192. * @param value2 defines second vector
  1193. * @returns the squared distance between vectors
  1194. */
  1195. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1196. /**
  1197. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1198. * @param value1 defines first vector
  1199. * @param value2 defines second vector
  1200. * @returns a new Vector2
  1201. */
  1202. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1203. /**
  1204. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1205. * @param p defines the middle point
  1206. * @param segA defines one point of the segment
  1207. * @param segB defines the other point of the segment
  1208. * @returns the shortest distance
  1209. */
  1210. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1211. }
  1212. /**
  1213. * Classed used to store (x,y,z) vector representation
  1214. * A Vector3 is the main object used in 3D geometry
  1215. * It can represent etiher the coordinates of a point the space, either a direction
  1216. * Reminder: js uses a left handed forward facing system
  1217. */
  1218. export class Vector3 {
  1219. /**
  1220. * Defines the first coordinates (on X axis)
  1221. */
  1222. x: number;
  1223. /**
  1224. * Defines the second coordinates (on Y axis)
  1225. */
  1226. y: number;
  1227. /**
  1228. * Defines the third coordinates (on Z axis)
  1229. */
  1230. z: number;
  1231. private static _UpReadOnly;
  1232. private static _ZeroReadOnly;
  1233. /**
  1234. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1235. * @param x defines the first coordinates (on X axis)
  1236. * @param y defines the second coordinates (on Y axis)
  1237. * @param z defines the third coordinates (on Z axis)
  1238. */
  1239. constructor(
  1240. /**
  1241. * Defines the first coordinates (on X axis)
  1242. */
  1243. x?: number,
  1244. /**
  1245. * Defines the second coordinates (on Y axis)
  1246. */
  1247. y?: number,
  1248. /**
  1249. * Defines the third coordinates (on Z axis)
  1250. */
  1251. z?: number);
  1252. /**
  1253. * Creates a string representation of the Vector3
  1254. * @returns a string with the Vector3 coordinates.
  1255. */
  1256. toString(): string;
  1257. /**
  1258. * Gets the class name
  1259. * @returns the string "Vector3"
  1260. */
  1261. getClassName(): string;
  1262. /**
  1263. * Creates the Vector3 hash code
  1264. * @returns a number which tends to be unique between Vector3 instances
  1265. */
  1266. getHashCode(): number;
  1267. /**
  1268. * Creates an array containing three elements : the coordinates of the Vector3
  1269. * @returns a new array of numbers
  1270. */
  1271. asArray(): number[];
  1272. /**
  1273. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1274. * @param array defines the destination array
  1275. * @param index defines the offset in the destination array
  1276. * @returns the current Vector3
  1277. */
  1278. toArray(array: FloatArray, index?: number): Vector3;
  1279. /**
  1280. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1281. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1282. */
  1283. toQuaternion(): Quaternion;
  1284. /**
  1285. * Adds the given vector to the current Vector3
  1286. * @param otherVector defines the second operand
  1287. * @returns the current updated Vector3
  1288. */
  1289. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1290. /**
  1291. * Adds the given coordinates to the current Vector3
  1292. * @param x defines the x coordinate of the operand
  1293. * @param y defines the y coordinate of the operand
  1294. * @param z defines the z coordinate of the operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1298. /**
  1299. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1300. * @param otherVector defines the second operand
  1301. * @returns the resulting Vector3
  1302. */
  1303. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1306. * @param otherVector defines the second operand
  1307. * @param result defines the Vector3 object where to store the result
  1308. * @returns the current Vector3
  1309. */
  1310. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1311. /**
  1312. * Subtract the given vector from the current Vector3
  1313. * @param otherVector defines the second operand
  1314. * @returns the current updated Vector3
  1315. */
  1316. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1317. /**
  1318. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the resulting Vector3
  1321. */
  1322. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1325. * @param otherVector defines the second operand
  1326. * @param result defines the Vector3 object where to store the result
  1327. * @returns the current Vector3
  1328. */
  1329. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1330. /**
  1331. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1332. * @param x defines the x coordinate of the operand
  1333. * @param y defines the y coordinate of the operand
  1334. * @param z defines the z coordinate of the operand
  1335. * @returns the resulting Vector3
  1336. */
  1337. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1338. /**
  1339. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @param result defines the Vector3 object where to store the result
  1344. * @returns the current Vector3
  1345. */
  1346. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1347. /**
  1348. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1349. * @returns a new Vector3
  1350. */
  1351. negate(): Vector3;
  1352. /**
  1353. * Multiplies the Vector3 coordinates by the float "scale"
  1354. * @param scale defines the multiplier factor
  1355. * @returns the current updated Vector3
  1356. */
  1357. scaleInPlace(scale: number): Vector3;
  1358. /**
  1359. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns a new Vector3
  1362. */
  1363. scale(scale: number): Vector3;
  1364. /**
  1365. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1366. * @param scale defines the multiplier factor
  1367. * @param result defines the Vector3 object where to store the result
  1368. * @returns the current Vector3
  1369. */
  1370. scaleToRef(scale: number, result: Vector3): Vector3;
  1371. /**
  1372. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1373. * @param scale defines the scale factor
  1374. * @param result defines the Vector3 object where to store the result
  1375. * @returns the unmodified current Vector3
  1376. */
  1377. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1378. /**
  1379. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1380. * @param otherVector defines the second operand
  1381. * @returns true if both vectors are equals
  1382. */
  1383. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1386. * @param otherVector defines the second operand
  1387. * @param epsilon defines the minimal distance to define values as equals
  1388. * @returns true if both vectors are distant less than epsilon
  1389. */
  1390. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1391. /**
  1392. * Returns true if the current Vector3 coordinates equals the given floats
  1393. * @param x defines the x coordinate of the operand
  1394. * @param y defines the y coordinate of the operand
  1395. * @param z defines the z coordinate of the operand
  1396. * @returns true if both vectors are equals
  1397. */
  1398. equalsToFloats(x: number, y: number, z: number): boolean;
  1399. /**
  1400. * Multiplies the current Vector3 coordinates by the given ones
  1401. * @param otherVector defines the second operand
  1402. * @returns the current updated Vector3
  1403. */
  1404. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1405. /**
  1406. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1407. * @param otherVector defines the second operand
  1408. * @returns the new Vector3
  1409. */
  1410. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1413. * @param otherVector defines the second operand
  1414. * @param result defines the Vector3 object where to store the result
  1415. * @returns the current Vector3
  1416. */
  1417. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1418. /**
  1419. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1420. * @param x defines the x coordinate of the operand
  1421. * @param y defines the y coordinate of the operand
  1422. * @param z defines the z coordinate of the operand
  1423. * @returns the new Vector3
  1424. */
  1425. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1428. * @param otherVector defines the second operand
  1429. * @returns the new Vector3
  1430. */
  1431. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1432. /**
  1433. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1434. * @param otherVector defines the second operand
  1435. * @param result defines the Vector3 object where to store the result
  1436. * @returns the current Vector3
  1437. */
  1438. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1439. /**
  1440. * Divides the current Vector3 coordinates by the given ones.
  1441. * @param otherVector defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. divideInPlace(otherVector: Vector3): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1447. * @param other defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1459. * @param x defines the x coordinate of the operand
  1460. * @param y defines the y coordinate of the operand
  1461. * @param z defines the z coordinate of the operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1475. * Check if is non uniform within a certain amount of decimal places to account for this
  1476. * @param epsilon the amount the values can differ
  1477. * @returns if the the vector is non uniform to a certain number of decimal places
  1478. */
  1479. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1480. /**
  1481. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1482. */
  1483. readonly isNonUniform: boolean;
  1484. /**
  1485. * Gets a new Vector3 from current Vector3 floored values
  1486. * @returns a new Vector3
  1487. */
  1488. floor(): Vector3;
  1489. /**
  1490. * Gets a new Vector3 from current Vector3 floored values
  1491. * @returns a new Vector3
  1492. */
  1493. fract(): Vector3;
  1494. /**
  1495. * Gets the length of the Vector3
  1496. * @returns the length of the Vector3
  1497. */
  1498. length(): number;
  1499. /**
  1500. * Gets the squared length of the Vector3
  1501. * @returns squared length of the Vector3
  1502. */
  1503. lengthSquared(): number;
  1504. /**
  1505. * Normalize the current Vector3.
  1506. * Please note that this is an in place operation.
  1507. * @returns the current updated Vector3
  1508. */
  1509. normalize(): Vector3;
  1510. /**
  1511. * Reorders the x y z properties of the vector in place
  1512. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1513. * @returns the current updated vector
  1514. */
  1515. reorderInPlace(order: string): this;
  1516. /**
  1517. * Rotates the vector around 0,0,0 by a quaternion
  1518. * @param quaternion the rotation quaternion
  1519. * @param result vector to store the result
  1520. * @returns the resulting vector
  1521. */
  1522. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1523. /**
  1524. * Rotates a vector around a given point
  1525. * @param quaternion the rotation quaternion
  1526. * @param point the point to rotate around
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1531. /**
  1532. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1533. * The cross product is then orthogonal to both current and "other"
  1534. * @param other defines the right operand
  1535. * @returns the cross product
  1536. */
  1537. cross(other: Vector3): Vector3;
  1538. /**
  1539. * Normalize the current Vector3 with the given input length.
  1540. * Please note that this is an in place operation.
  1541. * @param len the length of the vector
  1542. * @returns the current updated Vector3
  1543. */
  1544. normalizeFromLength(len: number): Vector3;
  1545. /**
  1546. * Normalize the current Vector3 to a new vector
  1547. * @returns the new Vector3
  1548. */
  1549. normalizeToNew(): Vector3;
  1550. /**
  1551. * Normalize the current Vector3 to the reference
  1552. * @param reference define the Vector3 to update
  1553. * @returns the updated Vector3
  1554. */
  1555. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1556. /**
  1557. * Creates a new Vector3 copied from the current Vector3
  1558. * @returns the new Vector3
  1559. */
  1560. clone(): Vector3;
  1561. /**
  1562. * Copies the given vector coordinates to the current Vector3 ones
  1563. * @param source defines the source Vector3
  1564. * @returns the current updated Vector3
  1565. */
  1566. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1567. /**
  1568. * Copies the given floats to the current Vector3 coordinates
  1569. * @param x defines the x coordinate of the operand
  1570. * @param y defines the y coordinate of the operand
  1571. * @param z defines the z coordinate of the operand
  1572. * @returns the current updated Vector3
  1573. */
  1574. copyFromFloats(x: number, y: number, z: number): Vector3;
  1575. /**
  1576. * Copies the given floats to the current Vector3 coordinates
  1577. * @param x defines the x coordinate of the operand
  1578. * @param y defines the y coordinate of the operand
  1579. * @param z defines the z coordinate of the operand
  1580. * @returns the current updated Vector3
  1581. */
  1582. set(x: number, y: number, z: number): Vector3;
  1583. /**
  1584. * Copies the given float to the current Vector3 coordinates
  1585. * @param v defines the x, y and z coordinates of the operand
  1586. * @returns the current updated Vector3
  1587. */
  1588. setAll(v: number): Vector3;
  1589. /**
  1590. * Get the clip factor between two vectors
  1591. * @param vector0 defines the first operand
  1592. * @param vector1 defines the second operand
  1593. * @param axis defines the axis to use
  1594. * @param size defines the size along the axis
  1595. * @returns the clip factor
  1596. */
  1597. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1598. /**
  1599. * Get angle between two vectors
  1600. * @param vector0 angle between vector0 and vector1
  1601. * @param vector1 angle between vector0 and vector1
  1602. * @param normal direction of the normal
  1603. * @return the angle between vector0 and vector1
  1604. */
  1605. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1606. /**
  1607. * Returns a new Vector3 set from the index "offset" of the given array
  1608. * @param array defines the source array
  1609. * @param offset defines the offset in the source array
  1610. * @returns the new Vector3
  1611. */
  1612. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1613. /**
  1614. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1615. * This function is deprecated. Use FromArray instead
  1616. * @param array defines the source array
  1617. * @param offset defines the offset in the source array
  1618. * @returns the new Vector3
  1619. */
  1620. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1621. /**
  1622. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1623. * @param array defines the source array
  1624. * @param offset defines the offset in the source array
  1625. * @param result defines the Vector3 where to store the result
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1628. /**
  1629. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1630. * This function is deprecated. Use FromArrayToRef instead.
  1631. * @param array defines the source array
  1632. * @param offset defines the offset in the source array
  1633. * @param result defines the Vector3 where to store the result
  1634. */
  1635. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1636. /**
  1637. * Sets the given vector "result" with the given floats.
  1638. * @param x defines the x coordinate of the source
  1639. * @param y defines the y coordinate of the source
  1640. * @param z defines the z coordinate of the source
  1641. * @param result defines the Vector3 where to store the result
  1642. */
  1643. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1646. * @returns a new empty Vector3
  1647. */
  1648. static Zero(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1651. * @returns a new unit Vector3
  1652. */
  1653. static One(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1656. * @returns a new up Vector3
  1657. */
  1658. static Up(): Vector3;
  1659. /**
  1660. * Gets a up Vector3 that must not be updated
  1661. */
  1662. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1663. /**
  1664. * Gets a zero Vector3 that must not be updated
  1665. */
  1666. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1667. /**
  1668. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1669. * @returns a new down Vector3
  1670. */
  1671. static Down(): Vector3;
  1672. /**
  1673. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1674. * @returns a new forward Vector3
  1675. */
  1676. static Forward(): Vector3;
  1677. /**
  1678. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1679. * @returns a new forward Vector3
  1680. */
  1681. static Backward(): Vector3;
  1682. /**
  1683. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1684. * @returns a new right Vector3
  1685. */
  1686. static Right(): Vector3;
  1687. /**
  1688. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1689. * @returns a new left Vector3
  1690. */
  1691. static Left(): Vector3;
  1692. /**
  1693. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1694. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1695. * @param vector defines the Vector3 to transform
  1696. * @param transformation defines the transformation matrix
  1697. * @returns the transformed Vector3
  1698. */
  1699. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1700. /**
  1701. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1702. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1703. * @param vector defines the Vector3 to transform
  1704. * @param transformation defines the transformation matrix
  1705. * @param result defines the Vector3 where to store the result
  1706. */
  1707. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1708. /**
  1709. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1710. * This method computes tranformed coordinates only, not transformed direction vectors
  1711. * @param x define the x coordinate of the source vector
  1712. * @param y define the y coordinate of the source vector
  1713. * @param z define the z coordinate of the source vector
  1714. * @param transformation defines the transformation matrix
  1715. * @param result defines the Vector3 where to store the result
  1716. */
  1717. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1718. /**
  1719. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1720. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1721. * @param vector defines the Vector3 to transform
  1722. * @param transformation defines the transformation matrix
  1723. * @returns the new Vector3
  1724. */
  1725. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1726. /**
  1727. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1728. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1729. * @param vector defines the Vector3 to transform
  1730. * @param transformation defines the transformation matrix
  1731. * @param result defines the Vector3 where to store the result
  1732. */
  1733. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1734. /**
  1735. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1736. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1737. * @param x define the x coordinate of the source vector
  1738. * @param y define the y coordinate of the source vector
  1739. * @param z define the z coordinate of the source vector
  1740. * @param transformation defines the transformation matrix
  1741. * @param result defines the Vector3 where to store the result
  1742. */
  1743. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1744. /**
  1745. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1746. * @param value1 defines the first control point
  1747. * @param value2 defines the second control point
  1748. * @param value3 defines the third control point
  1749. * @param value4 defines the fourth control point
  1750. * @param amount defines the amount on the spline to use
  1751. * @returns the new Vector3
  1752. */
  1753. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1754. /**
  1755. * 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"
  1756. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1757. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1758. * @param value defines the current value
  1759. * @param min defines the lower range value
  1760. * @param max defines the upper range value
  1761. * @returns the new Vector3
  1762. */
  1763. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1764. /**
  1765. * 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"
  1766. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1767. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1768. * @param value defines the current value
  1769. * @param min defines the lower range value
  1770. * @param max defines the upper range value
  1771. * @param result defines the Vector3 where to store the result
  1772. */
  1773. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1774. /**
  1775. * Checks if a given vector is inside a specific range
  1776. * @param v defines the vector to test
  1777. * @param min defines the minimum range
  1778. * @param max defines the maximum range
  1779. */
  1780. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1781. /**
  1782. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1783. * @param value1 defines the first control point
  1784. * @param tangent1 defines the first tangent vector
  1785. * @param value2 defines the second control point
  1786. * @param tangent2 defines the second tangent vector
  1787. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @returns the new Vector3
  1797. */
  1798. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1799. /**
  1800. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1801. * @param start defines the start value
  1802. * @param end defines the end value
  1803. * @param amount max defines amount between both (between 0 and 1)
  1804. * @param result defines the Vector3 where to store the result
  1805. */
  1806. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1807. /**
  1808. * Returns the dot product (float) between the vectors "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the dot product
  1812. */
  1813. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1814. /**
  1815. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @returns the cross product
  1820. */
  1821. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1822. /**
  1823. * Sets the given vector "result" with the cross product of "left" and "right"
  1824. * The cross product is then orthogonal to both "left" and "right"
  1825. * @param left defines the left operand
  1826. * @param right defines the right operand
  1827. * @param result defines the Vector3 where to store the result
  1828. */
  1829. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1830. /**
  1831. * Returns a new Vector3 as the normalization of the given vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @returns the new Vector3
  1834. */
  1835. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1836. /**
  1837. * Sets the given vector "result" with the normalization of the given first vector
  1838. * @param vector defines the Vector3 to normalize
  1839. * @param result defines the Vector3 where to store the result
  1840. */
  1841. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1842. /**
  1843. * Project a Vector3 onto screen space
  1844. * @param vector defines the Vector3 to project
  1845. * @param world defines the world matrix to use
  1846. * @param transform defines the transform (view x projection) matrix to use
  1847. * @param viewport defines the screen viewport to use
  1848. * @returns the new Vector3
  1849. */
  1850. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1851. /** @hidden */
  1852. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param source defines the screen space Vector3 to use
  1856. * @param viewportWidth defines the current width of the viewport
  1857. * @param viewportHeight defines the current height of the viewport
  1858. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1859. * @param transform defines the transform (view x projection) matrix to use
  1860. * @returns the new Vector3
  1861. */
  1862. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1863. /**
  1864. * Unproject from screen space to object space
  1865. * @param source defines the screen space Vector3 to use
  1866. * @param viewportWidth defines the current width of the viewport
  1867. * @param viewportHeight defines the current height of the viewport
  1868. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1869. * @param view defines the view matrix to use
  1870. * @param projection defines the projection matrix to use
  1871. * @returns the new Vector3
  1872. */
  1873. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1874. /**
  1875. * Unproject from screen space to object space
  1876. * @param source defines the screen space Vector3 to use
  1877. * @param viewportWidth defines the current width of the viewport
  1878. * @param viewportHeight defines the current height of the viewport
  1879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1880. * @param view defines the view matrix to use
  1881. * @param projection defines the projection matrix to use
  1882. * @param result defines the Vector3 where to store the result
  1883. */
  1884. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1885. /**
  1886. * Unproject from screen space to object space
  1887. * @param sourceX defines the screen space x coordinate to use
  1888. * @param sourceY defines the screen space y coordinate to use
  1889. * @param sourceZ defines the screen space z coordinate to use
  1890. * @param viewportWidth defines the current width of the viewport
  1891. * @param viewportHeight defines the current height of the viewport
  1892. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1893. * @param view defines the view matrix to use
  1894. * @param projection defines the projection matrix to use
  1895. * @param result defines the Vector3 where to store the result
  1896. */
  1897. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1898. /**
  1899. * Gets the minimal coordinate values between two Vector3
  1900. * @param left defines the first operand
  1901. * @param right defines the second operand
  1902. * @returns the new Vector3
  1903. */
  1904. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1905. /**
  1906. * Gets the maximal coordinate values between two Vector3
  1907. * @param left defines the first operand
  1908. * @param right defines the second operand
  1909. * @returns the new Vector3
  1910. */
  1911. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * Returns the distance between the vectors "value1" and "value2"
  1914. * @param value1 defines the first operand
  1915. * @param value2 defines the second operand
  1916. * @returns the distance
  1917. */
  1918. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1919. /**
  1920. * Returns the squared distance between the vectors "value1" and "value2"
  1921. * @param value1 defines the first operand
  1922. * @param value2 defines the second operand
  1923. * @returns the squared distance
  1924. */
  1925. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1926. /**
  1927. * Returns a new Vector3 located at the center between "value1" and "value2"
  1928. * @param value1 defines the first operand
  1929. * @param value2 defines the second operand
  1930. * @returns the new Vector3
  1931. */
  1932. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1933. /**
  1934. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1935. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1936. * to something in order to rotate it from its local system to the given target system
  1937. * Note: axis1, axis2 and axis3 are normalized during this operation
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @returns a new Vector3
  1942. */
  1943. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1944. /**
  1945. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1946. * @param axis1 defines the first axis
  1947. * @param axis2 defines the second axis
  1948. * @param axis3 defines the third axis
  1949. * @param ref defines the Vector3 where to store the result
  1950. */
  1951. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1952. }
  1953. /**
  1954. * Vector4 class created for EulerAngle class conversion to Quaternion
  1955. */
  1956. export class Vector4 {
  1957. /** x value of the vector */
  1958. x: number;
  1959. /** y value of the vector */
  1960. y: number;
  1961. /** z value of the vector */
  1962. z: number;
  1963. /** w value of the vector */
  1964. w: number;
  1965. /**
  1966. * Creates a Vector4 object from the given floats.
  1967. * @param x x value of the vector
  1968. * @param y y value of the vector
  1969. * @param z z value of the vector
  1970. * @param w w value of the vector
  1971. */
  1972. constructor(
  1973. /** x value of the vector */
  1974. x: number,
  1975. /** y value of the vector */
  1976. y: number,
  1977. /** z value of the vector */
  1978. z: number,
  1979. /** w value of the vector */
  1980. w: number);
  1981. /**
  1982. * Returns the string with the Vector4 coordinates.
  1983. * @returns a string containing all the vector values
  1984. */
  1985. toString(): string;
  1986. /**
  1987. * Returns the string "Vector4".
  1988. * @returns "Vector4"
  1989. */
  1990. getClassName(): string;
  1991. /**
  1992. * Returns the Vector4 hash code.
  1993. * @returns a unique hash code
  1994. */
  1995. getHashCode(): number;
  1996. /**
  1997. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1998. * @returns the resulting array
  1999. */
  2000. asArray(): number[];
  2001. /**
  2002. * Populates the given array from the given index with the Vector4 coordinates.
  2003. * @param array array to populate
  2004. * @param index index of the array to start at (default: 0)
  2005. * @returns the Vector4.
  2006. */
  2007. toArray(array: FloatArray, index?: number): Vector4;
  2008. /**
  2009. * Adds the given vector to the current Vector4.
  2010. * @param otherVector the vector to add
  2011. * @returns the updated Vector4.
  2012. */
  2013. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @returns the resulting vector
  2018. */
  2019. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2020. /**
  2021. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2022. * @param otherVector the vector to add
  2023. * @param result the vector to store the result
  2024. * @returns the current Vector4.
  2025. */
  2026. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2027. /**
  2028. * Subtract in place the given vector from the current Vector4.
  2029. * @param otherVector the vector to subtract
  2030. * @returns the updated Vector4.
  2031. */
  2032. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to add
  2036. * @returns the new vector with the result
  2037. */
  2038. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2039. /**
  2040. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2041. * @param otherVector the vector to subtract
  2042. * @param result the vector to store the result
  2043. * @returns the current Vector4.
  2044. */
  2045. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2046. /**
  2047. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2048. */
  2049. /**
  2050. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2051. * @param x value to subtract
  2052. * @param y value to subtract
  2053. * @param z value to subtract
  2054. * @param w value to subtract
  2055. * @returns new vector containing the result
  2056. */
  2057. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2058. /**
  2059. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2060. * @param x value to subtract
  2061. * @param y value to subtract
  2062. * @param z value to subtract
  2063. * @param w value to subtract
  2064. * @param result the vector to store the result in
  2065. * @returns the current Vector4.
  2066. */
  2067. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2068. /**
  2069. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2070. * @returns a new vector with the negated values
  2071. */
  2072. negate(): Vector4;
  2073. /**
  2074. * Multiplies the current Vector4 coordinates by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns the updated Vector4.
  2077. */
  2078. scaleInPlace(scale: number): Vector4;
  2079. /**
  2080. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @returns a new vector with the result
  2083. */
  2084. scale(scale: number): Vector4;
  2085. /**
  2086. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2087. * @param scale the number to scale with
  2088. * @param result a vector to store the result in
  2089. * @returns the current Vector4.
  2090. */
  2091. scaleToRef(scale: number, result: Vector4): Vector4;
  2092. /**
  2093. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2094. * @param scale defines the scale factor
  2095. * @param result defines the Vector4 object where to store the result
  2096. * @returns the unmodified current Vector4
  2097. */
  2098. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2101. * @param otherVector the vector to compare against
  2102. * @returns true if they are equal
  2103. */
  2104. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2105. /**
  2106. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2107. * @param otherVector vector to compare against
  2108. * @param epsilon (Default: very small number)
  2109. * @returns true if they are equal
  2110. */
  2111. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2112. /**
  2113. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2114. * @param x x value to compare against
  2115. * @param y y value to compare against
  2116. * @param z z value to compare against
  2117. * @param w w value to compare against
  2118. * @returns true if equal
  2119. */
  2120. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2121. /**
  2122. * Multiplies in place the current Vector4 by the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns the updated Vector4.
  2125. */
  2126. multiplyInPlace(otherVector: Vector4): Vector4;
  2127. /**
  2128. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @returns resulting new vector
  2131. */
  2132. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2133. /**
  2134. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2135. * @param otherVector vector to multiple with
  2136. * @param result vector to store the result
  2137. * @returns the current Vector4.
  2138. */
  2139. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2140. /**
  2141. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2142. * @param x x value multiply with
  2143. * @param y y value multiply with
  2144. * @param z z value multiply with
  2145. * @param w w value multiply with
  2146. * @returns resulting new vector
  2147. */
  2148. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2149. /**
  2150. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @returns resulting new vector
  2153. */
  2154. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2155. /**
  2156. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2157. * @param otherVector vector to devide with
  2158. * @param result vector to store the result
  2159. * @returns the current Vector4.
  2160. */
  2161. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2162. /**
  2163. * Divides the current Vector3 coordinates by the given ones.
  2164. * @param otherVector vector to devide with
  2165. * @returns the updated Vector3.
  2166. */
  2167. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2176. * @param other defines the second operand
  2177. * @returns the current updated Vector4
  2178. */
  2179. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2180. /**
  2181. * Gets a new Vector4 from current Vector4 floored values
  2182. * @returns a new Vector4
  2183. */
  2184. floor(): Vector4;
  2185. /**
  2186. * Gets a new Vector4 from current Vector3 floored values
  2187. * @returns a new Vector4
  2188. */
  2189. fract(): Vector4;
  2190. /**
  2191. * Returns the Vector4 length (float).
  2192. * @returns the length
  2193. */
  2194. length(): number;
  2195. /**
  2196. * Returns the Vector4 squared length (float).
  2197. * @returns the length squared
  2198. */
  2199. lengthSquared(): number;
  2200. /**
  2201. * Normalizes in place the Vector4.
  2202. * @returns the updated Vector4.
  2203. */
  2204. normalize(): Vector4;
  2205. /**
  2206. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2207. * @returns this converted to a new vector3
  2208. */
  2209. toVector3(): Vector3;
  2210. /**
  2211. * Returns a new Vector4 copied from the current one.
  2212. * @returns the new cloned vector
  2213. */
  2214. clone(): Vector4;
  2215. /**
  2216. * Updates the current Vector4 with the given one coordinates.
  2217. * @param source the source vector to copy from
  2218. * @returns the updated Vector4.
  2219. */
  2220. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2221. /**
  2222. * Updates the current Vector4 coordinates with the given floats.
  2223. * @param x float to copy from
  2224. * @param y float to copy from
  2225. * @param z float to copy from
  2226. * @param w float to copy from
  2227. * @returns the updated Vector4.
  2228. */
  2229. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2230. /**
  2231. * Updates the current Vector4 coordinates with the given floats.
  2232. * @param x float to set from
  2233. * @param y float to set from
  2234. * @param z float to set from
  2235. * @param w float to set from
  2236. * @returns the updated Vector4.
  2237. */
  2238. set(x: number, y: number, z: number, w: number): Vector4;
  2239. /**
  2240. * Copies the given float to the current Vector3 coordinates
  2241. * @param v defines the x, y, z and w coordinates of the operand
  2242. * @returns the current updated Vector3
  2243. */
  2244. setAll(v: number): Vector4;
  2245. /**
  2246. * Returns a new Vector4 set from the starting index of the given array.
  2247. * @param array the array to pull values from
  2248. * @param offset the offset into the array to start at
  2249. * @returns the new vector
  2250. */
  2251. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2252. /**
  2253. * Updates the given vector "result" from the starting index of the given array.
  2254. * @param array the array to pull values from
  2255. * @param offset the offset into the array to start at
  2256. * @param result the vector to store the result in
  2257. */
  2258. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2259. /**
  2260. * Updates the given vector "result" from the starting index of the given Float32Array.
  2261. * @param array the array to pull values from
  2262. * @param offset the offset into the array to start at
  2263. * @param result the vector to store the result in
  2264. */
  2265. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2266. /**
  2267. * Updates the given vector "result" coordinates from the given floats.
  2268. * @param x float to set from
  2269. * @param y float to set from
  2270. * @param z float to set from
  2271. * @param w float to set from
  2272. * @param result the vector to the floats in
  2273. */
  2274. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2275. /**
  2276. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2277. * @returns the new vector
  2278. */
  2279. static Zero(): Vector4;
  2280. /**
  2281. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2282. * @returns the new vector
  2283. */
  2284. static One(): Vector4;
  2285. /**
  2286. * Returns a new normalized Vector4 from the given one.
  2287. * @param vector the vector to normalize
  2288. * @returns the vector
  2289. */
  2290. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2291. /**
  2292. * Updates the given vector "result" from the normalization of the given one.
  2293. * @param vector the vector to normalize
  2294. * @param result the vector to store the result in
  2295. */
  2296. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2297. /**
  2298. * Returns a vector with the minimum values from the left and right vectors
  2299. * @param left left vector to minimize
  2300. * @param right right vector to minimize
  2301. * @returns a new vector with the minimum of the left and right vector values
  2302. */
  2303. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2304. /**
  2305. * Returns a vector with the maximum values from the left and right vectors
  2306. * @param left left vector to maximize
  2307. * @param right right vector to maximize
  2308. * @returns a new vector with the maximum of the left and right vector values
  2309. */
  2310. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2311. /**
  2312. * Returns the distance (float) between the vectors "value1" and "value2".
  2313. * @param value1 value to calulate the distance between
  2314. * @param value2 value to calulate the distance between
  2315. * @return the distance between the two vectors
  2316. */
  2317. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2318. /**
  2319. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2320. * @param value1 value to calulate the distance between
  2321. * @param value2 value to calulate the distance between
  2322. * @return the distance between the two vectors squared
  2323. */
  2324. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2325. /**
  2326. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2327. * @param value1 value to calulate the center between
  2328. * @param value2 value to calulate the center between
  2329. * @return the center between the two vectors
  2330. */
  2331. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2332. /**
  2333. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @returns the new vector
  2338. */
  2339. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param vector the vector to transform
  2344. * @param transformation the transformation matrix to apply
  2345. * @param result the vector to store the result in
  2346. */
  2347. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2348. /**
  2349. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2350. * This methods computes transformed normalized direction vectors only.
  2351. * @param x value to transform
  2352. * @param y value to transform
  2353. * @param z value to transform
  2354. * @param w value to transform
  2355. * @param transformation the transformation matrix to apply
  2356. * @param result the vector to store the results in
  2357. */
  2358. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2359. /**
  2360. * Creates a new Vector4 from a Vector3
  2361. * @param source defines the source data
  2362. * @param w defines the 4th component (default is 0)
  2363. * @returns a new Vector4
  2364. */
  2365. static FromVector3(source: Vector3, w?: number): Vector4;
  2366. }
  2367. /**
  2368. * Class used to store quaternion data
  2369. * @see https://en.wikipedia.org/wiki/Quaternion
  2370. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2371. */
  2372. export class Quaternion {
  2373. /** defines the first component (0 by default) */
  2374. x: number;
  2375. /** defines the second component (0 by default) */
  2376. y: number;
  2377. /** defines the third component (0 by default) */
  2378. z: number;
  2379. /** defines the fourth component (1.0 by default) */
  2380. w: number;
  2381. /**
  2382. * Creates a new Quaternion from the given floats
  2383. * @param x defines the first component (0 by default)
  2384. * @param y defines the second component (0 by default)
  2385. * @param z defines the third component (0 by default)
  2386. * @param w defines the fourth component (1.0 by default)
  2387. */
  2388. constructor(
  2389. /** defines the first component (0 by default) */
  2390. x?: number,
  2391. /** defines the second component (0 by default) */
  2392. y?: number,
  2393. /** defines the third component (0 by default) */
  2394. z?: number,
  2395. /** defines the fourth component (1.0 by default) */
  2396. w?: number);
  2397. /**
  2398. * Gets a string representation for the current quaternion
  2399. * @returns a string with the Quaternion coordinates
  2400. */
  2401. toString(): string;
  2402. /**
  2403. * Gets the class name of the quaternion
  2404. * @returns the string "Quaternion"
  2405. */
  2406. getClassName(): string;
  2407. /**
  2408. * Gets a hash code for this quaternion
  2409. * @returns the quaternion hash code
  2410. */
  2411. getHashCode(): number;
  2412. /**
  2413. * Copy the quaternion to an array
  2414. * @returns a new array populated with 4 elements from the quaternion coordinates
  2415. */
  2416. asArray(): number[];
  2417. /**
  2418. * Check if two quaternions are equals
  2419. * @param otherQuaternion defines the second operand
  2420. * @return true if the current quaternion and the given one coordinates are strictly equals
  2421. */
  2422. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2423. /**
  2424. * Clone the current quaternion
  2425. * @returns a new quaternion copied from the current one
  2426. */
  2427. clone(): Quaternion;
  2428. /**
  2429. * Copy a quaternion to the current one
  2430. * @param other defines the other quaternion
  2431. * @returns the updated current quaternion
  2432. */
  2433. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2434. /**
  2435. * Updates the current quaternion with the given float coordinates
  2436. * @param x defines the x coordinate
  2437. * @param y defines the y coordinate
  2438. * @param z defines the z coordinate
  2439. * @param w defines the w coordinate
  2440. * @returns the updated current quaternion
  2441. */
  2442. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2443. /**
  2444. * Updates the current quaternion from the given float coordinates
  2445. * @param x defines the x coordinate
  2446. * @param y defines the y coordinate
  2447. * @param z defines the z coordinate
  2448. * @param w defines the w coordinate
  2449. * @returns the updated current quaternion
  2450. */
  2451. set(x: number, y: number, z: number, w: number): Quaternion;
  2452. /**
  2453. * Adds two quaternions
  2454. * @param other defines the second operand
  2455. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2456. */
  2457. add(other: DeepImmutable<Quaternion>): Quaternion;
  2458. /**
  2459. * Add a quaternion to the current one
  2460. * @param other defines the quaternion to add
  2461. * @returns the current quaternion
  2462. */
  2463. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2464. /**
  2465. * Subtract two quaternions
  2466. * @param other defines the second operand
  2467. * @returns a new quaternion as the subtraction result of the given one from the current one
  2468. */
  2469. subtract(other: Quaternion): Quaternion;
  2470. /**
  2471. * Multiplies the current quaternion by a scale factor
  2472. * @param value defines the scale factor
  2473. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2474. */
  2475. scale(value: number): Quaternion;
  2476. /**
  2477. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2478. * @param scale defines the scale factor
  2479. * @param result defines the Quaternion object where to store the result
  2480. * @returns the unmodified current quaternion
  2481. */
  2482. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2483. /**
  2484. * Multiplies in place the current quaternion by a scale factor
  2485. * @param value defines the scale factor
  2486. * @returns the current modified quaternion
  2487. */
  2488. scaleInPlace(value: number): Quaternion;
  2489. /**
  2490. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2491. * @param scale defines the scale factor
  2492. * @param result defines the Quaternion object where to store the result
  2493. * @returns the unmodified current quaternion
  2494. */
  2495. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2496. /**
  2497. * Multiplies two quaternions
  2498. * @param q1 defines the second operand
  2499. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2500. */
  2501. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2502. /**
  2503. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2504. * @param q1 defines the second operand
  2505. * @param result defines the target quaternion
  2506. * @returns the current quaternion
  2507. */
  2508. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2509. /**
  2510. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2511. * @param q1 defines the second operand
  2512. * @returns the currentupdated quaternion
  2513. */
  2514. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2517. * @param ref defines the target quaternion
  2518. * @returns the current quaternion
  2519. */
  2520. conjugateToRef(ref: Quaternion): Quaternion;
  2521. /**
  2522. * Conjugates in place (1-q) the current quaternion
  2523. * @returns the current updated quaternion
  2524. */
  2525. conjugateInPlace(): Quaternion;
  2526. /**
  2527. * Conjugates in place (1-q) the current quaternion
  2528. * @returns a new quaternion
  2529. */
  2530. conjugate(): Quaternion;
  2531. /**
  2532. * Gets length of current quaternion
  2533. * @returns the quaternion length (float)
  2534. */
  2535. length(): number;
  2536. /**
  2537. * Normalize in place the current quaternion
  2538. * @returns the current updated quaternion
  2539. */
  2540. normalize(): Quaternion;
  2541. /**
  2542. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2543. * @param order is a reserved parameter and is ignore for now
  2544. * @returns a new Vector3 containing the Euler angles
  2545. */
  2546. toEulerAngles(order?: string): Vector3;
  2547. /**
  2548. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2549. * @param result defines the vector which will be filled with the Euler angles
  2550. * @param order is a reserved parameter and is ignore for now
  2551. * @returns the current unchanged quaternion
  2552. */
  2553. toEulerAnglesToRef(result: Vector3): Quaternion;
  2554. /**
  2555. * Updates the given rotation matrix with the current quaternion values
  2556. * @param result defines the target matrix
  2557. * @returns the current unchanged quaternion
  2558. */
  2559. toRotationMatrix(result: Matrix): Quaternion;
  2560. /**
  2561. * Updates the current quaternion from the given rotation matrix values
  2562. * @param matrix defines the source matrix
  2563. * @returns the current updated quaternion
  2564. */
  2565. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2566. /**
  2567. * Creates a new quaternion from a rotation matrix
  2568. * @param matrix defines the source matrix
  2569. * @returns a new quaternion created from the given rotation matrix values
  2570. */
  2571. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2572. /**
  2573. * Updates the given quaternion with the given rotation matrix values
  2574. * @param matrix defines the source matrix
  2575. * @param result defines the target quaternion
  2576. */
  2577. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2578. /**
  2579. * Returns the dot product (float) between the quaternions "left" and "right"
  2580. * @param left defines the left operand
  2581. * @param right defines the right operand
  2582. * @returns the dot product
  2583. */
  2584. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2585. /**
  2586. * Checks if the two quaternions are close to each other
  2587. * @param quat0 defines the first quaternion to check
  2588. * @param quat1 defines the second quaternion to check
  2589. * @returns true if the two quaternions are close to each other
  2590. */
  2591. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2592. /**
  2593. * Creates an empty quaternion
  2594. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2595. */
  2596. static Zero(): Quaternion;
  2597. /**
  2598. * Inverse a given quaternion
  2599. * @param q defines the source quaternion
  2600. * @returns a new quaternion as the inverted current quaternion
  2601. */
  2602. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2603. /**
  2604. * Inverse a given quaternion
  2605. * @param q defines the source quaternion
  2606. * @param result the quaternion the result will be stored in
  2607. * @returns the result quaternion
  2608. */
  2609. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2610. /**
  2611. * Creates an identity quaternion
  2612. * @returns the identity quaternion
  2613. */
  2614. static Identity(): Quaternion;
  2615. /**
  2616. * Gets a boolean indicating if the given quaternion is identity
  2617. * @param quaternion defines the quaternion to check
  2618. * @returns true if the quaternion is identity
  2619. */
  2620. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2621. /**
  2622. * Creates a quaternion from a rotation around an axis
  2623. * @param axis defines the axis to use
  2624. * @param angle defines the angle to use
  2625. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2626. */
  2627. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2628. /**
  2629. * Creates a rotation around an axis and stores it into the given quaternion
  2630. * @param axis defines the axis to use
  2631. * @param angle defines the angle to use
  2632. * @param result defines the target quaternion
  2633. * @returns the target quaternion
  2634. */
  2635. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2636. /**
  2637. * Creates a new quaternion from data stored into an array
  2638. * @param array defines the data source
  2639. * @param offset defines the offset in the source array where the data starts
  2640. * @returns a new quaternion
  2641. */
  2642. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2643. /**
  2644. * Create a quaternion from Euler rotation angles
  2645. * @param x Pitch
  2646. * @param y Yaw
  2647. * @param z Roll
  2648. * @returns the new Quaternion
  2649. */
  2650. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2651. /**
  2652. * Updates a quaternion from Euler rotation angles
  2653. * @param x Pitch
  2654. * @param y Yaw
  2655. * @param z Roll
  2656. * @param result the quaternion to store the result
  2657. * @returns the updated quaternion
  2658. */
  2659. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2660. /**
  2661. * Create a quaternion from Euler rotation vector
  2662. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2663. * @returns the new Quaternion
  2664. */
  2665. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2666. /**
  2667. * Updates a quaternion from Euler rotation vector
  2668. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2669. * @param result the quaternion to store the result
  2670. * @returns the updated quaternion
  2671. */
  2672. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2675. * @param yaw defines the rotation around Y axis
  2676. * @param pitch defines the rotation around X axis
  2677. * @param roll defines the rotation around Z axis
  2678. * @returns the new quaternion
  2679. */
  2680. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2681. /**
  2682. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2683. * @param yaw defines the rotation around Y axis
  2684. * @param pitch defines the rotation around X axis
  2685. * @param roll defines the rotation around Z axis
  2686. * @param result defines the target quaternion
  2687. */
  2688. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2689. /**
  2690. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2691. * @param alpha defines the rotation around first axis
  2692. * @param beta defines the rotation around second axis
  2693. * @param gamma defines the rotation around third axis
  2694. * @returns the new quaternion
  2695. */
  2696. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2697. /**
  2698. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2699. * @param alpha defines the rotation around first axis
  2700. * @param beta defines the rotation around second axis
  2701. * @param gamma defines the rotation around third axis
  2702. * @param result defines the target quaternion
  2703. */
  2704. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2705. /**
  2706. * 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)
  2707. * @param axis1 defines the first axis
  2708. * @param axis2 defines the second axis
  2709. * @param axis3 defines the third axis
  2710. * @returns the new quaternion
  2711. */
  2712. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2713. /**
  2714. * 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
  2715. * @param axis1 defines the first axis
  2716. * @param axis2 defines the second axis
  2717. * @param axis3 defines the third axis
  2718. * @param ref defines the target quaternion
  2719. */
  2720. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2721. /**
  2722. * Interpolates between two quaternions
  2723. * @param left defines first quaternion
  2724. * @param right defines second quaternion
  2725. * @param amount defines the gradient to use
  2726. * @returns the new interpolated quaternion
  2727. */
  2728. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2729. /**
  2730. * Interpolates between two quaternions and stores it into a target quaternion
  2731. * @param left defines first quaternion
  2732. * @param right defines second quaternion
  2733. * @param amount defines the gradient to use
  2734. * @param result defines the target quaternion
  2735. */
  2736. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2737. /**
  2738. * Interpolate between two quaternions using Hermite interpolation
  2739. * @param value1 defines first quaternion
  2740. * @param tangent1 defines the incoming tangent
  2741. * @param value2 defines second quaternion
  2742. * @param tangent2 defines the outgoing tangent
  2743. * @param amount defines the target quaternion
  2744. * @returns the new interpolated quaternion
  2745. */
  2746. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2747. }
  2748. /**
  2749. * Class used to store matrix data (4x4)
  2750. */
  2751. export class Matrix {
  2752. private static _updateFlagSeed;
  2753. private static _identityReadOnly;
  2754. private _isIdentity;
  2755. private _isIdentityDirty;
  2756. private _isIdentity3x2;
  2757. private _isIdentity3x2Dirty;
  2758. /**
  2759. * Gets the update flag of the matrix which is an unique number for the matrix.
  2760. * It will be incremented every time the matrix data change.
  2761. * You can use it to speed the comparison between two versions of the same matrix.
  2762. */
  2763. updateFlag: number;
  2764. private readonly _m;
  2765. /**
  2766. * Gets the internal data of the matrix
  2767. */
  2768. readonly m: DeepImmutable<Float32Array>;
  2769. /** @hidden */
  2770. _markAsUpdated(): void;
  2771. /** @hidden */
  2772. private _updateIdentityStatus;
  2773. /**
  2774. * Creates an empty matrix (filled with zeros)
  2775. */
  2776. constructor();
  2777. /**
  2778. * Check if the current matrix is identity
  2779. * @returns true is the matrix is the identity matrix
  2780. */
  2781. isIdentity(): boolean;
  2782. /**
  2783. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2784. * @returns true is the matrix is the identity matrix
  2785. */
  2786. isIdentityAs3x2(): boolean;
  2787. /**
  2788. * Gets the determinant of the matrix
  2789. * @returns the matrix determinant
  2790. */
  2791. determinant(): number;
  2792. /**
  2793. * Returns the matrix as a Float32Array
  2794. * @returns the matrix underlying array
  2795. */
  2796. toArray(): DeepImmutable<Float32Array>;
  2797. /**
  2798. * Returns the matrix as a Float32Array
  2799. * @returns the matrix underlying array.
  2800. */
  2801. asArray(): DeepImmutable<Float32Array>;
  2802. /**
  2803. * Inverts the current matrix in place
  2804. * @returns the current inverted matrix
  2805. */
  2806. invert(): Matrix;
  2807. /**
  2808. * Sets all the matrix elements to zero
  2809. * @returns the current matrix
  2810. */
  2811. reset(): Matrix;
  2812. /**
  2813. * Adds the current matrix with a second one
  2814. * @param other defines the matrix to add
  2815. * @returns a new matrix as the addition of the current matrix and the given one
  2816. */
  2817. add(other: DeepImmutable<Matrix>): Matrix;
  2818. /**
  2819. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2820. * @param other defines the matrix to add
  2821. * @param result defines the target matrix
  2822. * @returns the current matrix
  2823. */
  2824. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2825. /**
  2826. * Adds in place the given matrix to the current matrix
  2827. * @param other defines the second operand
  2828. * @returns the current updated matrix
  2829. */
  2830. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2831. /**
  2832. * Sets the given matrix to the current inverted Matrix
  2833. * @param other defines the target matrix
  2834. * @returns the unmodified current matrix
  2835. */
  2836. invertToRef(other: Matrix): Matrix;
  2837. /**
  2838. * add a value at the specified position in the current Matrix
  2839. * @param index the index of the value within the matrix. between 0 and 15.
  2840. * @param value the value to be added
  2841. * @returns the current updated matrix
  2842. */
  2843. addAtIndex(index: number, value: number): Matrix;
  2844. /**
  2845. * mutiply the specified position in the current Matrix by a value
  2846. * @param index the index of the value within the matrix. between 0 and 15.
  2847. * @param value the value to be added
  2848. * @returns the current updated matrix
  2849. */
  2850. multiplyAtIndex(index: number, value: number): Matrix;
  2851. /**
  2852. * Inserts the translation vector (using 3 floats) in the current matrix
  2853. * @param x defines the 1st component of the translation
  2854. * @param y defines the 2nd component of the translation
  2855. * @param z defines the 3rd component of the translation
  2856. * @returns the current updated matrix
  2857. */
  2858. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2859. /**
  2860. * Adds the translation vector (using 3 floats) in the current matrix
  2861. * @param x defines the 1st component of the translation
  2862. * @param y defines the 2nd component of the translation
  2863. * @param z defines the 3rd component of the translation
  2864. * @returns the current updated matrix
  2865. */
  2866. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2867. /**
  2868. * Inserts the translation vector in the current matrix
  2869. * @param vector3 defines the translation to insert
  2870. * @returns the current updated matrix
  2871. */
  2872. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2873. /**
  2874. * Gets the translation value of the current matrix
  2875. * @returns a new Vector3 as the extracted translation from the matrix
  2876. */
  2877. getTranslation(): Vector3;
  2878. /**
  2879. * Fill a Vector3 with the extracted translation from the matrix
  2880. * @param result defines the Vector3 where to store the translation
  2881. * @returns the current matrix
  2882. */
  2883. getTranslationToRef(result: Vector3): Matrix;
  2884. /**
  2885. * Remove rotation and scaling part from the matrix
  2886. * @returns the updated matrix
  2887. */
  2888. removeRotationAndScaling(): Matrix;
  2889. /**
  2890. * Multiply two matrices
  2891. * @param other defines the second operand
  2892. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2893. */
  2894. multiply(other: DeepImmutable<Matrix>): Matrix;
  2895. /**
  2896. * Copy the current matrix from the given one
  2897. * @param other defines the source matrix
  2898. * @returns the current updated matrix
  2899. */
  2900. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Populates the given array from the starting index with the current matrix values
  2903. * @param array defines the target array
  2904. * @param offset defines the offset in the target array where to start storing values
  2905. * @returns the current matrix
  2906. */
  2907. copyToArray(array: Float32Array, offset?: number): Matrix;
  2908. /**
  2909. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2910. * @param other defines the second operand
  2911. * @param result defines the matrix where to store the multiplication
  2912. * @returns the current matrix
  2913. */
  2914. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2915. /**
  2916. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2917. * @param other defines the second operand
  2918. * @param result defines the array where to store the multiplication
  2919. * @param offset defines the offset in the target array where to start storing values
  2920. * @returns the current matrix
  2921. */
  2922. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2923. /**
  2924. * Check equality between this matrix and a second one
  2925. * @param value defines the second matrix to compare
  2926. * @returns true is the current matrix and the given one values are strictly equal
  2927. */
  2928. equals(value: DeepImmutable<Matrix>): boolean;
  2929. /**
  2930. * Clone the current matrix
  2931. * @returns a new matrix from the current matrix
  2932. */
  2933. clone(): Matrix;
  2934. /**
  2935. * Returns the name of the current matrix class
  2936. * @returns the string "Matrix"
  2937. */
  2938. getClassName(): string;
  2939. /**
  2940. * Gets the hash code of the current matrix
  2941. * @returns the hash code
  2942. */
  2943. getHashCode(): number;
  2944. /**
  2945. * Decomposes the current Matrix into a translation, rotation and scaling components
  2946. * @param scale defines the scale vector3 given as a reference to update
  2947. * @param rotation defines the rotation quaternion given as a reference to update
  2948. * @param translation defines the translation vector3 given as a reference to update
  2949. * @returns true if operation was successful
  2950. */
  2951. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2952. /**
  2953. * Gets specific row of the matrix
  2954. * @param index defines the number of the row to get
  2955. * @returns the index-th row of the current matrix as a new Vector4
  2956. */
  2957. getRow(index: number): Nullable<Vector4>;
  2958. /**
  2959. * Sets the index-th row of the current matrix to the vector4 values
  2960. * @param index defines the number of the row to set
  2961. * @param row defines the target vector4
  2962. * @returns the updated current matrix
  2963. */
  2964. setRow(index: number, row: Vector4): Matrix;
  2965. /**
  2966. * Compute the transpose of the matrix
  2967. * @returns the new transposed matrix
  2968. */
  2969. transpose(): Matrix;
  2970. /**
  2971. * Compute the transpose of the matrix and store it in a given matrix
  2972. * @param result defines the target matrix
  2973. * @returns the current matrix
  2974. */
  2975. transposeToRef(result: Matrix): Matrix;
  2976. /**
  2977. * Sets the index-th row of the current matrix with the given 4 x float values
  2978. * @param index defines the row index
  2979. * @param x defines the x component to set
  2980. * @param y defines the y component to set
  2981. * @param z defines the z component to set
  2982. * @param w defines the w component to set
  2983. * @returns the updated current matrix
  2984. */
  2985. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2986. /**
  2987. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2988. * @param scale defines the scale factor
  2989. * @returns a new matrix
  2990. */
  2991. scale(scale: number): Matrix;
  2992. /**
  2993. * Scale the current matrix values by a factor to a given result matrix
  2994. * @param scale defines the scale factor
  2995. * @param result defines the matrix to store the result
  2996. * @returns the current matrix
  2997. */
  2998. scaleToRef(scale: number, result: Matrix): Matrix;
  2999. /**
  3000. * Scale the current matrix values by a factor and add the result to a given matrix
  3001. * @param scale defines the scale factor
  3002. * @param result defines the Matrix to store the result
  3003. * @returns the current matrix
  3004. */
  3005. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3006. /**
  3007. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3008. * @param ref matrix to store the result
  3009. */
  3010. toNormalMatrix(ref: Matrix): void;
  3011. /**
  3012. * Gets only rotation part of the current matrix
  3013. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3014. */
  3015. getRotationMatrix(): Matrix;
  3016. /**
  3017. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3018. * @param result defines the target matrix to store data to
  3019. * @returns the current matrix
  3020. */
  3021. getRotationMatrixToRef(result: Matrix): Matrix;
  3022. /**
  3023. * Toggles model matrix from being right handed to left handed in place and vice versa
  3024. */
  3025. toggleModelMatrixHandInPlace(): void;
  3026. /**
  3027. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3028. */
  3029. toggleProjectionMatrixHandInPlace(): void;
  3030. /**
  3031. * Creates a matrix from an array
  3032. * @param array defines the source array
  3033. * @param offset defines an offset in the source array
  3034. * @returns a new Matrix set from the starting index of the given array
  3035. */
  3036. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3037. /**
  3038. * Copy the content of an array into a given matrix
  3039. * @param array defines the source array
  3040. * @param offset defines an offset in the source array
  3041. * @param result defines the target matrix
  3042. */
  3043. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3044. /**
  3045. * Stores an array into a matrix after having multiplied each component by a given factor
  3046. * @param array defines the source array
  3047. * @param offset defines the offset in the source array
  3048. * @param scale defines the scaling factor
  3049. * @param result defines the target matrix
  3050. */
  3051. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3052. /**
  3053. * Gets an identity matrix that must not be updated
  3054. */
  3055. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3056. /**
  3057. * Stores a list of values (16) inside a given matrix
  3058. * @param initialM11 defines 1st value of 1st row
  3059. * @param initialM12 defines 2nd value of 1st row
  3060. * @param initialM13 defines 3rd value of 1st row
  3061. * @param initialM14 defines 4th value of 1st row
  3062. * @param initialM21 defines 1st value of 2nd row
  3063. * @param initialM22 defines 2nd value of 2nd row
  3064. * @param initialM23 defines 3rd value of 2nd row
  3065. * @param initialM24 defines 4th value of 2nd row
  3066. * @param initialM31 defines 1st value of 3rd row
  3067. * @param initialM32 defines 2nd value of 3rd row
  3068. * @param initialM33 defines 3rd value of 3rd row
  3069. * @param initialM34 defines 4th value of 3rd row
  3070. * @param initialM41 defines 1st value of 4th row
  3071. * @param initialM42 defines 2nd value of 4th row
  3072. * @param initialM43 defines 3rd value of 4th row
  3073. * @param initialM44 defines 4th value of 4th row
  3074. * @param result defines the target matrix
  3075. */
  3076. 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;
  3077. /**
  3078. * Creates new matrix from a list of values (16)
  3079. * @param initialM11 defines 1st value of 1st row
  3080. * @param initialM12 defines 2nd value of 1st row
  3081. * @param initialM13 defines 3rd value of 1st row
  3082. * @param initialM14 defines 4th value of 1st row
  3083. * @param initialM21 defines 1st value of 2nd row
  3084. * @param initialM22 defines 2nd value of 2nd row
  3085. * @param initialM23 defines 3rd value of 2nd row
  3086. * @param initialM24 defines 4th value of 2nd row
  3087. * @param initialM31 defines 1st value of 3rd row
  3088. * @param initialM32 defines 2nd value of 3rd row
  3089. * @param initialM33 defines 3rd value of 3rd row
  3090. * @param initialM34 defines 4th value of 3rd row
  3091. * @param initialM41 defines 1st value of 4th row
  3092. * @param initialM42 defines 2nd value of 4th row
  3093. * @param initialM43 defines 3rd value of 4th row
  3094. * @param initialM44 defines 4th value of 4th row
  3095. * @returns the new matrix
  3096. */
  3097. 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;
  3098. /**
  3099. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3100. * @param scale defines the scale vector3
  3101. * @param rotation defines the rotation quaternion
  3102. * @param translation defines the translation vector3
  3103. * @returns a new matrix
  3104. */
  3105. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3106. /**
  3107. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3108. * @param scale defines the scale vector3
  3109. * @param rotation defines the rotation quaternion
  3110. * @param translation defines the translation vector3
  3111. * @param result defines the target matrix
  3112. */
  3113. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3114. /**
  3115. * Creates a new identity matrix
  3116. * @returns a new identity matrix
  3117. */
  3118. static Identity(): Matrix;
  3119. /**
  3120. * Creates a new identity matrix and stores the result in a given matrix
  3121. * @param result defines the target matrix
  3122. */
  3123. static IdentityToRef(result: Matrix): void;
  3124. /**
  3125. * Creates a new zero matrix
  3126. * @returns a new zero matrix
  3127. */
  3128. static Zero(): Matrix;
  3129. /**
  3130. * Creates a new rotation matrix for "angle" radians around the X axis
  3131. * @param angle defines the angle (in radians) to use
  3132. * @return the new matrix
  3133. */
  3134. static RotationX(angle: number): Matrix;
  3135. /**
  3136. * Creates a new matrix as the invert of a given matrix
  3137. * @param source defines the source matrix
  3138. * @returns the new matrix
  3139. */
  3140. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3141. /**
  3142. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3143. * @param angle defines the angle (in radians) to use
  3144. * @param result defines the target matrix
  3145. */
  3146. static RotationXToRef(angle: number, result: Matrix): void;
  3147. /**
  3148. * Creates a new rotation matrix for "angle" radians around the Y axis
  3149. * @param angle defines the angle (in radians) to use
  3150. * @return the new matrix
  3151. */
  3152. static RotationY(angle: number): Matrix;
  3153. /**
  3154. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3155. * @param angle defines the angle (in radians) to use
  3156. * @param result defines the target matrix
  3157. */
  3158. static RotationYToRef(angle: number, result: Matrix): void;
  3159. /**
  3160. * Creates a new rotation matrix for "angle" radians around the Z axis
  3161. * @param angle defines the angle (in radians) to use
  3162. * @return the new matrix
  3163. */
  3164. static RotationZ(angle: number): Matrix;
  3165. /**
  3166. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3167. * @param angle defines the angle (in radians) to use
  3168. * @param result defines the target matrix
  3169. */
  3170. static RotationZToRef(angle: number, result: Matrix): void;
  3171. /**
  3172. * Creates a new rotation matrix for "angle" radians around the given axis
  3173. * @param axis defines the axis to use
  3174. * @param angle defines the angle (in radians) to use
  3175. * @return the new matrix
  3176. */
  3177. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3178. /**
  3179. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3180. * @param axis defines the axis to use
  3181. * @param angle defines the angle (in radians) to use
  3182. * @param result defines the target matrix
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3185. /**
  3186. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3187. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3188. * @param from defines the vector to align
  3189. * @param to defines the vector to align to
  3190. * @param result defines the target matrix
  3191. */
  3192. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3193. /**
  3194. * Creates a rotation matrix
  3195. * @param yaw defines the yaw angle in radians (Y axis)
  3196. * @param pitch defines the pitch angle in radians (X axis)
  3197. * @param roll defines the roll angle in radians (X axis)
  3198. * @returns the new rotation matrix
  3199. */
  3200. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3201. /**
  3202. * Creates a rotation matrix and stores it in a given matrix
  3203. * @param yaw defines the yaw angle in radians (Y axis)
  3204. * @param pitch defines the pitch angle in radians (X axis)
  3205. * @param roll defines the roll angle in radians (X axis)
  3206. * @param result defines the target matrix
  3207. */
  3208. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3209. /**
  3210. * Creates a scaling matrix
  3211. * @param x defines the scale factor on X axis
  3212. * @param y defines the scale factor on Y axis
  3213. * @param z defines the scale factor on Z axis
  3214. * @returns the new matrix
  3215. */
  3216. static Scaling(x: number, y: number, z: number): Matrix;
  3217. /**
  3218. * Creates a scaling matrix and stores it in a given matrix
  3219. * @param x defines the scale factor on X axis
  3220. * @param y defines the scale factor on Y axis
  3221. * @param z defines the scale factor on Z axis
  3222. * @param result defines the target matrix
  3223. */
  3224. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3225. /**
  3226. * Creates a translation matrix
  3227. * @param x defines the translation on X axis
  3228. * @param y defines the translation on Y axis
  3229. * @param z defines the translationon Z axis
  3230. * @returns the new matrix
  3231. */
  3232. static Translation(x: number, y: number, z: number): Matrix;
  3233. /**
  3234. * Creates a translation matrix and stores it in a given matrix
  3235. * @param x defines the translation on X axis
  3236. * @param y defines the translation on Y axis
  3237. * @param z defines the translationon Z axis
  3238. * @param result defines the target matrix
  3239. */
  3240. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3241. /**
  3242. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3243. * @param startValue defines the start value
  3244. * @param endValue defines the end value
  3245. * @param gradient defines the gradient factor
  3246. * @returns the new matrix
  3247. */
  3248. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3249. /**
  3250. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3251. * @param startValue defines the start value
  3252. * @param endValue defines the end value
  3253. * @param gradient defines the gradient factor
  3254. * @param result defines the Matrix object where to store data
  3255. */
  3256. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3257. /**
  3258. * Builds a new matrix whose values are computed by:
  3259. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3260. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3261. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3262. * @param startValue defines the first matrix
  3263. * @param endValue defines the second matrix
  3264. * @param gradient defines the gradient between the two matrices
  3265. * @returns the new matrix
  3266. */
  3267. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3268. /**
  3269. * Update a matrix to values which are computed by:
  3270. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3271. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3272. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3273. * @param startValue defines the first matrix
  3274. * @param endValue defines the second matrix
  3275. * @param gradient defines the gradient between the two matrices
  3276. * @param result defines the target matrix
  3277. */
  3278. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3279. /**
  3280. * 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"
  3281. * This function works in left handed mode
  3282. * @param eye defines the final position of the entity
  3283. * @param target defines where the entity should look at
  3284. * @param up defines the up vector for the entity
  3285. * @returns the new matrix
  3286. */
  3287. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3288. /**
  3289. * 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".
  3290. * This function works in left handed mode
  3291. * @param eye defines the final position of the entity
  3292. * @param target defines where the entity should look at
  3293. * @param up defines the up vector for the entity
  3294. * @param result defines the target matrix
  3295. */
  3296. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3297. /**
  3298. * 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"
  3299. * This function works in right handed mode
  3300. * @param eye defines the final position of the entity
  3301. * @param target defines where the entity should look at
  3302. * @param up defines the up vector for the entity
  3303. * @returns the new matrix
  3304. */
  3305. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3306. /**
  3307. * 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".
  3308. * This function works in right handed mode
  3309. * @param eye defines the final position of the entity
  3310. * @param target defines where the entity should look at
  3311. * @param up defines the up vector for the entity
  3312. * @param result defines the target matrix
  3313. */
  3314. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3315. /**
  3316. * Create a left-handed orthographic projection matrix
  3317. * @param width defines the viewport width
  3318. * @param height defines the viewport height
  3319. * @param znear defines the near clip plane
  3320. * @param zfar defines the far clip plane
  3321. * @returns a new matrix as a left-handed orthographic projection matrix
  3322. */
  3323. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3324. /**
  3325. * Store a left-handed orthographic projection to a given matrix
  3326. * @param width defines the viewport width
  3327. * @param height defines the viewport height
  3328. * @param znear defines the near clip plane
  3329. * @param zfar defines the far clip plane
  3330. * @param result defines the target matrix
  3331. */
  3332. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3333. /**
  3334. * Create a left-handed orthographic projection matrix
  3335. * @param left defines the viewport left coordinate
  3336. * @param right defines the viewport right coordinate
  3337. * @param bottom defines the viewport bottom coordinate
  3338. * @param top defines the viewport top coordinate
  3339. * @param znear defines the near clip plane
  3340. * @param zfar defines the far clip plane
  3341. * @returns a new matrix as a left-handed orthographic projection matrix
  3342. */
  3343. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3344. /**
  3345. * Stores a left-handed orthographic projection into a given matrix
  3346. * @param left defines the viewport left coordinate
  3347. * @param right defines the viewport right coordinate
  3348. * @param bottom defines the viewport bottom coordinate
  3349. * @param top defines the viewport top coordinate
  3350. * @param znear defines the near clip plane
  3351. * @param zfar defines the far clip plane
  3352. * @param result defines the target matrix
  3353. */
  3354. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3355. /**
  3356. * Creates a right-handed orthographic projection matrix
  3357. * @param left defines the viewport left coordinate
  3358. * @param right defines the viewport right coordinate
  3359. * @param bottom defines the viewport bottom coordinate
  3360. * @param top defines the viewport top coordinate
  3361. * @param znear defines the near clip plane
  3362. * @param zfar defines the far clip plane
  3363. * @returns a new matrix as a right-handed orthographic projection matrix
  3364. */
  3365. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3366. /**
  3367. * Stores a right-handed orthographic projection into a given matrix
  3368. * @param left defines the viewport left coordinate
  3369. * @param right defines the viewport right coordinate
  3370. * @param bottom defines the viewport bottom coordinate
  3371. * @param top defines the viewport top coordinate
  3372. * @param znear defines the near clip plane
  3373. * @param zfar defines the far clip plane
  3374. * @param result defines the target matrix
  3375. */
  3376. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3377. /**
  3378. * Creates a left-handed perspective projection matrix
  3379. * @param width defines the viewport width
  3380. * @param height defines the viewport height
  3381. * @param znear defines the near clip plane
  3382. * @param zfar defines the far clip plane
  3383. * @returns a new matrix as a left-handed perspective projection matrix
  3384. */
  3385. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3386. /**
  3387. * Creates a left-handed perspective projection matrix
  3388. * @param fov defines the horizontal field of view
  3389. * @param aspect defines the aspect ratio
  3390. * @param znear defines the near clip plane
  3391. * @param zfar defines the far clip plane
  3392. * @returns a new matrix as a left-handed perspective projection matrix
  3393. */
  3394. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3395. /**
  3396. * Stores a left-handed perspective projection into a given matrix
  3397. * @param fov defines the horizontal field of view
  3398. * @param aspect defines the aspect ratio
  3399. * @param znear defines the near clip plane
  3400. * @param zfar defines the far clip plane
  3401. * @param result defines the target matrix
  3402. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3403. */
  3404. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3405. /**
  3406. * Creates a right-handed perspective projection matrix
  3407. * @param fov defines the horizontal field of view
  3408. * @param aspect defines the aspect ratio
  3409. * @param znear defines the near clip plane
  3410. * @param zfar defines the far clip plane
  3411. * @returns a new matrix as a right-handed perspective projection matrix
  3412. */
  3413. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3414. /**
  3415. * Stores a right-handed perspective projection into a given matrix
  3416. * @param fov defines the horizontal field of view
  3417. * @param aspect defines the aspect ratio
  3418. * @param znear defines the near clip plane
  3419. * @param zfar defines the far clip plane
  3420. * @param result defines the target matrix
  3421. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3422. */
  3423. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3424. /**
  3425. * Stores a perspective projection for WebVR info a given matrix
  3426. * @param fov defines the field of view
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @param result defines the target matrix
  3430. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3431. */
  3432. static PerspectiveFovWebVRToRef(fov: {
  3433. upDegrees: number;
  3434. downDegrees: number;
  3435. leftDegrees: number;
  3436. rightDegrees: number;
  3437. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3438. /**
  3439. * Computes a complete transformation matrix
  3440. * @param viewport defines the viewport to use
  3441. * @param world defines the world matrix
  3442. * @param view defines the view matrix
  3443. * @param projection defines the projection matrix
  3444. * @param zmin defines the near clip plane
  3445. * @param zmax defines the far clip plane
  3446. * @returns the transformation matrix
  3447. */
  3448. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3449. /**
  3450. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3451. * @param matrix defines the matrix to use
  3452. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3453. */
  3454. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3455. /**
  3456. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3457. * @param matrix defines the matrix to use
  3458. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3459. */
  3460. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3461. /**
  3462. * Compute the transpose of a given matrix
  3463. * @param matrix defines the matrix to transpose
  3464. * @returns the new matrix
  3465. */
  3466. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3467. /**
  3468. * Compute the transpose of a matrix and store it in a target matrix
  3469. * @param matrix defines the matrix to transpose
  3470. * @param result defines the target matrix
  3471. */
  3472. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3473. /**
  3474. * Computes a reflection matrix from a plane
  3475. * @param plane defines the reflection plane
  3476. * @returns a new matrix
  3477. */
  3478. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3479. /**
  3480. * Computes a reflection matrix from a plane
  3481. * @param plane defines the reflection plane
  3482. * @param result defines the target matrix
  3483. */
  3484. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3485. /**
  3486. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3487. * @param xaxis defines the value of the 1st axis
  3488. * @param yaxis defines the value of the 2nd axis
  3489. * @param zaxis defines the value of the 3rd axis
  3490. * @param result defines the target matrix
  3491. */
  3492. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3493. /**
  3494. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3495. * @param quat defines the quaternion to use
  3496. * @param result defines the target matrix
  3497. */
  3498. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3499. }
  3500. /**
  3501. * @hidden
  3502. */
  3503. export class TmpVectors {
  3504. static Vector2: Vector2[];
  3505. static Vector3: Vector3[];
  3506. static Vector4: Vector4[];
  3507. static Quaternion: Quaternion[];
  3508. static Matrix: Matrix[];
  3509. }
  3510. }
  3511. declare module "babylonjs/Maths/math.color" {
  3512. import { DeepImmutable, FloatArray } from "babylonjs/types";
  3513. /**
  3514. * Class used to hold a RBG color
  3515. */
  3516. export class Color3 {
  3517. /**
  3518. * Defines the red component (between 0 and 1, default is 0)
  3519. */
  3520. r: number;
  3521. /**
  3522. * Defines the green component (between 0 and 1, default is 0)
  3523. */
  3524. g: number;
  3525. /**
  3526. * Defines the blue component (between 0 and 1, default is 0)
  3527. */
  3528. b: number;
  3529. /**
  3530. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3531. * @param r defines the red component (between 0 and 1, default is 0)
  3532. * @param g defines the green component (between 0 and 1, default is 0)
  3533. * @param b defines the blue component (between 0 and 1, default is 0)
  3534. */
  3535. constructor(
  3536. /**
  3537. * Defines the red component (between 0 and 1, default is 0)
  3538. */
  3539. r?: number,
  3540. /**
  3541. * Defines the green component (between 0 and 1, default is 0)
  3542. */
  3543. g?: number,
  3544. /**
  3545. * Defines the blue component (between 0 and 1, default is 0)
  3546. */
  3547. b?: number);
  3548. /**
  3549. * Creates a string with the Color3 current values
  3550. * @returns the string representation of the Color3 object
  3551. */
  3552. toString(): string;
  3553. /**
  3554. * Returns the string "Color3"
  3555. * @returns "Color3"
  3556. */
  3557. getClassName(): string;
  3558. /**
  3559. * Compute the Color3 hash code
  3560. * @returns an unique number that can be used to hash Color3 objects
  3561. */
  3562. getHashCode(): number;
  3563. /**
  3564. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3565. * @param array defines the array where to store the r,g,b components
  3566. * @param index defines an optional index in the target array to define where to start storing values
  3567. * @returns the current Color3 object
  3568. */
  3569. toArray(array: FloatArray, index?: number): Color3;
  3570. /**
  3571. * Returns a new Color4 object from the current Color3 and the given alpha
  3572. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3573. * @returns a new Color4 object
  3574. */
  3575. toColor4(alpha?: number): Color4;
  3576. /**
  3577. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3578. * @returns the new array
  3579. */
  3580. asArray(): number[];
  3581. /**
  3582. * Returns the luminance value
  3583. * @returns a float value
  3584. */
  3585. toLuminance(): number;
  3586. /**
  3587. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3588. * @param otherColor defines the second operand
  3589. * @returns the new Color3 object
  3590. */
  3591. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3592. /**
  3593. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3594. * @param otherColor defines the second operand
  3595. * @param result defines the Color3 object where to store the result
  3596. * @returns the current Color3
  3597. */
  3598. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3599. /**
  3600. * Determines equality between Color3 objects
  3601. * @param otherColor defines the second operand
  3602. * @returns true if the rgb values are equal to the given ones
  3603. */
  3604. equals(otherColor: DeepImmutable<Color3>): boolean;
  3605. /**
  3606. * Determines equality between the current Color3 object and a set of r,b,g values
  3607. * @param r defines the red component to check
  3608. * @param g defines the green component to check
  3609. * @param b defines the blue component to check
  3610. * @returns true if the rgb values are equal to the given ones
  3611. */
  3612. equalsFloats(r: number, g: number, b: number): boolean;
  3613. /**
  3614. * Multiplies in place each rgb value by scale
  3615. * @param scale defines the scaling factor
  3616. * @returns the updated Color3
  3617. */
  3618. scale(scale: number): Color3;
  3619. /**
  3620. * Multiplies the rgb values by scale and stores the result into "result"
  3621. * @param scale defines the scaling factor
  3622. * @param result defines the Color3 object where to store the result
  3623. * @returns the unmodified current Color3
  3624. */
  3625. scaleToRef(scale: number, result: Color3): Color3;
  3626. /**
  3627. * Scale the current Color3 values by a factor and add the result to a given Color3
  3628. * @param scale defines the scale factor
  3629. * @param result defines color to store the result into
  3630. * @returns the unmodified current Color3
  3631. */
  3632. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3633. /**
  3634. * Clamps the rgb values by the min and max values and stores the result into "result"
  3635. * @param min defines minimum clamping value (default is 0)
  3636. * @param max defines maximum clamping value (default is 1)
  3637. * @param result defines color to store the result into
  3638. * @returns the original Color3
  3639. */
  3640. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3641. /**
  3642. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3643. * @param otherColor defines the second operand
  3644. * @returns the new Color3
  3645. */
  3646. add(otherColor: DeepImmutable<Color3>): Color3;
  3647. /**
  3648. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3649. * @param otherColor defines the second operand
  3650. * @param result defines Color3 object to store the result into
  3651. * @returns the unmodified current Color3
  3652. */
  3653. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3654. /**
  3655. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3656. * @param otherColor defines the second operand
  3657. * @returns the new Color3
  3658. */
  3659. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3660. /**
  3661. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3662. * @param otherColor defines the second operand
  3663. * @param result defines Color3 object to store the result into
  3664. * @returns the unmodified current Color3
  3665. */
  3666. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3667. /**
  3668. * Copy the current object
  3669. * @returns a new Color3 copied the current one
  3670. */
  3671. clone(): Color3;
  3672. /**
  3673. * Copies the rgb values from the source in the current Color3
  3674. * @param source defines the source Color3 object
  3675. * @returns the updated Color3 object
  3676. */
  3677. copyFrom(source: DeepImmutable<Color3>): Color3;
  3678. /**
  3679. * Updates the Color3 rgb values from the given floats
  3680. * @param r defines the red component to read from
  3681. * @param g defines the green component to read from
  3682. * @param b defines the blue component to read from
  3683. * @returns the current Color3 object
  3684. */
  3685. copyFromFloats(r: number, g: number, b: number): Color3;
  3686. /**
  3687. * Updates the Color3 rgb values from the given floats
  3688. * @param r defines the red component to read from
  3689. * @param g defines the green component to read from
  3690. * @param b defines the blue component to read from
  3691. * @returns the current Color3 object
  3692. */
  3693. set(r: number, g: number, b: number): Color3;
  3694. /**
  3695. * Compute the Color3 hexadecimal code as a string
  3696. * @returns a string containing the hexadecimal representation of the Color3 object
  3697. */
  3698. toHexString(): string;
  3699. /**
  3700. * Computes a new Color3 converted from the current one to linear space
  3701. * @returns a new Color3 object
  3702. */
  3703. toLinearSpace(): Color3;
  3704. /**
  3705. * Converts current color in rgb space to HSV values
  3706. * @returns a new color3 representing the HSV values
  3707. */
  3708. toHSV(): Color3;
  3709. /**
  3710. * Converts current color in rgb space to HSV values
  3711. * @param result defines the Color3 where to store the HSV values
  3712. */
  3713. toHSVToRef(result: Color3): void;
  3714. /**
  3715. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3716. * @param convertedColor defines the Color3 object where to store the linear space version
  3717. * @returns the unmodified Color3
  3718. */
  3719. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3720. /**
  3721. * Computes a new Color3 converted from the current one to gamma space
  3722. * @returns a new Color3 object
  3723. */
  3724. toGammaSpace(): Color3;
  3725. /**
  3726. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3727. * @param convertedColor defines the Color3 object where to store the gamma space version
  3728. * @returns the unmodified Color3
  3729. */
  3730. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3731. private static _BlackReadOnly;
  3732. /**
  3733. * Convert Hue, saturation and value to a Color3 (RGB)
  3734. * @param hue defines the hue
  3735. * @param saturation defines the saturation
  3736. * @param value defines the value
  3737. * @param result defines the Color3 where to store the RGB values
  3738. */
  3739. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3740. /**
  3741. * Creates a new Color3 from the string containing valid hexadecimal values
  3742. * @param hex defines a string containing valid hexadecimal values
  3743. * @returns a new Color3 object
  3744. */
  3745. static FromHexString(hex: string): Color3;
  3746. /**
  3747. * Creates a new Color3 from the starting index of the given array
  3748. * @param array defines the source array
  3749. * @param offset defines an offset in the source array
  3750. * @returns a new Color3 object
  3751. */
  3752. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3753. /**
  3754. * Creates a new Color3 from integer values (< 256)
  3755. * @param r defines the red component to read from (value between 0 and 255)
  3756. * @param g defines the green component to read from (value between 0 and 255)
  3757. * @param b defines the blue component to read from (value between 0 and 255)
  3758. * @returns a new Color3 object
  3759. */
  3760. static FromInts(r: number, g: number, b: number): Color3;
  3761. /**
  3762. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3763. * @param start defines the start Color3 value
  3764. * @param end defines the end Color3 value
  3765. * @param amount defines the gradient value between start and end
  3766. * @returns a new Color3 object
  3767. */
  3768. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3769. /**
  3770. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3771. * @param left defines the start value
  3772. * @param right defines the end value
  3773. * @param amount defines the gradient factor
  3774. * @param result defines the Color3 object where to store the result
  3775. */
  3776. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3777. /**
  3778. * Returns a Color3 value containing a red color
  3779. * @returns a new Color3 object
  3780. */
  3781. static Red(): Color3;
  3782. /**
  3783. * Returns a Color3 value containing a green color
  3784. * @returns a new Color3 object
  3785. */
  3786. static Green(): Color3;
  3787. /**
  3788. * Returns a Color3 value containing a blue color
  3789. * @returns a new Color3 object
  3790. */
  3791. static Blue(): Color3;
  3792. /**
  3793. * Returns a Color3 value containing a black color
  3794. * @returns a new Color3 object
  3795. */
  3796. static Black(): Color3;
  3797. /**
  3798. * Gets a Color3 value containing a black color that must not be updated
  3799. */
  3800. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3801. /**
  3802. * Returns a Color3 value containing a white color
  3803. * @returns a new Color3 object
  3804. */
  3805. static White(): Color3;
  3806. /**
  3807. * Returns a Color3 value containing a purple color
  3808. * @returns a new Color3 object
  3809. */
  3810. static Purple(): Color3;
  3811. /**
  3812. * Returns a Color3 value containing a magenta color
  3813. * @returns a new Color3 object
  3814. */
  3815. static Magenta(): Color3;
  3816. /**
  3817. * Returns a Color3 value containing a yellow color
  3818. * @returns a new Color3 object
  3819. */
  3820. static Yellow(): Color3;
  3821. /**
  3822. * Returns a Color3 value containing a gray color
  3823. * @returns a new Color3 object
  3824. */
  3825. static Gray(): Color3;
  3826. /**
  3827. * Returns a Color3 value containing a teal color
  3828. * @returns a new Color3 object
  3829. */
  3830. static Teal(): Color3;
  3831. /**
  3832. * Returns a Color3 value containing a random color
  3833. * @returns a new Color3 object
  3834. */
  3835. static Random(): Color3;
  3836. }
  3837. /**
  3838. * Class used to hold a RBGA color
  3839. */
  3840. export class Color4 {
  3841. /**
  3842. * Defines the red component (between 0 and 1, default is 0)
  3843. */
  3844. r: number;
  3845. /**
  3846. * Defines the green component (between 0 and 1, default is 0)
  3847. */
  3848. g: number;
  3849. /**
  3850. * Defines the blue component (between 0 and 1, default is 0)
  3851. */
  3852. b: number;
  3853. /**
  3854. * Defines the alpha component (between 0 and 1, default is 1)
  3855. */
  3856. a: number;
  3857. /**
  3858. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3859. * @param r defines the red component (between 0 and 1, default is 0)
  3860. * @param g defines the green component (between 0 and 1, default is 0)
  3861. * @param b defines the blue component (between 0 and 1, default is 0)
  3862. * @param a defines the alpha component (between 0 and 1, default is 1)
  3863. */
  3864. constructor(
  3865. /**
  3866. * Defines the red component (between 0 and 1, default is 0)
  3867. */
  3868. r?: number,
  3869. /**
  3870. * Defines the green component (between 0 and 1, default is 0)
  3871. */
  3872. g?: number,
  3873. /**
  3874. * Defines the blue component (between 0 and 1, default is 0)
  3875. */
  3876. b?: number,
  3877. /**
  3878. * Defines the alpha component (between 0 and 1, default is 1)
  3879. */
  3880. a?: number);
  3881. /**
  3882. * Adds in place the given Color4 values to the current Color4 object
  3883. * @param right defines the second operand
  3884. * @returns the current updated Color4 object
  3885. */
  3886. addInPlace(right: DeepImmutable<Color4>): Color4;
  3887. /**
  3888. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3889. * @returns the new array
  3890. */
  3891. asArray(): number[];
  3892. /**
  3893. * Stores from the starting index in the given array the Color4 successive values
  3894. * @param array defines the array where to store the r,g,b components
  3895. * @param index defines an optional index in the target array to define where to start storing values
  3896. * @returns the current Color4 object
  3897. */
  3898. toArray(array: number[], index?: number): Color4;
  3899. /**
  3900. * Determines equality between Color4 objects
  3901. * @param otherColor defines the second operand
  3902. * @returns true if the rgba values are equal to the given ones
  3903. */
  3904. equals(otherColor: DeepImmutable<Color4>): boolean;
  3905. /**
  3906. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3907. * @param right defines the second operand
  3908. * @returns a new Color4 object
  3909. */
  3910. add(right: DeepImmutable<Color4>): Color4;
  3911. /**
  3912. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3913. * @param right defines the second operand
  3914. * @returns a new Color4 object
  3915. */
  3916. subtract(right: DeepImmutable<Color4>): Color4;
  3917. /**
  3918. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3919. * @param right defines the second operand
  3920. * @param result defines the Color4 object where to store the result
  3921. * @returns the current Color4 object
  3922. */
  3923. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3924. /**
  3925. * Creates a new Color4 with the current Color4 values multiplied by scale
  3926. * @param scale defines the scaling factor to apply
  3927. * @returns a new Color4 object
  3928. */
  3929. scale(scale: number): Color4;
  3930. /**
  3931. * Multiplies the current Color4 values by scale and stores the result in "result"
  3932. * @param scale defines the scaling factor to apply
  3933. * @param result defines the Color4 object where to store the result
  3934. * @returns the current unmodified Color4
  3935. */
  3936. scaleToRef(scale: number, result: Color4): Color4;
  3937. /**
  3938. * Scale the current Color4 values by a factor and add the result to a given Color4
  3939. * @param scale defines the scale factor
  3940. * @param result defines the Color4 object where to store the result
  3941. * @returns the unmodified current Color4
  3942. */
  3943. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3944. /**
  3945. * Clamps the rgb values by the min and max values and stores the result into "result"
  3946. * @param min defines minimum clamping value (default is 0)
  3947. * @param max defines maximum clamping value (default is 1)
  3948. * @param result defines color to store the result into.
  3949. * @returns the cuurent Color4
  3950. */
  3951. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3952. /**
  3953. * Multipy an Color4 value by another and return a new Color4 object
  3954. * @param color defines the Color4 value to multiply by
  3955. * @returns a new Color4 object
  3956. */
  3957. multiply(color: Color4): Color4;
  3958. /**
  3959. * Multipy a Color4 value by another and push the result in a reference value
  3960. * @param color defines the Color4 value to multiply by
  3961. * @param result defines the Color4 to fill the result in
  3962. * @returns the result Color4
  3963. */
  3964. multiplyToRef(color: Color4, result: Color4): Color4;
  3965. /**
  3966. * Creates a string with the Color4 current values
  3967. * @returns the string representation of the Color4 object
  3968. */
  3969. toString(): string;
  3970. /**
  3971. * Returns the string "Color4"
  3972. * @returns "Color4"
  3973. */
  3974. getClassName(): string;
  3975. /**
  3976. * Compute the Color4 hash code
  3977. * @returns an unique number that can be used to hash Color4 objects
  3978. */
  3979. getHashCode(): number;
  3980. /**
  3981. * Creates a new Color4 copied from the current one
  3982. * @returns a new Color4 object
  3983. */
  3984. clone(): Color4;
  3985. /**
  3986. * Copies the given Color4 values into the current one
  3987. * @param source defines the source Color4 object
  3988. * @returns the current updated Color4 object
  3989. */
  3990. copyFrom(source: Color4): Color4;
  3991. /**
  3992. * Copies the given float values into the current one
  3993. * @param r defines the red component to read from
  3994. * @param g defines the green component to read from
  3995. * @param b defines the blue component to read from
  3996. * @param a defines the alpha component to read from
  3997. * @returns the current updated Color4 object
  3998. */
  3999. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4000. /**
  4001. * Copies the given float values into the current one
  4002. * @param r defines the red component to read from
  4003. * @param g defines the green component to read from
  4004. * @param b defines the blue component to read from
  4005. * @param a defines the alpha component to read from
  4006. * @returns the current updated Color4 object
  4007. */
  4008. set(r: number, g: number, b: number, a: number): Color4;
  4009. /**
  4010. * Compute the Color4 hexadecimal code as a string
  4011. * @returns a string containing the hexadecimal representation of the Color4 object
  4012. */
  4013. toHexString(): string;
  4014. /**
  4015. * Computes a new Color4 converted from the current one to linear space
  4016. * @returns a new Color4 object
  4017. */
  4018. toLinearSpace(): Color4;
  4019. /**
  4020. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4021. * @param convertedColor defines the Color4 object where to store the linear space version
  4022. * @returns the unmodified Color4
  4023. */
  4024. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4025. /**
  4026. * Computes a new Color4 converted from the current one to gamma space
  4027. * @returns a new Color4 object
  4028. */
  4029. toGammaSpace(): Color4;
  4030. /**
  4031. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4032. * @param convertedColor defines the Color4 object where to store the gamma space version
  4033. * @returns the unmodified Color4
  4034. */
  4035. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4036. /**
  4037. * Creates a new Color4 from the string containing valid hexadecimal values
  4038. * @param hex defines a string containing valid hexadecimal values
  4039. * @returns a new Color4 object
  4040. */
  4041. static FromHexString(hex: string): Color4;
  4042. /**
  4043. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4044. * @param left defines the start value
  4045. * @param right defines the end value
  4046. * @param amount defines the gradient factor
  4047. * @returns a new Color4 object
  4048. */
  4049. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4050. /**
  4051. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4052. * @param left defines the start value
  4053. * @param right defines the end value
  4054. * @param amount defines the gradient factor
  4055. * @param result defines the Color4 object where to store data
  4056. */
  4057. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4058. /**
  4059. * Creates a new Color4 from a Color3 and an alpha value
  4060. * @param color3 defines the source Color3 to read from
  4061. * @param alpha defines the alpha component (1.0 by default)
  4062. * @returns a new Color4 object
  4063. */
  4064. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4065. /**
  4066. * Creates a new Color4 from the starting index element of the given array
  4067. * @param array defines the source array to read from
  4068. * @param offset defines the offset in the source array
  4069. * @returns a new Color4 object
  4070. */
  4071. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4072. /**
  4073. * Creates a new Color3 from integer values (< 256)
  4074. * @param r defines the red component to read from (value between 0 and 255)
  4075. * @param g defines the green component to read from (value between 0 and 255)
  4076. * @param b defines the blue component to read from (value between 0 and 255)
  4077. * @param a defines the alpha component to read from (value between 0 and 255)
  4078. * @returns a new Color3 object
  4079. */
  4080. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4081. /**
  4082. * Check the content of a given array and convert it to an array containing RGBA data
  4083. * If the original array was already containing count * 4 values then it is returned directly
  4084. * @param colors defines the array to check
  4085. * @param count defines the number of RGBA data to expect
  4086. * @returns an array containing count * 4 values (RGBA)
  4087. */
  4088. static CheckColors4(colors: number[], count: number): number[];
  4089. }
  4090. /**
  4091. * @hidden
  4092. */
  4093. export class TmpColors {
  4094. static Color3: Color3[];
  4095. static Color4: Color4[];
  4096. }
  4097. }
  4098. declare module "babylonjs/Maths/sphericalPolynomial" {
  4099. import { Vector3 } from "babylonjs/Maths/math.vector";
  4100. import { Color3 } from "babylonjs/Maths/math.color";
  4101. /**
  4102. * Class representing spherical harmonics coefficients to the 3rd degree
  4103. */
  4104. export class SphericalHarmonics {
  4105. /**
  4106. * Defines whether or not the harmonics have been prescaled for rendering.
  4107. */
  4108. preScaled: boolean;
  4109. /**
  4110. * The l0,0 coefficients of the spherical harmonics
  4111. */
  4112. l00: Vector3;
  4113. /**
  4114. * The l1,-1 coefficients of the spherical harmonics
  4115. */
  4116. l1_1: Vector3;
  4117. /**
  4118. * The l1,0 coefficients of the spherical harmonics
  4119. */
  4120. l10: Vector3;
  4121. /**
  4122. * The l1,1 coefficients of the spherical harmonics
  4123. */
  4124. l11: Vector3;
  4125. /**
  4126. * The l2,-2 coefficients of the spherical harmonics
  4127. */
  4128. l2_2: Vector3;
  4129. /**
  4130. * The l2,-1 coefficients of the spherical harmonics
  4131. */
  4132. l2_1: Vector3;
  4133. /**
  4134. * The l2,0 coefficients of the spherical harmonics
  4135. */
  4136. l20: Vector3;
  4137. /**
  4138. * The l2,1 coefficients of the spherical harmonics
  4139. */
  4140. l21: Vector3;
  4141. /**
  4142. * The l2,2 coefficients of the spherical harmonics
  4143. */
  4144. l22: Vector3;
  4145. /**
  4146. * Adds a light to the spherical harmonics
  4147. * @param direction the direction of the light
  4148. * @param color the color of the light
  4149. * @param deltaSolidAngle the delta solid angle of the light
  4150. */
  4151. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4152. /**
  4153. * Scales the spherical harmonics by the given amount
  4154. * @param scale the amount to scale
  4155. */
  4156. scaleInPlace(scale: number): void;
  4157. /**
  4158. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4159. *
  4160. * ```
  4161. * E_lm = A_l * L_lm
  4162. * ```
  4163. *
  4164. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4165. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4166. * the scaling factors are given in equation 9.
  4167. */
  4168. convertIncidentRadianceToIrradiance(): void;
  4169. /**
  4170. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4171. *
  4172. * ```
  4173. * L = (1/pi) * E * rho
  4174. * ```
  4175. *
  4176. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4177. */
  4178. convertIrradianceToLambertianRadiance(): void;
  4179. /**
  4180. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4181. * required operations at run time.
  4182. *
  4183. * This is simply done by scaling back the SH with Ylm constants parameter.
  4184. * The trigonometric part being applied by the shader at run time.
  4185. */
  4186. preScaleForRendering(): void;
  4187. /**
  4188. * Constructs a spherical harmonics from an array.
  4189. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4190. * @returns the spherical harmonics
  4191. */
  4192. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4193. /**
  4194. * Gets the spherical harmonics from polynomial
  4195. * @param polynomial the spherical polynomial
  4196. * @returns the spherical harmonics
  4197. */
  4198. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4199. }
  4200. /**
  4201. * Class representing spherical polynomial coefficients to the 3rd degree
  4202. */
  4203. export class SphericalPolynomial {
  4204. private _harmonics;
  4205. /**
  4206. * The spherical harmonics used to create the polynomials.
  4207. */
  4208. readonly preScaledHarmonics: SphericalHarmonics;
  4209. /**
  4210. * The x coefficients of the spherical polynomial
  4211. */
  4212. x: Vector3;
  4213. /**
  4214. * The y coefficients of the spherical polynomial
  4215. */
  4216. y: Vector3;
  4217. /**
  4218. * The z coefficients of the spherical polynomial
  4219. */
  4220. z: Vector3;
  4221. /**
  4222. * The xx coefficients of the spherical polynomial
  4223. */
  4224. xx: Vector3;
  4225. /**
  4226. * The yy coefficients of the spherical polynomial
  4227. */
  4228. yy: Vector3;
  4229. /**
  4230. * The zz coefficients of the spherical polynomial
  4231. */
  4232. zz: Vector3;
  4233. /**
  4234. * The xy coefficients of the spherical polynomial
  4235. */
  4236. xy: Vector3;
  4237. /**
  4238. * The yz coefficients of the spherical polynomial
  4239. */
  4240. yz: Vector3;
  4241. /**
  4242. * The zx coefficients of the spherical polynomial
  4243. */
  4244. zx: Vector3;
  4245. /**
  4246. * Adds an ambient color to the spherical polynomial
  4247. * @param color the color to add
  4248. */
  4249. addAmbient(color: Color3): void;
  4250. /**
  4251. * Scales the spherical polynomial by the given amount
  4252. * @param scale the amount to scale
  4253. */
  4254. scaleInPlace(scale: number): void;
  4255. /**
  4256. * Gets the spherical polynomial from harmonics
  4257. * @param harmonics the spherical harmonics
  4258. * @returns the spherical polynomial
  4259. */
  4260. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4261. /**
  4262. * Constructs a spherical polynomial from an array.
  4263. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4264. * @returns the spherical polynomial
  4265. */
  4266. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4267. }
  4268. }
  4269. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  4270. /**
  4271. * Define options used to create a render target texture
  4272. */
  4273. export class RenderTargetCreationOptions {
  4274. /**
  4275. * Specifies is mipmaps must be generated
  4276. */
  4277. generateMipMaps?: boolean;
  4278. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4279. generateDepthBuffer?: boolean;
  4280. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4281. generateStencilBuffer?: boolean;
  4282. /** Defines texture type (int by default) */
  4283. type?: number;
  4284. /** Defines sampling mode (trilinear by default) */
  4285. samplingMode?: number;
  4286. /** Defines format (RGBA by default) */
  4287. format?: number;
  4288. }
  4289. }
  4290. declare module "babylonjs/States/alphaCullingState" {
  4291. /**
  4292. * @hidden
  4293. **/
  4294. export class _AlphaState {
  4295. private _isAlphaBlendDirty;
  4296. private _isBlendFunctionParametersDirty;
  4297. private _isBlendEquationParametersDirty;
  4298. private _isBlendConstantsDirty;
  4299. private _alphaBlend;
  4300. private _blendFunctionParameters;
  4301. private _blendEquationParameters;
  4302. private _blendConstants;
  4303. /**
  4304. * Initializes the state.
  4305. */
  4306. constructor();
  4307. readonly isDirty: boolean;
  4308. alphaBlend: boolean;
  4309. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  4310. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  4311. setAlphaEquationParameters(rgb: number, alpha: number): void;
  4312. reset(): void;
  4313. apply(gl: WebGLRenderingContext): void;
  4314. }
  4315. }
  4316. declare module "babylonjs/States/depthCullingState" {
  4317. import { Nullable } from "babylonjs/types";
  4318. /**
  4319. * @hidden
  4320. **/
  4321. export class _DepthCullingState {
  4322. private _isDepthTestDirty;
  4323. private _isDepthMaskDirty;
  4324. private _isDepthFuncDirty;
  4325. private _isCullFaceDirty;
  4326. private _isCullDirty;
  4327. private _isZOffsetDirty;
  4328. private _isFrontFaceDirty;
  4329. private _depthTest;
  4330. private _depthMask;
  4331. private _depthFunc;
  4332. private _cull;
  4333. private _cullFace;
  4334. private _zOffset;
  4335. private _frontFace;
  4336. /**
  4337. * Initializes the state.
  4338. */
  4339. constructor();
  4340. readonly isDirty: boolean;
  4341. zOffset: number;
  4342. cullFace: Nullable<number>;
  4343. cull: Nullable<boolean>;
  4344. depthFunc: Nullable<number>;
  4345. depthMask: boolean;
  4346. depthTest: boolean;
  4347. frontFace: Nullable<number>;
  4348. reset(): void;
  4349. apply(gl: WebGLRenderingContext): void;
  4350. }
  4351. }
  4352. declare module "babylonjs/Engines/constants" {
  4353. /** Defines the cross module used constants to avoid circular dependncies */
  4354. export class Constants {
  4355. /** Defines that alpha blending is disabled */
  4356. static readonly ALPHA_DISABLE: number;
  4357. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4358. static readonly ALPHA_ADD: number;
  4359. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4360. static readonly ALPHA_COMBINE: number;
  4361. /** Defines that alpha blending to DEST - SRC * DEST */
  4362. static readonly ALPHA_SUBTRACT: number;
  4363. /** Defines that alpha blending to SRC * DEST */
  4364. static readonly ALPHA_MULTIPLY: number;
  4365. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4366. static readonly ALPHA_MAXIMIZED: number;
  4367. /** Defines that alpha blending to SRC + DEST */
  4368. static readonly ALPHA_ONEONE: number;
  4369. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4370. static readonly ALPHA_PREMULTIPLIED: number;
  4371. /**
  4372. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4373. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4374. */
  4375. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4376. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4377. static readonly ALPHA_INTERPOLATE: number;
  4378. /**
  4379. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4380. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4381. */
  4382. static readonly ALPHA_SCREENMODE: number;
  4383. /**
  4384. * Defines that alpha blending to SRC + DST
  4385. * Alpha will be set to SRC ALPHA + DST ALPHA
  4386. */
  4387. static readonly ALPHA_ONEONE_ONEONE: number;
  4388. /**
  4389. * Defines that alpha blending to SRC * DST ALPHA + DST
  4390. * Alpha will be set to 0
  4391. */
  4392. static readonly ALPHA_ALPHATOCOLOR: number;
  4393. /**
  4394. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4395. */
  4396. static readonly ALPHA_REVERSEONEMINUS: number;
  4397. /**
  4398. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4399. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4400. */
  4401. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4402. /**
  4403. * Defines that alpha blending to SRC + DST
  4404. * Alpha will be set to SRC ALPHA
  4405. */
  4406. static readonly ALPHA_ONEONE_ONEZERO: number;
  4407. /** Defines that alpha blending equation a SUM */
  4408. static readonly ALPHA_EQUATION_ADD: number;
  4409. /** Defines that alpha blending equation a SUBSTRACTION */
  4410. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4411. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4412. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4413. /** Defines that alpha blending equation a MAX operation */
  4414. static readonly ALPHA_EQUATION_MAX: number;
  4415. /** Defines that alpha blending equation a MIN operation */
  4416. static readonly ALPHA_EQUATION_MIN: number;
  4417. /**
  4418. * Defines that alpha blending equation a DARKEN operation:
  4419. * It takes the min of the src and sums the alpha channels.
  4420. */
  4421. static readonly ALPHA_EQUATION_DARKEN: number;
  4422. /** Defines that the ressource is not delayed*/
  4423. static readonly DELAYLOADSTATE_NONE: number;
  4424. /** Defines that the ressource was successfully delay loaded */
  4425. static readonly DELAYLOADSTATE_LOADED: number;
  4426. /** Defines that the ressource is currently delay loading */
  4427. static readonly DELAYLOADSTATE_LOADING: number;
  4428. /** Defines that the ressource is delayed and has not started loading */
  4429. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4430. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4431. static readonly NEVER: number;
  4432. /** 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 */
  4433. static readonly ALWAYS: number;
  4434. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4435. static readonly LESS: number;
  4436. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4437. static readonly EQUAL: number;
  4438. /** 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 */
  4439. static readonly LEQUAL: number;
  4440. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4441. static readonly GREATER: number;
  4442. /** 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 */
  4443. static readonly GEQUAL: number;
  4444. /** 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 */
  4445. static readonly NOTEQUAL: number;
  4446. /** Passed to stencilOperation to specify that stencil value must be kept */
  4447. static readonly KEEP: number;
  4448. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4449. static readonly REPLACE: number;
  4450. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4451. static readonly INCR: number;
  4452. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4453. static readonly DECR: number;
  4454. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4455. static readonly INVERT: number;
  4456. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4457. static readonly INCR_WRAP: number;
  4458. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4459. static readonly DECR_WRAP: number;
  4460. /** Texture is not repeating outside of 0..1 UVs */
  4461. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4462. /** Texture is repeating outside of 0..1 UVs */
  4463. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4464. /** Texture is repeating and mirrored */
  4465. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4466. /** ALPHA */
  4467. static readonly TEXTUREFORMAT_ALPHA: number;
  4468. /** LUMINANCE */
  4469. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4470. /** LUMINANCE_ALPHA */
  4471. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4472. /** RGB */
  4473. static readonly TEXTUREFORMAT_RGB: number;
  4474. /** RGBA */
  4475. static readonly TEXTUREFORMAT_RGBA: number;
  4476. /** RED */
  4477. static readonly TEXTUREFORMAT_RED: number;
  4478. /** RED (2nd reference) */
  4479. static readonly TEXTUREFORMAT_R: number;
  4480. /** RG */
  4481. static readonly TEXTUREFORMAT_RG: number;
  4482. /** RED_INTEGER */
  4483. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4484. /** RED_INTEGER (2nd reference) */
  4485. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4486. /** RG_INTEGER */
  4487. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4488. /** RGB_INTEGER */
  4489. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4490. /** RGBA_INTEGER */
  4491. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4492. /** UNSIGNED_BYTE */
  4493. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4494. /** UNSIGNED_BYTE (2nd reference) */
  4495. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4496. /** FLOAT */
  4497. static readonly TEXTURETYPE_FLOAT: number;
  4498. /** HALF_FLOAT */
  4499. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4500. /** BYTE */
  4501. static readonly TEXTURETYPE_BYTE: number;
  4502. /** SHORT */
  4503. static readonly TEXTURETYPE_SHORT: number;
  4504. /** UNSIGNED_SHORT */
  4505. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4506. /** INT */
  4507. static readonly TEXTURETYPE_INT: number;
  4508. /** UNSIGNED_INT */
  4509. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4510. /** UNSIGNED_SHORT_4_4_4_4 */
  4511. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4512. /** UNSIGNED_SHORT_5_5_5_1 */
  4513. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4514. /** UNSIGNED_SHORT_5_6_5 */
  4515. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4516. /** UNSIGNED_INT_2_10_10_10_REV */
  4517. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4518. /** UNSIGNED_INT_24_8 */
  4519. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4520. /** UNSIGNED_INT_10F_11F_11F_REV */
  4521. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4522. /** UNSIGNED_INT_5_9_9_9_REV */
  4523. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4524. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4525. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4526. /** nearest is mag = nearest and min = nearest and mip = linear */
  4527. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4528. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4529. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4530. /** Trilinear is mag = linear and min = linear and mip = linear */
  4531. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4532. /** nearest is mag = nearest and min = nearest and mip = linear */
  4533. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4534. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4535. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4536. /** Trilinear is mag = linear and min = linear and mip = linear */
  4537. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4538. /** mag = nearest and min = nearest and mip = nearest */
  4539. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4540. /** mag = nearest and min = linear and mip = nearest */
  4541. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4542. /** mag = nearest and min = linear and mip = linear */
  4543. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4544. /** mag = nearest and min = linear and mip = none */
  4545. static readonly TEXTURE_NEAREST_LINEAR: number;
  4546. /** mag = nearest and min = nearest and mip = none */
  4547. static readonly TEXTURE_NEAREST_NEAREST: number;
  4548. /** mag = linear and min = nearest and mip = nearest */
  4549. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4550. /** mag = linear and min = nearest and mip = linear */
  4551. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4552. /** mag = linear and min = linear and mip = none */
  4553. static readonly TEXTURE_LINEAR_LINEAR: number;
  4554. /** mag = linear and min = nearest and mip = none */
  4555. static readonly TEXTURE_LINEAR_NEAREST: number;
  4556. /** Explicit coordinates mode */
  4557. static readonly TEXTURE_EXPLICIT_MODE: number;
  4558. /** Spherical coordinates mode */
  4559. static readonly TEXTURE_SPHERICAL_MODE: number;
  4560. /** Planar coordinates mode */
  4561. static readonly TEXTURE_PLANAR_MODE: number;
  4562. /** Cubic coordinates mode */
  4563. static readonly TEXTURE_CUBIC_MODE: number;
  4564. /** Projection coordinates mode */
  4565. static readonly TEXTURE_PROJECTION_MODE: number;
  4566. /** Skybox coordinates mode */
  4567. static readonly TEXTURE_SKYBOX_MODE: number;
  4568. /** Inverse Cubic coordinates mode */
  4569. static readonly TEXTURE_INVCUBIC_MODE: number;
  4570. /** Equirectangular coordinates mode */
  4571. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4572. /** Equirectangular Fixed coordinates mode */
  4573. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4574. /** Equirectangular Fixed Mirrored coordinates mode */
  4575. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4576. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4577. static readonly SCALEMODE_FLOOR: number;
  4578. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4579. static readonly SCALEMODE_NEAREST: number;
  4580. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4581. static readonly SCALEMODE_CEILING: number;
  4582. /**
  4583. * The dirty texture flag value
  4584. */
  4585. static readonly MATERIAL_TextureDirtyFlag: number;
  4586. /**
  4587. * The dirty light flag value
  4588. */
  4589. static readonly MATERIAL_LightDirtyFlag: number;
  4590. /**
  4591. * The dirty fresnel flag value
  4592. */
  4593. static readonly MATERIAL_FresnelDirtyFlag: number;
  4594. /**
  4595. * The dirty attribute flag value
  4596. */
  4597. static readonly MATERIAL_AttributesDirtyFlag: number;
  4598. /**
  4599. * The dirty misc flag value
  4600. */
  4601. static readonly MATERIAL_MiscDirtyFlag: number;
  4602. /**
  4603. * The all dirty flag value
  4604. */
  4605. static readonly MATERIAL_AllDirtyFlag: number;
  4606. /**
  4607. * Returns the triangle fill mode
  4608. */
  4609. static readonly MATERIAL_TriangleFillMode: number;
  4610. /**
  4611. * Returns the wireframe mode
  4612. */
  4613. static readonly MATERIAL_WireFrameFillMode: number;
  4614. /**
  4615. * Returns the point fill mode
  4616. */
  4617. static readonly MATERIAL_PointFillMode: number;
  4618. /**
  4619. * Returns the point list draw mode
  4620. */
  4621. static readonly MATERIAL_PointListDrawMode: number;
  4622. /**
  4623. * Returns the line list draw mode
  4624. */
  4625. static readonly MATERIAL_LineListDrawMode: number;
  4626. /**
  4627. * Returns the line loop draw mode
  4628. */
  4629. static readonly MATERIAL_LineLoopDrawMode: number;
  4630. /**
  4631. * Returns the line strip draw mode
  4632. */
  4633. static readonly MATERIAL_LineStripDrawMode: number;
  4634. /**
  4635. * Returns the triangle strip draw mode
  4636. */
  4637. static readonly MATERIAL_TriangleStripDrawMode: number;
  4638. /**
  4639. * Returns the triangle fan draw mode
  4640. */
  4641. static readonly MATERIAL_TriangleFanDrawMode: number;
  4642. /**
  4643. * Stores the clock-wise side orientation
  4644. */
  4645. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4646. /**
  4647. * Stores the counter clock-wise side orientation
  4648. */
  4649. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4650. /**
  4651. * Nothing
  4652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4653. */
  4654. static readonly ACTION_NothingTrigger: number;
  4655. /**
  4656. * On pick
  4657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4658. */
  4659. static readonly ACTION_OnPickTrigger: number;
  4660. /**
  4661. * On left pick
  4662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4663. */
  4664. static readonly ACTION_OnLeftPickTrigger: number;
  4665. /**
  4666. * On right pick
  4667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4668. */
  4669. static readonly ACTION_OnRightPickTrigger: number;
  4670. /**
  4671. * On center pick
  4672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4673. */
  4674. static readonly ACTION_OnCenterPickTrigger: number;
  4675. /**
  4676. * On pick down
  4677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4678. */
  4679. static readonly ACTION_OnPickDownTrigger: number;
  4680. /**
  4681. * On double pick
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_OnDoublePickTrigger: number;
  4685. /**
  4686. * On pick up
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickUpTrigger: number;
  4690. /**
  4691. * On pick out.
  4692. * This trigger will only be raised if you also declared a OnPickDown
  4693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4694. */
  4695. static readonly ACTION_OnPickOutTrigger: number;
  4696. /**
  4697. * On long press
  4698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4699. */
  4700. static readonly ACTION_OnLongPressTrigger: number;
  4701. /**
  4702. * On pointer over
  4703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4704. */
  4705. static readonly ACTION_OnPointerOverTrigger: number;
  4706. /**
  4707. * On pointer out
  4708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4709. */
  4710. static readonly ACTION_OnPointerOutTrigger: number;
  4711. /**
  4712. * On every frame
  4713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4714. */
  4715. static readonly ACTION_OnEveryFrameTrigger: number;
  4716. /**
  4717. * On intersection enter
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4721. /**
  4722. * On intersection exit
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnIntersectionExitTrigger: number;
  4726. /**
  4727. * On key down
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnKeyDownTrigger: number;
  4731. /**
  4732. * On key up
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnKeyUpTrigger: number;
  4736. /**
  4737. * Billboard mode will only apply to Y axis
  4738. */
  4739. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4740. /**
  4741. * Billboard mode will apply to all axes
  4742. */
  4743. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4744. /**
  4745. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4746. */
  4747. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4748. /**
  4749. * Gets or sets base Assets URL
  4750. */
  4751. static PARTICLES_BaseAssetsUrl: string;
  4752. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4753. * Test order :
  4754. * Is the bounding sphere outside the frustum ?
  4755. * If not, are the bounding box vertices outside the frustum ?
  4756. * It not, then the cullable object is in the frustum.
  4757. */
  4758. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4759. /** Culling strategy : Bounding Sphere Only.
  4760. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4761. * It's also less accurate than the standard because some not visible objects can still be selected.
  4762. * Test : is the bounding sphere outside the frustum ?
  4763. * If not, then the cullable object is in the frustum.
  4764. */
  4765. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4766. /** Culling strategy : Optimistic Inclusion.
  4767. * This in an inclusion test first, then the standard exclusion test.
  4768. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4769. * 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.
  4770. * Anyway, it's as accurate as the standard strategy.
  4771. * Test :
  4772. * Is the cullable object bounding sphere center in the frustum ?
  4773. * If not, apply the default culling strategy.
  4774. */
  4775. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4776. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4777. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4778. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4779. * 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.
  4780. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4781. * Test :
  4782. * Is the cullable object bounding sphere center in the frustum ?
  4783. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4784. */
  4785. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4786. /**
  4787. * No logging while loading
  4788. */
  4789. static readonly SCENELOADER_NO_LOGGING: number;
  4790. /**
  4791. * Minimal logging while loading
  4792. */
  4793. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4794. /**
  4795. * Summary logging while loading
  4796. */
  4797. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4798. /**
  4799. * Detailled logging while loading
  4800. */
  4801. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4802. }
  4803. }
  4804. declare module "babylonjs/States/stencilState" {
  4805. /**
  4806. * @hidden
  4807. **/
  4808. export class _StencilState {
  4809. /** 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 */
  4810. static readonly ALWAYS: number;
  4811. /** Passed to stencilOperation to specify that stencil value must be kept */
  4812. static readonly KEEP: number;
  4813. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4814. static readonly REPLACE: number;
  4815. private _isStencilTestDirty;
  4816. private _isStencilMaskDirty;
  4817. private _isStencilFuncDirty;
  4818. private _isStencilOpDirty;
  4819. private _stencilTest;
  4820. private _stencilMask;
  4821. private _stencilFunc;
  4822. private _stencilFuncRef;
  4823. private _stencilFuncMask;
  4824. private _stencilOpStencilFail;
  4825. private _stencilOpDepthFail;
  4826. private _stencilOpStencilDepthPass;
  4827. readonly isDirty: boolean;
  4828. stencilFunc: number;
  4829. stencilFuncRef: number;
  4830. stencilFuncMask: number;
  4831. stencilOpStencilFail: number;
  4832. stencilOpDepthFail: number;
  4833. stencilOpStencilDepthPass: number;
  4834. stencilMask: number;
  4835. stencilTest: boolean;
  4836. constructor();
  4837. reset(): void;
  4838. apply(gl: WebGLRenderingContext): void;
  4839. }
  4840. }
  4841. declare module "babylonjs/States/index" {
  4842. export * from "babylonjs/States/alphaCullingState";
  4843. export * from "babylonjs/States/depthCullingState";
  4844. export * from "babylonjs/States/stencilState";
  4845. }
  4846. declare module "babylonjs/Instrumentation/timeToken" {
  4847. import { Nullable } from "babylonjs/types";
  4848. /**
  4849. * @hidden
  4850. **/
  4851. export class _TimeToken {
  4852. _startTimeQuery: Nullable<WebGLQuery>;
  4853. _endTimeQuery: Nullable<WebGLQuery>;
  4854. _timeElapsedQuery: Nullable<WebGLQuery>;
  4855. _timeElapsedQueryEnded: boolean;
  4856. }
  4857. }
  4858. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  4859. import { Nullable } from "babylonjs/types";
  4860. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  4861. /**
  4862. * This represents the required contract to create a new type of texture loader.
  4863. */
  4864. export interface IInternalTextureLoader {
  4865. /**
  4866. * Defines wether the loader supports cascade loading the different faces.
  4867. */
  4868. supportCascades: boolean;
  4869. /**
  4870. * This returns if the loader support the current file information.
  4871. * @param extension defines the file extension of the file being loaded
  4872. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4873. * @param fallback defines the fallback internal texture if any
  4874. * @param isBase64 defines whether the texture is encoded as a base64
  4875. * @param isBuffer defines whether the texture data are stored as a buffer
  4876. * @returns true if the loader can load the specified file
  4877. */
  4878. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4879. /**
  4880. * Transform the url before loading if required.
  4881. * @param rootUrl the url of the texture
  4882. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4883. * @returns the transformed texture
  4884. */
  4885. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4886. /**
  4887. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4888. * @param rootUrl the url of the texture
  4889. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4890. * @returns the fallback texture
  4891. */
  4892. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4893. /**
  4894. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4895. * @param data contains the texture data
  4896. * @param texture defines the BabylonJS internal texture
  4897. * @param createPolynomials will be true if polynomials have been requested
  4898. * @param onLoad defines the callback to trigger once the texture is ready
  4899. * @param onError defines the callback to trigger in case of error
  4900. */
  4901. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4902. /**
  4903. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4904. * @param data contains the texture data
  4905. * @param texture defines the BabylonJS internal texture
  4906. * @param callback defines the method to call once ready to upload
  4907. */
  4908. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4909. }
  4910. }
  4911. declare module "babylonjs/Engines/IPipelineContext" {
  4912. /**
  4913. * Class used to store and describe the pipeline context associated with an effect
  4914. */
  4915. export interface IPipelineContext {
  4916. /**
  4917. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4918. */
  4919. isAsync: boolean;
  4920. /**
  4921. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4922. */
  4923. isReady: boolean;
  4924. /** @hidden */
  4925. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4926. }
  4927. }
  4928. declare module "babylonjs/Meshes/dataBuffer" {
  4929. /**
  4930. * Class used to store gfx data (like WebGLBuffer)
  4931. */
  4932. export class DataBuffer {
  4933. /**
  4934. * Gets or sets the number of objects referencing this buffer
  4935. */
  4936. references: number;
  4937. /** Gets or sets the size of the underlying buffer */
  4938. capacity: number;
  4939. /**
  4940. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4941. */
  4942. is32Bits: boolean;
  4943. /**
  4944. * Gets the underlying buffer
  4945. */
  4946. readonly underlyingResource: any;
  4947. }
  4948. }
  4949. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4950. /** @hidden */
  4951. export interface IShaderProcessor {
  4952. attributeProcessor?: (attribute: string) => string;
  4953. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4954. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4955. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4956. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4957. lineProcessor?: (line: string, isFragment: boolean) => string;
  4958. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4959. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4960. }
  4961. }
  4962. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4963. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4964. /** @hidden */
  4965. export interface ProcessingOptions {
  4966. defines: string[];
  4967. indexParameters: any;
  4968. isFragment: boolean;
  4969. shouldUseHighPrecisionShader: boolean;
  4970. supportsUniformBuffers: boolean;
  4971. shadersRepository: string;
  4972. includesShadersStore: {
  4973. [key: string]: string;
  4974. };
  4975. processor?: IShaderProcessor;
  4976. version: string;
  4977. platformName: string;
  4978. lookForClosingBracketForUniformBuffer?: boolean;
  4979. }
  4980. }
  4981. declare module "babylonjs/Misc/stringTools" {
  4982. /**
  4983. * Helper to manipulate strings
  4984. */
  4985. export class StringTools {
  4986. /**
  4987. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4988. * @param str Source string
  4989. * @param suffix Suffix to search for in the source string
  4990. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4991. */
  4992. static EndsWith(str: string, suffix: string): boolean;
  4993. /**
  4994. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4995. * @param str Source string
  4996. * @param suffix Suffix to search for in the source string
  4997. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4998. */
  4999. static StartsWith(str: string, suffix: string): boolean;
  5000. }
  5001. }
  5002. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5003. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5004. /** @hidden */
  5005. export class ShaderCodeNode {
  5006. line: string;
  5007. children: ShaderCodeNode[];
  5008. additionalDefineKey?: string;
  5009. additionalDefineValue?: string;
  5010. isValid(preprocessors: {
  5011. [key: string]: string;
  5012. }): boolean;
  5013. process(preprocessors: {
  5014. [key: string]: string;
  5015. }, options: ProcessingOptions): string;
  5016. }
  5017. }
  5018. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5019. /** @hidden */
  5020. export class ShaderCodeCursor {
  5021. private _lines;
  5022. lineIndex: number;
  5023. readonly currentLine: string;
  5024. readonly canRead: boolean;
  5025. lines: string[];
  5026. }
  5027. }
  5028. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5029. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5030. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5031. /** @hidden */
  5032. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5033. process(preprocessors: {
  5034. [key: string]: string;
  5035. }, options: ProcessingOptions): string;
  5036. }
  5037. }
  5038. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5039. /** @hidden */
  5040. export class ShaderDefineExpression {
  5041. isTrue(preprocessors: {
  5042. [key: string]: string;
  5043. }): boolean;
  5044. }
  5045. }
  5046. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5047. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5048. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5049. /** @hidden */
  5050. export class ShaderCodeTestNode extends ShaderCodeNode {
  5051. testExpression: ShaderDefineExpression;
  5052. isValid(preprocessors: {
  5053. [key: string]: string;
  5054. }): boolean;
  5055. }
  5056. }
  5057. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5058. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5059. /** @hidden */
  5060. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5061. define: string;
  5062. not: boolean;
  5063. constructor(define: string, not?: boolean);
  5064. isTrue(preprocessors: {
  5065. [key: string]: string;
  5066. }): boolean;
  5067. }
  5068. }
  5069. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5070. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5071. /** @hidden */
  5072. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5073. leftOperand: ShaderDefineExpression;
  5074. rightOperand: ShaderDefineExpression;
  5075. isTrue(preprocessors: {
  5076. [key: string]: string;
  5077. }): boolean;
  5078. }
  5079. }
  5080. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5081. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5082. /** @hidden */
  5083. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5084. leftOperand: ShaderDefineExpression;
  5085. rightOperand: ShaderDefineExpression;
  5086. isTrue(preprocessors: {
  5087. [key: string]: string;
  5088. }): boolean;
  5089. }
  5090. }
  5091. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5092. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5093. /** @hidden */
  5094. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5095. define: string;
  5096. operand: string;
  5097. testValue: string;
  5098. constructor(define: string, operand: string, testValue: string);
  5099. isTrue(preprocessors: {
  5100. [key: string]: string;
  5101. }): boolean;
  5102. }
  5103. }
  5104. declare module "babylonjs/Misc/loadFileError" {
  5105. import { WebRequest } from "babylonjs/Misc/webRequest";
  5106. /**
  5107. * @ignore
  5108. * Application error to support additional information when loading a file
  5109. */
  5110. export class LoadFileError extends Error {
  5111. /** defines the optional web request */
  5112. request?: WebRequest | undefined;
  5113. private static _setPrototypeOf;
  5114. /**
  5115. * Creates a new LoadFileError
  5116. * @param message defines the message of the error
  5117. * @param request defines the optional web request
  5118. */
  5119. constructor(message: string,
  5120. /** defines the optional web request */
  5121. request?: WebRequest | undefined);
  5122. }
  5123. }
  5124. declare module "babylonjs/Offline/IOfflineProvider" {
  5125. /**
  5126. * Class used to enable access to offline support
  5127. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5128. */
  5129. export interface IOfflineProvider {
  5130. /**
  5131. * Gets a boolean indicating if scene must be saved in the database
  5132. */
  5133. enableSceneOffline: boolean;
  5134. /**
  5135. * Gets a boolean indicating if textures must be saved in the database
  5136. */
  5137. enableTexturesOffline: boolean;
  5138. /**
  5139. * Open the offline support and make it available
  5140. * @param successCallback defines the callback to call on success
  5141. * @param errorCallback defines the callback to call on error
  5142. */
  5143. open(successCallback: () => void, errorCallback: () => void): void;
  5144. /**
  5145. * Loads an image from the offline support
  5146. * @param url defines the url to load from
  5147. * @param image defines the target DOM image
  5148. */
  5149. loadImage(url: string, image: HTMLImageElement): void;
  5150. /**
  5151. * Loads a file from offline support
  5152. * @param url defines the URL to load from
  5153. * @param sceneLoaded defines a callback to call on success
  5154. * @param progressCallBack defines a callback to call when progress changed
  5155. * @param errorCallback defines a callback to call on error
  5156. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5157. */
  5158. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5159. }
  5160. }
  5161. declare module "babylonjs/Misc/filesInputStore" {
  5162. /**
  5163. * Class used to help managing file picking and drag'n'drop
  5164. * File Storage
  5165. */
  5166. export class FilesInputStore {
  5167. /**
  5168. * List of files ready to be loaded
  5169. */
  5170. static FilesToLoad: {
  5171. [key: string]: File;
  5172. };
  5173. }
  5174. }
  5175. declare module "babylonjs/Misc/retryStrategy" {
  5176. import { WebRequest } from "babylonjs/Misc/webRequest";
  5177. /**
  5178. * Class used to define a retry strategy when error happens while loading assets
  5179. */
  5180. export class RetryStrategy {
  5181. /**
  5182. * Function used to defines an exponential back off strategy
  5183. * @param maxRetries defines the maximum number of retries (3 by default)
  5184. * @param baseInterval defines the interval between retries
  5185. * @returns the strategy function to use
  5186. */
  5187. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5188. }
  5189. }
  5190. declare module "babylonjs/Misc/fileTools" {
  5191. import { WebRequest } from "babylonjs/Misc/webRequest";
  5192. import { Nullable } from "babylonjs/types";
  5193. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  5194. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  5195. /**
  5196. * @hidden
  5197. */
  5198. export class FileTools {
  5199. /**
  5200. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5201. */
  5202. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5203. /**
  5204. * Gets or sets the base URL to use to load assets
  5205. */
  5206. static BaseUrl: string;
  5207. /**
  5208. * Default behaviour for cors in the application.
  5209. * It can be a string if the expected behavior is identical in the entire app.
  5210. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5211. */
  5212. static CorsBehavior: string | ((url: string | string[]) => string);
  5213. /**
  5214. * Gets or sets a function used to pre-process url before using them to load assets
  5215. */
  5216. static PreprocessUrl: (url: string) => string;
  5217. /**
  5218. * Removes unwanted characters from an url
  5219. * @param url defines the url to clean
  5220. * @returns the cleaned url
  5221. */
  5222. private static _CleanUrl;
  5223. /**
  5224. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5225. * @param url define the url we are trying
  5226. * @param element define the dom element where to configure the cors policy
  5227. */
  5228. static SetCorsBehavior(url: string | string[], element: {
  5229. crossOrigin: string | null;
  5230. }): void;
  5231. /**
  5232. * Loads an image as an HTMLImageElement.
  5233. * @param input url string, ArrayBuffer, or Blob to load
  5234. * @param onLoad callback called when the image successfully loads
  5235. * @param onError callback called when the image fails to load
  5236. * @param offlineProvider offline provider for caching
  5237. * @returns the HTMLImageElement of the loaded image
  5238. */
  5239. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5240. /**
  5241. * Loads a file
  5242. * @param fileToLoad defines the file to load
  5243. * @param callback defines the callback to call when data is loaded
  5244. * @param progressCallBack defines the callback to call during loading process
  5245. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5246. * @returns a file request object
  5247. */
  5248. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5249. /**
  5250. * Loads a file
  5251. * @param url url string, ArrayBuffer, or Blob to load
  5252. * @param onSuccess callback called when the file successfully loads
  5253. * @param onProgress callback called while file is loading (if the server supports this mode)
  5254. * @param offlineProvider defines the offline provider for caching
  5255. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5256. * @param onError callback called when the file fails to load
  5257. * @returns a file request object
  5258. */
  5259. 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;
  5260. /**
  5261. * Checks if the loaded document was accessed via `file:`-Protocol.
  5262. * @returns boolean
  5263. */
  5264. static IsFileURL(): boolean;
  5265. }
  5266. }
  5267. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5268. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5269. /** @hidden */
  5270. export class ShaderProcessor {
  5271. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5272. private static _ProcessPrecision;
  5273. private static _ExtractOperation;
  5274. private static _BuildSubExpression;
  5275. private static _BuildExpression;
  5276. private static _MoveCursorWithinIf;
  5277. private static _MoveCursor;
  5278. private static _EvaluatePreProcessors;
  5279. private static _PreparePreProcessors;
  5280. private static _ProcessShaderConversion;
  5281. private static _ProcessIncludes;
  5282. }
  5283. }
  5284. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5285. /**
  5286. * Class used to evalaute queries containing `and` and `or` operators
  5287. */
  5288. export class AndOrNotEvaluator {
  5289. /**
  5290. * Evaluate a query
  5291. * @param query defines the query to evaluate
  5292. * @param evaluateCallback defines the callback used to filter result
  5293. * @returns true if the query matches
  5294. */
  5295. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5296. private static _HandleParenthesisContent;
  5297. private static _SimplifyNegation;
  5298. }
  5299. }
  5300. declare module "babylonjs/Misc/tags" {
  5301. /**
  5302. * Class used to store custom tags
  5303. */
  5304. export class Tags {
  5305. /**
  5306. * Adds support for tags on the given object
  5307. * @param obj defines the object to use
  5308. */
  5309. static EnableFor(obj: any): void;
  5310. /**
  5311. * Removes tags support
  5312. * @param obj defines the object to use
  5313. */
  5314. static DisableFor(obj: any): void;
  5315. /**
  5316. * Gets a boolean indicating if the given object has tags
  5317. * @param obj defines the object to use
  5318. * @returns a boolean
  5319. */
  5320. static HasTags(obj: any): boolean;
  5321. /**
  5322. * Gets the tags available on a given object
  5323. * @param obj defines the object to use
  5324. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5325. * @returns the tags
  5326. */
  5327. static GetTags(obj: any, asString?: boolean): any;
  5328. /**
  5329. * Adds tags to an object
  5330. * @param obj defines the object to use
  5331. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5332. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5333. */
  5334. static AddTagsTo(obj: any, tagsString: string): void;
  5335. /**
  5336. * @hidden
  5337. */
  5338. static _AddTagTo(obj: any, tag: string): void;
  5339. /**
  5340. * Removes specific tags from a specific object
  5341. * @param obj defines the object to use
  5342. * @param tagsString defines the tags to remove
  5343. */
  5344. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5345. /**
  5346. * @hidden
  5347. */
  5348. static _RemoveTagFrom(obj: any, tag: string): void;
  5349. /**
  5350. * Defines if tags hosted on an object match a given query
  5351. * @param obj defines the object to use
  5352. * @param tagsQuery defines the tag query
  5353. * @returns a boolean
  5354. */
  5355. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5356. }
  5357. }
  5358. declare module "babylonjs/Maths/math.path" {
  5359. import { DeepImmutable, Nullable } from "babylonjs/types";
  5360. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5361. /**
  5362. * Defines potential orientation for back face culling
  5363. */
  5364. export enum Orientation {
  5365. /**
  5366. * Clockwise
  5367. */
  5368. CW = 0,
  5369. /** Counter clockwise */
  5370. CCW = 1
  5371. }
  5372. /** Class used to represent a Bezier curve */
  5373. export class BezierCurve {
  5374. /**
  5375. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5376. * @param t defines the time
  5377. * @param x1 defines the left coordinate on X axis
  5378. * @param y1 defines the left coordinate on Y axis
  5379. * @param x2 defines the right coordinate on X axis
  5380. * @param y2 defines the right coordinate on Y axis
  5381. * @returns the interpolated value
  5382. */
  5383. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5384. }
  5385. /**
  5386. * Defines angle representation
  5387. */
  5388. export class Angle {
  5389. private _radians;
  5390. /**
  5391. * Creates an Angle object of "radians" radians (float).
  5392. * @param radians the angle in radians
  5393. */
  5394. constructor(radians: number);
  5395. /**
  5396. * Get value in degrees
  5397. * @returns the Angle value in degrees (float)
  5398. */
  5399. degrees(): number;
  5400. /**
  5401. * Get value in radians
  5402. * @returns the Angle value in radians (float)
  5403. */
  5404. radians(): number;
  5405. /**
  5406. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5407. * @param a defines first vector
  5408. * @param b defines second vector
  5409. * @returns a new Angle
  5410. */
  5411. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5412. /**
  5413. * Gets a new Angle object from the given float in radians
  5414. * @param radians defines the angle value in radians
  5415. * @returns a new Angle
  5416. */
  5417. static FromRadians(radians: number): Angle;
  5418. /**
  5419. * Gets a new Angle object from the given float in degrees
  5420. * @param degrees defines the angle value in degrees
  5421. * @returns a new Angle
  5422. */
  5423. static FromDegrees(degrees: number): Angle;
  5424. }
  5425. /**
  5426. * This represents an arc in a 2d space.
  5427. */
  5428. export class Arc2 {
  5429. /** Defines the start point of the arc */
  5430. startPoint: Vector2;
  5431. /** Defines the mid point of the arc */
  5432. midPoint: Vector2;
  5433. /** Defines the end point of the arc */
  5434. endPoint: Vector2;
  5435. /**
  5436. * Defines the center point of the arc.
  5437. */
  5438. centerPoint: Vector2;
  5439. /**
  5440. * Defines the radius of the arc.
  5441. */
  5442. radius: number;
  5443. /**
  5444. * Defines the angle of the arc (from mid point to end point).
  5445. */
  5446. angle: Angle;
  5447. /**
  5448. * Defines the start angle of the arc (from start point to middle point).
  5449. */
  5450. startAngle: Angle;
  5451. /**
  5452. * Defines the orientation of the arc (clock wise/counter clock wise).
  5453. */
  5454. orientation: Orientation;
  5455. /**
  5456. * Creates an Arc object from the three given points : start, middle and end.
  5457. * @param startPoint Defines the start point of the arc
  5458. * @param midPoint Defines the midlle point of the arc
  5459. * @param endPoint Defines the end point of the arc
  5460. */
  5461. constructor(
  5462. /** Defines the start point of the arc */
  5463. startPoint: Vector2,
  5464. /** Defines the mid point of the arc */
  5465. midPoint: Vector2,
  5466. /** Defines the end point of the arc */
  5467. endPoint: Vector2);
  5468. }
  5469. /**
  5470. * Represents a 2D path made up of multiple 2D points
  5471. */
  5472. export class Path2 {
  5473. private _points;
  5474. private _length;
  5475. /**
  5476. * If the path start and end point are the same
  5477. */
  5478. closed: boolean;
  5479. /**
  5480. * Creates a Path2 object from the starting 2D coordinates x and y.
  5481. * @param x the starting points x value
  5482. * @param y the starting points y value
  5483. */
  5484. constructor(x: number, y: number);
  5485. /**
  5486. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5487. * @param x the added points x value
  5488. * @param y the added points y value
  5489. * @returns the updated Path2.
  5490. */
  5491. addLineTo(x: number, y: number): Path2;
  5492. /**
  5493. * 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.
  5494. * @param midX middle point x value
  5495. * @param midY middle point y value
  5496. * @param endX end point x value
  5497. * @param endY end point y value
  5498. * @param numberOfSegments (default: 36)
  5499. * @returns the updated Path2.
  5500. */
  5501. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5502. /**
  5503. * Closes the Path2.
  5504. * @returns the Path2.
  5505. */
  5506. close(): Path2;
  5507. /**
  5508. * Gets the sum of the distance between each sequential point in the path
  5509. * @returns the Path2 total length (float).
  5510. */
  5511. length(): number;
  5512. /**
  5513. * Gets the points which construct the path
  5514. * @returns the Path2 internal array of points.
  5515. */
  5516. getPoints(): Vector2[];
  5517. /**
  5518. * Retreives the point at the distance aways from the starting point
  5519. * @param normalizedLengthPosition the length along the path to retreive the point from
  5520. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5521. */
  5522. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5523. /**
  5524. * Creates a new path starting from an x and y position
  5525. * @param x starting x value
  5526. * @param y starting y value
  5527. * @returns a new Path2 starting at the coordinates (x, y).
  5528. */
  5529. static StartingAt(x: number, y: number): Path2;
  5530. }
  5531. /**
  5532. * Represents a 3D path made up of multiple 3D points
  5533. */
  5534. export class Path3D {
  5535. /**
  5536. * an array of Vector3, the curve axis of the Path3D
  5537. */
  5538. path: Vector3[];
  5539. private _curve;
  5540. private _distances;
  5541. private _tangents;
  5542. private _normals;
  5543. private _binormals;
  5544. private _raw;
  5545. /**
  5546. * new Path3D(path, normal, raw)
  5547. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5548. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5549. * @param path an array of Vector3, the curve axis of the Path3D
  5550. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5551. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5552. */
  5553. constructor(
  5554. /**
  5555. * an array of Vector3, the curve axis of the Path3D
  5556. */
  5557. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5558. /**
  5559. * Returns the Path3D array of successive Vector3 designing its curve.
  5560. * @returns the Path3D array of successive Vector3 designing its curve.
  5561. */
  5562. getCurve(): Vector3[];
  5563. /**
  5564. * Returns an array populated with tangent vectors on each Path3D curve point.
  5565. * @returns an array populated with tangent vectors on each Path3D curve point.
  5566. */
  5567. getTangents(): Vector3[];
  5568. /**
  5569. * Returns an array populated with normal vectors on each Path3D curve point.
  5570. * @returns an array populated with normal vectors on each Path3D curve point.
  5571. */
  5572. getNormals(): Vector3[];
  5573. /**
  5574. * Returns an array populated with binormal vectors on each Path3D curve point.
  5575. * @returns an array populated with binormal vectors on each Path3D curve point.
  5576. */
  5577. getBinormals(): Vector3[];
  5578. /**
  5579. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5580. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5581. */
  5582. getDistances(): number[];
  5583. /**
  5584. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5585. * @param path path which all values are copied into the curves points
  5586. * @param firstNormal which should be projected onto the curve
  5587. * @returns the same object updated.
  5588. */
  5589. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5590. private _compute;
  5591. private _getFirstNonNullVector;
  5592. private _getLastNonNullVector;
  5593. private _normalVector;
  5594. }
  5595. /**
  5596. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5597. * A Curve3 is designed from a series of successive Vector3.
  5598. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5599. */
  5600. export class Curve3 {
  5601. private _points;
  5602. private _length;
  5603. /**
  5604. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5605. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5606. * @param v1 (Vector3) the control point
  5607. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5608. * @param nbPoints (integer) the wanted number of points in the curve
  5609. * @returns the created Curve3
  5610. */
  5611. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5612. /**
  5613. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5614. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5615. * @param v1 (Vector3) the first control point
  5616. * @param v2 (Vector3) the second control point
  5617. * @param v3 (Vector3) the end point of the Cubic Bezier
  5618. * @param nbPoints (integer) the wanted number of points in the curve
  5619. * @returns the created Curve3
  5620. */
  5621. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5622. /**
  5623. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5624. * @param p1 (Vector3) the origin point of the Hermite Spline
  5625. * @param t1 (Vector3) the tangent vector at the origin point
  5626. * @param p2 (Vector3) the end point of the Hermite Spline
  5627. * @param t2 (Vector3) the tangent vector at the end point
  5628. * @param nbPoints (integer) the wanted number of points in the curve
  5629. * @returns the created Curve3
  5630. */
  5631. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5632. /**
  5633. * Returns a Curve3 object along a CatmullRom Spline curve :
  5634. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5635. * @param nbPoints (integer) the wanted number of points between each curve control points
  5636. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5637. * @returns the created Curve3
  5638. */
  5639. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5640. /**
  5641. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5642. * A Curve3 is designed from a series of successive Vector3.
  5643. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5644. * @param points points which make up the curve
  5645. */
  5646. constructor(points: Vector3[]);
  5647. /**
  5648. * @returns the Curve3 stored array of successive Vector3
  5649. */
  5650. getPoints(): Vector3[];
  5651. /**
  5652. * @returns the computed length (float) of the curve.
  5653. */
  5654. length(): number;
  5655. /**
  5656. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5657. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5658. * curveA and curveB keep unchanged.
  5659. * @param curve the curve to continue from this curve
  5660. * @returns the newly constructed curve
  5661. */
  5662. continue(curve: DeepImmutable<Curve3>): Curve3;
  5663. private _computeLength;
  5664. }
  5665. }
  5666. declare module "babylonjs/Animations/easing" {
  5667. /**
  5668. * This represents the main contract an easing function should follow.
  5669. * Easing functions are used throughout the animation system.
  5670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5671. */
  5672. export interface IEasingFunction {
  5673. /**
  5674. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5675. * of the easing function.
  5676. * The link below provides some of the most common examples of easing functions.
  5677. * @see https://easings.net/
  5678. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5679. * @returns the corresponding value on the curve defined by the easing function
  5680. */
  5681. ease(gradient: number): number;
  5682. }
  5683. /**
  5684. * Base class used for every default easing function.
  5685. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5686. */
  5687. export class EasingFunction implements IEasingFunction {
  5688. /**
  5689. * Interpolation follows the mathematical formula associated with the easing function.
  5690. */
  5691. static readonly EASINGMODE_EASEIN: number;
  5692. /**
  5693. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5694. */
  5695. static readonly EASINGMODE_EASEOUT: number;
  5696. /**
  5697. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5698. */
  5699. static readonly EASINGMODE_EASEINOUT: number;
  5700. private _easingMode;
  5701. /**
  5702. * Sets the easing mode of the current function.
  5703. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5704. */
  5705. setEasingMode(easingMode: number): void;
  5706. /**
  5707. * Gets the current easing mode.
  5708. * @returns the easing mode
  5709. */
  5710. getEasingMode(): number;
  5711. /**
  5712. * @hidden
  5713. */
  5714. easeInCore(gradient: number): number;
  5715. /**
  5716. * Given an input gradient between 0 and 1, this returns the corresponding value
  5717. * of the easing function.
  5718. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5719. * @returns the corresponding value on the curve defined by the easing function
  5720. */
  5721. ease(gradient: number): number;
  5722. }
  5723. /**
  5724. * Easing function with a circle shape (see link below).
  5725. * @see https://easings.net/#easeInCirc
  5726. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5727. */
  5728. export class CircleEase extends EasingFunction implements IEasingFunction {
  5729. /** @hidden */
  5730. easeInCore(gradient: number): number;
  5731. }
  5732. /**
  5733. * Easing function with a ease back shape (see link below).
  5734. * @see https://easings.net/#easeInBack
  5735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5736. */
  5737. export class BackEase extends EasingFunction implements IEasingFunction {
  5738. /** Defines the amplitude of the function */
  5739. amplitude: number;
  5740. /**
  5741. * Instantiates a back ease easing
  5742. * @see https://easings.net/#easeInBack
  5743. * @param amplitude Defines the amplitude of the function
  5744. */
  5745. constructor(
  5746. /** Defines the amplitude of the function */
  5747. amplitude?: number);
  5748. /** @hidden */
  5749. easeInCore(gradient: number): number;
  5750. }
  5751. /**
  5752. * Easing function with a bouncing shape (see link below).
  5753. * @see https://easings.net/#easeInBounce
  5754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5755. */
  5756. export class BounceEase extends EasingFunction implements IEasingFunction {
  5757. /** Defines the number of bounces */
  5758. bounces: number;
  5759. /** Defines the amplitude of the bounce */
  5760. bounciness: number;
  5761. /**
  5762. * Instantiates a bounce easing
  5763. * @see https://easings.net/#easeInBounce
  5764. * @param bounces Defines the number of bounces
  5765. * @param bounciness Defines the amplitude of the bounce
  5766. */
  5767. constructor(
  5768. /** Defines the number of bounces */
  5769. bounces?: number,
  5770. /** Defines the amplitude of the bounce */
  5771. bounciness?: number);
  5772. /** @hidden */
  5773. easeInCore(gradient: number): number;
  5774. }
  5775. /**
  5776. * Easing function with a power of 3 shape (see link below).
  5777. * @see https://easings.net/#easeInCubic
  5778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5779. */
  5780. export class CubicEase extends EasingFunction implements IEasingFunction {
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with an elastic shape (see link below).
  5786. * @see https://easings.net/#easeInElastic
  5787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5790. /** Defines the number of oscillations*/
  5791. oscillations: number;
  5792. /** Defines the amplitude of the oscillations*/
  5793. springiness: number;
  5794. /**
  5795. * Instantiates an elastic easing function
  5796. * @see https://easings.net/#easeInElastic
  5797. * @param oscillations Defines the number of oscillations
  5798. * @param springiness Defines the amplitude of the oscillations
  5799. */
  5800. constructor(
  5801. /** Defines the number of oscillations*/
  5802. oscillations?: number,
  5803. /** Defines the amplitude of the oscillations*/
  5804. springiness?: number);
  5805. /** @hidden */
  5806. easeInCore(gradient: number): number;
  5807. }
  5808. /**
  5809. * Easing function with an exponential shape (see link below).
  5810. * @see https://easings.net/#easeInExpo
  5811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5812. */
  5813. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5814. /** Defines the exponent of the function */
  5815. exponent: number;
  5816. /**
  5817. * Instantiates an exponential easing function
  5818. * @see https://easings.net/#easeInExpo
  5819. * @param exponent Defines the exponent of the function
  5820. */
  5821. constructor(
  5822. /** Defines the exponent of the function */
  5823. exponent?: number);
  5824. /** @hidden */
  5825. easeInCore(gradient: number): number;
  5826. }
  5827. /**
  5828. * Easing function with a power shape (see link below).
  5829. * @see https://easings.net/#easeInQuad
  5830. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5831. */
  5832. export class PowerEase extends EasingFunction implements IEasingFunction {
  5833. /** Defines the power of the function */
  5834. power: number;
  5835. /**
  5836. * Instantiates an power base easing function
  5837. * @see https://easings.net/#easeInQuad
  5838. * @param power Defines the power of the function
  5839. */
  5840. constructor(
  5841. /** Defines the power of the function */
  5842. power?: number);
  5843. /** @hidden */
  5844. easeInCore(gradient: number): number;
  5845. }
  5846. /**
  5847. * Easing function with a power of 2 shape (see link below).
  5848. * @see https://easings.net/#easeInQuad
  5849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5850. */
  5851. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5852. /** @hidden */
  5853. easeInCore(gradient: number): number;
  5854. }
  5855. /**
  5856. * Easing function with a power of 4 shape (see link below).
  5857. * @see https://easings.net/#easeInQuart
  5858. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5859. */
  5860. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5861. /** @hidden */
  5862. easeInCore(gradient: number): number;
  5863. }
  5864. /**
  5865. * Easing function with a power of 5 shape (see link below).
  5866. * @see https://easings.net/#easeInQuint
  5867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5868. */
  5869. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5870. /** @hidden */
  5871. easeInCore(gradient: number): number;
  5872. }
  5873. /**
  5874. * Easing function with a sin shape (see link below).
  5875. * @see https://easings.net/#easeInSine
  5876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5877. */
  5878. export class SineEase extends EasingFunction implements IEasingFunction {
  5879. /** @hidden */
  5880. easeInCore(gradient: number): number;
  5881. }
  5882. /**
  5883. * Easing function with a bezier shape (see link below).
  5884. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5886. */
  5887. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5888. /** Defines the x component of the start tangent in the bezier curve */
  5889. x1: number;
  5890. /** Defines the y component of the start tangent in the bezier curve */
  5891. y1: number;
  5892. /** Defines the x component of the end tangent in the bezier curve */
  5893. x2: number;
  5894. /** Defines the y component of the end tangent in the bezier curve */
  5895. y2: number;
  5896. /**
  5897. * Instantiates a bezier function
  5898. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5899. * @param x1 Defines the x component of the start tangent in the bezier curve
  5900. * @param y1 Defines the y component of the start tangent in the bezier curve
  5901. * @param x2 Defines the x component of the end tangent in the bezier curve
  5902. * @param y2 Defines the y component of the end tangent in the bezier curve
  5903. */
  5904. constructor(
  5905. /** Defines the x component of the start tangent in the bezier curve */
  5906. x1?: number,
  5907. /** Defines the y component of the start tangent in the bezier curve */
  5908. y1?: number,
  5909. /** Defines the x component of the end tangent in the bezier curve */
  5910. x2?: number,
  5911. /** Defines the y component of the end tangent in the bezier curve */
  5912. y2?: number);
  5913. /** @hidden */
  5914. easeInCore(gradient: number): number;
  5915. }
  5916. }
  5917. declare module "babylonjs/Animations/animationKey" {
  5918. /**
  5919. * Defines an interface which represents an animation key frame
  5920. */
  5921. export interface IAnimationKey {
  5922. /**
  5923. * Frame of the key frame
  5924. */
  5925. frame: number;
  5926. /**
  5927. * Value at the specifies key frame
  5928. */
  5929. value: any;
  5930. /**
  5931. * The input tangent for the cubic hermite spline
  5932. */
  5933. inTangent?: any;
  5934. /**
  5935. * The output tangent for the cubic hermite spline
  5936. */
  5937. outTangent?: any;
  5938. /**
  5939. * The animation interpolation type
  5940. */
  5941. interpolation?: AnimationKeyInterpolation;
  5942. }
  5943. /**
  5944. * Enum for the animation key frame interpolation type
  5945. */
  5946. export enum AnimationKeyInterpolation {
  5947. /**
  5948. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5949. */
  5950. STEP = 1
  5951. }
  5952. }
  5953. declare module "babylonjs/Animations/animationRange" {
  5954. /**
  5955. * Represents the range of an animation
  5956. */
  5957. export class AnimationRange {
  5958. /**The name of the animation range**/
  5959. name: string;
  5960. /**The starting frame of the animation */
  5961. from: number;
  5962. /**The ending frame of the animation*/
  5963. to: number;
  5964. /**
  5965. * Initializes the range of an animation
  5966. * @param name The name of the animation range
  5967. * @param from The starting frame of the animation
  5968. * @param to The ending frame of the animation
  5969. */
  5970. constructor(
  5971. /**The name of the animation range**/
  5972. name: string,
  5973. /**The starting frame of the animation */
  5974. from: number,
  5975. /**The ending frame of the animation*/
  5976. to: number);
  5977. /**
  5978. * Makes a copy of the animation range
  5979. * @returns A copy of the animation range
  5980. */
  5981. clone(): AnimationRange;
  5982. }
  5983. }
  5984. declare module "babylonjs/Animations/animationEvent" {
  5985. /**
  5986. * Composed of a frame, and an action function
  5987. */
  5988. export class AnimationEvent {
  5989. /** The frame for which the event is triggered **/
  5990. frame: number;
  5991. /** The event to perform when triggered **/
  5992. action: (currentFrame: number) => void;
  5993. /** Specifies if the event should be triggered only once**/
  5994. onlyOnce?: boolean | undefined;
  5995. /**
  5996. * Specifies if the animation event is done
  5997. */
  5998. isDone: boolean;
  5999. /**
  6000. * Initializes the animation event
  6001. * @param frame The frame for which the event is triggered
  6002. * @param action The event to perform when triggered
  6003. * @param onlyOnce Specifies if the event should be triggered only once
  6004. */
  6005. constructor(
  6006. /** The frame for which the event is triggered **/
  6007. frame: number,
  6008. /** The event to perform when triggered **/
  6009. action: (currentFrame: number) => void,
  6010. /** Specifies if the event should be triggered only once**/
  6011. onlyOnce?: boolean | undefined);
  6012. /** @hidden */
  6013. _clone(): AnimationEvent;
  6014. }
  6015. }
  6016. declare module "babylonjs/Behaviors/behavior" {
  6017. import { Nullable } from "babylonjs/types";
  6018. /**
  6019. * Interface used to define a behavior
  6020. */
  6021. export interface Behavior<T> {
  6022. /** gets or sets behavior's name */
  6023. name: string;
  6024. /**
  6025. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6026. */
  6027. init(): void;
  6028. /**
  6029. * Called when the behavior is attached to a target
  6030. * @param target defines the target where the behavior is attached to
  6031. */
  6032. attach(target: T): void;
  6033. /**
  6034. * Called when the behavior is detached from its target
  6035. */
  6036. detach(): void;
  6037. }
  6038. /**
  6039. * Interface implemented by classes supporting behaviors
  6040. */
  6041. export interface IBehaviorAware<T> {
  6042. /**
  6043. * Attach a behavior
  6044. * @param behavior defines the behavior to attach
  6045. * @returns the current host
  6046. */
  6047. addBehavior(behavior: Behavior<T>): T;
  6048. /**
  6049. * Remove a behavior from the current object
  6050. * @param behavior defines the behavior to detach
  6051. * @returns the current host
  6052. */
  6053. removeBehavior(behavior: Behavior<T>): T;
  6054. /**
  6055. * Gets a behavior using its name to search
  6056. * @param name defines the name to search
  6057. * @returns the behavior or null if not found
  6058. */
  6059. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6060. }
  6061. }
  6062. declare module "babylonjs/Misc/smartArray" {
  6063. /**
  6064. * Defines an array and its length.
  6065. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6066. */
  6067. export interface ISmartArrayLike<T> {
  6068. /**
  6069. * The data of the array.
  6070. */
  6071. data: Array<T>;
  6072. /**
  6073. * The active length of the array.
  6074. */
  6075. length: number;
  6076. }
  6077. /**
  6078. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6079. */
  6080. export class SmartArray<T> implements ISmartArrayLike<T> {
  6081. /**
  6082. * The full set of data from the array.
  6083. */
  6084. data: Array<T>;
  6085. /**
  6086. * The active length of the array.
  6087. */
  6088. length: number;
  6089. protected _id: number;
  6090. /**
  6091. * Instantiates a Smart Array.
  6092. * @param capacity defines the default capacity of the array.
  6093. */
  6094. constructor(capacity: number);
  6095. /**
  6096. * Pushes a value at the end of the active data.
  6097. * @param value defines the object to push in the array.
  6098. */
  6099. push(value: T): void;
  6100. /**
  6101. * Iterates over the active data and apply the lambda to them.
  6102. * @param func defines the action to apply on each value.
  6103. */
  6104. forEach(func: (content: T) => void): void;
  6105. /**
  6106. * Sorts the full sets of data.
  6107. * @param compareFn defines the comparison function to apply.
  6108. */
  6109. sort(compareFn: (a: T, b: T) => number): void;
  6110. /**
  6111. * Resets the active data to an empty array.
  6112. */
  6113. reset(): void;
  6114. /**
  6115. * Releases all the data from the array as well as the array.
  6116. */
  6117. dispose(): void;
  6118. /**
  6119. * Concats the active data with a given array.
  6120. * @param array defines the data to concatenate with.
  6121. */
  6122. concat(array: any): void;
  6123. /**
  6124. * Returns the position of a value in the active data.
  6125. * @param value defines the value to find the index for
  6126. * @returns the index if found in the active data otherwise -1
  6127. */
  6128. indexOf(value: T): number;
  6129. /**
  6130. * Returns whether an element is part of the active data.
  6131. * @param value defines the value to look for
  6132. * @returns true if found in the active data otherwise false
  6133. */
  6134. contains(value: T): boolean;
  6135. private static _GlobalId;
  6136. }
  6137. /**
  6138. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6139. * The data in this array can only be present once
  6140. */
  6141. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6142. private _duplicateId;
  6143. /**
  6144. * Pushes a value at the end of the active data.
  6145. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6146. * @param value defines the object to push in the array.
  6147. */
  6148. push(value: T): void;
  6149. /**
  6150. * Pushes a value at the end of the active data.
  6151. * If the data is already present, it won t be added again
  6152. * @param value defines the object to push in the array.
  6153. * @returns true if added false if it was already present
  6154. */
  6155. pushNoDuplicate(value: T): boolean;
  6156. /**
  6157. * Resets the active data to an empty array.
  6158. */
  6159. reset(): void;
  6160. /**
  6161. * Concats the active data with a given array.
  6162. * This ensures no dupplicate will be present in the result.
  6163. * @param array defines the data to concatenate with.
  6164. */
  6165. concatWithNoDuplicate(array: any): void;
  6166. }
  6167. }
  6168. declare module "babylonjs/Cameras/cameraInputsManager" {
  6169. import { Nullable } from "babylonjs/types";
  6170. import { Camera } from "babylonjs/Cameras/camera";
  6171. /**
  6172. * @ignore
  6173. * This is a list of all the different input types that are available in the application.
  6174. * Fo instance: ArcRotateCameraGamepadInput...
  6175. */
  6176. export var CameraInputTypes: {};
  6177. /**
  6178. * This is the contract to implement in order to create a new input class.
  6179. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6180. */
  6181. export interface ICameraInput<TCamera extends Camera> {
  6182. /**
  6183. * Defines the camera the input is attached to.
  6184. */
  6185. camera: Nullable<TCamera>;
  6186. /**
  6187. * Gets the class name of the current intput.
  6188. * @returns the class name
  6189. */
  6190. getClassName(): string;
  6191. /**
  6192. * Get the friendly name associated with the input class.
  6193. * @returns the input friendly name
  6194. */
  6195. getSimpleName(): string;
  6196. /**
  6197. * Attach the input controls to a specific dom element to get the input from.
  6198. * @param element Defines the element the controls should be listened from
  6199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6200. */
  6201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6202. /**
  6203. * Detach the current controls from the specified dom element.
  6204. * @param element Defines the element to stop listening the inputs from
  6205. */
  6206. detachControl(element: Nullable<HTMLElement>): void;
  6207. /**
  6208. * Update the current camera state depending on the inputs that have been used this frame.
  6209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6210. */
  6211. checkInputs?: () => void;
  6212. }
  6213. /**
  6214. * Represents a map of input types to input instance or input index to input instance.
  6215. */
  6216. export interface CameraInputsMap<TCamera extends Camera> {
  6217. /**
  6218. * Accessor to the input by input type.
  6219. */
  6220. [name: string]: ICameraInput<TCamera>;
  6221. /**
  6222. * Accessor to the input by input index.
  6223. */
  6224. [idx: number]: ICameraInput<TCamera>;
  6225. }
  6226. /**
  6227. * This represents the input manager used within a camera.
  6228. * It helps dealing with all the different kind of input attached to a camera.
  6229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6230. */
  6231. export class CameraInputsManager<TCamera extends Camera> {
  6232. /**
  6233. * Defines the list of inputs attahed to the camera.
  6234. */
  6235. attached: CameraInputsMap<TCamera>;
  6236. /**
  6237. * Defines the dom element the camera is collecting inputs from.
  6238. * This is null if the controls have not been attached.
  6239. */
  6240. attachedElement: Nullable<HTMLElement>;
  6241. /**
  6242. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6243. */
  6244. noPreventDefault: boolean;
  6245. /**
  6246. * Defined the camera the input manager belongs to.
  6247. */
  6248. camera: TCamera;
  6249. /**
  6250. * Update the current camera state depending on the inputs that have been used this frame.
  6251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6252. */
  6253. checkInputs: () => void;
  6254. /**
  6255. * Instantiate a new Camera Input Manager.
  6256. * @param camera Defines the camera the input manager blongs to
  6257. */
  6258. constructor(camera: TCamera);
  6259. /**
  6260. * Add an input method to a camera
  6261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6262. * @param input camera input method
  6263. */
  6264. add(input: ICameraInput<TCamera>): void;
  6265. /**
  6266. * Remove a specific input method from a camera
  6267. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6268. * @param inputToRemove camera input method
  6269. */
  6270. remove(inputToRemove: ICameraInput<TCamera>): void;
  6271. /**
  6272. * Remove a specific input type from a camera
  6273. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6274. * @param inputType the type of the input to remove
  6275. */
  6276. removeByType(inputType: string): void;
  6277. private _addCheckInputs;
  6278. /**
  6279. * Attach the input controls to the currently attached dom element to listen the events from.
  6280. * @param input Defines the input to attach
  6281. */
  6282. attachInput(input: ICameraInput<TCamera>): void;
  6283. /**
  6284. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6285. * @param element Defines the dom element to collect the events from
  6286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6287. */
  6288. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6289. /**
  6290. * Detach the current manager inputs controls from a specific dom element.
  6291. * @param element Defines the dom element to collect the events from
  6292. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6293. */
  6294. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6295. /**
  6296. * Rebuild the dynamic inputCheck function from the current list of
  6297. * defined inputs in the manager.
  6298. */
  6299. rebuildInputCheck(): void;
  6300. /**
  6301. * Remove all attached input methods from a camera
  6302. */
  6303. clear(): void;
  6304. /**
  6305. * Serialize the current input manager attached to a camera.
  6306. * This ensures than once parsed,
  6307. * the input associated to the camera will be identical to the current ones
  6308. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6309. */
  6310. serialize(serializedCamera: any): void;
  6311. /**
  6312. * Parses an input manager serialized JSON to restore the previous list of inputs
  6313. * and states associated to a camera.
  6314. * @param parsedCamera Defines the JSON to parse
  6315. */
  6316. parse(parsedCamera: any): void;
  6317. }
  6318. }
  6319. declare module "babylonjs/Meshes/buffer" {
  6320. import { Nullable, DataArray } from "babylonjs/types";
  6321. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6322. /**
  6323. * Class used to store data that will be store in GPU memory
  6324. */
  6325. export class Buffer {
  6326. private _engine;
  6327. private _buffer;
  6328. /** @hidden */
  6329. _data: Nullable<DataArray>;
  6330. private _updatable;
  6331. private _instanced;
  6332. /**
  6333. * Gets the byte stride.
  6334. */
  6335. readonly byteStride: number;
  6336. /**
  6337. * Constructor
  6338. * @param engine the engine
  6339. * @param data the data to use for this buffer
  6340. * @param updatable whether the data is updatable
  6341. * @param stride the stride (optional)
  6342. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6343. * @param instanced whether the buffer is instanced (optional)
  6344. * @param useBytes set to true if the stride in in bytes (optional)
  6345. */
  6346. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6347. /**
  6348. * Create a new VertexBuffer based on the current buffer
  6349. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6350. * @param offset defines offset in the buffer (0 by default)
  6351. * @param size defines the size in floats of attributes (position is 3 for instance)
  6352. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6353. * @param instanced defines if the vertex buffer contains indexed data
  6354. * @param useBytes defines if the offset and stride are in bytes
  6355. * @returns the new vertex buffer
  6356. */
  6357. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6358. /**
  6359. * Gets a boolean indicating if the Buffer is updatable?
  6360. * @returns true if the buffer is updatable
  6361. */
  6362. isUpdatable(): boolean;
  6363. /**
  6364. * Gets current buffer's data
  6365. * @returns a DataArray or null
  6366. */
  6367. getData(): Nullable<DataArray>;
  6368. /**
  6369. * Gets underlying native buffer
  6370. * @returns underlying native buffer
  6371. */
  6372. getBuffer(): Nullable<DataBuffer>;
  6373. /**
  6374. * Gets the stride in float32 units (i.e. byte stride / 4).
  6375. * May not be an integer if the byte stride is not divisible by 4.
  6376. * DEPRECATED. Use byteStride instead.
  6377. * @returns the stride in float32 units
  6378. */
  6379. getStrideSize(): number;
  6380. /**
  6381. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6382. * @param data defines the data to store
  6383. */
  6384. create(data?: Nullable<DataArray>): void;
  6385. /** @hidden */
  6386. _rebuild(): void;
  6387. /**
  6388. * Update current buffer data
  6389. * @param data defines the data to store
  6390. */
  6391. update(data: DataArray): void;
  6392. /**
  6393. * Updates the data directly.
  6394. * @param data the new data
  6395. * @param offset the new offset
  6396. * @param vertexCount the vertex count (optional)
  6397. * @param useBytes set to true if the offset is in bytes
  6398. */
  6399. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6400. /**
  6401. * Release all resources
  6402. */
  6403. dispose(): void;
  6404. }
  6405. /**
  6406. * Specialized buffer used to store vertex data
  6407. */
  6408. export class VertexBuffer {
  6409. /** @hidden */
  6410. _buffer: Buffer;
  6411. private _kind;
  6412. private _size;
  6413. private _ownsBuffer;
  6414. private _instanced;
  6415. private _instanceDivisor;
  6416. /**
  6417. * The byte type.
  6418. */
  6419. static readonly BYTE: number;
  6420. /**
  6421. * The unsigned byte type.
  6422. */
  6423. static readonly UNSIGNED_BYTE: number;
  6424. /**
  6425. * The short type.
  6426. */
  6427. static readonly SHORT: number;
  6428. /**
  6429. * The unsigned short type.
  6430. */
  6431. static readonly UNSIGNED_SHORT: number;
  6432. /**
  6433. * The integer type.
  6434. */
  6435. static readonly INT: number;
  6436. /**
  6437. * The unsigned integer type.
  6438. */
  6439. static readonly UNSIGNED_INT: number;
  6440. /**
  6441. * The float type.
  6442. */
  6443. static readonly FLOAT: number;
  6444. /**
  6445. * Gets or sets the instance divisor when in instanced mode
  6446. */
  6447. instanceDivisor: number;
  6448. /**
  6449. * Gets the byte stride.
  6450. */
  6451. readonly byteStride: number;
  6452. /**
  6453. * Gets the byte offset.
  6454. */
  6455. readonly byteOffset: number;
  6456. /**
  6457. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6458. */
  6459. readonly normalized: boolean;
  6460. /**
  6461. * Gets the data type of each component in the array.
  6462. */
  6463. readonly type: number;
  6464. /**
  6465. * Constructor
  6466. * @param engine the engine
  6467. * @param data the data to use for this vertex buffer
  6468. * @param kind the vertex buffer kind
  6469. * @param updatable whether the data is updatable
  6470. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6471. * @param stride the stride (optional)
  6472. * @param instanced whether the buffer is instanced (optional)
  6473. * @param offset the offset of the data (optional)
  6474. * @param size the number of components (optional)
  6475. * @param type the type of the component (optional)
  6476. * @param normalized whether the data contains normalized data (optional)
  6477. * @param useBytes set to true if stride and offset are in bytes (optional)
  6478. */
  6479. 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);
  6480. /** @hidden */
  6481. _rebuild(): void;
  6482. /**
  6483. * Returns the kind of the VertexBuffer (string)
  6484. * @returns a string
  6485. */
  6486. getKind(): string;
  6487. /**
  6488. * Gets a boolean indicating if the VertexBuffer is updatable?
  6489. * @returns true if the buffer is updatable
  6490. */
  6491. isUpdatable(): boolean;
  6492. /**
  6493. * Gets current buffer's data
  6494. * @returns a DataArray or null
  6495. */
  6496. getData(): Nullable<DataArray>;
  6497. /**
  6498. * Gets underlying native buffer
  6499. * @returns underlying native buffer
  6500. */
  6501. getBuffer(): Nullable<DataBuffer>;
  6502. /**
  6503. * Gets the stride in float32 units (i.e. byte stride / 4).
  6504. * May not be an integer if the byte stride is not divisible by 4.
  6505. * DEPRECATED. Use byteStride instead.
  6506. * @returns the stride in float32 units
  6507. */
  6508. getStrideSize(): number;
  6509. /**
  6510. * Returns the offset as a multiple of the type byte length.
  6511. * DEPRECATED. Use byteOffset instead.
  6512. * @returns the offset in bytes
  6513. */
  6514. getOffset(): number;
  6515. /**
  6516. * Returns the number of components per vertex attribute (integer)
  6517. * @returns the size in float
  6518. */
  6519. getSize(): number;
  6520. /**
  6521. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6522. * @returns true if this buffer is instanced
  6523. */
  6524. getIsInstanced(): boolean;
  6525. /**
  6526. * Returns the instancing divisor, zero for non-instanced (integer).
  6527. * @returns a number
  6528. */
  6529. getInstanceDivisor(): number;
  6530. /**
  6531. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6532. * @param data defines the data to store
  6533. */
  6534. create(data?: DataArray): void;
  6535. /**
  6536. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6537. * This function will create a new buffer if the current one is not updatable
  6538. * @param data defines the data to store
  6539. */
  6540. update(data: DataArray): void;
  6541. /**
  6542. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6543. * Returns the directly updated WebGLBuffer.
  6544. * @param data the new data
  6545. * @param offset the new offset
  6546. * @param useBytes set to true if the offset is in bytes
  6547. */
  6548. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6549. /**
  6550. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6551. */
  6552. dispose(): void;
  6553. /**
  6554. * Enumerates each value of this vertex buffer as numbers.
  6555. * @param count the number of values to enumerate
  6556. * @param callback the callback function called for each value
  6557. */
  6558. forEach(count: number, callback: (value: number, index: number) => void): void;
  6559. /**
  6560. * Positions
  6561. */
  6562. static readonly PositionKind: string;
  6563. /**
  6564. * Normals
  6565. */
  6566. static readonly NormalKind: string;
  6567. /**
  6568. * Tangents
  6569. */
  6570. static readonly TangentKind: string;
  6571. /**
  6572. * Texture coordinates
  6573. */
  6574. static readonly UVKind: string;
  6575. /**
  6576. * Texture coordinates 2
  6577. */
  6578. static readonly UV2Kind: string;
  6579. /**
  6580. * Texture coordinates 3
  6581. */
  6582. static readonly UV3Kind: string;
  6583. /**
  6584. * Texture coordinates 4
  6585. */
  6586. static readonly UV4Kind: string;
  6587. /**
  6588. * Texture coordinates 5
  6589. */
  6590. static readonly UV5Kind: string;
  6591. /**
  6592. * Texture coordinates 6
  6593. */
  6594. static readonly UV6Kind: string;
  6595. /**
  6596. * Colors
  6597. */
  6598. static readonly ColorKind: string;
  6599. /**
  6600. * Matrix indices (for bones)
  6601. */
  6602. static readonly MatricesIndicesKind: string;
  6603. /**
  6604. * Matrix weights (for bones)
  6605. */
  6606. static readonly MatricesWeightsKind: string;
  6607. /**
  6608. * Additional matrix indices (for bones)
  6609. */
  6610. static readonly MatricesIndicesExtraKind: string;
  6611. /**
  6612. * Additional matrix weights (for bones)
  6613. */
  6614. static readonly MatricesWeightsExtraKind: string;
  6615. /**
  6616. * Deduces the stride given a kind.
  6617. * @param kind The kind string to deduce
  6618. * @returns The deduced stride
  6619. */
  6620. static DeduceStride(kind: string): number;
  6621. /**
  6622. * Gets the byte length of the given type.
  6623. * @param type the type
  6624. * @returns the number of bytes
  6625. */
  6626. static GetTypeByteLength(type: number): number;
  6627. /**
  6628. * Enumerates each value of the given parameters as numbers.
  6629. * @param data the data to enumerate
  6630. * @param byteOffset the byte offset of the data
  6631. * @param byteStride the byte stride of the data
  6632. * @param componentCount the number of components per element
  6633. * @param componentType the type of the component
  6634. * @param count the number of values to enumerate
  6635. * @param normalized whether the data is normalized
  6636. * @param callback the callback function called for each value
  6637. */
  6638. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6639. private static _GetFloatValue;
  6640. }
  6641. }
  6642. declare module "babylonjs/Collisions/intersectionInfo" {
  6643. import { Nullable } from "babylonjs/types";
  6644. /**
  6645. * @hidden
  6646. */
  6647. export class IntersectionInfo {
  6648. bu: Nullable<number>;
  6649. bv: Nullable<number>;
  6650. distance: number;
  6651. faceId: number;
  6652. subMeshId: number;
  6653. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6654. }
  6655. }
  6656. declare module "babylonjs/Maths/math.plane" {
  6657. import { DeepImmutable } from "babylonjs/types";
  6658. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6659. /**
  6660. * Represens a plane by the equation ax + by + cz + d = 0
  6661. */
  6662. export class Plane {
  6663. private static _TmpMatrix;
  6664. /**
  6665. * Normal of the plane (a,b,c)
  6666. */
  6667. normal: Vector3;
  6668. /**
  6669. * d component of the plane
  6670. */
  6671. d: number;
  6672. /**
  6673. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6674. * @param a a component of the plane
  6675. * @param b b component of the plane
  6676. * @param c c component of the plane
  6677. * @param d d component of the plane
  6678. */
  6679. constructor(a: number, b: number, c: number, d: number);
  6680. /**
  6681. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6682. */
  6683. asArray(): number[];
  6684. /**
  6685. * @returns a new plane copied from the current Plane.
  6686. */
  6687. clone(): Plane;
  6688. /**
  6689. * @returns the string "Plane".
  6690. */
  6691. getClassName(): string;
  6692. /**
  6693. * @returns the Plane hash code.
  6694. */
  6695. getHashCode(): number;
  6696. /**
  6697. * Normalize the current Plane in place.
  6698. * @returns the updated Plane.
  6699. */
  6700. normalize(): Plane;
  6701. /**
  6702. * Applies a transformation the plane and returns the result
  6703. * @param transformation the transformation matrix to be applied to the plane
  6704. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6705. */
  6706. transform(transformation: DeepImmutable<Matrix>): Plane;
  6707. /**
  6708. * Calcualtte the dot product between the point and the plane normal
  6709. * @param point point to calculate the dot product with
  6710. * @returns the dot product (float) of the point coordinates and the plane normal.
  6711. */
  6712. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6713. /**
  6714. * Updates the current Plane from the plane defined by the three given points.
  6715. * @param point1 one of the points used to contruct the plane
  6716. * @param point2 one of the points used to contruct the plane
  6717. * @param point3 one of the points used to contruct the plane
  6718. * @returns the updated Plane.
  6719. */
  6720. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6721. /**
  6722. * Checks if the plane is facing a given direction
  6723. * @param direction the direction to check if the plane is facing
  6724. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6725. * @returns True is the vector "direction" is the same side than the plane normal.
  6726. */
  6727. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6728. /**
  6729. * Calculates the distance to a point
  6730. * @param point point to calculate distance to
  6731. * @returns the signed distance (float) from the given point to the Plane.
  6732. */
  6733. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6734. /**
  6735. * Creates a plane from an array
  6736. * @param array the array to create a plane from
  6737. * @returns a new Plane from the given array.
  6738. */
  6739. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6740. /**
  6741. * Creates a plane from three points
  6742. * @param point1 point used to create the plane
  6743. * @param point2 point used to create the plane
  6744. * @param point3 point used to create the plane
  6745. * @returns a new Plane defined by the three given points.
  6746. */
  6747. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6748. /**
  6749. * Creates a plane from an origin point and a normal
  6750. * @param origin origin of the plane to be constructed
  6751. * @param normal normal of the plane to be constructed
  6752. * @returns a new Plane the normal vector to this plane at the given origin point.
  6753. * Note : the vector "normal" is updated because normalized.
  6754. */
  6755. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6756. /**
  6757. * Calculates the distance from a plane and a point
  6758. * @param origin origin of the plane to be constructed
  6759. * @param normal normal of the plane to be constructed
  6760. * @param point point to calculate distance to
  6761. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6762. */
  6763. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6764. }
  6765. }
  6766. declare module "babylonjs/Culling/boundingSphere" {
  6767. import { DeepImmutable } from "babylonjs/types";
  6768. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6769. import { Plane } from "babylonjs/Maths/math.plane";
  6770. /**
  6771. * Class used to store bounding sphere information
  6772. */
  6773. export class BoundingSphere {
  6774. /**
  6775. * Gets the center of the bounding sphere in local space
  6776. */
  6777. readonly center: Vector3;
  6778. /**
  6779. * Radius of the bounding sphere in local space
  6780. */
  6781. radius: number;
  6782. /**
  6783. * Gets the center of the bounding sphere in world space
  6784. */
  6785. readonly centerWorld: Vector3;
  6786. /**
  6787. * Radius of the bounding sphere in world space
  6788. */
  6789. radiusWorld: number;
  6790. /**
  6791. * Gets the minimum vector in local space
  6792. */
  6793. readonly minimum: Vector3;
  6794. /**
  6795. * Gets the maximum vector in local space
  6796. */
  6797. readonly maximum: Vector3;
  6798. private _worldMatrix;
  6799. private static readonly TmpVector3;
  6800. /**
  6801. * Creates a new bounding sphere
  6802. * @param min defines the minimum vector (in local space)
  6803. * @param max defines the maximum vector (in local space)
  6804. * @param worldMatrix defines the new world matrix
  6805. */
  6806. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6807. /**
  6808. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6809. * @param min defines the new minimum vector (in local space)
  6810. * @param max defines the new maximum vector (in local space)
  6811. * @param worldMatrix defines the new world matrix
  6812. */
  6813. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6814. /**
  6815. * Scale the current bounding sphere by applying a scale factor
  6816. * @param factor defines the scale factor to apply
  6817. * @returns the current bounding box
  6818. */
  6819. scale(factor: number): BoundingSphere;
  6820. /**
  6821. * Gets the world matrix of the bounding box
  6822. * @returns a matrix
  6823. */
  6824. getWorldMatrix(): DeepImmutable<Matrix>;
  6825. /** @hidden */
  6826. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6827. /**
  6828. * Tests if the bounding sphere is intersecting the frustum planes
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if there is an intersection
  6831. */
  6832. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if the bounding sphere center is in between the frustum planes.
  6835. * Used for optimistic fast inclusion.
  6836. * @param frustumPlanes defines the frustum planes to test
  6837. * @returns true if the sphere center is in between the frustum planes
  6838. */
  6839. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6840. /**
  6841. * Tests if a point is inside the bounding sphere
  6842. * @param point defines the point to test
  6843. * @returns true if the point is inside the bounding sphere
  6844. */
  6845. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6846. /**
  6847. * Checks if two sphere intersct
  6848. * @param sphere0 sphere 0
  6849. * @param sphere1 sphere 1
  6850. * @returns true if the speres intersect
  6851. */
  6852. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6853. }
  6854. }
  6855. declare module "babylonjs/Culling/boundingBox" {
  6856. import { DeepImmutable } from "babylonjs/types";
  6857. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6858. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6859. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6860. import { Plane } from "babylonjs/Maths/math.plane";
  6861. /**
  6862. * Class used to store bounding box information
  6863. */
  6864. export class BoundingBox implements ICullable {
  6865. /**
  6866. * Gets the 8 vectors representing the bounding box in local space
  6867. */
  6868. readonly vectors: Vector3[];
  6869. /**
  6870. * Gets the center of the bounding box in local space
  6871. */
  6872. readonly center: Vector3;
  6873. /**
  6874. * Gets the center of the bounding box in world space
  6875. */
  6876. readonly centerWorld: Vector3;
  6877. /**
  6878. * Gets the extend size in local space
  6879. */
  6880. readonly extendSize: Vector3;
  6881. /**
  6882. * Gets the extend size in world space
  6883. */
  6884. readonly extendSizeWorld: Vector3;
  6885. /**
  6886. * Gets the OBB (object bounding box) directions
  6887. */
  6888. readonly directions: Vector3[];
  6889. /**
  6890. * Gets the 8 vectors representing the bounding box in world space
  6891. */
  6892. readonly vectorsWorld: Vector3[];
  6893. /**
  6894. * Gets the minimum vector in world space
  6895. */
  6896. readonly minimumWorld: Vector3;
  6897. /**
  6898. * Gets the maximum vector in world space
  6899. */
  6900. readonly maximumWorld: Vector3;
  6901. /**
  6902. * Gets the minimum vector in local space
  6903. */
  6904. readonly minimum: Vector3;
  6905. /**
  6906. * Gets the maximum vector in local space
  6907. */
  6908. readonly maximum: Vector3;
  6909. private _worldMatrix;
  6910. private static readonly TmpVector3;
  6911. /**
  6912. * @hidden
  6913. */
  6914. _tag: number;
  6915. /**
  6916. * Creates a new bounding box
  6917. * @param min defines the minimum vector (in local space)
  6918. * @param max defines the maximum vector (in local space)
  6919. * @param worldMatrix defines the new world matrix
  6920. */
  6921. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6922. /**
  6923. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6924. * @param min defines the new minimum vector (in local space)
  6925. * @param max defines the new maximum vector (in local space)
  6926. * @param worldMatrix defines the new world matrix
  6927. */
  6928. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6929. /**
  6930. * Scale the current bounding box by applying a scale factor
  6931. * @param factor defines the scale factor to apply
  6932. * @returns the current bounding box
  6933. */
  6934. scale(factor: number): BoundingBox;
  6935. /**
  6936. * Gets the world matrix of the bounding box
  6937. * @returns a matrix
  6938. */
  6939. getWorldMatrix(): DeepImmutable<Matrix>;
  6940. /** @hidden */
  6941. _update(world: DeepImmutable<Matrix>): void;
  6942. /**
  6943. * Tests if the bounding box is intersecting the frustum planes
  6944. * @param frustumPlanes defines the frustum planes to test
  6945. * @returns true if there is an intersection
  6946. */
  6947. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6948. /**
  6949. * Tests if the bounding box is entirely inside the frustum planes
  6950. * @param frustumPlanes defines the frustum planes to test
  6951. * @returns true if there is an inclusion
  6952. */
  6953. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6954. /**
  6955. * Tests if a point is inside the bounding box
  6956. * @param point defines the point to test
  6957. * @returns true if the point is inside the bounding box
  6958. */
  6959. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6960. /**
  6961. * Tests if the bounding box intersects with a bounding sphere
  6962. * @param sphere defines the sphere to test
  6963. * @returns true if there is an intersection
  6964. */
  6965. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6966. /**
  6967. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6968. * @param min defines the min vector to use
  6969. * @param max defines the max vector to use
  6970. * @returns true if there is an intersection
  6971. */
  6972. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6973. /**
  6974. * Tests if two bounding boxes are intersections
  6975. * @param box0 defines the first box to test
  6976. * @param box1 defines the second box to test
  6977. * @returns true if there is an intersection
  6978. */
  6979. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6980. /**
  6981. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6982. * @param minPoint defines the minimum vector of the bounding box
  6983. * @param maxPoint defines the maximum vector of the bounding box
  6984. * @param sphereCenter defines the sphere center
  6985. * @param sphereRadius defines the sphere radius
  6986. * @returns true if there is an intersection
  6987. */
  6988. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6989. /**
  6990. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6991. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @return true if there is an inclusion
  6994. */
  6995. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6998. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @return true if there is an intersection
  7001. */
  7002. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. }
  7004. }
  7005. declare module "babylonjs/Collisions/collider" {
  7006. import { Nullable, IndicesArray } from "babylonjs/types";
  7007. import { Vector3 } from "babylonjs/Maths/math.vector";
  7008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7009. import { Plane } from "babylonjs/Maths/math.plane";
  7010. /** @hidden */
  7011. export class Collider {
  7012. /** Define if a collision was found */
  7013. collisionFound: boolean;
  7014. /**
  7015. * Define last intersection point in local space
  7016. */
  7017. intersectionPoint: Vector3;
  7018. /**
  7019. * Define last collided mesh
  7020. */
  7021. collidedMesh: Nullable<AbstractMesh>;
  7022. private _collisionPoint;
  7023. private _planeIntersectionPoint;
  7024. private _tempVector;
  7025. private _tempVector2;
  7026. private _tempVector3;
  7027. private _tempVector4;
  7028. private _edge;
  7029. private _baseToVertex;
  7030. private _destinationPoint;
  7031. private _slidePlaneNormal;
  7032. private _displacementVector;
  7033. /** @hidden */
  7034. _radius: Vector3;
  7035. /** @hidden */
  7036. _retry: number;
  7037. private _velocity;
  7038. private _basePoint;
  7039. private _epsilon;
  7040. /** @hidden */
  7041. _velocityWorldLength: number;
  7042. /** @hidden */
  7043. _basePointWorld: Vector3;
  7044. private _velocityWorld;
  7045. private _normalizedVelocity;
  7046. /** @hidden */
  7047. _initialVelocity: Vector3;
  7048. /** @hidden */
  7049. _initialPosition: Vector3;
  7050. private _nearestDistance;
  7051. private _collisionMask;
  7052. collisionMask: number;
  7053. /**
  7054. * Gets the plane normal used to compute the sliding response (in local space)
  7055. */
  7056. readonly slidePlaneNormal: Vector3;
  7057. /** @hidden */
  7058. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7059. /** @hidden */
  7060. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7061. /** @hidden */
  7062. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7063. /** @hidden */
  7064. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7065. /** @hidden */
  7066. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7067. /** @hidden */
  7068. _getResponse(pos: Vector3, vel: Vector3): void;
  7069. }
  7070. }
  7071. declare module "babylonjs/Culling/boundingInfo" {
  7072. import { DeepImmutable } from "babylonjs/types";
  7073. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7074. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7075. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7076. import { Plane } from "babylonjs/Maths/math.plane";
  7077. import { Collider } from "babylonjs/Collisions/collider";
  7078. /**
  7079. * Interface for cullable objects
  7080. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7081. */
  7082. export interface ICullable {
  7083. /**
  7084. * Checks if the object or part of the object is in the frustum
  7085. * @param frustumPlanes Camera near/planes
  7086. * @returns true if the object is in frustum otherwise false
  7087. */
  7088. isInFrustum(frustumPlanes: Plane[]): boolean;
  7089. /**
  7090. * Checks if a cullable object (mesh...) is in the camera frustum
  7091. * Unlike isInFrustum this cheks the full bounding box
  7092. * @param frustumPlanes Camera near/planes
  7093. * @returns true if the object is in frustum otherwise false
  7094. */
  7095. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7096. }
  7097. /**
  7098. * Info for a bounding data of a mesh
  7099. */
  7100. export class BoundingInfo implements ICullable {
  7101. /**
  7102. * Bounding box for the mesh
  7103. */
  7104. readonly boundingBox: BoundingBox;
  7105. /**
  7106. * Bounding sphere for the mesh
  7107. */
  7108. readonly boundingSphere: BoundingSphere;
  7109. private _isLocked;
  7110. private static readonly TmpVector3;
  7111. /**
  7112. * Constructs bounding info
  7113. * @param minimum min vector of the bounding box/sphere
  7114. * @param maximum max vector of the bounding box/sphere
  7115. * @param worldMatrix defines the new world matrix
  7116. */
  7117. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7118. /**
  7119. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7120. * @param min defines the new minimum vector (in local space)
  7121. * @param max defines the new maximum vector (in local space)
  7122. * @param worldMatrix defines the new world matrix
  7123. */
  7124. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7125. /**
  7126. * min vector of the bounding box/sphere
  7127. */
  7128. readonly minimum: Vector3;
  7129. /**
  7130. * max vector of the bounding box/sphere
  7131. */
  7132. readonly maximum: Vector3;
  7133. /**
  7134. * If the info is locked and won't be updated to avoid perf overhead
  7135. */
  7136. isLocked: boolean;
  7137. /**
  7138. * Updates the bounding sphere and box
  7139. * @param world world matrix to be used to update
  7140. */
  7141. update(world: DeepImmutable<Matrix>): void;
  7142. /**
  7143. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7144. * @param center New center of the bounding info
  7145. * @param extend New extend of the bounding info
  7146. * @returns the current bounding info
  7147. */
  7148. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7149. /**
  7150. * Scale the current bounding info by applying a scale factor
  7151. * @param factor defines the scale factor to apply
  7152. * @returns the current bounding info
  7153. */
  7154. scale(factor: number): BoundingInfo;
  7155. /**
  7156. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7157. * @param frustumPlanes defines the frustum to test
  7158. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7159. * @returns true if the bounding info is in the frustum planes
  7160. */
  7161. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7162. /**
  7163. * Gets the world distance between the min and max points of the bounding box
  7164. */
  7165. readonly diagonalLength: number;
  7166. /**
  7167. * Checks if a cullable object (mesh...) is in the camera frustum
  7168. * Unlike isInFrustum this cheks the full bounding box
  7169. * @param frustumPlanes Camera near/planes
  7170. * @returns true if the object is in frustum otherwise false
  7171. */
  7172. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7173. /** @hidden */
  7174. _checkCollision(collider: Collider): boolean;
  7175. /**
  7176. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7177. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7178. * @param point the point to check intersection with
  7179. * @returns if the point intersects
  7180. */
  7181. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7182. /**
  7183. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7184. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7185. * @param boundingInfo the bounding info to check intersection with
  7186. * @param precise if the intersection should be done using OBB
  7187. * @returns if the bounding info intersects
  7188. */
  7189. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7190. }
  7191. }
  7192. declare module "babylonjs/Maths/math.functions" {
  7193. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7194. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7195. /**
  7196. * Extracts minimum and maximum values from a list of indexed positions
  7197. * @param positions defines the positions to use
  7198. * @param indices defines the indices to the positions
  7199. * @param indexStart defines the start index
  7200. * @param indexCount defines the end index
  7201. * @param bias defines bias value to add to the result
  7202. * @return minimum and maximum values
  7203. */
  7204. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7205. minimum: Vector3;
  7206. maximum: Vector3;
  7207. };
  7208. /**
  7209. * Extracts minimum and maximum values from a list of positions
  7210. * @param positions defines the positions to use
  7211. * @param start defines the start index in the positions array
  7212. * @param count defines the number of positions to handle
  7213. * @param bias defines bias value to add to the result
  7214. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7215. * @return minimum and maximum values
  7216. */
  7217. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7218. minimum: Vector3;
  7219. maximum: Vector3;
  7220. };
  7221. }
  7222. declare module "babylonjs/Materials/uniformBuffer" {
  7223. import { Nullable, FloatArray } from "babylonjs/types";
  7224. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7225. import { Engine } from "babylonjs/Engines/engine";
  7226. import { Effect } from "babylonjs/Materials/effect";
  7227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7228. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7229. import { Color3 } from "babylonjs/Maths/math.color";
  7230. /**
  7231. * Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. */
  7240. export class UniformBuffer {
  7241. private _engine;
  7242. private _buffer;
  7243. private _data;
  7244. private _bufferData;
  7245. private _dynamic?;
  7246. private _uniformLocations;
  7247. private _uniformSizes;
  7248. private _uniformLocationPointer;
  7249. private _needSync;
  7250. private _noUBO;
  7251. private _currentEffect;
  7252. private static _MAX_UNIFORM_SIZE;
  7253. private static _tempBuffer;
  7254. /**
  7255. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7256. * This is dynamic to allow compat with webgl 1 and 2.
  7257. * You will need to pass the name of the uniform as well as the value.
  7258. */
  7259. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7260. /**
  7261. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7262. * This is dynamic to allow compat with webgl 1 and 2.
  7263. * You will need to pass the name of the uniform as well as the value.
  7264. */
  7265. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7266. /**
  7267. * Lambda to Update a single float in a uniform buffer.
  7268. * This is dynamic to allow compat with webgl 1 and 2.
  7269. * You will need to pass the name of the uniform as well as the value.
  7270. */
  7271. updateFloat: (name: string, x: number) => void;
  7272. /**
  7273. * Lambda to Update a vec2 of float in a uniform buffer.
  7274. * This is dynamic to allow compat with webgl 1 and 2.
  7275. * You will need to pass the name of the uniform as well as the value.
  7276. */
  7277. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7278. /**
  7279. * Lambda to Update a vec3 of float in a uniform buffer.
  7280. * This is dynamic to allow compat with webgl 1 and 2.
  7281. * You will need to pass the name of the uniform as well as the value.
  7282. */
  7283. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7284. /**
  7285. * Lambda to Update a vec4 of float in a uniform buffer.
  7286. * This is dynamic to allow compat with webgl 1 and 2.
  7287. * You will need to pass the name of the uniform as well as the value.
  7288. */
  7289. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7290. /**
  7291. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7292. * This is dynamic to allow compat with webgl 1 and 2.
  7293. * You will need to pass the name of the uniform as well as the value.
  7294. */
  7295. updateMatrix: (name: string, mat: Matrix) => void;
  7296. /**
  7297. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7298. * This is dynamic to allow compat with webgl 1 and 2.
  7299. * You will need to pass the name of the uniform as well as the value.
  7300. */
  7301. updateVector3: (name: string, vector: Vector3) => void;
  7302. /**
  7303. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateVector4: (name: string, vector: Vector4) => void;
  7308. /**
  7309. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7314. /**
  7315. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7320. /**
  7321. * Instantiates a new Uniform buffer objects.
  7322. *
  7323. * Handles blocks of uniform on the GPU.
  7324. *
  7325. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7326. *
  7327. * For more information, please refer to :
  7328. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7329. * @param engine Define the engine the buffer is associated with
  7330. * @param data Define the data contained in the buffer
  7331. * @param dynamic Define if the buffer is updatable
  7332. */
  7333. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7334. /**
  7335. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7336. * or just falling back on setUniformXXX calls.
  7337. */
  7338. readonly useUbo: boolean;
  7339. /**
  7340. * Indicates if the WebGL underlying uniform buffer is in sync
  7341. * with the javascript cache data.
  7342. */
  7343. readonly isSync: boolean;
  7344. /**
  7345. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7346. * Also, a dynamic UniformBuffer will disable cache verification and always
  7347. * update the underlying WebGL uniform buffer to the GPU.
  7348. * @returns if Dynamic, otherwise false
  7349. */
  7350. isDynamic(): boolean;
  7351. /**
  7352. * The data cache on JS side.
  7353. * @returns the underlying data as a float array
  7354. */
  7355. getData(): Float32Array;
  7356. /**
  7357. * The underlying WebGL Uniform buffer.
  7358. * @returns the webgl buffer
  7359. */
  7360. getBuffer(): Nullable<DataBuffer>;
  7361. /**
  7362. * std140 layout specifies how to align data within an UBO structure.
  7363. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7364. * for specs.
  7365. */
  7366. private _fillAlignment;
  7367. /**
  7368. * Adds an uniform in the buffer.
  7369. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7370. * for the layout to be correct !
  7371. * @param name Name of the uniform, as used in the uniform block in the shader.
  7372. * @param size Data size, or data directly.
  7373. */
  7374. addUniform(name: string, size: number | number[]): void;
  7375. /**
  7376. * Adds a Matrix 4x4 to the uniform buffer.
  7377. * @param name Name of the uniform, as used in the uniform block in the shader.
  7378. * @param mat A 4x4 matrix.
  7379. */
  7380. addMatrix(name: string, mat: Matrix): void;
  7381. /**
  7382. * Adds a vec2 to the uniform buffer.
  7383. * @param name Name of the uniform, as used in the uniform block in the shader.
  7384. * @param x Define the x component value of the vec2
  7385. * @param y Define the y component value of the vec2
  7386. */
  7387. addFloat2(name: string, x: number, y: number): void;
  7388. /**
  7389. * Adds a vec3 to the uniform buffer.
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param x Define the x component value of the vec3
  7392. * @param y Define the y component value of the vec3
  7393. * @param z Define the z component value of the vec3
  7394. */
  7395. addFloat3(name: string, x: number, y: number, z: number): void;
  7396. /**
  7397. * Adds a vec3 to the uniform buffer.
  7398. * @param name Name of the uniform, as used in the uniform block in the shader.
  7399. * @param color Define the vec3 from a Color
  7400. */
  7401. addColor3(name: string, color: Color3): void;
  7402. /**
  7403. * Adds a vec4 to the uniform buffer.
  7404. * @param name Name of the uniform, as used in the uniform block in the shader.
  7405. * @param color Define the rgb components from a Color
  7406. * @param alpha Define the a component of the vec4
  7407. */
  7408. addColor4(name: string, color: Color3, alpha: number): void;
  7409. /**
  7410. * Adds a vec3 to the uniform buffer.
  7411. * @param name Name of the uniform, as used in the uniform block in the shader.
  7412. * @param vector Define the vec3 components from a Vector
  7413. */
  7414. addVector3(name: string, vector: Vector3): void;
  7415. /**
  7416. * Adds a Matrix 3x3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. */
  7419. addMatrix3x3(name: string): void;
  7420. /**
  7421. * Adds a Matrix 2x2 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. */
  7424. addMatrix2x2(name: string): void;
  7425. /**
  7426. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7427. */
  7428. create(): void;
  7429. /** @hidden */
  7430. _rebuild(): void;
  7431. /**
  7432. * Updates the WebGL Uniform Buffer on the GPU.
  7433. * If the `dynamic` flag is set to true, no cache comparison is done.
  7434. * Otherwise, the buffer will be updated only if the cache differs.
  7435. */
  7436. update(): void;
  7437. /**
  7438. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7439. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7440. * @param data Define the flattened data
  7441. * @param size Define the size of the data.
  7442. */
  7443. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7444. private _valueCache;
  7445. private _cacheMatrix;
  7446. private _updateMatrix3x3ForUniform;
  7447. private _updateMatrix3x3ForEffect;
  7448. private _updateMatrix2x2ForEffect;
  7449. private _updateMatrix2x2ForUniform;
  7450. private _updateFloatForEffect;
  7451. private _updateFloatForUniform;
  7452. private _updateFloat2ForEffect;
  7453. private _updateFloat2ForUniform;
  7454. private _updateFloat3ForEffect;
  7455. private _updateFloat3ForUniform;
  7456. private _updateFloat4ForEffect;
  7457. private _updateFloat4ForUniform;
  7458. private _updateMatrixForEffect;
  7459. private _updateMatrixForUniform;
  7460. private _updateVector3ForEffect;
  7461. private _updateVector3ForUniform;
  7462. private _updateVector4ForEffect;
  7463. private _updateVector4ForUniform;
  7464. private _updateColor3ForEffect;
  7465. private _updateColor3ForUniform;
  7466. private _updateColor4ForEffect;
  7467. private _updateColor4ForUniform;
  7468. /**
  7469. * Sets a sampler uniform on the effect.
  7470. * @param name Define the name of the sampler.
  7471. * @param texture Define the texture to set in the sampler
  7472. */
  7473. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7474. /**
  7475. * Directly updates the value of the uniform in the cache AND on the GPU.
  7476. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7477. * @param data Define the flattened data
  7478. */
  7479. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7480. /**
  7481. * Binds this uniform buffer to an effect.
  7482. * @param effect Define the effect to bind the buffer to
  7483. * @param name Name of the uniform block in the shader.
  7484. */
  7485. bindToEffect(effect: Effect, name: string): void;
  7486. /**
  7487. * Disposes the uniform buffer.
  7488. */
  7489. dispose(): void;
  7490. }
  7491. }
  7492. declare module "babylonjs/Misc/iInspectable" {
  7493. /**
  7494. * Enum that determines the text-wrapping mode to use.
  7495. */
  7496. export enum InspectableType {
  7497. /**
  7498. * Checkbox for booleans
  7499. */
  7500. Checkbox = 0,
  7501. /**
  7502. * Sliders for numbers
  7503. */
  7504. Slider = 1,
  7505. /**
  7506. * Vector3
  7507. */
  7508. Vector3 = 2,
  7509. /**
  7510. * Quaternions
  7511. */
  7512. Quaternion = 3,
  7513. /**
  7514. * Color3
  7515. */
  7516. Color3 = 4,
  7517. /**
  7518. * String
  7519. */
  7520. String = 5
  7521. }
  7522. /**
  7523. * Interface used to define custom inspectable properties.
  7524. * This interface is used by the inspector to display custom property grids
  7525. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7526. */
  7527. export interface IInspectable {
  7528. /**
  7529. * Gets the label to display
  7530. */
  7531. label: string;
  7532. /**
  7533. * Gets the name of the property to edit
  7534. */
  7535. propertyName: string;
  7536. /**
  7537. * Gets the type of the editor to use
  7538. */
  7539. type: InspectableType;
  7540. /**
  7541. * Gets the minimum value of the property when using in "slider" mode
  7542. */
  7543. min?: number;
  7544. /**
  7545. * Gets the maximum value of the property when using in "slider" mode
  7546. */
  7547. max?: number;
  7548. /**
  7549. * Gets the setp to use when using in "slider" mode
  7550. */
  7551. step?: number;
  7552. }
  7553. }
  7554. declare module "babylonjs/Misc/timingTools" {
  7555. /**
  7556. * Class used to provide helper for timing
  7557. */
  7558. export class TimingTools {
  7559. /**
  7560. * Polyfill for setImmediate
  7561. * @param action defines the action to execute after the current execution block
  7562. */
  7563. static SetImmediate(action: () => void): void;
  7564. }
  7565. }
  7566. declare module "babylonjs/Misc/instantiationTools" {
  7567. /**
  7568. * Class used to enable instatition of objects by class name
  7569. */
  7570. export class InstantiationTools {
  7571. /**
  7572. * Use this object to register external classes like custom textures or material
  7573. * to allow the laoders to instantiate them
  7574. */
  7575. static RegisteredExternalClasses: {
  7576. [key: string]: Object;
  7577. };
  7578. /**
  7579. * Tries to instantiate a new object from a given class name
  7580. * @param className defines the class name to instantiate
  7581. * @returns the new object or null if the system was not able to do the instantiation
  7582. */
  7583. static Instantiate(className: string): any;
  7584. }
  7585. }
  7586. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7587. /**
  7588. * Define options used to create a depth texture
  7589. */
  7590. export class DepthTextureCreationOptions {
  7591. /** Specifies whether or not a stencil should be allocated in the texture */
  7592. generateStencil?: boolean;
  7593. /** Specifies whether or not bilinear filtering is enable on the texture */
  7594. bilinearFiltering?: boolean;
  7595. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7596. comparisonFunction?: number;
  7597. /** Specifies if the created texture is a cube texture */
  7598. isCube?: boolean;
  7599. }
  7600. }
  7601. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7603. import { Nullable } from "babylonjs/types";
  7604. import { Scene } from "babylonjs/scene";
  7605. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7606. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7607. module "babylonjs/Engines/baseEngine" {
  7608. interface BaseEngine {
  7609. /**
  7610. * Creates a depth stencil cube texture.
  7611. * This is only available in WebGL 2.
  7612. * @param size The size of face edge in the cube texture.
  7613. * @param options The options defining the cube texture.
  7614. * @returns The cube texture
  7615. */
  7616. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7617. /**
  7618. * Creates a cube texture
  7619. * @param rootUrl defines the url where the files to load is located
  7620. * @param scene defines the current scene
  7621. * @param files defines the list of files to load (1 per face)
  7622. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7623. * @param onLoad defines an optional callback raised when the texture is loaded
  7624. * @param onError defines an optional callback raised if there is an issue to load the texture
  7625. * @param format defines the format of the data
  7626. * @param forcedExtension defines the extension to use to pick the right loader
  7627. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7628. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7629. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7630. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7631. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7632. * @returns the cube texture as an InternalTexture
  7633. */
  7634. 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;
  7635. /**
  7636. * Creates a cube texture
  7637. * @param rootUrl defines the url where the files to load is located
  7638. * @param scene defines the current scene
  7639. * @param files defines the list of files to load (1 per face)
  7640. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7641. * @param onLoad defines an optional callback raised when the texture is loaded
  7642. * @param onError defines an optional callback raised if there is an issue to load the texture
  7643. * @param format defines the format of the data
  7644. * @param forcedExtension defines the extension to use to pick the right loader
  7645. * @returns the cube texture as an InternalTexture
  7646. */
  7647. 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;
  7648. /**
  7649. * Creates a cube texture
  7650. * @param rootUrl defines the url where the files to load is located
  7651. * @param scene defines the current scene
  7652. * @param files defines the list of files to load (1 per face)
  7653. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7654. * @param onLoad defines an optional callback raised when the texture is loaded
  7655. * @param onError defines an optional callback raised if there is an issue to load the texture
  7656. * @param format defines the format of the data
  7657. * @param forcedExtension defines the extension to use to pick the right loader
  7658. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7659. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7660. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7661. * @returns the cube texture as an InternalTexture
  7662. */
  7663. 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;
  7664. /** @hidden */
  7665. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7666. /** @hidden */
  7667. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7668. /** @hidden */
  7669. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7670. /** @hidden */
  7671. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7672. }
  7673. }
  7674. }
  7675. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7676. import { Nullable } from "babylonjs/types";
  7677. import { Scene } from "babylonjs/scene";
  7678. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7680. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7681. /**
  7682. * Class for creating a cube texture
  7683. */
  7684. export class CubeTexture extends BaseTexture {
  7685. private _delayedOnLoad;
  7686. /**
  7687. * The url of the texture
  7688. */
  7689. url: string;
  7690. /**
  7691. * Gets or sets the center of the bounding box associated with the cube texture.
  7692. * It must define where the camera used to render the texture was set
  7693. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7694. */
  7695. boundingBoxPosition: Vector3;
  7696. private _boundingBoxSize;
  7697. /**
  7698. * Gets or sets the size of the bounding box associated with the cube texture
  7699. * When defined, the cubemap will switch to local mode
  7700. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7701. * @example https://www.babylonjs-playground.com/#RNASML
  7702. */
  7703. /**
  7704. * Returns the bounding box size
  7705. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7706. */
  7707. boundingBoxSize: Vector3;
  7708. protected _rotationY: number;
  7709. /**
  7710. * Sets texture matrix rotation angle around Y axis in radians.
  7711. */
  7712. /**
  7713. * Gets texture matrix rotation angle around Y axis radians.
  7714. */
  7715. rotationY: number;
  7716. /**
  7717. * Are mip maps generated for this texture or not.
  7718. */
  7719. readonly noMipmap: boolean;
  7720. private _noMipmap;
  7721. private _files;
  7722. private _extensions;
  7723. private _textureMatrix;
  7724. private _format;
  7725. private _createPolynomials;
  7726. /** @hidden */
  7727. _prefiltered: boolean;
  7728. /**
  7729. * Creates a cube texture from an array of image urls
  7730. * @param files defines an array of image urls
  7731. * @param scene defines the hosting scene
  7732. * @param noMipmap specifies if mip maps are not used
  7733. * @returns a cube texture
  7734. */
  7735. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7736. /**
  7737. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7738. * @param url defines the url of the prefiltered texture
  7739. * @param scene defines the scene the texture is attached to
  7740. * @param forcedExtension defines the extension of the file if different from the url
  7741. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7742. * @return the prefiltered texture
  7743. */
  7744. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7745. /**
  7746. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7747. * as prefiltered data.
  7748. * @param rootUrl defines the url of the texture or the root name of the six images
  7749. * @param scene defines the scene the texture is attached to
  7750. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7751. * @param noMipmap defines if mipmaps should be created or not
  7752. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7753. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7754. * @param onError defines a callback triggered in case of error during load
  7755. * @param format defines the internal format to use for the texture once loaded
  7756. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7757. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7758. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @return the cube texture
  7762. */
  7763. 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);
  7764. /**
  7765. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7766. */
  7767. readonly isPrefiltered: boolean;
  7768. /**
  7769. * Get the current class name of the texture useful for serialization or dynamic coding.
  7770. * @returns "CubeTexture"
  7771. */
  7772. getClassName(): string;
  7773. /**
  7774. * Update the url (and optional buffer) of this texture if url was null during construction.
  7775. * @param url the url of the texture
  7776. * @param forcedExtension defines the extension to use
  7777. * @param onLoad callback called when the texture is loaded (defaults to null)
  7778. */
  7779. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7780. /**
  7781. * Delays loading of the cube texture
  7782. * @param forcedExtension defines the extension to use
  7783. */
  7784. delayLoad(forcedExtension?: string): void;
  7785. /**
  7786. * Returns the reflection texture matrix
  7787. * @returns the reflection texture matrix
  7788. */
  7789. getReflectionTextureMatrix(): Matrix;
  7790. /**
  7791. * Sets the reflection texture matrix
  7792. * @param value Reflection texture matrix
  7793. */
  7794. setReflectionTextureMatrix(value: Matrix): void;
  7795. /**
  7796. * Parses text to create a cube texture
  7797. * @param parsedTexture define the serialized text to read from
  7798. * @param scene defines the hosting scene
  7799. * @param rootUrl defines the root url of the cube texture
  7800. * @returns a cube texture
  7801. */
  7802. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7803. /**
  7804. * Makes a clone, or deep copy, of the cube texture
  7805. * @returns a new cube texture
  7806. */
  7807. clone(): CubeTexture;
  7808. }
  7809. }
  7810. declare module "babylonjs/Materials/materialDefines" {
  7811. /**
  7812. * Manages the defines for the Material
  7813. */
  7814. export class MaterialDefines {
  7815. /** @hidden */
  7816. protected _keys: string[];
  7817. private _isDirty;
  7818. /** @hidden */
  7819. _renderId: number;
  7820. /** @hidden */
  7821. _areLightsDirty: boolean;
  7822. /** @hidden */
  7823. _areLightsDisposed: boolean;
  7824. /** @hidden */
  7825. _areAttributesDirty: boolean;
  7826. /** @hidden */
  7827. _areTexturesDirty: boolean;
  7828. /** @hidden */
  7829. _areFresnelDirty: boolean;
  7830. /** @hidden */
  7831. _areMiscDirty: boolean;
  7832. /** @hidden */
  7833. _areImageProcessingDirty: boolean;
  7834. /** @hidden */
  7835. _normals: boolean;
  7836. /** @hidden */
  7837. _uvs: boolean;
  7838. /** @hidden */
  7839. _needNormals: boolean;
  7840. /** @hidden */
  7841. _needUVs: boolean;
  7842. [id: string]: any;
  7843. /**
  7844. * Specifies if the material needs to be re-calculated
  7845. */
  7846. readonly isDirty: boolean;
  7847. /**
  7848. * Marks the material to indicate that it has been re-calculated
  7849. */
  7850. markAsProcessed(): void;
  7851. /**
  7852. * Marks the material to indicate that it needs to be re-calculated
  7853. */
  7854. markAsUnprocessed(): void;
  7855. /**
  7856. * Marks the material to indicate all of its defines need to be re-calculated
  7857. */
  7858. markAllAsDirty(): void;
  7859. /**
  7860. * Marks the material to indicate that image processing needs to be re-calculated
  7861. */
  7862. markAsImageProcessingDirty(): void;
  7863. /**
  7864. * Marks the material to indicate the lights need to be re-calculated
  7865. * @param disposed Defines whether the light is dirty due to dispose or not
  7866. */
  7867. markAsLightDirty(disposed?: boolean): void;
  7868. /**
  7869. * Marks the attribute state as changed
  7870. */
  7871. markAsAttributesDirty(): void;
  7872. /**
  7873. * Marks the texture state as changed
  7874. */
  7875. markAsTexturesDirty(): void;
  7876. /**
  7877. * Marks the fresnel state as changed
  7878. */
  7879. markAsFresnelDirty(): void;
  7880. /**
  7881. * Marks the misc state as changed
  7882. */
  7883. markAsMiscDirty(): void;
  7884. /**
  7885. * Rebuilds the material defines
  7886. */
  7887. rebuild(): void;
  7888. /**
  7889. * Specifies if two material defines are equal
  7890. * @param other - A material define instance to compare to
  7891. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7892. */
  7893. isEqual(other: MaterialDefines): boolean;
  7894. /**
  7895. * Clones this instance's defines to another instance
  7896. * @param other - material defines to clone values to
  7897. */
  7898. cloneTo(other: MaterialDefines): void;
  7899. /**
  7900. * Resets the material define values
  7901. */
  7902. reset(): void;
  7903. /**
  7904. * Converts the material define values to a string
  7905. * @returns - String of material define information
  7906. */
  7907. toString(): string;
  7908. }
  7909. }
  7910. declare module "babylonjs/Materials/colorCurves" {
  7911. import { Effect } from "babylonjs/Materials/effect";
  7912. /**
  7913. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7914. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7915. * 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;
  7916. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7917. */
  7918. export class ColorCurves {
  7919. private _dirty;
  7920. private _tempColor;
  7921. private _globalCurve;
  7922. private _highlightsCurve;
  7923. private _midtonesCurve;
  7924. private _shadowsCurve;
  7925. private _positiveCurve;
  7926. private _negativeCurve;
  7927. private _globalHue;
  7928. private _globalDensity;
  7929. private _globalSaturation;
  7930. private _globalExposure;
  7931. /**
  7932. * Gets the global Hue value.
  7933. * 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).
  7934. */
  7935. /**
  7936. * Sets the global Hue value.
  7937. * 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).
  7938. */
  7939. globalHue: number;
  7940. /**
  7941. * Gets the global Density value.
  7942. * 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.
  7943. * Values less than zero provide a filter of opposite hue.
  7944. */
  7945. /**
  7946. * Sets the global Density value.
  7947. * 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.
  7948. * Values less than zero provide a filter of opposite hue.
  7949. */
  7950. globalDensity: number;
  7951. /**
  7952. * Gets the global Saturation value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the global Saturation value.
  7957. * 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.
  7958. */
  7959. globalSaturation: number;
  7960. /**
  7961. * Gets the global Exposure value.
  7962. * 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.
  7963. */
  7964. /**
  7965. * Sets the global Exposure value.
  7966. * 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.
  7967. */
  7968. globalExposure: number;
  7969. private _highlightsHue;
  7970. private _highlightsDensity;
  7971. private _highlightsSaturation;
  7972. private _highlightsExposure;
  7973. /**
  7974. * Gets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. /**
  7978. * Sets the highlights Hue value.
  7979. * 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).
  7980. */
  7981. highlightsHue: number;
  7982. /**
  7983. * Gets the highlights Density value.
  7984. * 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.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. /**
  7988. * Sets the highlights Density value.
  7989. * 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.
  7990. * Values less than zero provide a filter of opposite hue.
  7991. */
  7992. highlightsDensity: number;
  7993. /**
  7994. * Gets the highlights Saturation value.
  7995. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7996. */
  7997. /**
  7998. * Sets the highlights Saturation value.
  7999. * 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.
  8000. */
  8001. highlightsSaturation: number;
  8002. /**
  8003. * Gets the highlights Exposure value.
  8004. * 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.
  8005. */
  8006. /**
  8007. * Sets the highlights Exposure value.
  8008. * 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.
  8009. */
  8010. highlightsExposure: number;
  8011. private _midtonesHue;
  8012. private _midtonesDensity;
  8013. private _midtonesSaturation;
  8014. private _midtonesExposure;
  8015. /**
  8016. * Gets the midtones Hue value.
  8017. * 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).
  8018. */
  8019. /**
  8020. * Sets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. midtonesHue: number;
  8024. /**
  8025. * Gets the midtones Density value.
  8026. * 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.
  8027. * Values less than zero provide a filter of opposite hue.
  8028. */
  8029. /**
  8030. * Sets the midtones Density value.
  8031. * 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.
  8032. * Values less than zero provide a filter of opposite hue.
  8033. */
  8034. midtonesDensity: number;
  8035. /**
  8036. * Gets the midtones Saturation value.
  8037. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8038. */
  8039. /**
  8040. * Sets the midtones Saturation value.
  8041. * 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.
  8042. */
  8043. midtonesSaturation: number;
  8044. /**
  8045. * Gets the midtones Exposure value.
  8046. * 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.
  8047. */
  8048. /**
  8049. * Sets the midtones Exposure value.
  8050. * 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.
  8051. */
  8052. midtonesExposure: number;
  8053. private _shadowsHue;
  8054. private _shadowsDensity;
  8055. private _shadowsSaturation;
  8056. private _shadowsExposure;
  8057. /**
  8058. * Gets the shadows Hue value.
  8059. * 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).
  8060. */
  8061. /**
  8062. * Sets the shadows Hue value.
  8063. * 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).
  8064. */
  8065. shadowsHue: number;
  8066. /**
  8067. * Gets the shadows Density value.
  8068. * 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.
  8069. * Values less than zero provide a filter of opposite hue.
  8070. */
  8071. /**
  8072. * Sets the shadows Density value.
  8073. * 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.
  8074. * Values less than zero provide a filter of opposite hue.
  8075. */
  8076. shadowsDensity: number;
  8077. /**
  8078. * Gets the shadows Saturation value.
  8079. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8080. */
  8081. /**
  8082. * Sets the shadows Saturation value.
  8083. * 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.
  8084. */
  8085. shadowsSaturation: number;
  8086. /**
  8087. * Gets the shadows Exposure value.
  8088. * 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.
  8089. */
  8090. /**
  8091. * Sets the shadows Exposure value.
  8092. * 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.
  8093. */
  8094. shadowsExposure: number;
  8095. /**
  8096. * Returns the class name
  8097. * @returns The class name
  8098. */
  8099. getClassName(): string;
  8100. /**
  8101. * Binds the color curves to the shader.
  8102. * @param colorCurves The color curve to bind
  8103. * @param effect The effect to bind to
  8104. * @param positiveUniform The positive uniform shader parameter
  8105. * @param neutralUniform The neutral uniform shader parameter
  8106. * @param negativeUniform The negative uniform shader parameter
  8107. */
  8108. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8109. /**
  8110. * Prepare the list of uniforms associated with the ColorCurves effects.
  8111. * @param uniformsList The list of uniforms used in the effect
  8112. */
  8113. static PrepareUniforms(uniformsList: string[]): void;
  8114. /**
  8115. * Returns color grading data based on a hue, density, saturation and exposure value.
  8116. * @param filterHue The hue of the color filter.
  8117. * @param filterDensity The density of the color filter.
  8118. * @param saturation The saturation.
  8119. * @param exposure The exposure.
  8120. * @param result The result data container.
  8121. */
  8122. private getColorGradingDataToRef;
  8123. /**
  8124. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8125. * @param value The input slider value in range [-100,100].
  8126. * @returns Adjusted value.
  8127. */
  8128. private static applyColorGradingSliderNonlinear;
  8129. /**
  8130. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8131. * @param hue The hue (H) input.
  8132. * @param saturation The saturation (S) input.
  8133. * @param brightness The brightness (B) input.
  8134. * @result An RGBA color represented as Vector4.
  8135. */
  8136. private static fromHSBToRef;
  8137. /**
  8138. * Returns a value clamped between min and max
  8139. * @param value The value to clamp
  8140. * @param min The minimum of value
  8141. * @param max The maximum of value
  8142. * @returns The clamped value.
  8143. */
  8144. private static clamp;
  8145. /**
  8146. * Clones the current color curve instance.
  8147. * @return The cloned curves
  8148. */
  8149. clone(): ColorCurves;
  8150. /**
  8151. * Serializes the current color curve instance to a json representation.
  8152. * @return a JSON representation
  8153. */
  8154. serialize(): any;
  8155. /**
  8156. * Parses the color curve from a json representation.
  8157. * @param source the JSON source to parse
  8158. * @return The parsed curves
  8159. */
  8160. static Parse(source: any): ColorCurves;
  8161. }
  8162. }
  8163. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8164. import { Observable } from "babylonjs/Misc/observable";
  8165. import { Nullable } from "babylonjs/types";
  8166. import { Color4 } from "babylonjs/Maths/math.color";
  8167. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8168. import { Effect } from "babylonjs/Materials/effect";
  8169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8170. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8171. /**
  8172. * Interface to follow in your material defines to integrate easily the
  8173. * Image proccessing functions.
  8174. * @hidden
  8175. */
  8176. export interface IImageProcessingConfigurationDefines {
  8177. IMAGEPROCESSING: boolean;
  8178. VIGNETTE: boolean;
  8179. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8180. VIGNETTEBLENDMODEOPAQUE: boolean;
  8181. TONEMAPPING: boolean;
  8182. TONEMAPPING_ACES: boolean;
  8183. CONTRAST: boolean;
  8184. EXPOSURE: boolean;
  8185. COLORCURVES: boolean;
  8186. COLORGRADING: boolean;
  8187. COLORGRADING3D: boolean;
  8188. SAMPLER3DGREENDEPTH: boolean;
  8189. SAMPLER3DBGRMAP: boolean;
  8190. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8191. }
  8192. /**
  8193. * @hidden
  8194. */
  8195. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8196. IMAGEPROCESSING: boolean;
  8197. VIGNETTE: boolean;
  8198. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8199. VIGNETTEBLENDMODEOPAQUE: boolean;
  8200. TONEMAPPING: boolean;
  8201. TONEMAPPING_ACES: boolean;
  8202. CONTRAST: boolean;
  8203. COLORCURVES: boolean;
  8204. COLORGRADING: boolean;
  8205. COLORGRADING3D: boolean;
  8206. SAMPLER3DGREENDEPTH: boolean;
  8207. SAMPLER3DBGRMAP: boolean;
  8208. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8209. EXPOSURE: boolean;
  8210. constructor();
  8211. }
  8212. /**
  8213. * This groups together the common properties used for image processing either in direct forward pass
  8214. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8215. * or not.
  8216. */
  8217. export class ImageProcessingConfiguration {
  8218. /**
  8219. * Default tone mapping applied in BabylonJS.
  8220. */
  8221. static readonly TONEMAPPING_STANDARD: number;
  8222. /**
  8223. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8224. * to other engines rendering to increase portability.
  8225. */
  8226. static readonly TONEMAPPING_ACES: number;
  8227. /**
  8228. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8229. */
  8230. colorCurves: Nullable<ColorCurves>;
  8231. private _colorCurvesEnabled;
  8232. /**
  8233. * Gets wether the color curves effect is enabled.
  8234. */
  8235. /**
  8236. * Sets wether the color curves effect is enabled.
  8237. */
  8238. colorCurvesEnabled: boolean;
  8239. private _colorGradingTexture;
  8240. /**
  8241. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8242. */
  8243. /**
  8244. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8245. */
  8246. colorGradingTexture: Nullable<BaseTexture>;
  8247. private _colorGradingEnabled;
  8248. /**
  8249. * Gets wether the color grading effect is enabled.
  8250. */
  8251. /**
  8252. * Sets wether the color grading effect is enabled.
  8253. */
  8254. colorGradingEnabled: boolean;
  8255. private _colorGradingWithGreenDepth;
  8256. /**
  8257. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8258. */
  8259. /**
  8260. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8261. */
  8262. colorGradingWithGreenDepth: boolean;
  8263. private _colorGradingBGR;
  8264. /**
  8265. * Gets wether the color grading texture contains BGR values.
  8266. */
  8267. /**
  8268. * Sets wether the color grading texture contains BGR values.
  8269. */
  8270. colorGradingBGR: boolean;
  8271. /** @hidden */
  8272. _exposure: number;
  8273. /**
  8274. * Gets the Exposure used in the effect.
  8275. */
  8276. /**
  8277. * Sets the Exposure used in the effect.
  8278. */
  8279. exposure: number;
  8280. private _toneMappingEnabled;
  8281. /**
  8282. * Gets wether the tone mapping effect is enabled.
  8283. */
  8284. /**
  8285. * Sets wether the tone mapping effect is enabled.
  8286. */
  8287. toneMappingEnabled: boolean;
  8288. private _toneMappingType;
  8289. /**
  8290. * Gets the type of tone mapping effect.
  8291. */
  8292. /**
  8293. * Sets the type of tone mapping effect used in BabylonJS.
  8294. */
  8295. toneMappingType: number;
  8296. protected _contrast: number;
  8297. /**
  8298. * Gets the contrast used in the effect.
  8299. */
  8300. /**
  8301. * Sets the contrast used in the effect.
  8302. */
  8303. contrast: number;
  8304. /**
  8305. * Vignette stretch size.
  8306. */
  8307. vignetteStretch: number;
  8308. /**
  8309. * Vignette centre X Offset.
  8310. */
  8311. vignetteCentreX: number;
  8312. /**
  8313. * Vignette centre Y Offset.
  8314. */
  8315. vignetteCentreY: number;
  8316. /**
  8317. * Vignette weight or intensity of the vignette effect.
  8318. */
  8319. vignetteWeight: number;
  8320. /**
  8321. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8322. * if vignetteEnabled is set to true.
  8323. */
  8324. vignetteColor: Color4;
  8325. /**
  8326. * Camera field of view used by the Vignette effect.
  8327. */
  8328. vignetteCameraFov: number;
  8329. private _vignetteBlendMode;
  8330. /**
  8331. * Gets the vignette blend mode allowing different kind of effect.
  8332. */
  8333. /**
  8334. * Sets the vignette blend mode allowing different kind of effect.
  8335. */
  8336. vignetteBlendMode: number;
  8337. private _vignetteEnabled;
  8338. /**
  8339. * Gets wether the vignette effect is enabled.
  8340. */
  8341. /**
  8342. * Sets wether the vignette effect is enabled.
  8343. */
  8344. vignetteEnabled: boolean;
  8345. private _applyByPostProcess;
  8346. /**
  8347. * Gets wether the image processing is applied through a post process or not.
  8348. */
  8349. /**
  8350. * Sets wether the image processing is applied through a post process or not.
  8351. */
  8352. applyByPostProcess: boolean;
  8353. private _isEnabled;
  8354. /**
  8355. * Gets wether the image processing is enabled or not.
  8356. */
  8357. /**
  8358. * Sets wether the image processing is enabled or not.
  8359. */
  8360. isEnabled: boolean;
  8361. /**
  8362. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8363. */
  8364. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8365. /**
  8366. * Method called each time the image processing information changes requires to recompile the effect.
  8367. */
  8368. protected _updateParameters(): void;
  8369. /**
  8370. * Gets the current class name.
  8371. * @return "ImageProcessingConfiguration"
  8372. */
  8373. getClassName(): string;
  8374. /**
  8375. * Prepare the list of uniforms associated with the Image Processing effects.
  8376. * @param uniforms The list of uniforms used in the effect
  8377. * @param defines the list of defines currently in use
  8378. */
  8379. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8380. /**
  8381. * Prepare the list of samplers associated with the Image Processing effects.
  8382. * @param samplersList The list of uniforms used in the effect
  8383. * @param defines the list of defines currently in use
  8384. */
  8385. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8386. /**
  8387. * Prepare the list of defines associated to the shader.
  8388. * @param defines the list of defines to complete
  8389. * @param forPostProcess Define if we are currently in post process mode or not
  8390. */
  8391. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8392. /**
  8393. * Returns true if all the image processing information are ready.
  8394. * @returns True if ready, otherwise, false
  8395. */
  8396. isReady(): boolean;
  8397. /**
  8398. * Binds the image processing to the shader.
  8399. * @param effect The effect to bind to
  8400. * @param aspectRatio Define the current aspect ratio of the effect
  8401. */
  8402. bind(effect: Effect, aspectRatio?: number): void;
  8403. /**
  8404. * Clones the current image processing instance.
  8405. * @return The cloned image processing
  8406. */
  8407. clone(): ImageProcessingConfiguration;
  8408. /**
  8409. * Serializes the current image processing instance to a json representation.
  8410. * @return a JSON representation
  8411. */
  8412. serialize(): any;
  8413. /**
  8414. * Parses the image processing from a json representation.
  8415. * @param source the JSON source to parse
  8416. * @return The parsed image processing
  8417. */
  8418. static Parse(source: any): ImageProcessingConfiguration;
  8419. private static _VIGNETTEMODE_MULTIPLY;
  8420. private static _VIGNETTEMODE_OPAQUE;
  8421. /**
  8422. * Used to apply the vignette as a mix with the pixel color.
  8423. */
  8424. static readonly VIGNETTEMODE_MULTIPLY: number;
  8425. /**
  8426. * Used to apply the vignette as a replacement of the pixel color.
  8427. */
  8428. static readonly VIGNETTEMODE_OPAQUE: number;
  8429. }
  8430. }
  8431. declare module "babylonjs/Shaders/postprocess.vertex" {
  8432. /** @hidden */
  8433. export var postprocessVertexShader: {
  8434. name: string;
  8435. shader: string;
  8436. };
  8437. }
  8438. declare module "babylonjs/Maths/math.axis" {
  8439. import { Vector3 } from "babylonjs/Maths/math.vector";
  8440. /** Defines supported spaces */
  8441. export enum Space {
  8442. /** Local (object) space */
  8443. LOCAL = 0,
  8444. /** World space */
  8445. WORLD = 1,
  8446. /** Bone space */
  8447. BONE = 2
  8448. }
  8449. /** Defines the 3 main axes */
  8450. export class Axis {
  8451. /** X axis */
  8452. static X: Vector3;
  8453. /** Y axis */
  8454. static Y: Vector3;
  8455. /** Z axis */
  8456. static Z: Vector3;
  8457. }
  8458. }
  8459. declare module "babylonjs/Cameras/targetCamera" {
  8460. import { Nullable } from "babylonjs/types";
  8461. import { Camera } from "babylonjs/Cameras/camera";
  8462. import { Scene } from "babylonjs/scene";
  8463. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8464. /**
  8465. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8466. * This is the base of the follow, arc rotate cameras and Free camera
  8467. * @see http://doc.babylonjs.com/features/cameras
  8468. */
  8469. export class TargetCamera extends Camera {
  8470. private static _RigCamTransformMatrix;
  8471. private static _TargetTransformMatrix;
  8472. private static _TargetFocalPoint;
  8473. /**
  8474. * Define the current direction the camera is moving to
  8475. */
  8476. cameraDirection: Vector3;
  8477. /**
  8478. * Define the current rotation the camera is rotating to
  8479. */
  8480. cameraRotation: Vector2;
  8481. /**
  8482. * When set, the up vector of the camera will be updated by the rotation of the camera
  8483. */
  8484. updateUpVectorFromRotation: boolean;
  8485. private _tmpQuaternion;
  8486. /**
  8487. * Define the current rotation of the camera
  8488. */
  8489. rotation: Vector3;
  8490. /**
  8491. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8492. */
  8493. rotationQuaternion: Quaternion;
  8494. /**
  8495. * Define the current speed of the camera
  8496. */
  8497. speed: number;
  8498. /**
  8499. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8500. * around all axis.
  8501. */
  8502. noRotationConstraint: boolean;
  8503. /**
  8504. * Define the current target of the camera as an object or a position.
  8505. */
  8506. lockedTarget: any;
  8507. /** @hidden */
  8508. _currentTarget: Vector3;
  8509. /** @hidden */
  8510. _initialFocalDistance: number;
  8511. /** @hidden */
  8512. _viewMatrix: Matrix;
  8513. /** @hidden */
  8514. _camMatrix: Matrix;
  8515. /** @hidden */
  8516. _cameraTransformMatrix: Matrix;
  8517. /** @hidden */
  8518. _cameraRotationMatrix: Matrix;
  8519. /** @hidden */
  8520. _referencePoint: Vector3;
  8521. /** @hidden */
  8522. _transformedReferencePoint: Vector3;
  8523. protected _globalCurrentTarget: Vector3;
  8524. protected _globalCurrentUpVector: Vector3;
  8525. /** @hidden */
  8526. _reset: () => void;
  8527. private _defaultUp;
  8528. /**
  8529. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8530. * This is the base of the follow, arc rotate cameras and Free camera
  8531. * @see http://doc.babylonjs.com/features/cameras
  8532. * @param name Defines the name of the camera in the scene
  8533. * @param position Defines the start position of the camera in the scene
  8534. * @param scene Defines the scene the camera belongs to
  8535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8536. */
  8537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8538. /**
  8539. * Gets the position in front of the camera at a given distance.
  8540. * @param distance The distance from the camera we want the position to be
  8541. * @returns the position
  8542. */
  8543. getFrontPosition(distance: number): Vector3;
  8544. /** @hidden */
  8545. _getLockedTargetPosition(): Nullable<Vector3>;
  8546. private _storedPosition;
  8547. private _storedRotation;
  8548. private _storedRotationQuaternion;
  8549. /**
  8550. * Store current camera state of the camera (fov, position, rotation, etc..)
  8551. * @returns the camera
  8552. */
  8553. storeState(): Camera;
  8554. /**
  8555. * Restored camera state. You must call storeState() first
  8556. * @returns whether it was successful or not
  8557. * @hidden
  8558. */
  8559. _restoreStateValues(): boolean;
  8560. /** @hidden */
  8561. _initCache(): void;
  8562. /** @hidden */
  8563. _updateCache(ignoreParentClass?: boolean): void;
  8564. /** @hidden */
  8565. _isSynchronizedViewMatrix(): boolean;
  8566. /** @hidden */
  8567. _computeLocalCameraSpeed(): number;
  8568. /**
  8569. * Defines the target the camera should look at.
  8570. * @param target Defines the new target as a Vector or a mesh
  8571. */
  8572. setTarget(target: Vector3): void;
  8573. /**
  8574. * Return the current target position of the camera. This value is expressed in local space.
  8575. * @returns the target position
  8576. */
  8577. getTarget(): Vector3;
  8578. /** @hidden */
  8579. _decideIfNeedsToMove(): boolean;
  8580. /** @hidden */
  8581. _updatePosition(): void;
  8582. /** @hidden */
  8583. _checkInputs(): void;
  8584. protected _updateCameraRotationMatrix(): void;
  8585. /**
  8586. * 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)
  8587. * @returns the current camera
  8588. */
  8589. private _rotateUpVectorWithCameraRotationMatrix;
  8590. private _cachedRotationZ;
  8591. private _cachedQuaternionRotationZ;
  8592. /** @hidden */
  8593. _getViewMatrix(): Matrix;
  8594. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8595. /**
  8596. * @hidden
  8597. */
  8598. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8599. /**
  8600. * @hidden
  8601. */
  8602. _updateRigCameras(): void;
  8603. private _getRigCamPositionAndTarget;
  8604. /**
  8605. * Gets the current object class name.
  8606. * @return the class name
  8607. */
  8608. getClassName(): string;
  8609. }
  8610. }
  8611. declare module "babylonjs/Events/keyboardEvents" {
  8612. /**
  8613. * Gather the list of keyboard event types as constants.
  8614. */
  8615. export class KeyboardEventTypes {
  8616. /**
  8617. * The keydown event is fired when a key becomes active (pressed).
  8618. */
  8619. static readonly KEYDOWN: number;
  8620. /**
  8621. * The keyup event is fired when a key has been released.
  8622. */
  8623. static readonly KEYUP: number;
  8624. }
  8625. /**
  8626. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8627. */
  8628. export class KeyboardInfo {
  8629. /**
  8630. * Defines the type of event (KeyboardEventTypes)
  8631. */
  8632. type: number;
  8633. /**
  8634. * Defines the related dom event
  8635. */
  8636. event: KeyboardEvent;
  8637. /**
  8638. * Instantiates a new keyboard info.
  8639. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8640. * @param type Defines the type of event (KeyboardEventTypes)
  8641. * @param event Defines the related dom event
  8642. */
  8643. constructor(
  8644. /**
  8645. * Defines the type of event (KeyboardEventTypes)
  8646. */
  8647. type: number,
  8648. /**
  8649. * Defines the related dom event
  8650. */
  8651. event: KeyboardEvent);
  8652. }
  8653. /**
  8654. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8655. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8656. */
  8657. export class KeyboardInfoPre extends KeyboardInfo {
  8658. /**
  8659. * Defines the type of event (KeyboardEventTypes)
  8660. */
  8661. type: number;
  8662. /**
  8663. * Defines the related dom event
  8664. */
  8665. event: KeyboardEvent;
  8666. /**
  8667. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8668. */
  8669. skipOnPointerObservable: boolean;
  8670. /**
  8671. * Instantiates a new keyboard pre info.
  8672. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8673. * @param type Defines the type of event (KeyboardEventTypes)
  8674. * @param event Defines the related dom event
  8675. */
  8676. constructor(
  8677. /**
  8678. * Defines the type of event (KeyboardEventTypes)
  8679. */
  8680. type: number,
  8681. /**
  8682. * Defines the related dom event
  8683. */
  8684. event: KeyboardEvent);
  8685. }
  8686. }
  8687. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8688. import { Nullable } from "babylonjs/types";
  8689. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8690. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8691. /**
  8692. * Manage the keyboard inputs to control the movement of a free camera.
  8693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8694. */
  8695. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8696. /**
  8697. * Defines the camera the input is attached to.
  8698. */
  8699. camera: FreeCamera;
  8700. /**
  8701. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8702. */
  8703. keysUp: number[];
  8704. /**
  8705. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8706. */
  8707. keysDown: number[];
  8708. /**
  8709. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8710. */
  8711. keysLeft: number[];
  8712. /**
  8713. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8714. */
  8715. keysRight: number[];
  8716. private _keys;
  8717. private _onCanvasBlurObserver;
  8718. private _onKeyboardObserver;
  8719. private _engine;
  8720. private _scene;
  8721. /**
  8722. * Attach the input controls to a specific dom element to get the input from.
  8723. * @param element Defines the element the controls should be listened from
  8724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8725. */
  8726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8727. /**
  8728. * Detach the current controls from the specified dom element.
  8729. * @param element Defines the element to stop listening the inputs from
  8730. */
  8731. detachControl(element: Nullable<HTMLElement>): void;
  8732. /**
  8733. * Update the current camera state depending on the inputs that have been used this frame.
  8734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8735. */
  8736. checkInputs(): void;
  8737. /**
  8738. * Gets the class name of the current intput.
  8739. * @returns the class name
  8740. */
  8741. getClassName(): string;
  8742. /** @hidden */
  8743. _onLostFocus(): void;
  8744. /**
  8745. * Get the friendly name associated with the input class.
  8746. * @returns the input friendly name
  8747. */
  8748. getSimpleName(): string;
  8749. }
  8750. }
  8751. declare module "babylonjs/Lights/shadowLight" {
  8752. import { Camera } from "babylonjs/Cameras/camera";
  8753. import { Scene } from "babylonjs/scene";
  8754. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8756. import { Light } from "babylonjs/Lights/light";
  8757. /**
  8758. * Interface describing all the common properties and methods a shadow light needs to implement.
  8759. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8760. * as well as binding the different shadow properties to the effects.
  8761. */
  8762. export interface IShadowLight extends Light {
  8763. /**
  8764. * The light id in the scene (used in scene.findLighById for instance)
  8765. */
  8766. id: string;
  8767. /**
  8768. * The position the shdow will be casted from.
  8769. */
  8770. position: Vector3;
  8771. /**
  8772. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8773. */
  8774. direction: Vector3;
  8775. /**
  8776. * The transformed position. Position of the light in world space taking parenting in account.
  8777. */
  8778. transformedPosition: Vector3;
  8779. /**
  8780. * The transformed direction. Direction of the light in world space taking parenting in account.
  8781. */
  8782. transformedDirection: Vector3;
  8783. /**
  8784. * The friendly name of the light in the scene.
  8785. */
  8786. name: string;
  8787. /**
  8788. * Defines the shadow projection clipping minimum z value.
  8789. */
  8790. shadowMinZ: number;
  8791. /**
  8792. * Defines the shadow projection clipping maximum z value.
  8793. */
  8794. shadowMaxZ: number;
  8795. /**
  8796. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8797. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8798. */
  8799. computeTransformedInformation(): boolean;
  8800. /**
  8801. * Gets the scene the light belongs to.
  8802. * @returns The scene
  8803. */
  8804. getScene(): Scene;
  8805. /**
  8806. * Callback defining a custom Projection Matrix Builder.
  8807. * This can be used to override the default projection matrix computation.
  8808. */
  8809. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8810. /**
  8811. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8812. * @param matrix The materix to updated with the projection information
  8813. * @param viewMatrix The transform matrix of the light
  8814. * @param renderList The list of mesh to render in the map
  8815. * @returns The current light
  8816. */
  8817. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8818. /**
  8819. * Gets the current depth scale used in ESM.
  8820. * @returns The scale
  8821. */
  8822. getDepthScale(): number;
  8823. /**
  8824. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8825. * @returns true if a cube texture needs to be use
  8826. */
  8827. needCube(): boolean;
  8828. /**
  8829. * Detects if the projection matrix requires to be recomputed this frame.
  8830. * @returns true if it requires to be recomputed otherwise, false.
  8831. */
  8832. needProjectionMatrixCompute(): boolean;
  8833. /**
  8834. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8835. */
  8836. forceProjectionMatrixCompute(): void;
  8837. /**
  8838. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8839. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8840. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8841. */
  8842. getShadowDirection(faceIndex?: number): Vector3;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. }
  8856. /**
  8857. * Base implementation IShadowLight
  8858. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8859. */
  8860. export abstract class ShadowLight extends Light implements IShadowLight {
  8861. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8862. protected _position: Vector3;
  8863. protected _setPosition(value: Vector3): void;
  8864. /**
  8865. * Sets the position the shadow will be casted from. Also use as the light position for both
  8866. * point and spot lights.
  8867. */
  8868. /**
  8869. * Sets the position the shadow will be casted from. Also use as the light position for both
  8870. * point and spot lights.
  8871. */
  8872. position: Vector3;
  8873. protected _direction: Vector3;
  8874. protected _setDirection(value: Vector3): void;
  8875. /**
  8876. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8877. * Also use as the light direction on spot and directional lights.
  8878. */
  8879. /**
  8880. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8881. * Also use as the light direction on spot and directional lights.
  8882. */
  8883. direction: Vector3;
  8884. private _shadowMinZ;
  8885. /**
  8886. * Gets the shadow projection clipping minimum z value.
  8887. */
  8888. /**
  8889. * Sets the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. private _shadowMaxZ;
  8893. /**
  8894. * Sets the shadow projection clipping maximum z value.
  8895. */
  8896. /**
  8897. * Gets the shadow projection clipping maximum z value.
  8898. */
  8899. shadowMaxZ: number;
  8900. /**
  8901. * Callback defining a custom Projection Matrix Builder.
  8902. * This can be used to override the default projection matrix computation.
  8903. */
  8904. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8905. /**
  8906. * The transformed position. Position of the light in world space taking parenting in account.
  8907. */
  8908. transformedPosition: Vector3;
  8909. /**
  8910. * The transformed direction. Direction of the light in world space taking parenting in account.
  8911. */
  8912. transformedDirection: Vector3;
  8913. private _needProjectionMatrixCompute;
  8914. /**
  8915. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8916. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8917. */
  8918. computeTransformedInformation(): boolean;
  8919. /**
  8920. * Return the depth scale used for the shadow map.
  8921. * @returns the depth scale.
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8926. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8927. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8928. */
  8929. getShadowDirection(faceIndex?: number): Vector3;
  8930. /**
  8931. * Returns the ShadowLight absolute position in the World.
  8932. * @returns the position vector in world space
  8933. */
  8934. getAbsolutePosition(): Vector3;
  8935. /**
  8936. * Sets the ShadowLight direction toward the passed target.
  8937. * @param target The point to target in local space
  8938. * @returns the updated ShadowLight direction
  8939. */
  8940. setDirectionToTarget(target: Vector3): Vector3;
  8941. /**
  8942. * Returns the light rotation in euler definition.
  8943. * @returns the x y z rotation in local space.
  8944. */
  8945. getRotation(): Vector3;
  8946. /**
  8947. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8948. * @returns true if a cube texture needs to be use
  8949. */
  8950. needCube(): boolean;
  8951. /**
  8952. * Detects if the projection matrix requires to be recomputed this frame.
  8953. * @returns true if it requires to be recomputed otherwise, false.
  8954. */
  8955. needProjectionMatrixCompute(): boolean;
  8956. /**
  8957. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8958. */
  8959. forceProjectionMatrixCompute(): void;
  8960. /** @hidden */
  8961. _initCache(): void;
  8962. /** @hidden */
  8963. _isSynchronized(): boolean;
  8964. /**
  8965. * Computes the world matrix of the node
  8966. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8967. * @returns the world matrix
  8968. */
  8969. computeWorldMatrix(force?: boolean): Matrix;
  8970. /**
  8971. * Gets the minZ used for shadow according to both the scene and the light.
  8972. * @param activeCamera The camera we are returning the min for
  8973. * @returns the depth min z
  8974. */
  8975. getDepthMinZ(activeCamera: Camera): number;
  8976. /**
  8977. * Gets the maxZ used for shadow according to both the scene and the light.
  8978. * @param activeCamera The camera we are returning the max for
  8979. * @returns the depth max z
  8980. */
  8981. getDepthMaxZ(activeCamera: Camera): number;
  8982. /**
  8983. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8984. * @param matrix The materix to updated with the projection information
  8985. * @param viewMatrix The transform matrix of the light
  8986. * @param renderList The list of mesh to render in the map
  8987. * @returns The current light
  8988. */
  8989. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8990. }
  8991. }
  8992. declare module "babylonjs/Materials/materialHelper" {
  8993. import { Nullable } from "babylonjs/types";
  8994. import { Scene } from "babylonjs/scene";
  8995. import { Engine } from "babylonjs/Engines/engine";
  8996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8997. import { Light } from "babylonjs/Lights/light";
  8998. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8999. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9001. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9002. /**
  9003. * "Static Class" containing the most commonly used helper while dealing with material for
  9004. * rendering purpose.
  9005. *
  9006. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9007. *
  9008. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9009. */
  9010. export class MaterialHelper {
  9011. /**
  9012. * Bind the current view position to an effect.
  9013. * @param effect The effect to be bound
  9014. * @param scene The scene the eyes position is used from
  9015. */
  9016. static BindEyePosition(effect: Effect, scene: Scene): void;
  9017. /**
  9018. * Helps preparing the defines values about the UVs in used in the effect.
  9019. * UVs are shared as much as we can accross channels in the shaders.
  9020. * @param texture The texture we are preparing the UVs for
  9021. * @param defines The defines to update
  9022. * @param key The channel key "diffuse", "specular"... used in the shader
  9023. */
  9024. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9025. /**
  9026. * Binds a texture matrix value to its corrsponding uniform
  9027. * @param texture The texture to bind the matrix for
  9028. * @param uniformBuffer The uniform buffer receivin the data
  9029. * @param key The channel key "diffuse", "specular"... used in the shader
  9030. */
  9031. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9032. /**
  9033. * Gets the current status of the fog (should it be enabled?)
  9034. * @param mesh defines the mesh to evaluate for fog support
  9035. * @param scene defines the hosting scene
  9036. * @returns true if fog must be enabled
  9037. */
  9038. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9039. /**
  9040. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9041. * @param mesh defines the current mesh
  9042. * @param scene defines the current scene
  9043. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9044. * @param pointsCloud defines if point cloud rendering has to be turned on
  9045. * @param fogEnabled defines if fog has to be turned on
  9046. * @param alphaTest defines if alpha testing has to be turned on
  9047. * @param defines defines the current list of defines
  9048. */
  9049. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9050. /**
  9051. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9052. * @param scene defines the current scene
  9053. * @param engine defines the current engine
  9054. * @param defines specifies the list of active defines
  9055. * @param useInstances defines if instances have to be turned on
  9056. * @param useClipPlane defines if clip plane have to be turned on
  9057. */
  9058. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9059. /**
  9060. * Prepares the defines for bones
  9061. * @param mesh The mesh containing the geometry data we will draw
  9062. * @param defines The defines to update
  9063. */
  9064. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9065. /**
  9066. * Prepares the defines for morph targets
  9067. * @param mesh The mesh containing the geometry data we will draw
  9068. * @param defines The defines to update
  9069. */
  9070. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9071. /**
  9072. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9073. * @param mesh The mesh containing the geometry data we will draw
  9074. * @param defines The defines to update
  9075. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9076. * @param useBones Precise whether bones should be used or not (override mesh info)
  9077. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9078. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9079. * @returns false if defines are considered not dirty and have not been checked
  9080. */
  9081. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9082. /**
  9083. * Prepares the defines related to multiview
  9084. * @param scene The scene we are intending to draw
  9085. * @param defines The defines to update
  9086. */
  9087. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9088. /**
  9089. * Prepares the defines related to the light information passed in parameter
  9090. * @param scene The scene we are intending to draw
  9091. * @param mesh The mesh the effect is compiling for
  9092. * @param light The light the effect is compiling for
  9093. * @param lightIndex The index of the light
  9094. * @param defines The defines to update
  9095. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9096. * @param state Defines the current state regarding what is needed (normals, etc...)
  9097. */
  9098. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9099. needNormals: boolean;
  9100. needRebuild: boolean;
  9101. shadowEnabled: boolean;
  9102. specularEnabled: boolean;
  9103. lightmapMode: boolean;
  9104. }): void;
  9105. /**
  9106. * Prepares the defines related to the light information passed in parameter
  9107. * @param scene The scene we are intending to draw
  9108. * @param mesh The mesh the effect is compiling for
  9109. * @param defines The defines to update
  9110. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9111. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9112. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9113. * @returns true if normals will be required for the rest of the effect
  9114. */
  9115. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9116. /**
  9117. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9118. * @param lightIndex defines the light index
  9119. * @param uniformsList The uniform list
  9120. * @param samplersList The sampler list
  9121. * @param projectedLightTexture defines if projected texture must be used
  9122. * @param uniformBuffersList defines an optional list of uniform buffers
  9123. */
  9124. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9125. /**
  9126. * Prepares the uniforms and samplers list to be used in the effect
  9127. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9128. * @param samplersList The sampler list
  9129. * @param defines The defines helping in the list generation
  9130. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9131. */
  9132. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9133. /**
  9134. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9135. * @param defines The defines to update while falling back
  9136. * @param fallbacks The authorized effect fallbacks
  9137. * @param maxSimultaneousLights The maximum number of lights allowed
  9138. * @param rank the current rank of the Effect
  9139. * @returns The newly affected rank
  9140. */
  9141. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9142. private static _TmpMorphInfluencers;
  9143. /**
  9144. * Prepares the list of attributes required for morph targets according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param mesh The mesh to prepare the morph targets attributes for
  9147. * @param influencers The number of influencers
  9148. */
  9149. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9150. /**
  9151. * Prepares the list of attributes required for morph targets according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the morph targets attributes for
  9154. * @param defines The current Defines of the effect
  9155. */
  9156. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9157. /**
  9158. * Prepares the list of attributes required for bones according to the effect defines.
  9159. * @param attribs The current list of supported attribs
  9160. * @param mesh The mesh to prepare the bones attributes for
  9161. * @param defines The current Defines of the effect
  9162. * @param fallbacks The current efffect fallback strategy
  9163. */
  9164. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9165. /**
  9166. * Check and prepare the list of attributes required for instances according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param defines The current MaterialDefines of the effect
  9169. */
  9170. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9171. /**
  9172. * Add the list of attributes required for instances to the attribs array.
  9173. * @param attribs The current list of supported attribs
  9174. */
  9175. static PushAttributesForInstances(attribs: string[]): void;
  9176. /**
  9177. * Binds the light shadow information to the effect for the given mesh.
  9178. * @param light The light containing the generator
  9179. * @param scene The scene the lights belongs to
  9180. * @param mesh The mesh we are binding the information to render
  9181. * @param lightIndex The light index in the effect used to render the mesh
  9182. * @param effect The effect we are binding the data to
  9183. */
  9184. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9185. /**
  9186. * Binds the light information to the effect.
  9187. * @param light The light containing the generator
  9188. * @param effect The effect we are binding the data to
  9189. * @param lightIndex The light index in the effect used to render
  9190. */
  9191. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9192. /**
  9193. * Binds the lights information from the scene to the effect for the given mesh.
  9194. * @param light Light to bind
  9195. * @param lightIndex Light index
  9196. * @param scene The scene where the light belongs to
  9197. * @param mesh The mesh we are binding the information to render
  9198. * @param effect The effect we are binding the data to
  9199. * @param useSpecular Defines if specular is supported
  9200. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9201. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9202. */
  9203. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9204. /**
  9205. * Binds the lights information from the scene to the effect for the given mesh.
  9206. * @param scene The scene the lights belongs to
  9207. * @param mesh The mesh we are binding the information to render
  9208. * @param effect The effect we are binding the data to
  9209. * @param defines The generated defines for the effect
  9210. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9211. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9212. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9213. */
  9214. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9215. private static _tempFogColor;
  9216. /**
  9217. * Binds the fog information from the scene to the effect for the given mesh.
  9218. * @param scene The scene the lights belongs to
  9219. * @param mesh The mesh we are binding the information to render
  9220. * @param effect The effect we are binding the data to
  9221. * @param linearSpace Defines if the fog effect is applied in linear space
  9222. */
  9223. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9224. /**
  9225. * Binds the bones information from the mesh to the effect.
  9226. * @param mesh The mesh we are binding the information to render
  9227. * @param effect The effect we are binding the data to
  9228. */
  9229. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9230. /**
  9231. * Binds the morph targets information from the mesh to the effect.
  9232. * @param abstractMesh The mesh we are binding the information to render
  9233. * @param effect The effect we are binding the data to
  9234. */
  9235. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9236. /**
  9237. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9238. * @param defines The generated defines used in the effect
  9239. * @param effect The effect we are binding the data to
  9240. * @param scene The scene we are willing to render with logarithmic scale for
  9241. */
  9242. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9243. /**
  9244. * Binds the clip plane information from the scene to the effect.
  9245. * @param scene The scene the clip plane information are extracted from
  9246. * @param effect The effect we are binding the data to
  9247. */
  9248. static BindClipPlane(effect: Effect, scene: Scene): void;
  9249. }
  9250. }
  9251. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9252. /** @hidden */
  9253. export var packingFunctions: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9259. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9260. /** @hidden */
  9261. export var shadowMapPixelShader: {
  9262. name: string;
  9263. shader: string;
  9264. };
  9265. }
  9266. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9267. /** @hidden */
  9268. export var bonesDeclaration: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9274. /** @hidden */
  9275. export var morphTargetsVertexGlobalDeclaration: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9281. /** @hidden */
  9282. export var morphTargetsVertexDeclaration: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9288. /** @hidden */
  9289. export var instancesDeclaration: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9295. /** @hidden */
  9296. export var helperFunctions: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9302. /** @hidden */
  9303. export var morphTargetsVertex: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9309. /** @hidden */
  9310. export var instancesVertex: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9316. /** @hidden */
  9317. export var bonesVertex: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9323. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9324. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9326. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9327. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9329. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9330. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9331. /** @hidden */
  9332. export var shadowMapVertexShader: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9338. /** @hidden */
  9339. export var depthBoxBlurPixelShader: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9345. import { Nullable } from "babylonjs/types";
  9346. import { Scene } from "babylonjs/scene";
  9347. import { Matrix } from "babylonjs/Maths/math.vector";
  9348. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9350. import { Mesh } from "babylonjs/Meshes/mesh";
  9351. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9352. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9353. import { Effect } from "babylonjs/Materials/effect";
  9354. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9355. import "babylonjs/Shaders/shadowMap.fragment";
  9356. import "babylonjs/Shaders/shadowMap.vertex";
  9357. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9358. import { Observable } from "babylonjs/Misc/observable";
  9359. /**
  9360. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9361. */
  9362. export interface ICustomShaderOptions {
  9363. /**
  9364. * Gets or sets the custom shader name to use
  9365. */
  9366. shaderName: string;
  9367. /**
  9368. * The list of attribute names used in the shader
  9369. */
  9370. attributes?: string[];
  9371. /**
  9372. * The list of unifrom names used in the shader
  9373. */
  9374. uniforms?: string[];
  9375. /**
  9376. * The list of sampler names used in the shader
  9377. */
  9378. samplers?: string[];
  9379. /**
  9380. * The list of defines used in the shader
  9381. */
  9382. defines?: string[];
  9383. }
  9384. /**
  9385. * Interface to implement to create a shadow generator compatible with BJS.
  9386. */
  9387. export interface IShadowGenerator {
  9388. /**
  9389. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9390. * @returns The render target texture if present otherwise, null
  9391. */
  9392. getShadowMap(): Nullable<RenderTargetTexture>;
  9393. /**
  9394. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9395. * @returns The render target texture if the shadow map is present otherwise, null
  9396. */
  9397. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9398. /**
  9399. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9400. * @param subMesh The submesh we want to render in the shadow map
  9401. * @param useInstances Defines wether will draw in the map using instances
  9402. * @returns true if ready otherwise, false
  9403. */
  9404. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9405. /**
  9406. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9407. * @param defines Defines of the material we want to update
  9408. * @param lightIndex Index of the light in the enabled light list of the material
  9409. */
  9410. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9411. /**
  9412. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9413. * defined in the generator but impacting the effect).
  9414. * It implies the unifroms available on the materials are the standard BJS ones.
  9415. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9416. * @param effect The effect we are binfing the information for
  9417. */
  9418. bindShadowLight(lightIndex: string, effect: Effect): void;
  9419. /**
  9420. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9421. * (eq to shadow prjection matrix * light transform matrix)
  9422. * @returns The transform matrix used to create the shadow map
  9423. */
  9424. getTransformMatrix(): Matrix;
  9425. /**
  9426. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9427. * Cube and 2D textures for instance.
  9428. */
  9429. recreateShadowMap(): void;
  9430. /**
  9431. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9432. * @param onCompiled Callback triggered at the and of the effects compilation
  9433. * @param options Sets of optional options forcing the compilation with different modes
  9434. */
  9435. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9436. useInstances: boolean;
  9437. }>): void;
  9438. /**
  9439. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9440. * @param options Sets of optional options forcing the compilation with different modes
  9441. * @returns A promise that resolves when the compilation completes
  9442. */
  9443. forceCompilationAsync(options?: Partial<{
  9444. useInstances: boolean;
  9445. }>): Promise<void>;
  9446. /**
  9447. * Serializes the shadow generator setup to a json object.
  9448. * @returns The serialized JSON object
  9449. */
  9450. serialize(): any;
  9451. /**
  9452. * Disposes the Shadow map and related Textures and effects.
  9453. */
  9454. dispose(): void;
  9455. }
  9456. /**
  9457. * Default implementation IShadowGenerator.
  9458. * This is the main object responsible of generating shadows in the framework.
  9459. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9460. */
  9461. export class ShadowGenerator implements IShadowGenerator {
  9462. /**
  9463. * Shadow generator mode None: no filtering applied.
  9464. */
  9465. static readonly FILTER_NONE: number;
  9466. /**
  9467. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9468. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9469. */
  9470. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9471. /**
  9472. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9473. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9474. */
  9475. static readonly FILTER_POISSONSAMPLING: number;
  9476. /**
  9477. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9478. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9479. */
  9480. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9481. /**
  9482. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9483. * edge artifacts on steep falloff.
  9484. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9485. */
  9486. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9487. /**
  9488. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9489. * edge artifacts on steep falloff.
  9490. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9491. */
  9492. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9493. /**
  9494. * Shadow generator mode PCF: Percentage Closer Filtering
  9495. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9496. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9497. */
  9498. static readonly FILTER_PCF: number;
  9499. /**
  9500. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9501. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9502. * Contact Hardening
  9503. */
  9504. static readonly FILTER_PCSS: number;
  9505. /**
  9506. * Reserved for PCF and PCSS
  9507. * Highest Quality.
  9508. *
  9509. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9510. *
  9511. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9512. */
  9513. static readonly QUALITY_HIGH: number;
  9514. /**
  9515. * Reserved for PCF and PCSS
  9516. * Good tradeoff for quality/perf cross devices
  9517. *
  9518. * Execute PCF on a 3*3 kernel.
  9519. *
  9520. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9521. */
  9522. static readonly QUALITY_MEDIUM: number;
  9523. /**
  9524. * Reserved for PCF and PCSS
  9525. * The lowest quality but the fastest.
  9526. *
  9527. * Execute PCF on a 1*1 kernel.
  9528. *
  9529. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9530. */
  9531. static readonly QUALITY_LOW: number;
  9532. /** Gets or sets the custom shader name to use */
  9533. customShaderOptions: ICustomShaderOptions;
  9534. /**
  9535. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9536. */
  9537. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9538. /**
  9539. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9540. */
  9541. onAfterShadowMapRenderObservable: Observable<Effect>;
  9542. /**
  9543. * Observable triggered before a mesh is rendered in the shadow map.
  9544. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9545. */
  9546. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9547. /**
  9548. * Observable triggered after a mesh is rendered in the shadow map.
  9549. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9550. */
  9551. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9552. private _bias;
  9553. /**
  9554. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9555. */
  9556. /**
  9557. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9558. */
  9559. bias: number;
  9560. private _normalBias;
  9561. /**
  9562. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9563. */
  9564. /**
  9565. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9566. */
  9567. normalBias: number;
  9568. private _blurBoxOffset;
  9569. /**
  9570. * Gets the blur box offset: offset applied during the blur pass.
  9571. * Only useful if useKernelBlur = false
  9572. */
  9573. /**
  9574. * Sets the blur box offset: offset applied during the blur pass.
  9575. * Only useful if useKernelBlur = false
  9576. */
  9577. blurBoxOffset: number;
  9578. private _blurScale;
  9579. /**
  9580. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9581. * 2 means half of the size.
  9582. */
  9583. /**
  9584. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9585. * 2 means half of the size.
  9586. */
  9587. blurScale: number;
  9588. private _blurKernel;
  9589. /**
  9590. * Gets the blur kernel: kernel size of the blur pass.
  9591. * Only useful if useKernelBlur = true
  9592. */
  9593. /**
  9594. * Sets the blur kernel: kernel size of the blur pass.
  9595. * Only useful if useKernelBlur = true
  9596. */
  9597. blurKernel: number;
  9598. private _useKernelBlur;
  9599. /**
  9600. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9601. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9602. */
  9603. /**
  9604. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9605. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9606. */
  9607. useKernelBlur: boolean;
  9608. private _depthScale;
  9609. /**
  9610. * Gets the depth scale used in ESM mode.
  9611. */
  9612. /**
  9613. * Sets the depth scale used in ESM mode.
  9614. * This can override the scale stored on the light.
  9615. */
  9616. depthScale: number;
  9617. private _filter;
  9618. /**
  9619. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9620. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9621. */
  9622. /**
  9623. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9624. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9625. */
  9626. filter: number;
  9627. /**
  9628. * Gets if the current filter is set to Poisson Sampling.
  9629. */
  9630. /**
  9631. * Sets the current filter to Poisson Sampling.
  9632. */
  9633. usePoissonSampling: boolean;
  9634. /**
  9635. * Gets if the current filter is set to ESM.
  9636. */
  9637. /**
  9638. * Sets the current filter is to ESM.
  9639. */
  9640. useExponentialShadowMap: boolean;
  9641. /**
  9642. * Gets if the current filter is set to filtered ESM.
  9643. */
  9644. /**
  9645. * Gets if the current filter is set to filtered ESM.
  9646. */
  9647. useBlurExponentialShadowMap: boolean;
  9648. /**
  9649. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9650. * exponential to prevent steep falloff artifacts).
  9651. */
  9652. /**
  9653. * Sets the current filter to "close ESM" (using the inverse of the
  9654. * exponential to prevent steep falloff artifacts).
  9655. */
  9656. useCloseExponentialShadowMap: boolean;
  9657. /**
  9658. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9659. * exponential to prevent steep falloff artifacts).
  9660. */
  9661. /**
  9662. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9663. * exponential to prevent steep falloff artifacts).
  9664. */
  9665. useBlurCloseExponentialShadowMap: boolean;
  9666. /**
  9667. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9668. */
  9669. /**
  9670. * Sets the current filter to "PCF" (percentage closer filtering).
  9671. */
  9672. usePercentageCloserFiltering: boolean;
  9673. private _filteringQuality;
  9674. /**
  9675. * Gets the PCF or PCSS Quality.
  9676. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9677. */
  9678. /**
  9679. * Sets the PCF or PCSS Quality.
  9680. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9681. */
  9682. filteringQuality: number;
  9683. /**
  9684. * Gets if the current filter is set to "PCSS" (contact hardening).
  9685. */
  9686. /**
  9687. * Sets the current filter to "PCSS" (contact hardening).
  9688. */
  9689. useContactHardeningShadow: boolean;
  9690. private _contactHardeningLightSizeUVRatio;
  9691. /**
  9692. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9693. * Using a ratio helps keeping shape stability independently of the map size.
  9694. *
  9695. * It does not account for the light projection as it was having too much
  9696. * instability during the light setup or during light position changes.
  9697. *
  9698. * Only valid if useContactHardeningShadow is true.
  9699. */
  9700. /**
  9701. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9702. * Using a ratio helps keeping shape stability independently of the map size.
  9703. *
  9704. * It does not account for the light projection as it was having too much
  9705. * instability during the light setup or during light position changes.
  9706. *
  9707. * Only valid if useContactHardeningShadow is true.
  9708. */
  9709. contactHardeningLightSizeUVRatio: number;
  9710. private _darkness;
  9711. /** Gets or sets the actual darkness of a shadow */
  9712. darkness: number;
  9713. /**
  9714. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9715. * 0 means strongest and 1 would means no shadow.
  9716. * @returns the darkness.
  9717. */
  9718. getDarkness(): number;
  9719. /**
  9720. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9721. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9722. * @returns the shadow generator allowing fluent coding.
  9723. */
  9724. setDarkness(darkness: number): ShadowGenerator;
  9725. private _transparencyShadow;
  9726. /** Gets or sets the ability to have transparent shadow */
  9727. transparencyShadow: boolean;
  9728. /**
  9729. * Sets the ability to have transparent shadow (boolean).
  9730. * @param transparent True if transparent else False
  9731. * @returns the shadow generator allowing fluent coding
  9732. */
  9733. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9734. private _shadowMap;
  9735. private _shadowMap2;
  9736. /**
  9737. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9738. * @returns The render target texture if present otherwise, null
  9739. */
  9740. getShadowMap(): Nullable<RenderTargetTexture>;
  9741. /**
  9742. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9743. * @returns The render target texture if the shadow map is present otherwise, null
  9744. */
  9745. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9746. /**
  9747. * Gets the class name of that object
  9748. * @returns "ShadowGenerator"
  9749. */
  9750. getClassName(): string;
  9751. /**
  9752. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9753. * @param mesh Mesh to add
  9754. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9755. * @returns the Shadow Generator itself
  9756. */
  9757. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9758. /**
  9759. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9760. * @param mesh Mesh to remove
  9761. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9762. * @returns the Shadow Generator itself
  9763. */
  9764. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9765. /**
  9766. * Controls the extent to which the shadows fade out at the edge of the frustum
  9767. * Used only by directionals and spots
  9768. */
  9769. frustumEdgeFalloff: number;
  9770. private _light;
  9771. /**
  9772. * Returns the associated light object.
  9773. * @returns the light generating the shadow
  9774. */
  9775. getLight(): IShadowLight;
  9776. /**
  9777. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9778. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9779. * It might on the other hand introduce peter panning.
  9780. */
  9781. forceBackFacesOnly: boolean;
  9782. private _scene;
  9783. private _lightDirection;
  9784. private _effect;
  9785. private _viewMatrix;
  9786. private _projectionMatrix;
  9787. private _transformMatrix;
  9788. private _cachedPosition;
  9789. private _cachedDirection;
  9790. private _cachedDefines;
  9791. private _currentRenderID;
  9792. private _boxBlurPostprocess;
  9793. private _kernelBlurXPostprocess;
  9794. private _kernelBlurYPostprocess;
  9795. private _blurPostProcesses;
  9796. private _mapSize;
  9797. private _currentFaceIndex;
  9798. private _currentFaceIndexCache;
  9799. private _textureType;
  9800. private _defaultTextureMatrix;
  9801. /** @hidden */
  9802. static _SceneComponentInitialization: (scene: Scene) => void;
  9803. /**
  9804. * Creates a ShadowGenerator object.
  9805. * A ShadowGenerator is the required tool to use the shadows.
  9806. * Each light casting shadows needs to use its own ShadowGenerator.
  9807. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9808. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9809. * @param light The light object generating the shadows.
  9810. * @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.
  9811. */
  9812. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9813. private _initializeGenerator;
  9814. private _initializeShadowMap;
  9815. private _initializeBlurRTTAndPostProcesses;
  9816. private _renderForShadowMap;
  9817. private _renderSubMeshForShadowMap;
  9818. private _applyFilterValues;
  9819. /**
  9820. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9821. * @param onCompiled Callback triggered at the and of the effects compilation
  9822. * @param options Sets of optional options forcing the compilation with different modes
  9823. */
  9824. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9825. useInstances: boolean;
  9826. }>): void;
  9827. /**
  9828. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9829. * @param options Sets of optional options forcing the compilation with different modes
  9830. * @returns A promise that resolves when the compilation completes
  9831. */
  9832. forceCompilationAsync(options?: Partial<{
  9833. useInstances: boolean;
  9834. }>): Promise<void>;
  9835. /**
  9836. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9837. * @param subMesh The submesh we want to render in the shadow map
  9838. * @param useInstances Defines wether will draw in the map using instances
  9839. * @returns true if ready otherwise, false
  9840. */
  9841. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9842. /**
  9843. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9844. * @param defines Defines of the material we want to update
  9845. * @param lightIndex Index of the light in the enabled light list of the material
  9846. */
  9847. prepareDefines(defines: any, lightIndex: number): void;
  9848. /**
  9849. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9850. * defined in the generator but impacting the effect).
  9851. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9852. * @param effect The effect we are binfing the information for
  9853. */
  9854. bindShadowLight(lightIndex: string, effect: Effect): void;
  9855. /**
  9856. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9857. * (eq to shadow prjection matrix * light transform matrix)
  9858. * @returns The transform matrix used to create the shadow map
  9859. */
  9860. getTransformMatrix(): Matrix;
  9861. /**
  9862. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9863. * Cube and 2D textures for instance.
  9864. */
  9865. recreateShadowMap(): void;
  9866. private _disposeBlurPostProcesses;
  9867. private _disposeRTTandPostProcesses;
  9868. /**
  9869. * Disposes the ShadowGenerator.
  9870. * Returns nothing.
  9871. */
  9872. dispose(): void;
  9873. /**
  9874. * Serializes the shadow generator setup to a json object.
  9875. * @returns The serialized JSON object
  9876. */
  9877. serialize(): any;
  9878. /**
  9879. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9880. * @param parsedShadowGenerator The JSON object to parse
  9881. * @param scene The scene to create the shadow map for
  9882. * @returns The parsed shadow generator
  9883. */
  9884. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9885. }
  9886. }
  9887. declare module "babylonjs/Lights/light" {
  9888. import { Nullable } from "babylonjs/types";
  9889. import { Scene } from "babylonjs/scene";
  9890. import { Vector3 } from "babylonjs/Maths/math.vector";
  9891. import { Color3 } from "babylonjs/Maths/math.color";
  9892. import { Node } from "babylonjs/node";
  9893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9894. import { Effect } from "babylonjs/Materials/effect";
  9895. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9896. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9897. /**
  9898. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9899. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9900. * 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.
  9901. */
  9902. export abstract class Light extends Node {
  9903. /**
  9904. * Falloff Default: light is falling off following the material specification:
  9905. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9906. */
  9907. static readonly FALLOFF_DEFAULT: number;
  9908. /**
  9909. * Falloff Physical: light is falling off following the inverse squared distance law.
  9910. */
  9911. static readonly FALLOFF_PHYSICAL: number;
  9912. /**
  9913. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9914. * to enhance interoperability with other engines.
  9915. */
  9916. static readonly FALLOFF_GLTF: number;
  9917. /**
  9918. * Falloff Standard: light is falling off like in the standard material
  9919. * to enhance interoperability with other materials.
  9920. */
  9921. static readonly FALLOFF_STANDARD: number;
  9922. /**
  9923. * If every light affecting the material is in this lightmapMode,
  9924. * material.lightmapTexture adds or multiplies
  9925. * (depends on material.useLightmapAsShadowmap)
  9926. * after every other light calculations.
  9927. */
  9928. static readonly LIGHTMAP_DEFAULT: number;
  9929. /**
  9930. * material.lightmapTexture as only diffuse lighting from this light
  9931. * adds only specular lighting from this light
  9932. * adds dynamic shadows
  9933. */
  9934. static readonly LIGHTMAP_SPECULAR: number;
  9935. /**
  9936. * material.lightmapTexture as only lighting
  9937. * no light calculation from this light
  9938. * only adds dynamic shadows from this light
  9939. */
  9940. static readonly LIGHTMAP_SHADOWSONLY: number;
  9941. /**
  9942. * Each light type uses the default quantity according to its type:
  9943. * point/spot lights use luminous intensity
  9944. * directional lights use illuminance
  9945. */
  9946. static readonly INTENSITYMODE_AUTOMATIC: number;
  9947. /**
  9948. * lumen (lm)
  9949. */
  9950. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9951. /**
  9952. * candela (lm/sr)
  9953. */
  9954. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9955. /**
  9956. * lux (lm/m^2)
  9957. */
  9958. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9959. /**
  9960. * nit (cd/m^2)
  9961. */
  9962. static readonly INTENSITYMODE_LUMINANCE: number;
  9963. /**
  9964. * Light type const id of the point light.
  9965. */
  9966. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9967. /**
  9968. * Light type const id of the directional light.
  9969. */
  9970. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9971. /**
  9972. * Light type const id of the spot light.
  9973. */
  9974. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9975. /**
  9976. * Light type const id of the hemispheric light.
  9977. */
  9978. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9979. /**
  9980. * Diffuse gives the basic color to an object.
  9981. */
  9982. diffuse: Color3;
  9983. /**
  9984. * Specular produces a highlight color on an object.
  9985. * Note: This is note affecting PBR materials.
  9986. */
  9987. specular: Color3;
  9988. /**
  9989. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9990. * falling off base on range or angle.
  9991. * This can be set to any values in Light.FALLOFF_x.
  9992. *
  9993. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9994. * other types of materials.
  9995. */
  9996. falloffType: number;
  9997. /**
  9998. * Strength of the light.
  9999. * Note: By default it is define in the framework own unit.
  10000. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10001. */
  10002. intensity: number;
  10003. private _range;
  10004. protected _inverseSquaredRange: number;
  10005. /**
  10006. * Defines how far from the source the light is impacting in scene units.
  10007. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10008. */
  10009. /**
  10010. * Defines how far from the source the light is impacting in scene units.
  10011. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10012. */
  10013. range: number;
  10014. /**
  10015. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10016. * of light.
  10017. */
  10018. private _photometricScale;
  10019. private _intensityMode;
  10020. /**
  10021. * Gets the photometric scale used to interpret the intensity.
  10022. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10023. */
  10024. /**
  10025. * Sets the photometric scale used to interpret the intensity.
  10026. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10027. */
  10028. intensityMode: number;
  10029. private _radius;
  10030. /**
  10031. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10032. */
  10033. /**
  10034. * sets the light radius used by PBR Materials to simulate soft area lights.
  10035. */
  10036. radius: number;
  10037. private _renderPriority;
  10038. /**
  10039. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10040. * exceeding the number allowed of the materials.
  10041. */
  10042. renderPriority: number;
  10043. private _shadowEnabled;
  10044. /**
  10045. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10046. * the current shadow generator.
  10047. */
  10048. /**
  10049. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10050. * the current shadow generator.
  10051. */
  10052. shadowEnabled: boolean;
  10053. private _includedOnlyMeshes;
  10054. /**
  10055. * Gets the only meshes impacted by this light.
  10056. */
  10057. /**
  10058. * Sets the only meshes impacted by this light.
  10059. */
  10060. includedOnlyMeshes: AbstractMesh[];
  10061. private _excludedMeshes;
  10062. /**
  10063. * Gets the meshes not impacted by this light.
  10064. */
  10065. /**
  10066. * Sets the meshes not impacted by this light.
  10067. */
  10068. excludedMeshes: AbstractMesh[];
  10069. private _excludeWithLayerMask;
  10070. /**
  10071. * Gets the layer id use to find what meshes are not impacted by the light.
  10072. * Inactive if 0
  10073. */
  10074. /**
  10075. * Sets the layer id use to find what meshes are not impacted by the light.
  10076. * Inactive if 0
  10077. */
  10078. excludeWithLayerMask: number;
  10079. private _includeOnlyWithLayerMask;
  10080. /**
  10081. * Gets the layer id use to find what meshes are impacted by the light.
  10082. * Inactive if 0
  10083. */
  10084. /**
  10085. * Sets the layer id use to find what meshes are impacted by the light.
  10086. * Inactive if 0
  10087. */
  10088. includeOnlyWithLayerMask: number;
  10089. private _lightmapMode;
  10090. /**
  10091. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10092. */
  10093. /**
  10094. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10095. */
  10096. lightmapMode: number;
  10097. /**
  10098. * Shadow generator associted to the light.
  10099. * @hidden Internal use only.
  10100. */
  10101. _shadowGenerator: Nullable<IShadowGenerator>;
  10102. /**
  10103. * @hidden Internal use only.
  10104. */
  10105. _excludedMeshesIds: string[];
  10106. /**
  10107. * @hidden Internal use only.
  10108. */
  10109. _includedOnlyMeshesIds: string[];
  10110. /**
  10111. * The current light unifom buffer.
  10112. * @hidden Internal use only.
  10113. */
  10114. _uniformBuffer: UniformBuffer;
  10115. /**
  10116. * Creates a Light object in the scene.
  10117. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10118. * @param name The firendly name of the light
  10119. * @param scene The scene the light belongs too
  10120. */
  10121. constructor(name: string, scene: Scene);
  10122. protected abstract _buildUniformLayout(): void;
  10123. /**
  10124. * Sets the passed Effect "effect" with the Light information.
  10125. * @param effect The effect to update
  10126. * @param lightIndex The index of the light in the effect to update
  10127. * @returns The light
  10128. */
  10129. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10130. /**
  10131. * Sets the passed Effect "effect" with the Light information.
  10132. * @param effect The effect to update
  10133. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10134. * @returns The light
  10135. */
  10136. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10137. /**
  10138. * Returns the string "Light".
  10139. * @returns the class name
  10140. */
  10141. getClassName(): string;
  10142. /** @hidden */
  10143. readonly _isLight: boolean;
  10144. /**
  10145. * Converts the light information to a readable string for debug purpose.
  10146. * @param fullDetails Supports for multiple levels of logging within scene loading
  10147. * @returns the human readable light info
  10148. */
  10149. toString(fullDetails?: boolean): string;
  10150. /** @hidden */
  10151. protected _syncParentEnabledState(): void;
  10152. /**
  10153. * Set the enabled state of this node.
  10154. * @param value - the new enabled state
  10155. */
  10156. setEnabled(value: boolean): void;
  10157. /**
  10158. * Returns the Light associated shadow generator if any.
  10159. * @return the associated shadow generator.
  10160. */
  10161. getShadowGenerator(): Nullable<IShadowGenerator>;
  10162. /**
  10163. * Returns a Vector3, the absolute light position in the World.
  10164. * @returns the world space position of the light
  10165. */
  10166. getAbsolutePosition(): Vector3;
  10167. /**
  10168. * Specifies if the light will affect the passed mesh.
  10169. * @param mesh The mesh to test against the light
  10170. * @return true the mesh is affected otherwise, false.
  10171. */
  10172. canAffectMesh(mesh: AbstractMesh): boolean;
  10173. /**
  10174. * Sort function to order lights for rendering.
  10175. * @param a First Light object to compare to second.
  10176. * @param b Second Light object to compare first.
  10177. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10178. */
  10179. static CompareLightsPriority(a: Light, b: Light): number;
  10180. /**
  10181. * Releases resources associated with this node.
  10182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10184. */
  10185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10186. /**
  10187. * Returns the light type ID (integer).
  10188. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10189. */
  10190. getTypeID(): number;
  10191. /**
  10192. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10193. * @returns the scaled intensity in intensity mode unit
  10194. */
  10195. getScaledIntensity(): number;
  10196. /**
  10197. * Returns a new Light object, named "name", from the current one.
  10198. * @param name The name of the cloned light
  10199. * @returns the new created light
  10200. */
  10201. clone(name: string): Nullable<Light>;
  10202. /**
  10203. * Serializes the current light into a Serialization object.
  10204. * @returns the serialized object.
  10205. */
  10206. serialize(): any;
  10207. /**
  10208. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10209. * This new light is named "name" and added to the passed scene.
  10210. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10211. * @param name The friendly name of the light
  10212. * @param scene The scene the new light will belong to
  10213. * @returns the constructor function
  10214. */
  10215. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10216. /**
  10217. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10218. * @param parsedLight The JSON representation of the light
  10219. * @param scene The scene to create the parsed light in
  10220. * @returns the created light after parsing
  10221. */
  10222. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10223. private _hookArrayForExcluded;
  10224. private _hookArrayForIncludedOnly;
  10225. private _resyncMeshes;
  10226. /**
  10227. * Forces the meshes to update their light related information in their rendering used effects
  10228. * @hidden Internal Use Only
  10229. */
  10230. _markMeshesAsLightDirty(): void;
  10231. /**
  10232. * Recomputes the cached photometric scale if needed.
  10233. */
  10234. private _computePhotometricScale;
  10235. /**
  10236. * Returns the Photometric Scale according to the light type and intensity mode.
  10237. */
  10238. private _getPhotometricScale;
  10239. /**
  10240. * Reorder the light in the scene according to their defined priority.
  10241. * @hidden Internal Use Only
  10242. */
  10243. _reorderLightsInScene(): void;
  10244. /**
  10245. * Prepares the list of defines specific to the light type.
  10246. * @param defines the list of defines
  10247. * @param lightIndex defines the index of the light for the effect
  10248. */
  10249. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Actions/action" {
  10253. import { Observable } from "babylonjs/Misc/observable";
  10254. import { Condition } from "babylonjs/Actions/condition";
  10255. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10256. import { ActionManager } from "babylonjs/Actions/actionManager";
  10257. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10258. /**
  10259. * Interface used to define Action
  10260. */
  10261. export interface IAction {
  10262. /**
  10263. * Trigger for the action
  10264. */
  10265. trigger: number;
  10266. /** Options of the trigger */
  10267. triggerOptions: any;
  10268. /**
  10269. * Gets the trigger parameters
  10270. * @returns the trigger parameters
  10271. */
  10272. getTriggerParameter(): any;
  10273. /**
  10274. * Internal only - executes current action event
  10275. * @hidden
  10276. */
  10277. _executeCurrent(evt?: ActionEvent): void;
  10278. /**
  10279. * Serialize placeholder for child classes
  10280. * @param parent of child
  10281. * @returns the serialized object
  10282. */
  10283. serialize(parent: any): any;
  10284. /**
  10285. * Internal only
  10286. * @hidden
  10287. */
  10288. _prepare(): void;
  10289. /**
  10290. * Internal only - manager for action
  10291. * @hidden
  10292. */
  10293. _actionManager: AbstractActionManager;
  10294. /**
  10295. * Adds action to chain of actions, may be a DoNothingAction
  10296. * @param action defines the next action to execute
  10297. * @returns The action passed in
  10298. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10299. */
  10300. then(action: IAction): IAction;
  10301. }
  10302. /**
  10303. * The action to be carried out following a trigger
  10304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10305. */
  10306. export class Action implements IAction {
  10307. /** the trigger, with or without parameters, for the action */
  10308. triggerOptions: any;
  10309. /**
  10310. * Trigger for the action
  10311. */
  10312. trigger: number;
  10313. /**
  10314. * Internal only - manager for action
  10315. * @hidden
  10316. */
  10317. _actionManager: ActionManager;
  10318. private _nextActiveAction;
  10319. private _child;
  10320. private _condition?;
  10321. private _triggerParameter;
  10322. /**
  10323. * An event triggered prior to action being executed.
  10324. */
  10325. onBeforeExecuteObservable: Observable<Action>;
  10326. /**
  10327. * Creates a new Action
  10328. * @param triggerOptions the trigger, with or without parameters, for the action
  10329. * @param condition an optional determinant of action
  10330. */
  10331. constructor(
  10332. /** the trigger, with or without parameters, for the action */
  10333. triggerOptions: any, condition?: Condition);
  10334. /**
  10335. * Internal only
  10336. * @hidden
  10337. */
  10338. _prepare(): void;
  10339. /**
  10340. * Gets the trigger parameters
  10341. * @returns the trigger parameters
  10342. */
  10343. getTriggerParameter(): any;
  10344. /**
  10345. * Internal only - executes current action event
  10346. * @hidden
  10347. */
  10348. _executeCurrent(evt?: ActionEvent): void;
  10349. /**
  10350. * Execute placeholder for child classes
  10351. * @param evt optional action event
  10352. */
  10353. execute(evt?: ActionEvent): void;
  10354. /**
  10355. * Skips to next active action
  10356. */
  10357. skipToNextActiveAction(): void;
  10358. /**
  10359. * Adds action to chain of actions, may be a DoNothingAction
  10360. * @param action defines the next action to execute
  10361. * @returns The action passed in
  10362. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10363. */
  10364. then(action: Action): Action;
  10365. /**
  10366. * Internal only
  10367. * @hidden
  10368. */
  10369. _getProperty(propertyPath: string): string;
  10370. /**
  10371. * Internal only
  10372. * @hidden
  10373. */
  10374. _getEffectiveTarget(target: any, propertyPath: string): any;
  10375. /**
  10376. * Serialize placeholder for child classes
  10377. * @param parent of child
  10378. * @returns the serialized object
  10379. */
  10380. serialize(parent: any): any;
  10381. /**
  10382. * Internal only called by serialize
  10383. * @hidden
  10384. */
  10385. protected _serialize(serializedAction: any, parent?: any): any;
  10386. /**
  10387. * Internal only
  10388. * @hidden
  10389. */
  10390. static _SerializeValueAsString: (value: any) => string;
  10391. /**
  10392. * Internal only
  10393. * @hidden
  10394. */
  10395. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10396. name: string;
  10397. targetType: string;
  10398. value: string;
  10399. };
  10400. }
  10401. }
  10402. declare module "babylonjs/Actions/condition" {
  10403. import { ActionManager } from "babylonjs/Actions/actionManager";
  10404. /**
  10405. * A Condition applied to an Action
  10406. */
  10407. export class Condition {
  10408. /**
  10409. * Internal only - manager for action
  10410. * @hidden
  10411. */
  10412. _actionManager: ActionManager;
  10413. /**
  10414. * Internal only
  10415. * @hidden
  10416. */
  10417. _evaluationId: number;
  10418. /**
  10419. * Internal only
  10420. * @hidden
  10421. */
  10422. _currentResult: boolean;
  10423. /**
  10424. * Creates a new Condition
  10425. * @param actionManager the manager of the action the condition is applied to
  10426. */
  10427. constructor(actionManager: ActionManager);
  10428. /**
  10429. * Check if the current condition is valid
  10430. * @returns a boolean
  10431. */
  10432. isValid(): boolean;
  10433. /**
  10434. * Internal only
  10435. * @hidden
  10436. */
  10437. _getProperty(propertyPath: string): string;
  10438. /**
  10439. * Internal only
  10440. * @hidden
  10441. */
  10442. _getEffectiveTarget(target: any, propertyPath: string): any;
  10443. /**
  10444. * Serialize placeholder for child classes
  10445. * @returns the serialized object
  10446. */
  10447. serialize(): any;
  10448. /**
  10449. * Internal only
  10450. * @hidden
  10451. */
  10452. protected _serialize(serializedCondition: any): any;
  10453. }
  10454. /**
  10455. * Defines specific conditional operators as extensions of Condition
  10456. */
  10457. export class ValueCondition extends Condition {
  10458. /** path to specify the property of the target the conditional operator uses */
  10459. propertyPath: string;
  10460. /** the value compared by the conditional operator against the current value of the property */
  10461. value: any;
  10462. /** the conditional operator, default ValueCondition.IsEqual */
  10463. operator: number;
  10464. /**
  10465. * Internal only
  10466. * @hidden
  10467. */
  10468. private static _IsEqual;
  10469. /**
  10470. * Internal only
  10471. * @hidden
  10472. */
  10473. private static _IsDifferent;
  10474. /**
  10475. * Internal only
  10476. * @hidden
  10477. */
  10478. private static _IsGreater;
  10479. /**
  10480. * Internal only
  10481. * @hidden
  10482. */
  10483. private static _IsLesser;
  10484. /**
  10485. * returns the number for IsEqual
  10486. */
  10487. static readonly IsEqual: number;
  10488. /**
  10489. * Returns the number for IsDifferent
  10490. */
  10491. static readonly IsDifferent: number;
  10492. /**
  10493. * Returns the number for IsGreater
  10494. */
  10495. static readonly IsGreater: number;
  10496. /**
  10497. * Returns the number for IsLesser
  10498. */
  10499. static readonly IsLesser: number;
  10500. /**
  10501. * Internal only The action manager for the condition
  10502. * @hidden
  10503. */
  10504. _actionManager: ActionManager;
  10505. /**
  10506. * Internal only
  10507. * @hidden
  10508. */
  10509. private _target;
  10510. /**
  10511. * Internal only
  10512. * @hidden
  10513. */
  10514. private _effectiveTarget;
  10515. /**
  10516. * Internal only
  10517. * @hidden
  10518. */
  10519. private _property;
  10520. /**
  10521. * Creates a new ValueCondition
  10522. * @param actionManager manager for the action the condition applies to
  10523. * @param target for the action
  10524. * @param propertyPath path to specify the property of the target the conditional operator uses
  10525. * @param value the value compared by the conditional operator against the current value of the property
  10526. * @param operator the conditional operator, default ValueCondition.IsEqual
  10527. */
  10528. constructor(actionManager: ActionManager, target: any,
  10529. /** path to specify the property of the target the conditional operator uses */
  10530. propertyPath: string,
  10531. /** the value compared by the conditional operator against the current value of the property */
  10532. value: any,
  10533. /** the conditional operator, default ValueCondition.IsEqual */
  10534. operator?: number);
  10535. /**
  10536. * Compares the given value with the property value for the specified conditional operator
  10537. * @returns the result of the comparison
  10538. */
  10539. isValid(): boolean;
  10540. /**
  10541. * Serialize the ValueCondition into a JSON compatible object
  10542. * @returns serialization object
  10543. */
  10544. serialize(): any;
  10545. /**
  10546. * Gets the name of the conditional operator for the ValueCondition
  10547. * @param operator the conditional operator
  10548. * @returns the name
  10549. */
  10550. static GetOperatorName(operator: number): string;
  10551. }
  10552. /**
  10553. * Defines a predicate condition as an extension of Condition
  10554. */
  10555. export class PredicateCondition extends Condition {
  10556. /** defines the predicate function used to validate the condition */
  10557. predicate: () => boolean;
  10558. /**
  10559. * Internal only - manager for action
  10560. * @hidden
  10561. */
  10562. _actionManager: ActionManager;
  10563. /**
  10564. * Creates a new PredicateCondition
  10565. * @param actionManager manager for the action the condition applies to
  10566. * @param predicate defines the predicate function used to validate the condition
  10567. */
  10568. constructor(actionManager: ActionManager,
  10569. /** defines the predicate function used to validate the condition */
  10570. predicate: () => boolean);
  10571. /**
  10572. * @returns the validity of the predicate condition
  10573. */
  10574. isValid(): boolean;
  10575. }
  10576. /**
  10577. * Defines a state condition as an extension of Condition
  10578. */
  10579. export class StateCondition extends Condition {
  10580. /** Value to compare with target state */
  10581. value: string;
  10582. /**
  10583. * Internal only - manager for action
  10584. * @hidden
  10585. */
  10586. _actionManager: ActionManager;
  10587. /**
  10588. * Internal only
  10589. * @hidden
  10590. */
  10591. private _target;
  10592. /**
  10593. * Creates a new StateCondition
  10594. * @param actionManager manager for the action the condition applies to
  10595. * @param target of the condition
  10596. * @param value to compare with target state
  10597. */
  10598. constructor(actionManager: ActionManager, target: any,
  10599. /** Value to compare with target state */
  10600. value: string);
  10601. /**
  10602. * Gets a boolean indicating if the current condition is met
  10603. * @returns the validity of the state
  10604. */
  10605. isValid(): boolean;
  10606. /**
  10607. * Serialize the StateCondition into a JSON compatible object
  10608. * @returns serialization object
  10609. */
  10610. serialize(): any;
  10611. }
  10612. }
  10613. declare module "babylonjs/Actions/directActions" {
  10614. import { Action } from "babylonjs/Actions/action";
  10615. import { Condition } from "babylonjs/Actions/condition";
  10616. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10617. /**
  10618. * This defines an action responsible to toggle a boolean once triggered.
  10619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10620. */
  10621. export class SwitchBooleanAction extends Action {
  10622. /**
  10623. * The path to the boolean property in the target object
  10624. */
  10625. propertyPath: string;
  10626. private _target;
  10627. private _effectiveTarget;
  10628. private _property;
  10629. /**
  10630. * Instantiate the action
  10631. * @param triggerOptions defines the trigger options
  10632. * @param target defines the object containing the boolean
  10633. * @param propertyPath defines the path to the boolean property in the target object
  10634. * @param condition defines the trigger related conditions
  10635. */
  10636. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10637. /** @hidden */
  10638. _prepare(): void;
  10639. /**
  10640. * Execute the action toggle the boolean value.
  10641. */
  10642. execute(): void;
  10643. /**
  10644. * Serializes the actions and its related information.
  10645. * @param parent defines the object to serialize in
  10646. * @returns the serialized object
  10647. */
  10648. serialize(parent: any): any;
  10649. }
  10650. /**
  10651. * This defines an action responsible to set a the state field of the target
  10652. * to a desired value once triggered.
  10653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10654. */
  10655. export class SetStateAction extends Action {
  10656. /**
  10657. * The value to store in the state field.
  10658. */
  10659. value: string;
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the object containing the state property
  10665. * @param value defines the value to store in the state field
  10666. * @param condition defines the trigger related conditions
  10667. */
  10668. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10669. /**
  10670. * Execute the action and store the value on the target state property.
  10671. */
  10672. execute(): void;
  10673. /**
  10674. * Serializes the actions and its related information.
  10675. * @param parent defines the object to serialize in
  10676. * @returns the serialized object
  10677. */
  10678. serialize(parent: any): any;
  10679. }
  10680. /**
  10681. * This defines an action responsible to set a property of the target
  10682. * to a desired value once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class SetValueAction extends Action {
  10686. /**
  10687. * The path of the property to set in the target.
  10688. */
  10689. propertyPath: string;
  10690. /**
  10691. * The value to set in the property
  10692. */
  10693. value: any;
  10694. private _target;
  10695. private _effectiveTarget;
  10696. private _property;
  10697. /**
  10698. * Instantiate the action
  10699. * @param triggerOptions defines the trigger options
  10700. * @param target defines the object containing the property
  10701. * @param propertyPath defines the path of the property to set in the target
  10702. * @param value defines the value to set in the property
  10703. * @param condition defines the trigger related conditions
  10704. */
  10705. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10706. /** @hidden */
  10707. _prepare(): void;
  10708. /**
  10709. * Execute the action and set the targetted property to the desired value.
  10710. */
  10711. execute(): void;
  10712. /**
  10713. * Serializes the actions and its related information.
  10714. * @param parent defines the object to serialize in
  10715. * @returns the serialized object
  10716. */
  10717. serialize(parent: any): any;
  10718. }
  10719. /**
  10720. * This defines an action responsible to increment the target value
  10721. * to a desired value once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class IncrementValueAction extends Action {
  10725. /**
  10726. * The path of the property to increment in the target.
  10727. */
  10728. propertyPath: string;
  10729. /**
  10730. * The value we should increment the property by.
  10731. */
  10732. value: any;
  10733. private _target;
  10734. private _effectiveTarget;
  10735. private _property;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the object containing the property
  10740. * @param propertyPath defines the path of the property to increment in the target
  10741. * @param value defines the value value we should increment the property by
  10742. * @param condition defines the trigger related conditions
  10743. */
  10744. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10745. /** @hidden */
  10746. _prepare(): void;
  10747. /**
  10748. * Execute the action and increment the target of the value amount.
  10749. */
  10750. execute(): void;
  10751. /**
  10752. * Serializes the actions and its related information.
  10753. * @param parent defines the object to serialize in
  10754. * @returns the serialized object
  10755. */
  10756. serialize(parent: any): any;
  10757. }
  10758. /**
  10759. * This defines an action responsible to start an animation once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class PlayAnimationAction extends Action {
  10763. /**
  10764. * Where the animation should start (animation frame)
  10765. */
  10766. from: number;
  10767. /**
  10768. * Where the animation should stop (animation frame)
  10769. */
  10770. to: number;
  10771. /**
  10772. * Define if the animation should loop or stop after the first play.
  10773. */
  10774. loop?: boolean;
  10775. private _target;
  10776. /**
  10777. * Instantiate the action
  10778. * @param triggerOptions defines the trigger options
  10779. * @param target defines the target animation or animation name
  10780. * @param from defines from where the animation should start (animation frame)
  10781. * @param end defines where the animation should stop (animation frame)
  10782. * @param loop defines if the animation should loop or stop after the first play
  10783. * @param condition defines the trigger related conditions
  10784. */
  10785. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10786. /** @hidden */
  10787. _prepare(): void;
  10788. /**
  10789. * Execute the action and play the animation.
  10790. */
  10791. execute(): void;
  10792. /**
  10793. * Serializes the actions and its related information.
  10794. * @param parent defines the object to serialize in
  10795. * @returns the serialized object
  10796. */
  10797. serialize(parent: any): any;
  10798. }
  10799. /**
  10800. * This defines an action responsible to stop an animation once triggered.
  10801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10802. */
  10803. export class StopAnimationAction extends Action {
  10804. private _target;
  10805. /**
  10806. * Instantiate the action
  10807. * @param triggerOptions defines the trigger options
  10808. * @param target defines the target animation or animation name
  10809. * @param condition defines the trigger related conditions
  10810. */
  10811. constructor(triggerOptions: any, target: any, condition?: Condition);
  10812. /** @hidden */
  10813. _prepare(): void;
  10814. /**
  10815. * Execute the action and stop the animation.
  10816. */
  10817. execute(): void;
  10818. /**
  10819. * Serializes the actions and its related information.
  10820. * @param parent defines the object to serialize in
  10821. * @returns the serialized object
  10822. */
  10823. serialize(parent: any): any;
  10824. }
  10825. /**
  10826. * This defines an action responsible that does nothing once triggered.
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10828. */
  10829. export class DoNothingAction extends Action {
  10830. /**
  10831. * Instantiate the action
  10832. * @param triggerOptions defines the trigger options
  10833. * @param condition defines the trigger related conditions
  10834. */
  10835. constructor(triggerOptions?: any, condition?: Condition);
  10836. /**
  10837. * Execute the action and do nothing.
  10838. */
  10839. execute(): void;
  10840. /**
  10841. * Serializes the actions and its related information.
  10842. * @param parent defines the object to serialize in
  10843. * @returns the serialized object
  10844. */
  10845. serialize(parent: any): any;
  10846. }
  10847. /**
  10848. * This defines an action responsible to trigger several actions once triggered.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class CombineAction extends Action {
  10852. /**
  10853. * The list of aggregated animations to run.
  10854. */
  10855. children: Action[];
  10856. /**
  10857. * Instantiate the action
  10858. * @param triggerOptions defines the trigger options
  10859. * @param children defines the list of aggregated animations to run
  10860. * @param condition defines the trigger related conditions
  10861. */
  10862. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10863. /** @hidden */
  10864. _prepare(): void;
  10865. /**
  10866. * Execute the action and executes all the aggregated actions.
  10867. */
  10868. execute(evt: ActionEvent): void;
  10869. /**
  10870. * Serializes the actions and its related information.
  10871. * @param parent defines the object to serialize in
  10872. * @returns the serialized object
  10873. */
  10874. serialize(parent: any): any;
  10875. }
  10876. /**
  10877. * This defines an action responsible to run code (external event) once triggered.
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10879. */
  10880. export class ExecuteCodeAction extends Action {
  10881. /**
  10882. * The callback function to run.
  10883. */
  10884. func: (evt: ActionEvent) => void;
  10885. /**
  10886. * Instantiate the action
  10887. * @param triggerOptions defines the trigger options
  10888. * @param func defines the callback function to run
  10889. * @param condition defines the trigger related conditions
  10890. */
  10891. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10892. /**
  10893. * Execute the action and run the attached code.
  10894. */
  10895. execute(evt: ActionEvent): void;
  10896. }
  10897. /**
  10898. * This defines an action responsible to set the parent property of the target once triggered.
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10900. */
  10901. export class SetParentAction extends Action {
  10902. private _parent;
  10903. private _target;
  10904. /**
  10905. * Instantiate the action
  10906. * @param triggerOptions defines the trigger options
  10907. * @param target defines the target containing the parent property
  10908. * @param parent defines from where the animation should start (animation frame)
  10909. * @param condition defines the trigger related conditions
  10910. */
  10911. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10912. /** @hidden */
  10913. _prepare(): void;
  10914. /**
  10915. * Execute the action and set the parent property.
  10916. */
  10917. execute(): void;
  10918. /**
  10919. * Serializes the actions and its related information.
  10920. * @param parent defines the object to serialize in
  10921. * @returns the serialized object
  10922. */
  10923. serialize(parent: any): any;
  10924. }
  10925. }
  10926. declare module "babylonjs/Actions/actionManager" {
  10927. import { Nullable } from "babylonjs/types";
  10928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10929. import { Scene } from "babylonjs/scene";
  10930. import { IAction } from "babylonjs/Actions/action";
  10931. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10932. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10933. /**
  10934. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10935. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10937. */
  10938. export class ActionManager extends AbstractActionManager {
  10939. /**
  10940. * Nothing
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10942. */
  10943. static readonly NothingTrigger: number;
  10944. /**
  10945. * On pick
  10946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10947. */
  10948. static readonly OnPickTrigger: number;
  10949. /**
  10950. * On left pick
  10951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10952. */
  10953. static readonly OnLeftPickTrigger: number;
  10954. /**
  10955. * On right pick
  10956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10957. */
  10958. static readonly OnRightPickTrigger: number;
  10959. /**
  10960. * On center pick
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10962. */
  10963. static readonly OnCenterPickTrigger: number;
  10964. /**
  10965. * On pick down
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10967. */
  10968. static readonly OnPickDownTrigger: number;
  10969. /**
  10970. * On double pick
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10972. */
  10973. static readonly OnDoublePickTrigger: number;
  10974. /**
  10975. * On pick up
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10977. */
  10978. static readonly OnPickUpTrigger: number;
  10979. /**
  10980. * On pick out.
  10981. * This trigger will only be raised if you also declared a OnPickDown
  10982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10983. */
  10984. static readonly OnPickOutTrigger: number;
  10985. /**
  10986. * On long press
  10987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10988. */
  10989. static readonly OnLongPressTrigger: number;
  10990. /**
  10991. * On pointer over
  10992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10993. */
  10994. static readonly OnPointerOverTrigger: number;
  10995. /**
  10996. * On pointer out
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10998. */
  10999. static readonly OnPointerOutTrigger: number;
  11000. /**
  11001. * On every frame
  11002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11003. */
  11004. static readonly OnEveryFrameTrigger: number;
  11005. /**
  11006. * On intersection enter
  11007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11008. */
  11009. static readonly OnIntersectionEnterTrigger: number;
  11010. /**
  11011. * On intersection exit
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11013. */
  11014. static readonly OnIntersectionExitTrigger: number;
  11015. /**
  11016. * On key down
  11017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11018. */
  11019. static readonly OnKeyDownTrigger: number;
  11020. /**
  11021. * On key up
  11022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11023. */
  11024. static readonly OnKeyUpTrigger: number;
  11025. private _scene;
  11026. /**
  11027. * Creates a new action manager
  11028. * @param scene defines the hosting scene
  11029. */
  11030. constructor(scene: Scene);
  11031. /**
  11032. * Releases all associated resources
  11033. */
  11034. dispose(): void;
  11035. /**
  11036. * Gets hosting scene
  11037. * @returns the hosting scene
  11038. */
  11039. getScene(): Scene;
  11040. /**
  11041. * Does this action manager handles actions of any of the given triggers
  11042. * @param triggers defines the triggers to be tested
  11043. * @return a boolean indicating whether one (or more) of the triggers is handled
  11044. */
  11045. hasSpecificTriggers(triggers: number[]): boolean;
  11046. /**
  11047. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11048. * speed.
  11049. * @param triggerA defines the trigger to be tested
  11050. * @param triggerB defines the trigger to be tested
  11051. * @return a boolean indicating whether one (or more) of the triggers is handled
  11052. */
  11053. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11054. /**
  11055. * Does this action manager handles actions of a given trigger
  11056. * @param trigger defines the trigger to be tested
  11057. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11058. * @return whether the trigger is handled
  11059. */
  11060. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11061. /**
  11062. * Does this action manager has pointer triggers
  11063. */
  11064. readonly hasPointerTriggers: boolean;
  11065. /**
  11066. * Does this action manager has pick triggers
  11067. */
  11068. readonly hasPickTriggers: boolean;
  11069. /**
  11070. * Registers an action to this action manager
  11071. * @param action defines the action to be registered
  11072. * @return the action amended (prepared) after registration
  11073. */
  11074. registerAction(action: IAction): Nullable<IAction>;
  11075. /**
  11076. * Unregisters an action to this action manager
  11077. * @param action defines the action to be unregistered
  11078. * @return a boolean indicating whether the action has been unregistered
  11079. */
  11080. unregisterAction(action: IAction): Boolean;
  11081. /**
  11082. * Process a specific trigger
  11083. * @param trigger defines the trigger to process
  11084. * @param evt defines the event details to be processed
  11085. */
  11086. processTrigger(trigger: number, evt?: IActionEvent): void;
  11087. /** @hidden */
  11088. _getEffectiveTarget(target: any, propertyPath: string): any;
  11089. /** @hidden */
  11090. _getProperty(propertyPath: string): string;
  11091. /**
  11092. * Serialize this manager to a JSON object
  11093. * @param name defines the property name to store this manager
  11094. * @returns a JSON representation of this manager
  11095. */
  11096. serialize(name: string): any;
  11097. /**
  11098. * Creates a new ActionManager from a JSON data
  11099. * @param parsedActions defines the JSON data to read from
  11100. * @param object defines the hosting mesh
  11101. * @param scene defines the hosting scene
  11102. */
  11103. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11104. /**
  11105. * Get a trigger name by index
  11106. * @param trigger defines the trigger index
  11107. * @returns a trigger name
  11108. */
  11109. static GetTriggerName(trigger: number): string;
  11110. }
  11111. }
  11112. declare module "babylonjs/Culling/ray" {
  11113. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11114. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11116. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11117. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11118. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11119. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11120. import { Plane } from "babylonjs/Maths/math.plane";
  11121. /**
  11122. * Class representing a ray with position and direction
  11123. */
  11124. export class Ray {
  11125. /** origin point */
  11126. origin: Vector3;
  11127. /** direction */
  11128. direction: Vector3;
  11129. /** length of the ray */
  11130. length: number;
  11131. private static readonly TmpVector3;
  11132. private _tmpRay;
  11133. /**
  11134. * Creates a new ray
  11135. * @param origin origin point
  11136. * @param direction direction
  11137. * @param length length of the ray
  11138. */
  11139. constructor(
  11140. /** origin point */
  11141. origin: Vector3,
  11142. /** direction */
  11143. direction: Vector3,
  11144. /** length of the ray */
  11145. length?: number);
  11146. /**
  11147. * Checks if the ray intersects a box
  11148. * @param minimum bound of the box
  11149. * @param maximum bound of the box
  11150. * @param intersectionTreshold extra extend to be added to the box in all direction
  11151. * @returns if the box was hit
  11152. */
  11153. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11154. /**
  11155. * Checks if the ray intersects a box
  11156. * @param box the bounding box to check
  11157. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11158. * @returns if the box was hit
  11159. */
  11160. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11161. /**
  11162. * If the ray hits a sphere
  11163. * @param sphere the bounding sphere to check
  11164. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11165. * @returns true if it hits the sphere
  11166. */
  11167. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11168. /**
  11169. * If the ray hits a triange
  11170. * @param vertex0 triangle vertex
  11171. * @param vertex1 triangle vertex
  11172. * @param vertex2 triangle vertex
  11173. * @returns intersection information if hit
  11174. */
  11175. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11176. /**
  11177. * Checks if ray intersects a plane
  11178. * @param plane the plane to check
  11179. * @returns the distance away it was hit
  11180. */
  11181. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11182. /**
  11183. * Calculate the intercept of a ray on a given axis
  11184. * @param axis to check 'x' | 'y' | 'z'
  11185. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11186. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11187. */
  11188. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11189. /**
  11190. * Checks if ray intersects a mesh
  11191. * @param mesh the mesh to check
  11192. * @param fastCheck if only the bounding box should checked
  11193. * @returns picking info of the intersecton
  11194. */
  11195. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11196. /**
  11197. * Checks if ray intersects a mesh
  11198. * @param meshes the meshes to check
  11199. * @param fastCheck if only the bounding box should checked
  11200. * @param results array to store result in
  11201. * @returns Array of picking infos
  11202. */
  11203. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11204. private _comparePickingInfo;
  11205. private static smallnum;
  11206. private static rayl;
  11207. /**
  11208. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11209. * @param sega the first point of the segment to test the intersection against
  11210. * @param segb the second point of the segment to test the intersection against
  11211. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11212. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11213. */
  11214. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11215. /**
  11216. * Update the ray from viewport position
  11217. * @param x position
  11218. * @param y y position
  11219. * @param viewportWidth viewport width
  11220. * @param viewportHeight viewport height
  11221. * @param world world matrix
  11222. * @param view view matrix
  11223. * @param projection projection matrix
  11224. * @returns this ray updated
  11225. */
  11226. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11227. /**
  11228. * Creates a ray with origin and direction of 0,0,0
  11229. * @returns the new ray
  11230. */
  11231. static Zero(): Ray;
  11232. /**
  11233. * Creates a new ray from screen space and viewport
  11234. * @param x position
  11235. * @param y y position
  11236. * @param viewportWidth viewport width
  11237. * @param viewportHeight viewport height
  11238. * @param world world matrix
  11239. * @param view view matrix
  11240. * @param projection projection matrix
  11241. * @returns new ray
  11242. */
  11243. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11244. /**
  11245. * 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
  11246. * transformed to the given world matrix.
  11247. * @param origin The origin point
  11248. * @param end The end point
  11249. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11250. * @returns the new ray
  11251. */
  11252. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11253. /**
  11254. * Transforms a ray by a matrix
  11255. * @param ray ray to transform
  11256. * @param matrix matrix to apply
  11257. * @returns the resulting new ray
  11258. */
  11259. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11260. /**
  11261. * Transforms a ray by a matrix
  11262. * @param ray ray to transform
  11263. * @param matrix matrix to apply
  11264. * @param result ray to store result in
  11265. */
  11266. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11267. /**
  11268. * Unproject a ray from screen space to object space
  11269. * @param sourceX defines the screen space x coordinate to use
  11270. * @param sourceY defines the screen space y coordinate to use
  11271. * @param viewportWidth defines the current width of the viewport
  11272. * @param viewportHeight defines the current height of the viewport
  11273. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11274. * @param view defines the view matrix to use
  11275. * @param projection defines the projection matrix to use
  11276. */
  11277. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11278. }
  11279. /**
  11280. * Type used to define predicate used to select faces when a mesh intersection is detected
  11281. */
  11282. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11283. module "babylonjs/scene" {
  11284. interface Scene {
  11285. /** @hidden */
  11286. _tempPickingRay: Nullable<Ray>;
  11287. /** @hidden */
  11288. _cachedRayForTransform: Ray;
  11289. /** @hidden */
  11290. _pickWithRayInverseMatrix: Matrix;
  11291. /** @hidden */
  11292. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11293. /** @hidden */
  11294. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11295. }
  11296. }
  11297. }
  11298. declare module "babylonjs/sceneComponent" {
  11299. import { Scene } from "babylonjs/scene";
  11300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11301. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11302. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11303. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11304. import { Nullable } from "babylonjs/types";
  11305. import { Camera } from "babylonjs/Cameras/camera";
  11306. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11307. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11308. import { AbstractScene } from "babylonjs/abstractScene";
  11309. /**
  11310. * Groups all the scene component constants in one place to ease maintenance.
  11311. * @hidden
  11312. */
  11313. export class SceneComponentConstants {
  11314. static readonly NAME_EFFECTLAYER: string;
  11315. static readonly NAME_LAYER: string;
  11316. static readonly NAME_LENSFLARESYSTEM: string;
  11317. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11318. static readonly NAME_PARTICLESYSTEM: string;
  11319. static readonly NAME_GAMEPAD: string;
  11320. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11321. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11322. static readonly NAME_DEPTHRENDERER: string;
  11323. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11324. static readonly NAME_SPRITE: string;
  11325. static readonly NAME_OUTLINERENDERER: string;
  11326. static readonly NAME_PROCEDURALTEXTURE: string;
  11327. static readonly NAME_SHADOWGENERATOR: string;
  11328. static readonly NAME_OCTREE: string;
  11329. static readonly NAME_PHYSICSENGINE: string;
  11330. static readonly NAME_AUDIO: string;
  11331. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11332. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11333. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11334. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11335. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11336. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11337. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11338. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11339. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11340. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11341. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11342. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11343. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11344. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11345. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11346. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11347. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11348. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11349. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11350. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11351. static readonly STEP_AFTERRENDER_AUDIO: number;
  11352. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11353. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11354. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11355. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11356. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11357. static readonly STEP_POINTERMOVE_SPRITE: number;
  11358. static readonly STEP_POINTERDOWN_SPRITE: number;
  11359. static readonly STEP_POINTERUP_SPRITE: number;
  11360. }
  11361. /**
  11362. * This represents a scene component.
  11363. *
  11364. * This is used to decouple the dependency the scene is having on the different workloads like
  11365. * layers, post processes...
  11366. */
  11367. export interface ISceneComponent {
  11368. /**
  11369. * The name of the component. Each component must have a unique name.
  11370. */
  11371. name: string;
  11372. /**
  11373. * The scene the component belongs to.
  11374. */
  11375. scene: Scene;
  11376. /**
  11377. * Register the component to one instance of a scene.
  11378. */
  11379. register(): void;
  11380. /**
  11381. * Rebuilds the elements related to this component in case of
  11382. * context lost for instance.
  11383. */
  11384. rebuild(): void;
  11385. /**
  11386. * Disposes the component and the associated ressources.
  11387. */
  11388. dispose(): void;
  11389. }
  11390. /**
  11391. * This represents a SERIALIZABLE scene component.
  11392. *
  11393. * This extends Scene Component to add Serialization methods on top.
  11394. */
  11395. export interface ISceneSerializableComponent extends ISceneComponent {
  11396. /**
  11397. * Adds all the elements from the container to the scene
  11398. * @param container the container holding the elements
  11399. */
  11400. addFromContainer(container: AbstractScene): void;
  11401. /**
  11402. * Removes all the elements in the container from the scene
  11403. * @param container contains the elements to remove
  11404. * @param dispose if the removed element should be disposed (default: false)
  11405. */
  11406. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11407. /**
  11408. * Serializes the component data to the specified json object
  11409. * @param serializationObject The object to serialize to
  11410. */
  11411. serialize(serializationObject: any): void;
  11412. }
  11413. /**
  11414. * Strong typing of a Mesh related stage step action
  11415. */
  11416. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11417. /**
  11418. * Strong typing of a Evaluate Sub Mesh related stage step action
  11419. */
  11420. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11421. /**
  11422. * Strong typing of a Active Mesh related stage step action
  11423. */
  11424. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11425. /**
  11426. * Strong typing of a Camera related stage step action
  11427. */
  11428. export type CameraStageAction = (camera: Camera) => void;
  11429. /**
  11430. * Strong typing of a Camera Frame buffer related stage step action
  11431. */
  11432. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11433. /**
  11434. * Strong typing of a Render Target related stage step action
  11435. */
  11436. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11437. /**
  11438. * Strong typing of a RenderingGroup related stage step action
  11439. */
  11440. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11441. /**
  11442. * Strong typing of a Mesh Render related stage step action
  11443. */
  11444. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11445. /**
  11446. * Strong typing of a simple stage step action
  11447. */
  11448. export type SimpleStageAction = () => void;
  11449. /**
  11450. * Strong typing of a render target action.
  11451. */
  11452. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11453. /**
  11454. * Strong typing of a pointer move action.
  11455. */
  11456. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11457. /**
  11458. * Strong typing of a pointer up/down action.
  11459. */
  11460. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11461. /**
  11462. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11463. * @hidden
  11464. */
  11465. export class Stage<T extends Function> extends Array<{
  11466. index: number;
  11467. component: ISceneComponent;
  11468. action: T;
  11469. }> {
  11470. /**
  11471. * Hide ctor from the rest of the world.
  11472. * @param items The items to add.
  11473. */
  11474. private constructor();
  11475. /**
  11476. * Creates a new Stage.
  11477. * @returns A new instance of a Stage
  11478. */
  11479. static Create<T extends Function>(): Stage<T>;
  11480. /**
  11481. * Registers a step in an ordered way in the targeted stage.
  11482. * @param index Defines the position to register the step in
  11483. * @param component Defines the component attached to the step
  11484. * @param action Defines the action to launch during the step
  11485. */
  11486. registerStep(index: number, component: ISceneComponent, action: T): void;
  11487. /**
  11488. * Clears all the steps from the stage.
  11489. */
  11490. clear(): void;
  11491. }
  11492. }
  11493. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11494. import { Nullable } from "babylonjs/types";
  11495. import { Observable } from "babylonjs/Misc/observable";
  11496. import { Scene } from "babylonjs/scene";
  11497. import { Sprite } from "babylonjs/Sprites/sprite";
  11498. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11499. import { Ray } from "babylonjs/Culling/ray";
  11500. import { Camera } from "babylonjs/Cameras/camera";
  11501. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11502. import { ISceneComponent } from "babylonjs/sceneComponent";
  11503. module "babylonjs/scene" {
  11504. interface Scene {
  11505. /** @hidden */
  11506. _pointerOverSprite: Nullable<Sprite>;
  11507. /** @hidden */
  11508. _pickedDownSprite: Nullable<Sprite>;
  11509. /** @hidden */
  11510. _tempSpritePickingRay: Nullable<Ray>;
  11511. /**
  11512. * All of the sprite managers added to this scene
  11513. * @see http://doc.babylonjs.com/babylon101/sprites
  11514. */
  11515. spriteManagers: Array<ISpriteManager>;
  11516. /**
  11517. * An event triggered when sprites rendering is about to start
  11518. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11519. */
  11520. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11521. /**
  11522. * An event triggered when sprites rendering is done
  11523. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11524. */
  11525. onAfterSpritesRenderingObservable: Observable<Scene>;
  11526. /** @hidden */
  11527. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11528. /** Launch a ray to try to pick a sprite in the scene
  11529. * @param x position on screen
  11530. * @param y position on screen
  11531. * @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
  11532. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11533. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11534. * @returns a PickingInfo
  11535. */
  11536. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11537. /** Use the given ray to pick a sprite in the scene
  11538. * @param ray The ray (in world space) to use to pick meshes
  11539. * @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
  11540. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11541. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11542. * @returns a PickingInfo
  11543. */
  11544. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11545. /** @hidden */
  11546. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11547. /** Launch a ray to try to pick sprites in the scene
  11548. * @param x position on screen
  11549. * @param y position on screen
  11550. * @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
  11551. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11552. * @returns a PickingInfo array
  11553. */
  11554. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11555. /** Use the given ray to pick sprites in the scene
  11556. * @param ray The ray (in world space) to use to pick meshes
  11557. * @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
  11558. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11559. * @returns a PickingInfo array
  11560. */
  11561. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11562. /**
  11563. * Force the sprite under the pointer
  11564. * @param sprite defines the sprite to use
  11565. */
  11566. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11567. /**
  11568. * Gets the sprite under the pointer
  11569. * @returns a Sprite or null if no sprite is under the pointer
  11570. */
  11571. getPointerOverSprite(): Nullable<Sprite>;
  11572. }
  11573. }
  11574. /**
  11575. * Defines the sprite scene component responsible to manage sprites
  11576. * in a given scene.
  11577. */
  11578. export class SpriteSceneComponent implements ISceneComponent {
  11579. /**
  11580. * The component name helpfull to identify the component in the list of scene components.
  11581. */
  11582. readonly name: string;
  11583. /**
  11584. * The scene the component belongs to.
  11585. */
  11586. scene: Scene;
  11587. /** @hidden */
  11588. private _spritePredicate;
  11589. /**
  11590. * Creates a new instance of the component for the given scene
  11591. * @param scene Defines the scene to register the component in
  11592. */
  11593. constructor(scene: Scene);
  11594. /**
  11595. * Registers the component in a given scene
  11596. */
  11597. register(): void;
  11598. /**
  11599. * Rebuilds the elements related to this component in case of
  11600. * context lost for instance.
  11601. */
  11602. rebuild(): void;
  11603. /**
  11604. * Disposes the component and the associated ressources.
  11605. */
  11606. dispose(): void;
  11607. private _pickSpriteButKeepRay;
  11608. private _pointerMove;
  11609. private _pointerDown;
  11610. private _pointerUp;
  11611. }
  11612. }
  11613. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11614. /** @hidden */
  11615. export var fogFragmentDeclaration: {
  11616. name: string;
  11617. shader: string;
  11618. };
  11619. }
  11620. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11621. /** @hidden */
  11622. export var fogFragment: {
  11623. name: string;
  11624. shader: string;
  11625. };
  11626. }
  11627. declare module "babylonjs/Shaders/sprites.fragment" {
  11628. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11629. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11630. /** @hidden */
  11631. export var spritesPixelShader: {
  11632. name: string;
  11633. shader: string;
  11634. };
  11635. }
  11636. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11637. /** @hidden */
  11638. export var fogVertexDeclaration: {
  11639. name: string;
  11640. shader: string;
  11641. };
  11642. }
  11643. declare module "babylonjs/Shaders/sprites.vertex" {
  11644. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11645. /** @hidden */
  11646. export var spritesVertexShader: {
  11647. name: string;
  11648. shader: string;
  11649. };
  11650. }
  11651. declare module "babylonjs/Sprites/spriteManager" {
  11652. import { IDisposable, Scene } from "babylonjs/scene";
  11653. import { Nullable } from "babylonjs/types";
  11654. import { Observable } from "babylonjs/Misc/observable";
  11655. import { Sprite } from "babylonjs/Sprites/sprite";
  11656. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11657. import { Camera } from "babylonjs/Cameras/camera";
  11658. import { Texture } from "babylonjs/Materials/Textures/texture";
  11659. import "babylonjs/Shaders/sprites.fragment";
  11660. import "babylonjs/Shaders/sprites.vertex";
  11661. import { Ray } from "babylonjs/Culling/ray";
  11662. /**
  11663. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11664. */
  11665. export interface ISpriteManager extends IDisposable {
  11666. /**
  11667. * Restricts the camera to viewing objects with the same layerMask.
  11668. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11669. */
  11670. layerMask: number;
  11671. /**
  11672. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11673. */
  11674. isPickable: boolean;
  11675. /**
  11676. * Specifies the rendering group id for this mesh (0 by default)
  11677. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11678. */
  11679. renderingGroupId: number;
  11680. /**
  11681. * Defines the list of sprites managed by the manager.
  11682. */
  11683. sprites: Array<Sprite>;
  11684. /**
  11685. * Tests the intersection of a sprite with a specific ray.
  11686. * @param ray The ray we are sending to test the collision
  11687. * @param camera The camera space we are sending rays in
  11688. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11689. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11690. * @returns picking info or null.
  11691. */
  11692. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11693. /**
  11694. * Intersects the sprites with a ray
  11695. * @param ray defines the ray to intersect with
  11696. * @param camera defines the current active camera
  11697. * @param predicate defines a predicate used to select candidate sprites
  11698. * @returns null if no hit or a PickingInfo array
  11699. */
  11700. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11701. /**
  11702. * Renders the list of sprites on screen.
  11703. */
  11704. render(): void;
  11705. }
  11706. /**
  11707. * Class used to manage multiple sprites on the same spritesheet
  11708. * @see http://doc.babylonjs.com/babylon101/sprites
  11709. */
  11710. export class SpriteManager implements ISpriteManager {
  11711. /** defines the manager's name */
  11712. name: string;
  11713. /** Gets the list of sprites */
  11714. sprites: Sprite[];
  11715. /** Gets or sets the rendering group id (0 by default) */
  11716. renderingGroupId: number;
  11717. /** Gets or sets camera layer mask */
  11718. layerMask: number;
  11719. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11720. fogEnabled: boolean;
  11721. /** Gets or sets a boolean indicating if the sprites are pickable */
  11722. isPickable: boolean;
  11723. /** Defines the default width of a cell in the spritesheet */
  11724. cellWidth: number;
  11725. /** Defines the default height of a cell in the spritesheet */
  11726. cellHeight: number;
  11727. /** Associative array from JSON sprite data file */
  11728. private _cellData;
  11729. /** Array of sprite names from JSON sprite data file */
  11730. private _spriteMap;
  11731. /** True when packed cell data from JSON file is ready*/
  11732. private _packedAndReady;
  11733. /**
  11734. * An event triggered when the manager is disposed.
  11735. */
  11736. onDisposeObservable: Observable<SpriteManager>;
  11737. private _onDisposeObserver;
  11738. /**
  11739. * Callback called when the manager is disposed
  11740. */
  11741. onDispose: () => void;
  11742. private _capacity;
  11743. private _fromPacked;
  11744. private _spriteTexture;
  11745. private _epsilon;
  11746. private _scene;
  11747. private _vertexData;
  11748. private _buffer;
  11749. private _vertexBuffers;
  11750. private _indexBuffer;
  11751. private _effectBase;
  11752. private _effectFog;
  11753. /**
  11754. * Gets or sets the spritesheet texture
  11755. */
  11756. texture: Texture;
  11757. /**
  11758. * Creates a new sprite manager
  11759. * @param name defines the manager's name
  11760. * @param imgUrl defines the sprite sheet url
  11761. * @param capacity defines the maximum allowed number of sprites
  11762. * @param cellSize defines the size of a sprite cell
  11763. * @param scene defines the hosting scene
  11764. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11765. * @param samplingMode defines the smapling mode to use with spritesheet
  11766. * @param fromPacked set to false; do not alter
  11767. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11768. */
  11769. constructor(
  11770. /** defines the manager's name */
  11771. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11772. private _makePacked;
  11773. private _appendSpriteVertex;
  11774. /**
  11775. * Intersects the sprites with a ray
  11776. * @param ray defines the ray to intersect with
  11777. * @param camera defines the current active camera
  11778. * @param predicate defines a predicate used to select candidate sprites
  11779. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11780. * @returns null if no hit or a PickingInfo
  11781. */
  11782. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11783. /**
  11784. * Intersects the sprites with a ray
  11785. * @param ray defines the ray to intersect with
  11786. * @param camera defines the current active camera
  11787. * @param predicate defines a predicate used to select candidate sprites
  11788. * @returns null if no hit or a PickingInfo array
  11789. */
  11790. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11791. /**
  11792. * Render all child sprites
  11793. */
  11794. render(): void;
  11795. /**
  11796. * Release associated resources
  11797. */
  11798. dispose(): void;
  11799. }
  11800. }
  11801. declare module "babylonjs/Sprites/sprite" {
  11802. import { Vector3 } from "babylonjs/Maths/math.vector";
  11803. import { Nullable } from "babylonjs/types";
  11804. import { ActionManager } from "babylonjs/Actions/actionManager";
  11805. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11806. import { Color4 } from "babylonjs/Maths/math.color";
  11807. /**
  11808. * Class used to represent a sprite
  11809. * @see http://doc.babylonjs.com/babylon101/sprites
  11810. */
  11811. export class Sprite {
  11812. /** defines the name */
  11813. name: string;
  11814. /** Gets or sets the current world position */
  11815. position: Vector3;
  11816. /** Gets or sets the main color */
  11817. color: Color4;
  11818. /** Gets or sets the width */
  11819. width: number;
  11820. /** Gets or sets the height */
  11821. height: number;
  11822. /** Gets or sets rotation angle */
  11823. angle: number;
  11824. /** Gets or sets the cell index in the sprite sheet */
  11825. cellIndex: number;
  11826. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11827. cellRef: string;
  11828. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11829. invertU: number;
  11830. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11831. invertV: number;
  11832. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11833. disposeWhenFinishedAnimating: boolean;
  11834. /** Gets the list of attached animations */
  11835. animations: Animation[];
  11836. /** Gets or sets a boolean indicating if the sprite can be picked */
  11837. isPickable: boolean;
  11838. /**
  11839. * Gets or sets the associated action manager
  11840. */
  11841. actionManager: Nullable<ActionManager>;
  11842. private _animationStarted;
  11843. private _loopAnimation;
  11844. private _fromIndex;
  11845. private _toIndex;
  11846. private _delay;
  11847. private _direction;
  11848. private _manager;
  11849. private _time;
  11850. private _onAnimationEnd;
  11851. /**
  11852. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11853. */
  11854. isVisible: boolean;
  11855. /**
  11856. * Gets or sets the sprite size
  11857. */
  11858. size: number;
  11859. /**
  11860. * Creates a new Sprite
  11861. * @param name defines the name
  11862. * @param manager defines the manager
  11863. */
  11864. constructor(
  11865. /** defines the name */
  11866. name: string, manager: ISpriteManager);
  11867. /**
  11868. * Starts an animation
  11869. * @param from defines the initial key
  11870. * @param to defines the end key
  11871. * @param loop defines if the animation must loop
  11872. * @param delay defines the start delay (in ms)
  11873. * @param onAnimationEnd defines a callback to call when animation ends
  11874. */
  11875. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11876. /** Stops current animation (if any) */
  11877. stopAnimation(): void;
  11878. /** @hidden */
  11879. _animate(deltaTime: number): void;
  11880. /** Release associated resources */
  11881. dispose(): void;
  11882. }
  11883. }
  11884. declare module "babylonjs/Collisions/pickingInfo" {
  11885. import { Nullable } from "babylonjs/types";
  11886. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11888. import { Sprite } from "babylonjs/Sprites/sprite";
  11889. import { Ray } from "babylonjs/Culling/ray";
  11890. /**
  11891. * Information about the result of picking within a scene
  11892. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11893. */
  11894. export class PickingInfo {
  11895. /** @hidden */
  11896. _pickingUnavailable: boolean;
  11897. /**
  11898. * If the pick collided with an object
  11899. */
  11900. hit: boolean;
  11901. /**
  11902. * Distance away where the pick collided
  11903. */
  11904. distance: number;
  11905. /**
  11906. * The location of pick collision
  11907. */
  11908. pickedPoint: Nullable<Vector3>;
  11909. /**
  11910. * The mesh corresponding the the pick collision
  11911. */
  11912. pickedMesh: Nullable<AbstractMesh>;
  11913. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11914. bu: number;
  11915. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11916. bv: number;
  11917. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11918. faceId: number;
  11919. /** Id of the the submesh that was picked */
  11920. subMeshId: number;
  11921. /** If a sprite was picked, this will be the sprite the pick collided with */
  11922. pickedSprite: Nullable<Sprite>;
  11923. /**
  11924. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11925. */
  11926. originMesh: Nullable<AbstractMesh>;
  11927. /**
  11928. * The ray that was used to perform the picking.
  11929. */
  11930. ray: Nullable<Ray>;
  11931. /**
  11932. * Gets the normal correspodning to the face the pick collided with
  11933. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11934. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11935. * @returns The normal correspodning to the face the pick collided with
  11936. */
  11937. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11938. /**
  11939. * Gets the texture coordinates of where the pick occured
  11940. * @returns the vector containing the coordnates of the texture
  11941. */
  11942. getTextureCoordinates(): Nullable<Vector2>;
  11943. }
  11944. }
  11945. declare module "babylonjs/Events/pointerEvents" {
  11946. import { Nullable } from "babylonjs/types";
  11947. import { Vector2 } from "babylonjs/Maths/math.vector";
  11948. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11949. import { Ray } from "babylonjs/Culling/ray";
  11950. /**
  11951. * Gather the list of pointer event types as constants.
  11952. */
  11953. export class PointerEventTypes {
  11954. /**
  11955. * 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.
  11956. */
  11957. static readonly POINTERDOWN: number;
  11958. /**
  11959. * The pointerup event is fired when a pointer is no longer active.
  11960. */
  11961. static readonly POINTERUP: number;
  11962. /**
  11963. * The pointermove event is fired when a pointer changes coordinates.
  11964. */
  11965. static readonly POINTERMOVE: number;
  11966. /**
  11967. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11968. */
  11969. static readonly POINTERWHEEL: number;
  11970. /**
  11971. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11972. */
  11973. static readonly POINTERPICK: number;
  11974. /**
  11975. * The pointertap event is fired when a the object has been touched and released without drag.
  11976. */
  11977. static readonly POINTERTAP: number;
  11978. /**
  11979. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11980. */
  11981. static readonly POINTERDOUBLETAP: number;
  11982. }
  11983. /**
  11984. * Base class of pointer info types.
  11985. */
  11986. export class PointerInfoBase {
  11987. /**
  11988. * Defines the type of event (PointerEventTypes)
  11989. */
  11990. type: number;
  11991. /**
  11992. * Defines the related dom event
  11993. */
  11994. event: PointerEvent | MouseWheelEvent;
  11995. /**
  11996. * Instantiates the base class of pointers info.
  11997. * @param type Defines the type of event (PointerEventTypes)
  11998. * @param event Defines the related dom event
  11999. */
  12000. constructor(
  12001. /**
  12002. * Defines the type of event (PointerEventTypes)
  12003. */
  12004. type: number,
  12005. /**
  12006. * Defines the related dom event
  12007. */
  12008. event: PointerEvent | MouseWheelEvent);
  12009. }
  12010. /**
  12011. * This class is used to store pointer related info for the onPrePointerObservable event.
  12012. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12013. */
  12014. export class PointerInfoPre extends PointerInfoBase {
  12015. /**
  12016. * Ray from a pointer if availible (eg. 6dof controller)
  12017. */
  12018. ray: Nullable<Ray>;
  12019. /**
  12020. * Defines the local position of the pointer on the canvas.
  12021. */
  12022. localPosition: Vector2;
  12023. /**
  12024. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12025. */
  12026. skipOnPointerObservable: boolean;
  12027. /**
  12028. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12029. * @param type Defines the type of event (PointerEventTypes)
  12030. * @param event Defines the related dom event
  12031. * @param localX Defines the local x coordinates of the pointer when the event occured
  12032. * @param localY Defines the local y coordinates of the pointer when the event occured
  12033. */
  12034. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12035. }
  12036. /**
  12037. * This type contains all the data related to a pointer event in Babylon.js.
  12038. * 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.
  12039. */
  12040. export class PointerInfo extends PointerInfoBase {
  12041. /**
  12042. * Defines the picking info associated to the info (if any)\
  12043. */
  12044. pickInfo: Nullable<PickingInfo>;
  12045. /**
  12046. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12047. * @param type Defines the type of event (PointerEventTypes)
  12048. * @param event Defines the related dom event
  12049. * @param pickInfo Defines the picking info associated to the info (if any)\
  12050. */
  12051. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12052. /**
  12053. * Defines the picking info associated to the info (if any)\
  12054. */
  12055. pickInfo: Nullable<PickingInfo>);
  12056. }
  12057. /**
  12058. * Data relating to a touch event on the screen.
  12059. */
  12060. export interface PointerTouch {
  12061. /**
  12062. * X coordinate of touch.
  12063. */
  12064. x: number;
  12065. /**
  12066. * Y coordinate of touch.
  12067. */
  12068. y: number;
  12069. /**
  12070. * Id of touch. Unique for each finger.
  12071. */
  12072. pointerId: number;
  12073. /**
  12074. * Event type passed from DOM.
  12075. */
  12076. type: any;
  12077. }
  12078. }
  12079. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12080. import { Observable } from "babylonjs/Misc/observable";
  12081. import { Nullable } from "babylonjs/types";
  12082. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12084. /**
  12085. * Manage the mouse inputs to control the movement of a free camera.
  12086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12087. */
  12088. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12089. /**
  12090. * Define if touch is enabled in the mouse input
  12091. */
  12092. touchEnabled: boolean;
  12093. /**
  12094. * Defines the camera the input is attached to.
  12095. */
  12096. camera: FreeCamera;
  12097. /**
  12098. * Defines the buttons associated with the input to handle camera move.
  12099. */
  12100. buttons: number[];
  12101. /**
  12102. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12103. */
  12104. angularSensibility: number;
  12105. private _pointerInput;
  12106. private _onMouseMove;
  12107. private _observer;
  12108. private previousPosition;
  12109. /**
  12110. * Observable for when a pointer move event occurs containing the move offset
  12111. */
  12112. onPointerMovedObservable: Observable<{
  12113. offsetX: number;
  12114. offsetY: number;
  12115. }>;
  12116. /**
  12117. * @hidden
  12118. * If the camera should be rotated automatically based on pointer movement
  12119. */
  12120. _allowCameraRotation: boolean;
  12121. /**
  12122. * Manage the mouse inputs to control the movement of a free camera.
  12123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12124. * @param touchEnabled Defines if touch is enabled or not
  12125. */
  12126. constructor(
  12127. /**
  12128. * Define if touch is enabled in the mouse input
  12129. */
  12130. touchEnabled?: boolean);
  12131. /**
  12132. * Attach the input controls to a specific dom element to get the input from.
  12133. * @param element Defines the element the controls should be listened from
  12134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12135. */
  12136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12137. /**
  12138. * Called on JS contextmenu event.
  12139. * Override this method to provide functionality.
  12140. */
  12141. protected onContextMenu(evt: PointerEvent): void;
  12142. /**
  12143. * Detach the current controls from the specified dom element.
  12144. * @param element Defines the element to stop listening the inputs from
  12145. */
  12146. detachControl(element: Nullable<HTMLElement>): void;
  12147. /**
  12148. * Gets the class name of the current intput.
  12149. * @returns the class name
  12150. */
  12151. getClassName(): string;
  12152. /**
  12153. * Get the friendly name associated with the input class.
  12154. * @returns the input friendly name
  12155. */
  12156. getSimpleName(): string;
  12157. }
  12158. }
  12159. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12160. import { Nullable } from "babylonjs/types";
  12161. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12162. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12163. /**
  12164. * Manage the touch inputs to control the movement of a free camera.
  12165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12166. */
  12167. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12168. /**
  12169. * Defines the camera the input is attached to.
  12170. */
  12171. camera: FreeCamera;
  12172. /**
  12173. * Defines the touch sensibility for rotation.
  12174. * The higher the faster.
  12175. */
  12176. touchAngularSensibility: number;
  12177. /**
  12178. * Defines the touch sensibility for move.
  12179. * The higher the faster.
  12180. */
  12181. touchMoveSensibility: number;
  12182. private _offsetX;
  12183. private _offsetY;
  12184. private _pointerPressed;
  12185. private _pointerInput;
  12186. private _observer;
  12187. private _onLostFocus;
  12188. /**
  12189. * Attach the input controls to a specific dom element to get the input from.
  12190. * @param element Defines the element the controls should be listened from
  12191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12192. */
  12193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12194. /**
  12195. * Detach the current controls from the specified dom element.
  12196. * @param element Defines the element to stop listening the inputs from
  12197. */
  12198. detachControl(element: Nullable<HTMLElement>): void;
  12199. /**
  12200. * Update the current camera state depending on the inputs that have been used this frame.
  12201. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12202. */
  12203. checkInputs(): void;
  12204. /**
  12205. * Gets the class name of the current intput.
  12206. * @returns the class name
  12207. */
  12208. getClassName(): string;
  12209. /**
  12210. * Get the friendly name associated with the input class.
  12211. * @returns the input friendly name
  12212. */
  12213. getSimpleName(): string;
  12214. }
  12215. }
  12216. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12217. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12218. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12219. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12220. import { Nullable } from "babylonjs/types";
  12221. /**
  12222. * Default Inputs manager for the FreeCamera.
  12223. * It groups all the default supported inputs for ease of use.
  12224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12225. */
  12226. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12227. /**
  12228. * @hidden
  12229. */
  12230. _mouseInput: Nullable<FreeCameraMouseInput>;
  12231. /**
  12232. * Instantiates a new FreeCameraInputsManager.
  12233. * @param camera Defines the camera the inputs belong to
  12234. */
  12235. constructor(camera: FreeCamera);
  12236. /**
  12237. * Add keyboard input support to the input manager.
  12238. * @returns the current input manager
  12239. */
  12240. addKeyboard(): FreeCameraInputsManager;
  12241. /**
  12242. * Add mouse input support to the input manager.
  12243. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12244. * @returns the current input manager
  12245. */
  12246. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12247. /**
  12248. * Removes the mouse input support from the manager
  12249. * @returns the current input manager
  12250. */
  12251. removeMouse(): FreeCameraInputsManager;
  12252. /**
  12253. * Add touch input support to the input manager.
  12254. * @returns the current input manager
  12255. */
  12256. addTouch(): FreeCameraInputsManager;
  12257. /**
  12258. * Remove all attached input methods from a camera
  12259. */
  12260. clear(): void;
  12261. }
  12262. }
  12263. declare module "babylonjs/Cameras/freeCamera" {
  12264. import { Vector3 } from "babylonjs/Maths/math.vector";
  12265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12266. import { Scene } from "babylonjs/scene";
  12267. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12268. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12269. /**
  12270. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12271. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12273. */
  12274. export class FreeCamera extends TargetCamera {
  12275. /**
  12276. * Define the collision ellipsoid of the camera.
  12277. * This is helpful to simulate a camera body like the player body around the camera
  12278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12279. */
  12280. ellipsoid: Vector3;
  12281. /**
  12282. * Define an offset for the position of the ellipsoid around the camera.
  12283. * This can be helpful to determine the center of the body near the gravity center of the body
  12284. * instead of its head.
  12285. */
  12286. ellipsoidOffset: Vector3;
  12287. /**
  12288. * Enable or disable collisions of the camera with the rest of the scene objects.
  12289. */
  12290. checkCollisions: boolean;
  12291. /**
  12292. * Enable or disable gravity on the camera.
  12293. */
  12294. applyGravity: boolean;
  12295. /**
  12296. * Define the input manager associated to the camera.
  12297. */
  12298. inputs: FreeCameraInputsManager;
  12299. /**
  12300. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12301. * Higher values reduce sensitivity.
  12302. */
  12303. /**
  12304. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12305. * Higher values reduce sensitivity.
  12306. */
  12307. angularSensibility: number;
  12308. /**
  12309. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12310. */
  12311. keysUp: number[];
  12312. /**
  12313. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12314. */
  12315. keysDown: number[];
  12316. /**
  12317. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12318. */
  12319. keysLeft: number[];
  12320. /**
  12321. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12322. */
  12323. keysRight: number[];
  12324. /**
  12325. * Event raised when the camera collide with a mesh in the scene.
  12326. */
  12327. onCollide: (collidedMesh: AbstractMesh) => void;
  12328. private _collider;
  12329. private _needMoveForGravity;
  12330. private _oldPosition;
  12331. private _diffPosition;
  12332. private _newPosition;
  12333. /** @hidden */
  12334. _localDirection: Vector3;
  12335. /** @hidden */
  12336. _transformedDirection: Vector3;
  12337. /**
  12338. * Instantiates a Free Camera.
  12339. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12340. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12341. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12342. * @param name Define the name of the camera in the scene
  12343. * @param position Define the start position of the camera in the scene
  12344. * @param scene Define the scene the camera belongs to
  12345. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12346. */
  12347. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12348. /**
  12349. * Attached controls to the current camera.
  12350. * @param element Defines the element the controls should be listened from
  12351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12352. */
  12353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12354. /**
  12355. * Detach the current controls from the camera.
  12356. * The camera will stop reacting to inputs.
  12357. * @param element Defines the element to stop listening the inputs from
  12358. */
  12359. detachControl(element: HTMLElement): void;
  12360. private _collisionMask;
  12361. /**
  12362. * Define a collision mask to limit the list of object the camera can collide with
  12363. */
  12364. collisionMask: number;
  12365. /** @hidden */
  12366. _collideWithWorld(displacement: Vector3): void;
  12367. private _onCollisionPositionChange;
  12368. /** @hidden */
  12369. _checkInputs(): void;
  12370. /** @hidden */
  12371. _decideIfNeedsToMove(): boolean;
  12372. /** @hidden */
  12373. _updatePosition(): void;
  12374. /**
  12375. * Destroy the camera and release the current resources hold by it.
  12376. */
  12377. dispose(): void;
  12378. /**
  12379. * Gets the current object class name.
  12380. * @return the class name
  12381. */
  12382. getClassName(): string;
  12383. }
  12384. }
  12385. declare module "babylonjs/Gamepads/gamepad" {
  12386. import { Observable } from "babylonjs/Misc/observable";
  12387. /**
  12388. * Represents a gamepad control stick position
  12389. */
  12390. export class StickValues {
  12391. /**
  12392. * The x component of the control stick
  12393. */
  12394. x: number;
  12395. /**
  12396. * The y component of the control stick
  12397. */
  12398. y: number;
  12399. /**
  12400. * Initializes the gamepad x and y control stick values
  12401. * @param x The x component of the gamepad control stick value
  12402. * @param y The y component of the gamepad control stick value
  12403. */
  12404. constructor(
  12405. /**
  12406. * The x component of the control stick
  12407. */
  12408. x: number,
  12409. /**
  12410. * The y component of the control stick
  12411. */
  12412. y: number);
  12413. }
  12414. /**
  12415. * An interface which manages callbacks for gamepad button changes
  12416. */
  12417. export interface GamepadButtonChanges {
  12418. /**
  12419. * Called when a gamepad has been changed
  12420. */
  12421. changed: boolean;
  12422. /**
  12423. * Called when a gamepad press event has been triggered
  12424. */
  12425. pressChanged: boolean;
  12426. /**
  12427. * Called when a touch event has been triggered
  12428. */
  12429. touchChanged: boolean;
  12430. /**
  12431. * Called when a value has changed
  12432. */
  12433. valueChanged: boolean;
  12434. }
  12435. /**
  12436. * Represents a gamepad
  12437. */
  12438. export class Gamepad {
  12439. /**
  12440. * The id of the gamepad
  12441. */
  12442. id: string;
  12443. /**
  12444. * The index of the gamepad
  12445. */
  12446. index: number;
  12447. /**
  12448. * The browser gamepad
  12449. */
  12450. browserGamepad: any;
  12451. /**
  12452. * Specifies what type of gamepad this represents
  12453. */
  12454. type: number;
  12455. private _leftStick;
  12456. private _rightStick;
  12457. /** @hidden */
  12458. _isConnected: boolean;
  12459. private _leftStickAxisX;
  12460. private _leftStickAxisY;
  12461. private _rightStickAxisX;
  12462. private _rightStickAxisY;
  12463. /**
  12464. * Triggered when the left control stick has been changed
  12465. */
  12466. private _onleftstickchanged;
  12467. /**
  12468. * Triggered when the right control stick has been changed
  12469. */
  12470. private _onrightstickchanged;
  12471. /**
  12472. * Represents a gamepad controller
  12473. */
  12474. static GAMEPAD: number;
  12475. /**
  12476. * Represents a generic controller
  12477. */
  12478. static GENERIC: number;
  12479. /**
  12480. * Represents an XBox controller
  12481. */
  12482. static XBOX: number;
  12483. /**
  12484. * Represents a pose-enabled controller
  12485. */
  12486. static POSE_ENABLED: number;
  12487. /**
  12488. * Represents an Dual Shock controller
  12489. */
  12490. static DUALSHOCK: number;
  12491. /**
  12492. * Specifies whether the left control stick should be Y-inverted
  12493. */
  12494. protected _invertLeftStickY: boolean;
  12495. /**
  12496. * Specifies if the gamepad has been connected
  12497. */
  12498. readonly isConnected: boolean;
  12499. /**
  12500. * Initializes the gamepad
  12501. * @param id The id of the gamepad
  12502. * @param index The index of the gamepad
  12503. * @param browserGamepad The browser gamepad
  12504. * @param leftStickX The x component of the left joystick
  12505. * @param leftStickY The y component of the left joystick
  12506. * @param rightStickX The x component of the right joystick
  12507. * @param rightStickY The y component of the right joystick
  12508. */
  12509. constructor(
  12510. /**
  12511. * The id of the gamepad
  12512. */
  12513. id: string,
  12514. /**
  12515. * The index of the gamepad
  12516. */
  12517. index: number,
  12518. /**
  12519. * The browser gamepad
  12520. */
  12521. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12522. /**
  12523. * Callback triggered when the left joystick has changed
  12524. * @param callback
  12525. */
  12526. onleftstickchanged(callback: (values: StickValues) => void): void;
  12527. /**
  12528. * Callback triggered when the right joystick has changed
  12529. * @param callback
  12530. */
  12531. onrightstickchanged(callback: (values: StickValues) => void): void;
  12532. /**
  12533. * Gets the left joystick
  12534. */
  12535. /**
  12536. * Sets the left joystick values
  12537. */
  12538. leftStick: StickValues;
  12539. /**
  12540. * Gets the right joystick
  12541. */
  12542. /**
  12543. * Sets the right joystick value
  12544. */
  12545. rightStick: StickValues;
  12546. /**
  12547. * Updates the gamepad joystick positions
  12548. */
  12549. update(): void;
  12550. /**
  12551. * Disposes the gamepad
  12552. */
  12553. dispose(): void;
  12554. }
  12555. /**
  12556. * Represents a generic gamepad
  12557. */
  12558. export class GenericPad extends Gamepad {
  12559. private _buttons;
  12560. private _onbuttondown;
  12561. private _onbuttonup;
  12562. /**
  12563. * Observable triggered when a button has been pressed
  12564. */
  12565. onButtonDownObservable: Observable<number>;
  12566. /**
  12567. * Observable triggered when a button has been released
  12568. */
  12569. onButtonUpObservable: Observable<number>;
  12570. /**
  12571. * Callback triggered when a button has been pressed
  12572. * @param callback Called when a button has been pressed
  12573. */
  12574. onbuttondown(callback: (buttonPressed: number) => void): void;
  12575. /**
  12576. * Callback triggered when a button has been released
  12577. * @param callback Called when a button has been released
  12578. */
  12579. onbuttonup(callback: (buttonReleased: number) => void): void;
  12580. /**
  12581. * Initializes the generic gamepad
  12582. * @param id The id of the generic gamepad
  12583. * @param index The index of the generic gamepad
  12584. * @param browserGamepad The browser gamepad
  12585. */
  12586. constructor(id: string, index: number, browserGamepad: any);
  12587. private _setButtonValue;
  12588. /**
  12589. * Updates the generic gamepad
  12590. */
  12591. update(): void;
  12592. /**
  12593. * Disposes the generic gamepad
  12594. */
  12595. dispose(): void;
  12596. }
  12597. }
  12598. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12599. import { Nullable } from "babylonjs/types";
  12600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12601. import { Scene } from "babylonjs/scene";
  12602. module "babylonjs/Engines/baseEngine" {
  12603. interface BaseEngine {
  12604. /**
  12605. * Creates a raw texture
  12606. * @param data defines the data to store in the texture
  12607. * @param width defines the width of the texture
  12608. * @param height defines the height of the texture
  12609. * @param format defines the format of the data
  12610. * @param generateMipMaps defines if the engine should generate the mip levels
  12611. * @param invertY defines if data must be stored with Y axis inverted
  12612. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12613. * @param compression defines the compression used (null by default)
  12614. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12615. * @returns the raw texture inside an InternalTexture
  12616. */
  12617. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12618. /**
  12619. * Update a raw texture
  12620. * @param texture defines the texture to update
  12621. * @param data defines the data to store in the texture
  12622. * @param format defines the format of the data
  12623. * @param invertY defines if data must be stored with Y axis inverted
  12624. */
  12625. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12626. /**
  12627. * Update a raw texture
  12628. * @param texture defines the texture to update
  12629. * @param data defines the data to store in the texture
  12630. * @param format defines the format of the data
  12631. * @param invertY defines if data must be stored with Y axis inverted
  12632. * @param compression defines the compression used (null by default)
  12633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12634. */
  12635. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12636. /**
  12637. * Creates a new raw cube texture
  12638. * @param data defines the array of data to use to create each face
  12639. * @param size defines the size of the textures
  12640. * @param format defines the format of the data
  12641. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12642. * @param generateMipMaps defines if the engine should generate the mip levels
  12643. * @param invertY defines if data must be stored with Y axis inverted
  12644. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12645. * @param compression defines the compression used (null by default)
  12646. * @returns the cube texture as an InternalTexture
  12647. */
  12648. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12649. /**
  12650. * Update a raw cube texture
  12651. * @param texture defines the texture to udpdate
  12652. * @param data defines the data to store
  12653. * @param format defines the data format
  12654. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12655. * @param invertY defines if data must be stored with Y axis inverted
  12656. */
  12657. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12658. /**
  12659. * Update a raw cube texture
  12660. * @param texture defines the texture to udpdate
  12661. * @param data defines the data to store
  12662. * @param format defines the data format
  12663. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12664. * @param invertY defines if data must be stored with Y axis inverted
  12665. * @param compression defines the compression used (null by default)
  12666. */
  12667. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12668. /**
  12669. * Update a raw cube texture
  12670. * @param texture defines the texture to udpdate
  12671. * @param data defines the data to store
  12672. * @param format defines the data format
  12673. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12674. * @param invertY defines if data must be stored with Y axis inverted
  12675. * @param compression defines the compression used (null by default)
  12676. * @param level defines which level of the texture to update
  12677. */
  12678. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12679. /**
  12680. * Creates a new raw cube texture from a specified url
  12681. * @param url defines the url where the data is located
  12682. * @param scene defines the current scene
  12683. * @param size defines the size of the textures
  12684. * @param format defines the format of the data
  12685. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12686. * @param noMipmap defines if the engine should avoid generating the mip levels
  12687. * @param callback defines a callback used to extract texture data from loaded data
  12688. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12689. * @param onLoad defines a callback called when texture is loaded
  12690. * @param onError defines a callback called if there is an error
  12691. * @returns the cube texture as an InternalTexture
  12692. */
  12693. 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;
  12694. /**
  12695. * Creates a new raw cube texture from a specified url
  12696. * @param url defines the url where the data is located
  12697. * @param scene defines the current scene
  12698. * @param size defines the size of the textures
  12699. * @param format defines the format of the data
  12700. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12701. * @param noMipmap defines if the engine should avoid generating the mip levels
  12702. * @param callback defines a callback used to extract texture data from loaded data
  12703. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12704. * @param onLoad defines a callback called when texture is loaded
  12705. * @param onError defines a callback called if there is an error
  12706. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @returns the cube texture as an InternalTexture
  12709. */
  12710. 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;
  12711. /**
  12712. * Creates a new raw 3D texture
  12713. * @param data defines the data used to create the texture
  12714. * @param width defines the width of the texture
  12715. * @param height defines the height of the texture
  12716. * @param depth defines the depth of the texture
  12717. * @param format defines the format of the texture
  12718. * @param generateMipMaps defines if the engine must generate mip levels
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12721. * @param compression defines the compressed used (can be null)
  12722. * @param textureType defines the compressed used (can be null)
  12723. * @returns a new raw 3D texture (stored in an InternalTexture)
  12724. */
  12725. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12726. /**
  12727. * Update a raw 3D texture
  12728. * @param texture defines the texture to update
  12729. * @param data defines the data to store
  12730. * @param format defines the data format
  12731. * @param invertY defines if data must be stored with Y axis inverted
  12732. */
  12733. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12734. /**
  12735. * Update a raw 3D texture
  12736. * @param texture defines the texture to update
  12737. * @param data defines the data to store
  12738. * @param format defines the data format
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param compression defines the used compression (can be null)
  12741. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12742. */
  12743. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12744. }
  12745. }
  12746. }
  12747. declare module "babylonjs/Materials/Textures/rawTexture" {
  12748. import { Scene } from "babylonjs/scene";
  12749. import { Texture } from "babylonjs/Materials/Textures/texture";
  12750. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12751. /**
  12752. * Raw texture can help creating a texture directly from an array of data.
  12753. * This can be super useful if you either get the data from an uncompressed source or
  12754. * if you wish to create your texture pixel by pixel.
  12755. */
  12756. export class RawTexture extends Texture {
  12757. /**
  12758. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12759. */
  12760. format: number;
  12761. private _engine;
  12762. /**
  12763. * Instantiates a new RawTexture.
  12764. * Raw texture can help creating a texture directly from an array of data.
  12765. * This can be super useful if you either get the data from an uncompressed source or
  12766. * if you wish to create your texture pixel by pixel.
  12767. * @param data define the array of data to use to create the texture
  12768. * @param width define the width of the texture
  12769. * @param height define the height of the texture
  12770. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12771. * @param scene define the scene the texture belongs to
  12772. * @param generateMipMaps define whether mip maps should be generated or not
  12773. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12774. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12775. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12776. */
  12777. constructor(data: ArrayBufferView, width: number, height: number,
  12778. /**
  12779. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12780. */
  12781. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12782. /**
  12783. * Updates the texture underlying data.
  12784. * @param data Define the new data of the texture
  12785. */
  12786. update(data: ArrayBufferView): void;
  12787. /**
  12788. * Creates a luminance texture from some data.
  12789. * @param data Define the texture data
  12790. * @param width Define the width of the texture
  12791. * @param height Define the height of the texture
  12792. * @param scene Define the scene the texture belongs to
  12793. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12794. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12795. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12796. * @returns the luminance texture
  12797. */
  12798. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12799. /**
  12800. * Creates a luminance alpha texture from some data.
  12801. * @param data Define the texture data
  12802. * @param width Define the width of the texture
  12803. * @param height Define the height of the texture
  12804. * @param scene Define the scene the texture belongs to
  12805. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12806. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12807. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12808. * @returns the luminance alpha texture
  12809. */
  12810. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12811. /**
  12812. * Creates an alpha texture from some data.
  12813. * @param data Define the texture data
  12814. * @param width Define the width of the texture
  12815. * @param height Define the height of the texture
  12816. * @param scene Define the scene the texture belongs to
  12817. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12818. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12819. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12820. * @returns the alpha texture
  12821. */
  12822. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12823. /**
  12824. * Creates a RGB texture from some data.
  12825. * @param data Define the texture data
  12826. * @param width Define the width of the texture
  12827. * @param height Define the height of the texture
  12828. * @param scene Define the scene the texture belongs to
  12829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12832. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12833. * @returns the RGB alpha texture
  12834. */
  12835. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12836. /**
  12837. * Creates a RGBA texture from some data.
  12838. * @param data Define the texture data
  12839. * @param width Define the width of the texture
  12840. * @param height Define the height of the texture
  12841. * @param scene Define the scene the texture belongs to
  12842. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12843. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12844. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12845. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12846. * @returns the RGBA texture
  12847. */
  12848. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12849. /**
  12850. * Creates a R texture from some data.
  12851. * @param data Define the texture data
  12852. * @param width Define the width of the texture
  12853. * @param height Define the height of the texture
  12854. * @param scene Define the scene the texture belongs to
  12855. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12856. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12857. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12858. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12859. * @returns the R texture
  12860. */
  12861. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12862. }
  12863. }
  12864. declare module "babylonjs/Maths/math.size" {
  12865. /**
  12866. * Interface for the size containing width and height
  12867. */
  12868. export interface ISize {
  12869. /**
  12870. * Width
  12871. */
  12872. width: number;
  12873. /**
  12874. * Heighht
  12875. */
  12876. height: number;
  12877. }
  12878. /**
  12879. * Size containing widht and height
  12880. */
  12881. export class Size implements ISize {
  12882. /**
  12883. * Width
  12884. */
  12885. width: number;
  12886. /**
  12887. * Height
  12888. */
  12889. height: number;
  12890. /**
  12891. * Creates a Size object from the given width and height (floats).
  12892. * @param width width of the new size
  12893. * @param height height of the new size
  12894. */
  12895. constructor(width: number, height: number);
  12896. /**
  12897. * Returns a string with the Size width and height
  12898. * @returns a string with the Size width and height
  12899. */
  12900. toString(): string;
  12901. /**
  12902. * "Size"
  12903. * @returns the string "Size"
  12904. */
  12905. getClassName(): string;
  12906. /**
  12907. * Returns the Size hash code.
  12908. * @returns a hash code for a unique width and height
  12909. */
  12910. getHashCode(): number;
  12911. /**
  12912. * Updates the current size from the given one.
  12913. * @param src the given size
  12914. */
  12915. copyFrom(src: Size): void;
  12916. /**
  12917. * Updates in place the current Size from the given floats.
  12918. * @param width width of the new size
  12919. * @param height height of the new size
  12920. * @returns the updated Size.
  12921. */
  12922. copyFromFloats(width: number, height: number): Size;
  12923. /**
  12924. * Updates in place the current Size from the given floats.
  12925. * @param width width to set
  12926. * @param height height to set
  12927. * @returns the updated Size.
  12928. */
  12929. set(width: number, height: number): Size;
  12930. /**
  12931. * Multiplies the width and height by numbers
  12932. * @param w factor to multiple the width by
  12933. * @param h factor to multiple the height by
  12934. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12935. */
  12936. multiplyByFloats(w: number, h: number): Size;
  12937. /**
  12938. * Clones the size
  12939. * @returns a new Size copied from the given one.
  12940. */
  12941. clone(): Size;
  12942. /**
  12943. * True if the current Size and the given one width and height are strictly equal.
  12944. * @param other the other size to compare against
  12945. * @returns True if the current Size and the given one width and height are strictly equal.
  12946. */
  12947. equals(other: Size): boolean;
  12948. /**
  12949. * The surface of the Size : width * height (float).
  12950. */
  12951. readonly surface: number;
  12952. /**
  12953. * Create a new size of zero
  12954. * @returns a new Size set to (0.0, 0.0)
  12955. */
  12956. static Zero(): Size;
  12957. /**
  12958. * Sums the width and height of two sizes
  12959. * @param otherSize size to add to this size
  12960. * @returns a new Size set as the addition result of the current Size and the given one.
  12961. */
  12962. add(otherSize: Size): Size;
  12963. /**
  12964. * Subtracts the width and height of two
  12965. * @param otherSize size to subtract to this size
  12966. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12967. */
  12968. subtract(otherSize: Size): Size;
  12969. /**
  12970. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12971. * @param start starting size to lerp between
  12972. * @param end end size to lerp between
  12973. * @param amount amount to lerp between the start and end values
  12974. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12975. */
  12976. static Lerp(start: Size, end: Size, amount: number): Size;
  12977. }
  12978. }
  12979. declare module "babylonjs/Animations/runtimeAnimation" {
  12980. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12981. import { Animatable } from "babylonjs/Animations/animatable";
  12982. import { Scene } from "babylonjs/scene";
  12983. /**
  12984. * Defines a runtime animation
  12985. */
  12986. export class RuntimeAnimation {
  12987. private _events;
  12988. /**
  12989. * The current frame of the runtime animation
  12990. */
  12991. private _currentFrame;
  12992. /**
  12993. * The animation used by the runtime animation
  12994. */
  12995. private _animation;
  12996. /**
  12997. * The target of the runtime animation
  12998. */
  12999. private _target;
  13000. /**
  13001. * The initiating animatable
  13002. */
  13003. private _host;
  13004. /**
  13005. * The original value of the runtime animation
  13006. */
  13007. private _originalValue;
  13008. /**
  13009. * The original blend value of the runtime animation
  13010. */
  13011. private _originalBlendValue;
  13012. /**
  13013. * The offsets cache of the runtime animation
  13014. */
  13015. private _offsetsCache;
  13016. /**
  13017. * The high limits cache of the runtime animation
  13018. */
  13019. private _highLimitsCache;
  13020. /**
  13021. * Specifies if the runtime animation has been stopped
  13022. */
  13023. private _stopped;
  13024. /**
  13025. * The blending factor of the runtime animation
  13026. */
  13027. private _blendingFactor;
  13028. /**
  13029. * The BabylonJS scene
  13030. */
  13031. private _scene;
  13032. /**
  13033. * The current value of the runtime animation
  13034. */
  13035. private _currentValue;
  13036. /** @hidden */
  13037. _animationState: _IAnimationState;
  13038. /**
  13039. * The active target of the runtime animation
  13040. */
  13041. private _activeTargets;
  13042. private _currentActiveTarget;
  13043. private _directTarget;
  13044. /**
  13045. * The target path of the runtime animation
  13046. */
  13047. private _targetPath;
  13048. /**
  13049. * The weight of the runtime animation
  13050. */
  13051. private _weight;
  13052. /**
  13053. * The ratio offset of the runtime animation
  13054. */
  13055. private _ratioOffset;
  13056. /**
  13057. * The previous delay of the runtime animation
  13058. */
  13059. private _previousDelay;
  13060. /**
  13061. * The previous ratio of the runtime animation
  13062. */
  13063. private _previousRatio;
  13064. private _enableBlending;
  13065. private _keys;
  13066. private _minFrame;
  13067. private _maxFrame;
  13068. private _minValue;
  13069. private _maxValue;
  13070. private _targetIsArray;
  13071. /**
  13072. * Gets the current frame of the runtime animation
  13073. */
  13074. readonly currentFrame: number;
  13075. /**
  13076. * Gets the weight of the runtime animation
  13077. */
  13078. readonly weight: number;
  13079. /**
  13080. * Gets the current value of the runtime animation
  13081. */
  13082. readonly currentValue: any;
  13083. /**
  13084. * Gets the target path of the runtime animation
  13085. */
  13086. readonly targetPath: string;
  13087. /**
  13088. * Gets the actual target of the runtime animation
  13089. */
  13090. readonly target: any;
  13091. /** @hidden */
  13092. _onLoop: () => void;
  13093. /**
  13094. * Create a new RuntimeAnimation object
  13095. * @param target defines the target of the animation
  13096. * @param animation defines the source animation object
  13097. * @param scene defines the hosting scene
  13098. * @param host defines the initiating Animatable
  13099. */
  13100. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13101. private _preparePath;
  13102. /**
  13103. * Gets the animation from the runtime animation
  13104. */
  13105. readonly animation: Animation;
  13106. /**
  13107. * Resets the runtime animation to the beginning
  13108. * @param restoreOriginal defines whether to restore the target property to the original value
  13109. */
  13110. reset(restoreOriginal?: boolean): void;
  13111. /**
  13112. * Specifies if the runtime animation is stopped
  13113. * @returns Boolean specifying if the runtime animation is stopped
  13114. */
  13115. isStopped(): boolean;
  13116. /**
  13117. * Disposes of the runtime animation
  13118. */
  13119. dispose(): void;
  13120. /**
  13121. * Apply the interpolated value to the target
  13122. * @param currentValue defines the value computed by the animation
  13123. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13124. */
  13125. setValue(currentValue: any, weight: number): void;
  13126. private _getOriginalValues;
  13127. private _setValue;
  13128. /**
  13129. * Gets the loop pmode of the runtime animation
  13130. * @returns Loop Mode
  13131. */
  13132. private _getCorrectLoopMode;
  13133. /**
  13134. * Move the current animation to a given frame
  13135. * @param frame defines the frame to move to
  13136. */
  13137. goToFrame(frame: number): void;
  13138. /**
  13139. * @hidden Internal use only
  13140. */
  13141. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13142. /**
  13143. * Execute the current animation
  13144. * @param delay defines the delay to add to the current frame
  13145. * @param from defines the lower bound of the animation range
  13146. * @param to defines the upper bound of the animation range
  13147. * @param loop defines if the current animation must loop
  13148. * @param speedRatio defines the current speed ratio
  13149. * @param weight defines the weight of the animation (default is -1 so no weight)
  13150. * @param onLoop optional callback called when animation loops
  13151. * @returns a boolean indicating if the animation is running
  13152. */
  13153. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13154. }
  13155. }
  13156. declare module "babylonjs/Animations/animatable" {
  13157. import { Animation } from "babylonjs/Animations/animation";
  13158. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13159. import { Nullable } from "babylonjs/types";
  13160. import { Observable } from "babylonjs/Misc/observable";
  13161. import { Scene } from "babylonjs/scene";
  13162. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13163. import { Node } from "babylonjs/node";
  13164. /**
  13165. * Class used to store an actual running animation
  13166. */
  13167. export class Animatable {
  13168. /** defines the target object */
  13169. target: any;
  13170. /** defines the starting frame number (default is 0) */
  13171. fromFrame: number;
  13172. /** defines the ending frame number (default is 100) */
  13173. toFrame: number;
  13174. /** defines if the animation must loop (default is false) */
  13175. loopAnimation: boolean;
  13176. /** defines a callback to call when animation ends if it is not looping */
  13177. onAnimationEnd?: (() => void) | null | undefined;
  13178. /** defines a callback to call when animation loops */
  13179. onAnimationLoop?: (() => void) | null | undefined;
  13180. private _localDelayOffset;
  13181. private _pausedDelay;
  13182. private _runtimeAnimations;
  13183. private _paused;
  13184. private _scene;
  13185. private _speedRatio;
  13186. private _weight;
  13187. private _syncRoot;
  13188. /**
  13189. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13190. * This will only apply for non looping animation (default is true)
  13191. */
  13192. disposeOnEnd: boolean;
  13193. /**
  13194. * Gets a boolean indicating if the animation has started
  13195. */
  13196. animationStarted: boolean;
  13197. /**
  13198. * Observer raised when the animation ends
  13199. */
  13200. onAnimationEndObservable: Observable<Animatable>;
  13201. /**
  13202. * Observer raised when the animation loops
  13203. */
  13204. onAnimationLoopObservable: Observable<Animatable>;
  13205. /**
  13206. * Gets the root Animatable used to synchronize and normalize animations
  13207. */
  13208. readonly syncRoot: Nullable<Animatable>;
  13209. /**
  13210. * Gets the current frame of the first RuntimeAnimation
  13211. * Used to synchronize Animatables
  13212. */
  13213. readonly masterFrame: number;
  13214. /**
  13215. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13216. */
  13217. weight: number;
  13218. /**
  13219. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13220. */
  13221. speedRatio: number;
  13222. /**
  13223. * Creates a new Animatable
  13224. * @param scene defines the hosting scene
  13225. * @param target defines the target object
  13226. * @param fromFrame defines the starting frame number (default is 0)
  13227. * @param toFrame defines the ending frame number (default is 100)
  13228. * @param loopAnimation defines if the animation must loop (default is false)
  13229. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13230. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13231. * @param animations defines a group of animation to add to the new Animatable
  13232. * @param onAnimationLoop defines a callback to call when animation loops
  13233. */
  13234. constructor(scene: Scene,
  13235. /** defines the target object */
  13236. target: any,
  13237. /** defines the starting frame number (default is 0) */
  13238. fromFrame?: number,
  13239. /** defines the ending frame number (default is 100) */
  13240. toFrame?: number,
  13241. /** defines if the animation must loop (default is false) */
  13242. loopAnimation?: boolean, speedRatio?: number,
  13243. /** defines a callback to call when animation ends if it is not looping */
  13244. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13245. /** defines a callback to call when animation loops */
  13246. onAnimationLoop?: (() => void) | null | undefined);
  13247. /**
  13248. * Synchronize and normalize current Animatable with a source Animatable
  13249. * This is useful when using animation weights and when animations are not of the same length
  13250. * @param root defines the root Animatable to synchronize with
  13251. * @returns the current Animatable
  13252. */
  13253. syncWith(root: Animatable): Animatable;
  13254. /**
  13255. * Gets the list of runtime animations
  13256. * @returns an array of RuntimeAnimation
  13257. */
  13258. getAnimations(): RuntimeAnimation[];
  13259. /**
  13260. * Adds more animations to the current animatable
  13261. * @param target defines the target of the animations
  13262. * @param animations defines the new animations to add
  13263. */
  13264. appendAnimations(target: any, animations: Animation[]): void;
  13265. /**
  13266. * Gets the source animation for a specific property
  13267. * @param property defines the propertyu to look for
  13268. * @returns null or the source animation for the given property
  13269. */
  13270. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13271. /**
  13272. * Gets the runtime animation for a specific property
  13273. * @param property defines the propertyu to look for
  13274. * @returns null or the runtime animation for the given property
  13275. */
  13276. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13277. /**
  13278. * Resets the animatable to its original state
  13279. */
  13280. reset(): void;
  13281. /**
  13282. * Allows the animatable to blend with current running animations
  13283. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13284. * @param blendingSpeed defines the blending speed to use
  13285. */
  13286. enableBlending(blendingSpeed: number): void;
  13287. /**
  13288. * Disable animation blending
  13289. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13290. */
  13291. disableBlending(): void;
  13292. /**
  13293. * Jump directly to a given frame
  13294. * @param frame defines the frame to jump to
  13295. */
  13296. goToFrame(frame: number): void;
  13297. /**
  13298. * Pause the animation
  13299. */
  13300. pause(): void;
  13301. /**
  13302. * Restart the animation
  13303. */
  13304. restart(): void;
  13305. private _raiseOnAnimationEnd;
  13306. /**
  13307. * Stop and delete the current animation
  13308. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13309. * @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)
  13310. */
  13311. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13312. /**
  13313. * Wait asynchronously for the animation to end
  13314. * @returns a promise which will be fullfilled when the animation ends
  13315. */
  13316. waitAsync(): Promise<Animatable>;
  13317. /** @hidden */
  13318. _animate(delay: number): boolean;
  13319. }
  13320. module "babylonjs/scene" {
  13321. interface Scene {
  13322. /** @hidden */
  13323. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13324. /** @hidden */
  13325. _processLateAnimationBindingsForMatrices(holder: {
  13326. totalWeight: number;
  13327. animations: RuntimeAnimation[];
  13328. originalValue: Matrix;
  13329. }): any;
  13330. /** @hidden */
  13331. _processLateAnimationBindingsForQuaternions(holder: {
  13332. totalWeight: number;
  13333. animations: RuntimeAnimation[];
  13334. originalValue: Quaternion;
  13335. }, refQuaternion: Quaternion): Quaternion;
  13336. /** @hidden */
  13337. _processLateAnimationBindings(): void;
  13338. /**
  13339. * Will start the animation sequence of a given target
  13340. * @param target defines the target
  13341. * @param from defines from which frame should animation start
  13342. * @param to defines until which frame should animation run.
  13343. * @param weight defines the weight to apply to the animation (1.0 by default)
  13344. * @param loop defines if the animation loops
  13345. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13346. * @param onAnimationEnd defines the function to be executed when the animation ends
  13347. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13348. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13349. * @param onAnimationLoop defines the callback to call when an animation loops
  13350. * @returns the animatable object created for this animation
  13351. */
  13352. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13353. /**
  13354. * Will start the animation sequence of a given target
  13355. * @param target defines the target
  13356. * @param from defines from which frame should animation start
  13357. * @param to defines until which frame should animation run.
  13358. * @param loop defines if the animation loops
  13359. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13360. * @param onAnimationEnd defines the function to be executed when the animation ends
  13361. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13362. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13363. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13364. * @param onAnimationLoop defines the callback to call when an animation loops
  13365. * @returns the animatable object created for this animation
  13366. */
  13367. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13368. /**
  13369. * Will start the animation sequence of a given target and its hierarchy
  13370. * @param target defines the target
  13371. * @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.
  13372. * @param from defines from which frame should animation start
  13373. * @param to defines until which frame should animation run.
  13374. * @param loop defines if the animation loops
  13375. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13376. * @param onAnimationEnd defines the function to be executed when the animation ends
  13377. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13378. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13379. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13380. * @param onAnimationLoop defines the callback to call when an animation loops
  13381. * @returns the list of created animatables
  13382. */
  13383. 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[];
  13384. /**
  13385. * Begin a new animation on a given node
  13386. * @param target defines the target where the animation will take place
  13387. * @param animations defines the list of animations to start
  13388. * @param from defines the initial value
  13389. * @param to defines the final value
  13390. * @param loop defines if you want animation to loop (off by default)
  13391. * @param speedRatio defines the speed ratio to apply to all animations
  13392. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13393. * @param onAnimationLoop defines the callback to call when an animation loops
  13394. * @returns the list of created animatables
  13395. */
  13396. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13397. /**
  13398. * Begin a new animation on a given node and its hierarchy
  13399. * @param target defines the root node where the animation will take place
  13400. * @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.
  13401. * @param animations defines the list of animations to start
  13402. * @param from defines the initial value
  13403. * @param to defines the final value
  13404. * @param loop defines if you want animation to loop (off by default)
  13405. * @param speedRatio defines the speed ratio to apply to all animations
  13406. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13407. * @param onAnimationLoop defines the callback to call when an animation loops
  13408. * @returns the list of animatables created for all nodes
  13409. */
  13410. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13411. /**
  13412. * Gets the animatable associated with a specific target
  13413. * @param target defines the target of the animatable
  13414. * @returns the required animatable if found
  13415. */
  13416. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13417. /**
  13418. * Gets all animatables associated with a given target
  13419. * @param target defines the target to look animatables for
  13420. * @returns an array of Animatables
  13421. */
  13422. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13423. /**
  13424. * Stops and removes all animations that have been applied to the scene
  13425. */
  13426. stopAllAnimations(): void;
  13427. }
  13428. }
  13429. module "babylonjs/Bones/bone" {
  13430. interface Bone {
  13431. /**
  13432. * Copy an animation range from another bone
  13433. * @param source defines the source bone
  13434. * @param rangeName defines the range name to copy
  13435. * @param frameOffset defines the frame offset
  13436. * @param rescaleAsRequired defines if rescaling must be applied if required
  13437. * @param skelDimensionsRatio defines the scaling ratio
  13438. * @returns true if operation was successful
  13439. */
  13440. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13441. }
  13442. }
  13443. }
  13444. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13445. /**
  13446. * Class used to override all child animations of a given target
  13447. */
  13448. export class AnimationPropertiesOverride {
  13449. /**
  13450. * Gets or sets a value indicating if animation blending must be used
  13451. */
  13452. enableBlending: boolean;
  13453. /**
  13454. * Gets or sets the blending speed to use when enableBlending is true
  13455. */
  13456. blendingSpeed: number;
  13457. /**
  13458. * Gets or sets the default loop mode to use
  13459. */
  13460. loopMode: number;
  13461. }
  13462. }
  13463. declare module "babylonjs/Bones/skeleton" {
  13464. import { Bone } from "babylonjs/Bones/bone";
  13465. import { Observable } from "babylonjs/Misc/observable";
  13466. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13467. import { Scene } from "babylonjs/scene";
  13468. import { Nullable } from "babylonjs/types";
  13469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13470. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13471. import { Animatable } from "babylonjs/Animations/animatable";
  13472. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13473. import { Animation } from "babylonjs/Animations/animation";
  13474. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13475. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13476. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13477. /**
  13478. * Class used to handle skinning animations
  13479. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13480. */
  13481. export class Skeleton implements IAnimatable {
  13482. /** defines the skeleton name */
  13483. name: string;
  13484. /** defines the skeleton Id */
  13485. id: string;
  13486. /**
  13487. * Defines the list of child bones
  13488. */
  13489. bones: Bone[];
  13490. /**
  13491. * Defines an estimate of the dimension of the skeleton at rest
  13492. */
  13493. dimensionsAtRest: Vector3;
  13494. /**
  13495. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13496. */
  13497. needInitialSkinMatrix: boolean;
  13498. /**
  13499. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13500. */
  13501. overrideMesh: Nullable<AbstractMesh>;
  13502. /**
  13503. * Gets the list of animations attached to this skeleton
  13504. */
  13505. animations: Array<Animation>;
  13506. private _scene;
  13507. private _isDirty;
  13508. private _transformMatrices;
  13509. private _transformMatrixTexture;
  13510. private _meshesWithPoseMatrix;
  13511. private _animatables;
  13512. private _identity;
  13513. private _synchronizedWithMesh;
  13514. private _ranges;
  13515. private _lastAbsoluteTransformsUpdateId;
  13516. private _canUseTextureForBones;
  13517. private _uniqueId;
  13518. /** @hidden */
  13519. _numBonesWithLinkedTransformNode: number;
  13520. /** @hidden */
  13521. _hasWaitingData: Nullable<boolean>;
  13522. /**
  13523. * Specifies if the skeleton should be serialized
  13524. */
  13525. doNotSerialize: boolean;
  13526. private _useTextureToStoreBoneMatrices;
  13527. /**
  13528. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13529. * Please note that this option is not available if the hardware does not support it
  13530. */
  13531. useTextureToStoreBoneMatrices: boolean;
  13532. private _animationPropertiesOverride;
  13533. /**
  13534. * Gets or sets the animation properties override
  13535. */
  13536. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13537. /**
  13538. * List of inspectable custom properties (used by the Inspector)
  13539. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13540. */
  13541. inspectableCustomProperties: IInspectable[];
  13542. /**
  13543. * An observable triggered before computing the skeleton's matrices
  13544. */
  13545. onBeforeComputeObservable: Observable<Skeleton>;
  13546. /**
  13547. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13548. */
  13549. readonly isUsingTextureForMatrices: boolean;
  13550. /**
  13551. * Gets the unique ID of this skeleton
  13552. */
  13553. readonly uniqueId: number;
  13554. /**
  13555. * Creates a new skeleton
  13556. * @param name defines the skeleton name
  13557. * @param id defines the skeleton Id
  13558. * @param scene defines the hosting scene
  13559. */
  13560. constructor(
  13561. /** defines the skeleton name */
  13562. name: string,
  13563. /** defines the skeleton Id */
  13564. id: string, scene: Scene);
  13565. /**
  13566. * Gets the current object class name.
  13567. * @return the class name
  13568. */
  13569. getClassName(): string;
  13570. /**
  13571. * Returns an array containing the root bones
  13572. * @returns an array containing the root bones
  13573. */
  13574. getChildren(): Array<Bone>;
  13575. /**
  13576. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13577. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13578. * @returns a Float32Array containing matrices data
  13579. */
  13580. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13581. /**
  13582. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13583. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13584. * @returns a raw texture containing the data
  13585. */
  13586. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13587. /**
  13588. * Gets the current hosting scene
  13589. * @returns a scene object
  13590. */
  13591. getScene(): Scene;
  13592. /**
  13593. * Gets a string representing the current skeleton data
  13594. * @param fullDetails defines a boolean indicating if we want a verbose version
  13595. * @returns a string representing the current skeleton data
  13596. */
  13597. toString(fullDetails?: boolean): string;
  13598. /**
  13599. * Get bone's index searching by name
  13600. * @param name defines bone's name to search for
  13601. * @return the indice of the bone. Returns -1 if not found
  13602. */
  13603. getBoneIndexByName(name: string): number;
  13604. /**
  13605. * Creater a new animation range
  13606. * @param name defines the name of the range
  13607. * @param from defines the start key
  13608. * @param to defines the end key
  13609. */
  13610. createAnimationRange(name: string, from: number, to: number): void;
  13611. /**
  13612. * Delete a specific animation range
  13613. * @param name defines the name of the range
  13614. * @param deleteFrames defines if frames must be removed as well
  13615. */
  13616. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13617. /**
  13618. * Gets a specific animation range
  13619. * @param name defines the name of the range to look for
  13620. * @returns the requested animation range or null if not found
  13621. */
  13622. getAnimationRange(name: string): Nullable<AnimationRange>;
  13623. /**
  13624. * Gets the list of all animation ranges defined on this skeleton
  13625. * @returns an array
  13626. */
  13627. getAnimationRanges(): Nullable<AnimationRange>[];
  13628. /**
  13629. * Copy animation range from a source skeleton.
  13630. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13631. * @param source defines the source skeleton
  13632. * @param name defines the name of the range to copy
  13633. * @param rescaleAsRequired defines if rescaling must be applied if required
  13634. * @returns true if operation was successful
  13635. */
  13636. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13637. /**
  13638. * Forces the skeleton to go to rest pose
  13639. */
  13640. returnToRest(): void;
  13641. private _getHighestAnimationFrame;
  13642. /**
  13643. * Begin a specific animation range
  13644. * @param name defines the name of the range to start
  13645. * @param loop defines if looping must be turned on (false by default)
  13646. * @param speedRatio defines the speed ratio to apply (1 by default)
  13647. * @param onAnimationEnd defines a callback which will be called when animation will end
  13648. * @returns a new animatable
  13649. */
  13650. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13651. /** @hidden */
  13652. _markAsDirty(): void;
  13653. /** @hidden */
  13654. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13655. /** @hidden */
  13656. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13657. private _computeTransformMatrices;
  13658. /**
  13659. * Build all resources required to render a skeleton
  13660. */
  13661. prepare(): void;
  13662. /**
  13663. * Gets the list of animatables currently running for this skeleton
  13664. * @returns an array of animatables
  13665. */
  13666. getAnimatables(): IAnimatable[];
  13667. /**
  13668. * Clone the current skeleton
  13669. * @param name defines the name of the new skeleton
  13670. * @param id defines the id of the new skeleton
  13671. * @returns the new skeleton
  13672. */
  13673. clone(name: string, id: string): Skeleton;
  13674. /**
  13675. * Enable animation blending for this skeleton
  13676. * @param blendingSpeed defines the blending speed to apply
  13677. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13678. */
  13679. enableBlending(blendingSpeed?: number): void;
  13680. /**
  13681. * Releases all resources associated with the current skeleton
  13682. */
  13683. dispose(): void;
  13684. /**
  13685. * Serialize the skeleton in a JSON object
  13686. * @returns a JSON object
  13687. */
  13688. serialize(): any;
  13689. /**
  13690. * Creates a new skeleton from serialized data
  13691. * @param parsedSkeleton defines the serialized data
  13692. * @param scene defines the hosting scene
  13693. * @returns a new skeleton
  13694. */
  13695. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13696. /**
  13697. * Compute all node absolute transforms
  13698. * @param forceUpdate defines if computation must be done even if cache is up to date
  13699. */
  13700. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13701. /**
  13702. * Gets the root pose matrix
  13703. * @returns a matrix
  13704. */
  13705. getPoseMatrix(): Nullable<Matrix>;
  13706. /**
  13707. * Sorts bones per internal index
  13708. */
  13709. sortBones(): void;
  13710. private _sortBones;
  13711. }
  13712. }
  13713. declare module "babylonjs/Bones/bone" {
  13714. import { Skeleton } from "babylonjs/Bones/skeleton";
  13715. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13716. import { Nullable } from "babylonjs/types";
  13717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13718. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13719. import { Node } from "babylonjs/node";
  13720. import { Space } from "babylonjs/Maths/math.axis";
  13721. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13722. /**
  13723. * Class used to store bone information
  13724. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13725. */
  13726. export class Bone extends Node {
  13727. /**
  13728. * defines the bone name
  13729. */
  13730. name: string;
  13731. private static _tmpVecs;
  13732. private static _tmpQuat;
  13733. private static _tmpMats;
  13734. /**
  13735. * Gets the list of child bones
  13736. */
  13737. children: Bone[];
  13738. /** Gets the animations associated with this bone */
  13739. animations: import("babylonjs/Animations/animation").Animation[];
  13740. /**
  13741. * Gets or sets bone length
  13742. */
  13743. length: number;
  13744. /**
  13745. * @hidden Internal only
  13746. * Set this value to map this bone to a different index in the transform matrices
  13747. * Set this value to -1 to exclude the bone from the transform matrices
  13748. */
  13749. _index: Nullable<number>;
  13750. private _skeleton;
  13751. private _localMatrix;
  13752. private _restPose;
  13753. private _baseMatrix;
  13754. private _absoluteTransform;
  13755. private _invertedAbsoluteTransform;
  13756. private _parent;
  13757. private _scalingDeterminant;
  13758. private _worldTransform;
  13759. private _localScaling;
  13760. private _localRotation;
  13761. private _localPosition;
  13762. private _needToDecompose;
  13763. private _needToCompose;
  13764. /** @hidden */
  13765. _linkedTransformNode: Nullable<TransformNode>;
  13766. /** @hidden */
  13767. _waitingTransformNodeId: Nullable<string>;
  13768. /** @hidden */
  13769. /** @hidden */
  13770. _matrix: Matrix;
  13771. /**
  13772. * Create a new bone
  13773. * @param name defines the bone name
  13774. * @param skeleton defines the parent skeleton
  13775. * @param parentBone defines the parent (can be null if the bone is the root)
  13776. * @param localMatrix defines the local matrix
  13777. * @param restPose defines the rest pose matrix
  13778. * @param baseMatrix defines the base matrix
  13779. * @param index defines index of the bone in the hiearchy
  13780. */
  13781. constructor(
  13782. /**
  13783. * defines the bone name
  13784. */
  13785. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13786. /**
  13787. * Gets the current object class name.
  13788. * @return the class name
  13789. */
  13790. getClassName(): string;
  13791. /**
  13792. * Gets the parent skeleton
  13793. * @returns a skeleton
  13794. */
  13795. getSkeleton(): Skeleton;
  13796. /**
  13797. * Gets parent bone
  13798. * @returns a bone or null if the bone is the root of the bone hierarchy
  13799. */
  13800. getParent(): Nullable<Bone>;
  13801. /**
  13802. * Returns an array containing the root bones
  13803. * @returns an array containing the root bones
  13804. */
  13805. getChildren(): Array<Bone>;
  13806. /**
  13807. * Sets the parent bone
  13808. * @param parent defines the parent (can be null if the bone is the root)
  13809. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13810. */
  13811. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13812. /**
  13813. * Gets the local matrix
  13814. * @returns a matrix
  13815. */
  13816. getLocalMatrix(): Matrix;
  13817. /**
  13818. * Gets the base matrix (initial matrix which remains unchanged)
  13819. * @returns a matrix
  13820. */
  13821. getBaseMatrix(): Matrix;
  13822. /**
  13823. * Gets the rest pose matrix
  13824. * @returns a matrix
  13825. */
  13826. getRestPose(): Matrix;
  13827. /**
  13828. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13829. */
  13830. getWorldMatrix(): Matrix;
  13831. /**
  13832. * Sets the local matrix to rest pose matrix
  13833. */
  13834. returnToRest(): void;
  13835. /**
  13836. * Gets the inverse of the absolute transform matrix.
  13837. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13838. * @returns a matrix
  13839. */
  13840. getInvertedAbsoluteTransform(): Matrix;
  13841. /**
  13842. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13843. * @returns a matrix
  13844. */
  13845. getAbsoluteTransform(): Matrix;
  13846. /**
  13847. * Links with the given transform node.
  13848. * The local matrix of this bone is copied from the transform node every frame.
  13849. * @param transformNode defines the transform node to link to
  13850. */
  13851. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13852. /**
  13853. * Gets the node used to drive the bone's transformation
  13854. * @returns a transform node or null
  13855. */
  13856. getTransformNode(): Nullable<TransformNode>;
  13857. /** Gets or sets current position (in local space) */
  13858. position: Vector3;
  13859. /** Gets or sets current rotation (in local space) */
  13860. rotation: Vector3;
  13861. /** Gets or sets current rotation quaternion (in local space) */
  13862. rotationQuaternion: Quaternion;
  13863. /** Gets or sets current scaling (in local space) */
  13864. scaling: Vector3;
  13865. /**
  13866. * Gets the animation properties override
  13867. */
  13868. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13869. private _decompose;
  13870. private _compose;
  13871. /**
  13872. * Update the base and local matrices
  13873. * @param matrix defines the new base or local matrix
  13874. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13875. * @param updateLocalMatrix defines if the local matrix should be updated
  13876. */
  13877. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13878. /** @hidden */
  13879. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13880. /**
  13881. * Flag the bone as dirty (Forcing it to update everything)
  13882. */
  13883. markAsDirty(): void;
  13884. /** @hidden */
  13885. _markAsDirtyAndCompose(): void;
  13886. private _markAsDirtyAndDecompose;
  13887. /**
  13888. * Translate the bone in local or world space
  13889. * @param vec The amount to translate the bone
  13890. * @param space The space that the translation is in
  13891. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13892. */
  13893. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13894. /**
  13895. * Set the postion of the bone in local or world space
  13896. * @param position The position to set the bone
  13897. * @param space The space that the position is in
  13898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13899. */
  13900. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13901. /**
  13902. * Set the absolute position of the bone (world space)
  13903. * @param position The position to set the bone
  13904. * @param mesh The mesh that this bone is attached to
  13905. */
  13906. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13907. /**
  13908. * Scale the bone on the x, y and z axes (in local space)
  13909. * @param x The amount to scale the bone on the x axis
  13910. * @param y The amount to scale the bone on the y axis
  13911. * @param z The amount to scale the bone on the z axis
  13912. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13913. */
  13914. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13915. /**
  13916. * Set the bone scaling in local space
  13917. * @param scale defines the scaling vector
  13918. */
  13919. setScale(scale: Vector3): void;
  13920. /**
  13921. * Gets the current scaling in local space
  13922. * @returns the current scaling vector
  13923. */
  13924. getScale(): Vector3;
  13925. /**
  13926. * Gets the current scaling in local space and stores it in a target vector
  13927. * @param result defines the target vector
  13928. */
  13929. getScaleToRef(result: Vector3): void;
  13930. /**
  13931. * Set the yaw, pitch, and roll of the bone in local or world space
  13932. * @param yaw The rotation of the bone on the y axis
  13933. * @param pitch The rotation of the bone on the x axis
  13934. * @param roll The rotation of the bone on the z axis
  13935. * @param space The space that the axes of rotation are in
  13936. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13937. */
  13938. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13939. /**
  13940. * Add a rotation to the bone on an axis in local or world space
  13941. * @param axis The axis to rotate the bone on
  13942. * @param amount The amount to rotate the bone
  13943. * @param space The space that the axis is in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. */
  13946. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13947. /**
  13948. * Set the rotation of the bone to a particular axis angle in local or world space
  13949. * @param axis The axis to rotate the bone on
  13950. * @param angle The angle that the bone should be rotated to
  13951. * @param space The space that the axis is in
  13952. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13953. */
  13954. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13955. /**
  13956. * Set the euler rotation of the bone in local of world space
  13957. * @param rotation The euler rotation that the bone should be set to
  13958. * @param space The space that the rotation is in
  13959. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13960. */
  13961. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13962. /**
  13963. * Set the quaternion rotation of the bone in local of world space
  13964. * @param quat The quaternion rotation that the bone should be set to
  13965. * @param space The space that the rotation is in
  13966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13967. */
  13968. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13969. /**
  13970. * Set the rotation matrix of the bone in local of world space
  13971. * @param rotMat The rotation matrix that the bone should be set to
  13972. * @param space The space that the rotation is in
  13973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13974. */
  13975. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13976. private _rotateWithMatrix;
  13977. private _getNegativeRotationToRef;
  13978. /**
  13979. * Get the position of the bone in local or world space
  13980. * @param space The space that the returned position is in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. * @returns The position of the bone
  13983. */
  13984. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13985. /**
  13986. * Copy the position of the bone to a vector3 in local or world space
  13987. * @param space The space that the returned position is in
  13988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13989. * @param result The vector3 to copy the position to
  13990. */
  13991. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13992. /**
  13993. * Get the absolute position of the bone (world space)
  13994. * @param mesh The mesh that this bone is attached to
  13995. * @returns The absolute position of the bone
  13996. */
  13997. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13998. /**
  13999. * Copy the absolute position of the bone (world space) to the result param
  14000. * @param mesh The mesh that this bone is attached to
  14001. * @param result The vector3 to copy the absolute position to
  14002. */
  14003. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14004. /**
  14005. * Compute the absolute transforms of this bone and its children
  14006. */
  14007. computeAbsoluteTransforms(): void;
  14008. /**
  14009. * Get the world direction from an axis that is in the local space of the bone
  14010. * @param localAxis The local direction that is used to compute the world direction
  14011. * @param mesh The mesh that this bone is attached to
  14012. * @returns The world direction
  14013. */
  14014. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14015. /**
  14016. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14017. * @param localAxis The local direction that is used to compute the world direction
  14018. * @param mesh The mesh that this bone is attached to
  14019. * @param result The vector3 that the world direction will be copied to
  14020. */
  14021. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14022. /**
  14023. * Get the euler rotation of the bone in local or world space
  14024. * @param space The space that the rotation should be in
  14025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14026. * @returns The euler rotation
  14027. */
  14028. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14029. /**
  14030. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14031. * @param space The space that the rotation should be in
  14032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14033. * @param result The vector3 that the rotation should be copied to
  14034. */
  14035. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14036. /**
  14037. * Get the quaternion rotation of the bone in either local or world space
  14038. * @param space The space that the rotation should be in
  14039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14040. * @returns The quaternion rotation
  14041. */
  14042. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14043. /**
  14044. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14045. * @param space The space that the rotation should be in
  14046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14047. * @param result The quaternion that the rotation should be copied to
  14048. */
  14049. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14050. /**
  14051. * Get the rotation matrix of the bone in local or world space
  14052. * @param space The space that the rotation should be in
  14053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14054. * @returns The rotation matrix
  14055. */
  14056. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14057. /**
  14058. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14059. * @param space The space that the rotation should be in
  14060. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14061. * @param result The quaternion that the rotation should be copied to
  14062. */
  14063. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14064. /**
  14065. * Get the world position of a point that is in the local space of the bone
  14066. * @param position The local position
  14067. * @param mesh The mesh that this bone is attached to
  14068. * @returns The world position
  14069. */
  14070. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14071. /**
  14072. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14073. * @param position The local position
  14074. * @param mesh The mesh that this bone is attached to
  14075. * @param result The vector3 that the world position should be copied to
  14076. */
  14077. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14078. /**
  14079. * Get the local position of a point that is in world space
  14080. * @param position The world position
  14081. * @param mesh The mesh that this bone is attached to
  14082. * @returns The local position
  14083. */
  14084. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14085. /**
  14086. * Get the local position of a point that is in world space and copy it to the result param
  14087. * @param position The world position
  14088. * @param mesh The mesh that this bone is attached to
  14089. * @param result The vector3 that the local position should be copied to
  14090. */
  14091. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14092. }
  14093. }
  14094. declare module "babylonjs/Meshes/transformNode" {
  14095. import { DeepImmutable } from "babylonjs/types";
  14096. import { Observable } from "babylonjs/Misc/observable";
  14097. import { Nullable } from "babylonjs/types";
  14098. import { Camera } from "babylonjs/Cameras/camera";
  14099. import { Scene } from "babylonjs/scene";
  14100. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14101. import { Node } from "babylonjs/node";
  14102. import { Bone } from "babylonjs/Bones/bone";
  14103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14104. import { Space } from "babylonjs/Maths/math.axis";
  14105. /**
  14106. * 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.
  14107. * @see https://doc.babylonjs.com/how_to/transformnode
  14108. */
  14109. export class TransformNode extends Node {
  14110. /**
  14111. * Object will not rotate to face the camera
  14112. */
  14113. static BILLBOARDMODE_NONE: number;
  14114. /**
  14115. * Object will rotate to face the camera but only on the x axis
  14116. */
  14117. static BILLBOARDMODE_X: number;
  14118. /**
  14119. * Object will rotate to face the camera but only on the y axis
  14120. */
  14121. static BILLBOARDMODE_Y: number;
  14122. /**
  14123. * Object will rotate to face the camera but only on the z axis
  14124. */
  14125. static BILLBOARDMODE_Z: number;
  14126. /**
  14127. * Object will rotate to face the camera
  14128. */
  14129. static BILLBOARDMODE_ALL: number;
  14130. /**
  14131. * Object will rotate to face the camera's position instead of orientation
  14132. */
  14133. static BILLBOARDMODE_USE_POSITION: number;
  14134. private _forward;
  14135. private _forwardInverted;
  14136. private _up;
  14137. private _right;
  14138. private _rightInverted;
  14139. private _position;
  14140. private _rotation;
  14141. private _rotationQuaternion;
  14142. protected _scaling: Vector3;
  14143. protected _isDirty: boolean;
  14144. private _transformToBoneReferal;
  14145. private _isAbsoluteSynced;
  14146. private _billboardMode;
  14147. /**
  14148. * Gets or sets the billboard mode. Default is 0.
  14149. *
  14150. * | Value | Type | Description |
  14151. * | --- | --- | --- |
  14152. * | 0 | BILLBOARDMODE_NONE | |
  14153. * | 1 | BILLBOARDMODE_X | |
  14154. * | 2 | BILLBOARDMODE_Y | |
  14155. * | 4 | BILLBOARDMODE_Z | |
  14156. * | 7 | BILLBOARDMODE_ALL | |
  14157. *
  14158. */
  14159. billboardMode: number;
  14160. private _preserveParentRotationForBillboard;
  14161. /**
  14162. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14163. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14164. */
  14165. preserveParentRotationForBillboard: boolean;
  14166. /**
  14167. * 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
  14168. */
  14169. scalingDeterminant: number;
  14170. private _infiniteDistance;
  14171. /**
  14172. * Gets or sets the distance of the object to max, often used by skybox
  14173. */
  14174. infiniteDistance: boolean;
  14175. /**
  14176. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14177. * By default the system will update normals to compensate
  14178. */
  14179. ignoreNonUniformScaling: boolean;
  14180. /**
  14181. * 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
  14182. */
  14183. reIntegrateRotationIntoRotationQuaternion: boolean;
  14184. /** @hidden */
  14185. _poseMatrix: Nullable<Matrix>;
  14186. /** @hidden */
  14187. _localMatrix: Matrix;
  14188. private _usePivotMatrix;
  14189. private _absolutePosition;
  14190. private _absoluteScaling;
  14191. private _absoluteRotationQuaternion;
  14192. private _pivotMatrix;
  14193. private _pivotMatrixInverse;
  14194. protected _postMultiplyPivotMatrix: boolean;
  14195. protected _isWorldMatrixFrozen: boolean;
  14196. /** @hidden */
  14197. _indexInSceneTransformNodesArray: number;
  14198. /**
  14199. * An event triggered after the world matrix is updated
  14200. */
  14201. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14202. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14203. /**
  14204. * Gets a string identifying the name of the class
  14205. * @returns "TransformNode" string
  14206. */
  14207. getClassName(): string;
  14208. /**
  14209. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14210. */
  14211. position: Vector3;
  14212. /**
  14213. * 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)).
  14214. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14215. */
  14216. rotation: Vector3;
  14217. /**
  14218. * 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)).
  14219. */
  14220. scaling: Vector3;
  14221. /**
  14222. * 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).
  14223. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14224. */
  14225. rotationQuaternion: Nullable<Quaternion>;
  14226. /**
  14227. * The forward direction of that transform in world space.
  14228. */
  14229. readonly forward: Vector3;
  14230. /**
  14231. * The up direction of that transform in world space.
  14232. */
  14233. readonly up: Vector3;
  14234. /**
  14235. * The right direction of that transform in world space.
  14236. */
  14237. readonly right: Vector3;
  14238. /**
  14239. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14240. * @param matrix the matrix to copy the pose from
  14241. * @returns this TransformNode.
  14242. */
  14243. updatePoseMatrix(matrix: Matrix): TransformNode;
  14244. /**
  14245. * Returns the mesh Pose matrix.
  14246. * @returns the pose matrix
  14247. */
  14248. getPoseMatrix(): Matrix;
  14249. /** @hidden */
  14250. _isSynchronized(): boolean;
  14251. /** @hidden */
  14252. _initCache(): void;
  14253. /**
  14254. * Flag the transform node as dirty (Forcing it to update everything)
  14255. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14256. * @returns this transform node
  14257. */
  14258. markAsDirty(property: string): TransformNode;
  14259. /**
  14260. * Returns the current mesh absolute position.
  14261. * Returns a Vector3.
  14262. */
  14263. readonly absolutePosition: Vector3;
  14264. /**
  14265. * Returns the current mesh absolute scaling.
  14266. * Returns a Vector3.
  14267. */
  14268. readonly absoluteScaling: Vector3;
  14269. /**
  14270. * Returns the current mesh absolute rotation.
  14271. * Returns a Quaternion.
  14272. */
  14273. readonly absoluteRotationQuaternion: Quaternion;
  14274. /**
  14275. * Sets a new matrix to apply before all other transformation
  14276. * @param matrix defines the transform matrix
  14277. * @returns the current TransformNode
  14278. */
  14279. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14280. /**
  14281. * Sets a new pivot matrix to the current node
  14282. * @param matrix defines the new pivot matrix to use
  14283. * @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
  14284. * @returns the current TransformNode
  14285. */
  14286. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14287. /**
  14288. * Returns the mesh pivot matrix.
  14289. * Default : Identity.
  14290. * @returns the matrix
  14291. */
  14292. getPivotMatrix(): Matrix;
  14293. /**
  14294. * Instantiate (when possible) or clone that node with its hierarchy
  14295. * @param newParent defines the new parent to use for the instance (or clone)
  14296. * @returns an instance (or a clone) of the current node with its hiearchy
  14297. */
  14298. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14299. /**
  14300. * Prevents the World matrix to be computed any longer
  14301. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14302. * @returns the TransformNode.
  14303. */
  14304. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14305. /**
  14306. * Allows back the World matrix computation.
  14307. * @returns the TransformNode.
  14308. */
  14309. unfreezeWorldMatrix(): this;
  14310. /**
  14311. * True if the World matrix has been frozen.
  14312. */
  14313. readonly isWorldMatrixFrozen: boolean;
  14314. /**
  14315. * Retuns the mesh absolute position in the World.
  14316. * @returns a Vector3.
  14317. */
  14318. getAbsolutePosition(): Vector3;
  14319. /**
  14320. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14321. * @param absolutePosition the absolute position to set
  14322. * @returns the TransformNode.
  14323. */
  14324. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14325. /**
  14326. * Sets the mesh position in its local space.
  14327. * @param vector3 the position to set in localspace
  14328. * @returns the TransformNode.
  14329. */
  14330. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14331. /**
  14332. * Returns the mesh position in the local space from the current World matrix values.
  14333. * @returns a new Vector3.
  14334. */
  14335. getPositionExpressedInLocalSpace(): Vector3;
  14336. /**
  14337. * Translates the mesh along the passed Vector3 in its local space.
  14338. * @param vector3 the distance to translate in localspace
  14339. * @returns the TransformNode.
  14340. */
  14341. locallyTranslate(vector3: Vector3): TransformNode;
  14342. private static _lookAtVectorCache;
  14343. /**
  14344. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14345. * @param targetPoint the position (must be in same space as current mesh) to look at
  14346. * @param yawCor optional yaw (y-axis) correction in radians
  14347. * @param pitchCor optional pitch (x-axis) correction in radians
  14348. * @param rollCor optional roll (z-axis) correction in radians
  14349. * @param space the choosen space of the target
  14350. * @returns the TransformNode.
  14351. */
  14352. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14353. /**
  14354. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14355. * This Vector3 is expressed in the World space.
  14356. * @param localAxis axis to rotate
  14357. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14358. */
  14359. getDirection(localAxis: Vector3): Vector3;
  14360. /**
  14361. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14362. * localAxis is expressed in the mesh local space.
  14363. * result is computed in the Wordl space from the mesh World matrix.
  14364. * @param localAxis axis to rotate
  14365. * @param result the resulting transformnode
  14366. * @returns this TransformNode.
  14367. */
  14368. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14369. /**
  14370. * Sets this transform node rotation to the given local axis.
  14371. * @param localAxis the axis in local space
  14372. * @param yawCor optional yaw (y-axis) correction in radians
  14373. * @param pitchCor optional pitch (x-axis) correction in radians
  14374. * @param rollCor optional roll (z-axis) correction in radians
  14375. * @returns this TransformNode
  14376. */
  14377. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14378. /**
  14379. * Sets a new pivot point to the current node
  14380. * @param point defines the new pivot point to use
  14381. * @param space defines if the point is in world or local space (local by default)
  14382. * @returns the current TransformNode
  14383. */
  14384. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14385. /**
  14386. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14387. * @returns the pivot point
  14388. */
  14389. getPivotPoint(): Vector3;
  14390. /**
  14391. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14392. * @param result the vector3 to store the result
  14393. * @returns this TransformNode.
  14394. */
  14395. getPivotPointToRef(result: Vector3): TransformNode;
  14396. /**
  14397. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14398. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14399. */
  14400. getAbsolutePivotPoint(): Vector3;
  14401. /**
  14402. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14403. * @param result vector3 to store the result
  14404. * @returns this TransformNode.
  14405. */
  14406. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14407. /**
  14408. * Defines the passed node as the parent of the current node.
  14409. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14410. * @see https://doc.babylonjs.com/how_to/parenting
  14411. * @param node the node ot set as the parent
  14412. * @returns this TransformNode.
  14413. */
  14414. setParent(node: Nullable<Node>): TransformNode;
  14415. private _nonUniformScaling;
  14416. /**
  14417. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14418. */
  14419. readonly nonUniformScaling: boolean;
  14420. /** @hidden */
  14421. _updateNonUniformScalingState(value: boolean): boolean;
  14422. /**
  14423. * Attach the current TransformNode to another TransformNode associated with a bone
  14424. * @param bone Bone affecting the TransformNode
  14425. * @param affectedTransformNode TransformNode associated with the bone
  14426. * @returns this object
  14427. */
  14428. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14429. /**
  14430. * Detach the transform node if its associated with a bone
  14431. * @returns this object
  14432. */
  14433. detachFromBone(): TransformNode;
  14434. private static _rotationAxisCache;
  14435. /**
  14436. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14437. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14438. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14439. * The passed axis is also normalized.
  14440. * @param axis the axis to rotate around
  14441. * @param amount the amount to rotate in radians
  14442. * @param space Space to rotate in (Default: local)
  14443. * @returns the TransformNode.
  14444. */
  14445. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14446. /**
  14447. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14448. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14449. * The passed axis is also normalized. .
  14450. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14451. * @param point the point to rotate around
  14452. * @param axis the axis to rotate around
  14453. * @param amount the amount to rotate in radians
  14454. * @returns the TransformNode
  14455. */
  14456. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14457. /**
  14458. * Translates the mesh along the axis vector for the passed distance in the given space.
  14459. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14460. * @param axis the axis to translate in
  14461. * @param distance the distance to translate
  14462. * @param space Space to rotate in (Default: local)
  14463. * @returns the TransformNode.
  14464. */
  14465. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14466. /**
  14467. * Adds a rotation step to the mesh current rotation.
  14468. * x, y, z are Euler angles expressed in radians.
  14469. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14470. * This means this rotation is made in the mesh local space only.
  14471. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14472. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14473. * ```javascript
  14474. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14475. * ```
  14476. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14477. * 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.
  14478. * @param x Rotation to add
  14479. * @param y Rotation to add
  14480. * @param z Rotation to add
  14481. * @returns the TransformNode.
  14482. */
  14483. addRotation(x: number, y: number, z: number): TransformNode;
  14484. /**
  14485. * @hidden
  14486. */
  14487. protected _getEffectiveParent(): Nullable<Node>;
  14488. /**
  14489. * Computes the world matrix of the node
  14490. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14491. * @returns the world matrix
  14492. */
  14493. computeWorldMatrix(force?: boolean): Matrix;
  14494. protected _afterComputeWorldMatrix(): void;
  14495. /**
  14496. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14497. * @param func callback function to add
  14498. *
  14499. * @returns the TransformNode.
  14500. */
  14501. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14502. /**
  14503. * Removes a registered callback function.
  14504. * @param func callback function to remove
  14505. * @returns the TransformNode.
  14506. */
  14507. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14508. /**
  14509. * Gets the position of the current mesh in camera space
  14510. * @param camera defines the camera to use
  14511. * @returns a position
  14512. */
  14513. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14514. /**
  14515. * Returns the distance from the mesh to the active camera
  14516. * @param camera defines the camera to use
  14517. * @returns the distance
  14518. */
  14519. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14520. /**
  14521. * Clone the current transform node
  14522. * @param name Name of the new clone
  14523. * @param newParent New parent for the clone
  14524. * @param doNotCloneChildren Do not clone children hierarchy
  14525. * @returns the new transform node
  14526. */
  14527. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14528. /**
  14529. * Serializes the objects information.
  14530. * @param currentSerializationObject defines the object to serialize in
  14531. * @returns the serialized object
  14532. */
  14533. serialize(currentSerializationObject?: any): any;
  14534. /**
  14535. * Returns a new TransformNode object parsed from the source provided.
  14536. * @param parsedTransformNode is the source.
  14537. * @param scene the scne the object belongs to
  14538. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14539. * @returns a new TransformNode object parsed from the source provided.
  14540. */
  14541. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14542. /**
  14543. * Get all child-transformNodes of this node
  14544. * @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
  14545. * @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
  14546. * @returns an array of TransformNode
  14547. */
  14548. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14549. /**
  14550. * Releases resources associated with this transform node.
  14551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14553. */
  14554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14555. /**
  14556. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14557. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14558. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14559. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14560. * @returns the current mesh
  14561. */
  14562. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14563. private _syncAbsoluteScalingAndRotation;
  14564. }
  14565. }
  14566. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14567. import { Observable } from "babylonjs/Misc/observable";
  14568. import { Nullable } from "babylonjs/types";
  14569. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14572. import { Ray } from "babylonjs/Culling/ray";
  14573. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14574. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14575. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14576. /**
  14577. * Defines the types of pose enabled controllers that are supported
  14578. */
  14579. export enum PoseEnabledControllerType {
  14580. /**
  14581. * HTC Vive
  14582. */
  14583. VIVE = 0,
  14584. /**
  14585. * Oculus Rift
  14586. */
  14587. OCULUS = 1,
  14588. /**
  14589. * Windows mixed reality
  14590. */
  14591. WINDOWS = 2,
  14592. /**
  14593. * Samsung gear VR
  14594. */
  14595. GEAR_VR = 3,
  14596. /**
  14597. * Google Daydream
  14598. */
  14599. DAYDREAM = 4,
  14600. /**
  14601. * Generic
  14602. */
  14603. GENERIC = 5
  14604. }
  14605. /**
  14606. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14607. */
  14608. export interface MutableGamepadButton {
  14609. /**
  14610. * Value of the button/trigger
  14611. */
  14612. value: number;
  14613. /**
  14614. * If the button/trigger is currently touched
  14615. */
  14616. touched: boolean;
  14617. /**
  14618. * If the button/trigger is currently pressed
  14619. */
  14620. pressed: boolean;
  14621. }
  14622. /**
  14623. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14624. * @hidden
  14625. */
  14626. export interface ExtendedGamepadButton extends GamepadButton {
  14627. /**
  14628. * If the button/trigger is currently pressed
  14629. */
  14630. readonly pressed: boolean;
  14631. /**
  14632. * If the button/trigger is currently touched
  14633. */
  14634. readonly touched: boolean;
  14635. /**
  14636. * Value of the button/trigger
  14637. */
  14638. readonly value: number;
  14639. }
  14640. /** @hidden */
  14641. export interface _GamePadFactory {
  14642. /**
  14643. * Returns wether or not the current gamepad can be created for this type of controller.
  14644. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14645. * @returns true if it can be created, otherwise false
  14646. */
  14647. canCreate(gamepadInfo: any): boolean;
  14648. /**
  14649. * Creates a new instance of the Gamepad.
  14650. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14651. * @returns the new gamepad instance
  14652. */
  14653. create(gamepadInfo: any): Gamepad;
  14654. }
  14655. /**
  14656. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14657. */
  14658. export class PoseEnabledControllerHelper {
  14659. /** @hidden */
  14660. static _ControllerFactories: _GamePadFactory[];
  14661. /** @hidden */
  14662. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14663. /**
  14664. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14665. * @param vrGamepad the gamepad to initialized
  14666. * @returns a vr controller of the type the gamepad identified as
  14667. */
  14668. static InitiateController(vrGamepad: any): Gamepad;
  14669. }
  14670. /**
  14671. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14672. */
  14673. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14674. /**
  14675. * If the controller is used in a webXR session
  14676. */
  14677. isXR: boolean;
  14678. private _deviceRoomPosition;
  14679. private _deviceRoomRotationQuaternion;
  14680. /**
  14681. * The device position in babylon space
  14682. */
  14683. devicePosition: Vector3;
  14684. /**
  14685. * The device rotation in babylon space
  14686. */
  14687. deviceRotationQuaternion: Quaternion;
  14688. /**
  14689. * The scale factor of the device in babylon space
  14690. */
  14691. deviceScaleFactor: number;
  14692. /**
  14693. * (Likely devicePosition should be used instead) The device position in its room space
  14694. */
  14695. position: Vector3;
  14696. /**
  14697. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14698. */
  14699. rotationQuaternion: Quaternion;
  14700. /**
  14701. * The type of controller (Eg. Windows mixed reality)
  14702. */
  14703. controllerType: PoseEnabledControllerType;
  14704. protected _calculatedPosition: Vector3;
  14705. private _calculatedRotation;
  14706. /**
  14707. * The raw pose from the device
  14708. */
  14709. rawPose: DevicePose;
  14710. private _trackPosition;
  14711. private _maxRotationDistFromHeadset;
  14712. private _draggedRoomRotation;
  14713. /**
  14714. * @hidden
  14715. */
  14716. _disableTrackPosition(fixedPosition: Vector3): void;
  14717. /**
  14718. * Internal, the mesh attached to the controller
  14719. * @hidden
  14720. */
  14721. _mesh: Nullable<AbstractMesh>;
  14722. private _poseControlledCamera;
  14723. private _leftHandSystemQuaternion;
  14724. /**
  14725. * Internal, matrix used to convert room space to babylon space
  14726. * @hidden
  14727. */
  14728. _deviceToWorld: Matrix;
  14729. /**
  14730. * Node to be used when casting a ray from the controller
  14731. * @hidden
  14732. */
  14733. _pointingPoseNode: Nullable<TransformNode>;
  14734. /**
  14735. * Name of the child mesh that can be used to cast a ray from the controller
  14736. */
  14737. static readonly POINTING_POSE: string;
  14738. /**
  14739. * Creates a new PoseEnabledController from a gamepad
  14740. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14741. */
  14742. constructor(browserGamepad: any);
  14743. private _workingMatrix;
  14744. /**
  14745. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14746. */
  14747. update(): void;
  14748. /**
  14749. * Updates only the pose device and mesh without doing any button event checking
  14750. */
  14751. protected _updatePoseAndMesh(): void;
  14752. /**
  14753. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14754. * @param poseData raw pose fromthe device
  14755. */
  14756. updateFromDevice(poseData: DevicePose): void;
  14757. /**
  14758. * @hidden
  14759. */
  14760. _meshAttachedObservable: Observable<AbstractMesh>;
  14761. /**
  14762. * Attaches a mesh to the controller
  14763. * @param mesh the mesh to be attached
  14764. */
  14765. attachToMesh(mesh: AbstractMesh): void;
  14766. /**
  14767. * Attaches the controllers mesh to a camera
  14768. * @param camera the camera the mesh should be attached to
  14769. */
  14770. attachToPoseControlledCamera(camera: TargetCamera): void;
  14771. /**
  14772. * Disposes of the controller
  14773. */
  14774. dispose(): void;
  14775. /**
  14776. * The mesh that is attached to the controller
  14777. */
  14778. readonly mesh: Nullable<AbstractMesh>;
  14779. /**
  14780. * Gets the ray of the controller in the direction the controller is pointing
  14781. * @param length the length the resulting ray should be
  14782. * @returns a ray in the direction the controller is pointing
  14783. */
  14784. getForwardRay(length?: number): Ray;
  14785. }
  14786. }
  14787. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14788. import { Observable } from "babylonjs/Misc/observable";
  14789. import { Scene } from "babylonjs/scene";
  14790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14791. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14792. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14793. import { Nullable } from "babylonjs/types";
  14794. /**
  14795. * Defines the WebVRController object that represents controllers tracked in 3D space
  14796. */
  14797. export abstract class WebVRController extends PoseEnabledController {
  14798. /**
  14799. * Internal, the default controller model for the controller
  14800. */
  14801. protected _defaultModel: Nullable<AbstractMesh>;
  14802. /**
  14803. * Fired when the trigger state has changed
  14804. */
  14805. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14806. /**
  14807. * Fired when the main button state has changed
  14808. */
  14809. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14810. /**
  14811. * Fired when the secondary button state has changed
  14812. */
  14813. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14814. /**
  14815. * Fired when the pad state has changed
  14816. */
  14817. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14818. /**
  14819. * Fired when controllers stick values have changed
  14820. */
  14821. onPadValuesChangedObservable: Observable<StickValues>;
  14822. /**
  14823. * Array of button availible on the controller
  14824. */
  14825. protected _buttons: Array<MutableGamepadButton>;
  14826. private _onButtonStateChange;
  14827. /**
  14828. * Fired when a controller button's state has changed
  14829. * @param callback the callback containing the button that was modified
  14830. */
  14831. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14832. /**
  14833. * X and Y axis corresponding to the controllers joystick
  14834. */
  14835. pad: StickValues;
  14836. /**
  14837. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14838. */
  14839. hand: string;
  14840. /**
  14841. * The default controller model for the controller
  14842. */
  14843. readonly defaultModel: Nullable<AbstractMesh>;
  14844. /**
  14845. * Creates a new WebVRController from a gamepad
  14846. * @param vrGamepad the gamepad that the WebVRController should be created from
  14847. */
  14848. constructor(vrGamepad: any);
  14849. /**
  14850. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14851. */
  14852. update(): void;
  14853. /**
  14854. * Function to be called when a button is modified
  14855. */
  14856. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14857. /**
  14858. * Loads a mesh and attaches it to the controller
  14859. * @param scene the scene the mesh should be added to
  14860. * @param meshLoaded callback for when the mesh has been loaded
  14861. */
  14862. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14863. private _setButtonValue;
  14864. private _changes;
  14865. private _checkChanges;
  14866. /**
  14867. * Disposes of th webVRCOntroller
  14868. */
  14869. dispose(): void;
  14870. }
  14871. }
  14872. declare module "babylonjs/Lights/hemisphericLight" {
  14873. import { Nullable } from "babylonjs/types";
  14874. import { Scene } from "babylonjs/scene";
  14875. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14876. import { Color3 } from "babylonjs/Maths/math.color";
  14877. import { Effect } from "babylonjs/Materials/effect";
  14878. import { Light } from "babylonjs/Lights/light";
  14879. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14880. /**
  14881. * The HemisphericLight simulates the ambient environment light,
  14882. * so the passed direction is the light reflection direction, not the incoming direction.
  14883. */
  14884. export class HemisphericLight extends Light {
  14885. /**
  14886. * The groundColor is the light in the opposite direction to the one specified during creation.
  14887. * 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.
  14888. */
  14889. groundColor: Color3;
  14890. /**
  14891. * The light reflection direction, not the incoming direction.
  14892. */
  14893. direction: Vector3;
  14894. /**
  14895. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14896. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14897. * The HemisphericLight can't cast shadows.
  14898. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14899. * @param name The friendly name of the light
  14900. * @param direction The direction of the light reflection
  14901. * @param scene The scene the light belongs to
  14902. */
  14903. constructor(name: string, direction: Vector3, scene: Scene);
  14904. protected _buildUniformLayout(): void;
  14905. /**
  14906. * Returns the string "HemisphericLight".
  14907. * @return The class name
  14908. */
  14909. getClassName(): string;
  14910. /**
  14911. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14912. * Returns the updated direction.
  14913. * @param target The target the direction should point to
  14914. * @return The computed direction
  14915. */
  14916. setDirectionToTarget(target: Vector3): Vector3;
  14917. /**
  14918. * Returns the shadow generator associated to the light.
  14919. * @returns Always null for hemispheric lights because it does not support shadows.
  14920. */
  14921. getShadowGenerator(): Nullable<IShadowGenerator>;
  14922. /**
  14923. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14924. * @param effect The effect to update
  14925. * @param lightIndex The index of the light in the effect to update
  14926. * @returns The hemispheric light
  14927. */
  14928. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14929. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14930. /**
  14931. * Computes the world matrix of the node
  14932. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14933. * @param useWasUpdatedFlag defines a reserved property
  14934. * @returns the world matrix
  14935. */
  14936. computeWorldMatrix(): Matrix;
  14937. /**
  14938. * Returns the integer 3.
  14939. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14940. */
  14941. getTypeID(): number;
  14942. /**
  14943. * Prepares the list of defines specific to the light type.
  14944. * @param defines the list of defines
  14945. * @param lightIndex defines the index of the light for the effect
  14946. */
  14947. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14948. }
  14949. }
  14950. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14951. /** @hidden */
  14952. export var vrMultiviewToSingleviewPixelShader: {
  14953. name: string;
  14954. shader: string;
  14955. };
  14956. }
  14957. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14958. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14959. import { Scene } from "babylonjs/scene";
  14960. /**
  14961. * Renders to multiple views with a single draw call
  14962. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14963. */
  14964. export class MultiviewRenderTarget extends RenderTargetTexture {
  14965. /**
  14966. * Creates a multiview render target
  14967. * @param scene scene used with the render target
  14968. * @param size the size of the render target (used for each view)
  14969. */
  14970. constructor(scene: Scene, size?: number | {
  14971. width: number;
  14972. height: number;
  14973. } | {
  14974. ratio: number;
  14975. });
  14976. /**
  14977. * @hidden
  14978. * @param faceIndex the face index, if its a cube texture
  14979. */
  14980. _bindFrameBuffer(faceIndex?: number): void;
  14981. /**
  14982. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14983. * @returns the view count
  14984. */
  14985. getViewCount(): number;
  14986. }
  14987. }
  14988. declare module "babylonjs/Maths/math.frustum" {
  14989. import { Matrix } from "babylonjs/Maths/math.vector";
  14990. import { DeepImmutable } from "babylonjs/types";
  14991. import { Plane } from "babylonjs/Maths/math.plane";
  14992. /**
  14993. * Represents a camera frustum
  14994. */
  14995. export class Frustum {
  14996. /**
  14997. * Gets the planes representing the frustum
  14998. * @param transform matrix to be applied to the returned planes
  14999. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15000. */
  15001. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15002. /**
  15003. * Gets the near frustum plane transformed by the transform matrix
  15004. * @param transform transformation matrix to be applied to the resulting frustum plane
  15005. * @param frustumPlane the resuling frustum plane
  15006. */
  15007. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15008. /**
  15009. * Gets the far frustum plane transformed by the transform matrix
  15010. * @param transform transformation matrix to be applied to the resulting frustum plane
  15011. * @param frustumPlane the resuling frustum plane
  15012. */
  15013. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15014. /**
  15015. * Gets the left frustum plane transformed by the transform matrix
  15016. * @param transform transformation matrix to be applied to the resulting frustum plane
  15017. * @param frustumPlane the resuling frustum plane
  15018. */
  15019. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15020. /**
  15021. * Gets the right frustum plane transformed by the transform matrix
  15022. * @param transform transformation matrix to be applied to the resulting frustum plane
  15023. * @param frustumPlane the resuling frustum plane
  15024. */
  15025. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15026. /**
  15027. * Gets the top frustum plane transformed by the transform matrix
  15028. * @param transform transformation matrix to be applied to the resulting frustum plane
  15029. * @param frustumPlane the resuling frustum plane
  15030. */
  15031. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15032. /**
  15033. * Gets the bottom frustum plane transformed by the transform matrix
  15034. * @param transform transformation matrix to be applied to the resulting frustum plane
  15035. * @param frustumPlane the resuling frustum plane
  15036. */
  15037. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15038. /**
  15039. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15040. * @param transform transformation matrix to be applied to the resulting frustum planes
  15041. * @param frustumPlanes the resuling frustum planes
  15042. */
  15043. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15044. }
  15045. }
  15046. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15047. import { Camera } from "babylonjs/Cameras/camera";
  15048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15049. import { Nullable } from "babylonjs/types";
  15050. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15051. import { Matrix } from "babylonjs/Maths/math.vector";
  15052. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15053. module "babylonjs/Engines/engine" {
  15054. interface Engine {
  15055. /**
  15056. * Creates a new multiview render target
  15057. * @param width defines the width of the texture
  15058. * @param height defines the height of the texture
  15059. * @returns the created multiview texture
  15060. */
  15061. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15062. /**
  15063. * Binds a multiview framebuffer to be drawn to
  15064. * @param multiviewTexture texture to bind
  15065. */
  15066. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15067. }
  15068. }
  15069. module "babylonjs/Cameras/camera" {
  15070. interface Camera {
  15071. /**
  15072. * @hidden
  15073. * 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)
  15074. */
  15075. _useMultiviewToSingleView: boolean;
  15076. /**
  15077. * @hidden
  15078. * 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)
  15079. */
  15080. _multiviewTexture: Nullable<RenderTargetTexture>;
  15081. /**
  15082. * @hidden
  15083. * ensures the multiview texture of the camera exists and has the specified width/height
  15084. * @param width height to set on the multiview texture
  15085. * @param height width to set on the multiview texture
  15086. */
  15087. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15088. }
  15089. }
  15090. module "babylonjs/scene" {
  15091. interface Scene {
  15092. /** @hidden */
  15093. _transformMatrixR: Matrix;
  15094. /** @hidden */
  15095. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15096. /** @hidden */
  15097. _createMultiviewUbo(): void;
  15098. /** @hidden */
  15099. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15100. /** @hidden */
  15101. _renderMultiviewToSingleView(camera: Camera): void;
  15102. }
  15103. }
  15104. }
  15105. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15106. import { Camera } from "babylonjs/Cameras/camera";
  15107. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15108. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15109. import "babylonjs/Engines/Extensions/engine.multiview";
  15110. /**
  15111. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15112. * This will not be used for webXR as it supports displaying texture arrays directly
  15113. */
  15114. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15115. /**
  15116. * Initializes a VRMultiviewToSingleview
  15117. * @param name name of the post process
  15118. * @param camera camera to be applied to
  15119. * @param scaleFactor scaling factor to the size of the output texture
  15120. */
  15121. constructor(name: string, camera: Camera, scaleFactor: number);
  15122. }
  15123. }
  15124. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15125. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15126. import { Nullable } from "babylonjs/types";
  15127. import { Size } from "babylonjs/Maths/math.size";
  15128. import { Observable } from "babylonjs/Misc/observable";
  15129. module "babylonjs/Engines/engine" {
  15130. interface Engine {
  15131. /** @hidden */
  15132. _vrDisplay: any;
  15133. /** @hidden */
  15134. _vrSupported: boolean;
  15135. /** @hidden */
  15136. _oldSize: Size;
  15137. /** @hidden */
  15138. _oldHardwareScaleFactor: number;
  15139. /** @hidden */
  15140. _vrExclusivePointerMode: boolean;
  15141. /** @hidden */
  15142. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15143. /** @hidden */
  15144. _onVRDisplayPointerRestricted: () => void;
  15145. /** @hidden */
  15146. _onVRDisplayPointerUnrestricted: () => void;
  15147. /** @hidden */
  15148. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15149. /** @hidden */
  15150. _onVrDisplayDisconnect: Nullable<() => void>;
  15151. /** @hidden */
  15152. _onVrDisplayPresentChange: Nullable<() => void>;
  15153. /**
  15154. * Observable signaled when VR display mode changes
  15155. */
  15156. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15157. /**
  15158. * Observable signaled when VR request present is complete
  15159. */
  15160. onVRRequestPresentComplete: Observable<boolean>;
  15161. /**
  15162. * Observable signaled when VR request present starts
  15163. */
  15164. onVRRequestPresentStart: Observable<Engine>;
  15165. /**
  15166. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15167. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15168. */
  15169. isInVRExclusivePointerMode: boolean;
  15170. /**
  15171. * Gets a boolean indicating if a webVR device was detected
  15172. * @returns true if a webVR device was detected
  15173. */
  15174. isVRDevicePresent(): boolean;
  15175. /**
  15176. * Gets the current webVR device
  15177. * @returns the current webVR device (or null)
  15178. */
  15179. getVRDevice(): any;
  15180. /**
  15181. * Initializes a webVR display and starts listening to display change events
  15182. * The onVRDisplayChangedObservable will be notified upon these changes
  15183. * @returns A promise containing a VRDisplay and if vr is supported
  15184. */
  15185. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15186. /** @hidden */
  15187. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15188. /**
  15189. * Call this function to switch to webVR mode
  15190. * Will do nothing if webVR is not supported or if there is no webVR device
  15191. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15192. */
  15193. enableVR(): void;
  15194. /** @hidden */
  15195. _onVRFullScreenTriggered(): void;
  15196. }
  15197. }
  15198. }
  15199. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15200. import { Nullable } from "babylonjs/types";
  15201. import { Observable } from "babylonjs/Misc/observable";
  15202. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15203. import { Scene } from "babylonjs/scene";
  15204. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15205. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15206. import { Node } from "babylonjs/node";
  15207. import { Ray } from "babylonjs/Culling/ray";
  15208. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15209. import "babylonjs/Engines/Extensions/engine.webVR";
  15210. /**
  15211. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15212. * IMPORTANT!! The data is right-hand data.
  15213. * @export
  15214. * @interface DevicePose
  15215. */
  15216. export interface DevicePose {
  15217. /**
  15218. * The position of the device, values in array are [x,y,z].
  15219. */
  15220. readonly position: Nullable<Float32Array>;
  15221. /**
  15222. * The linearVelocity of the device, values in array are [x,y,z].
  15223. */
  15224. readonly linearVelocity: Nullable<Float32Array>;
  15225. /**
  15226. * The linearAcceleration of the device, values in array are [x,y,z].
  15227. */
  15228. readonly linearAcceleration: Nullable<Float32Array>;
  15229. /**
  15230. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15231. */
  15232. readonly orientation: Nullable<Float32Array>;
  15233. /**
  15234. * The angularVelocity of the device, values in array are [x,y,z].
  15235. */
  15236. readonly angularVelocity: Nullable<Float32Array>;
  15237. /**
  15238. * The angularAcceleration of the device, values in array are [x,y,z].
  15239. */
  15240. readonly angularAcceleration: Nullable<Float32Array>;
  15241. }
  15242. /**
  15243. * Interface representing a pose controlled object in Babylon.
  15244. * A pose controlled object has both regular pose values as well as pose values
  15245. * from an external device such as a VR head mounted display
  15246. */
  15247. export interface PoseControlled {
  15248. /**
  15249. * The position of the object in babylon space.
  15250. */
  15251. position: Vector3;
  15252. /**
  15253. * The rotation quaternion of the object in babylon space.
  15254. */
  15255. rotationQuaternion: Quaternion;
  15256. /**
  15257. * The position of the device in babylon space.
  15258. */
  15259. devicePosition?: Vector3;
  15260. /**
  15261. * The rotation quaternion of the device in babylon space.
  15262. */
  15263. deviceRotationQuaternion: Quaternion;
  15264. /**
  15265. * The raw pose coming from the device.
  15266. */
  15267. rawPose: Nullable<DevicePose>;
  15268. /**
  15269. * The scale of the device to be used when translating from device space to babylon space.
  15270. */
  15271. deviceScaleFactor: number;
  15272. /**
  15273. * Updates the poseControlled values based on the input device pose.
  15274. * @param poseData the pose data to update the object with
  15275. */
  15276. updateFromDevice(poseData: DevicePose): void;
  15277. }
  15278. /**
  15279. * Set of options to customize the webVRCamera
  15280. */
  15281. export interface WebVROptions {
  15282. /**
  15283. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15284. */
  15285. trackPosition?: boolean;
  15286. /**
  15287. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15288. */
  15289. positionScale?: number;
  15290. /**
  15291. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15292. */
  15293. displayName?: string;
  15294. /**
  15295. * Should the native controller meshes be initialized. (default: true)
  15296. */
  15297. controllerMeshes?: boolean;
  15298. /**
  15299. * Creating a default HemiLight only on controllers. (default: true)
  15300. */
  15301. defaultLightingOnControllers?: boolean;
  15302. /**
  15303. * If you don't want to use the default VR button of the helper. (default: false)
  15304. */
  15305. useCustomVRButton?: boolean;
  15306. /**
  15307. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15308. */
  15309. customVRButton?: HTMLButtonElement;
  15310. /**
  15311. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15312. */
  15313. rayLength?: number;
  15314. /**
  15315. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15316. */
  15317. defaultHeight?: number;
  15318. /**
  15319. * If multiview should be used if availible (default: false)
  15320. */
  15321. useMultiview?: boolean;
  15322. }
  15323. /**
  15324. * This represents a WebVR camera.
  15325. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15326. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15327. */
  15328. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15329. private webVROptions;
  15330. /**
  15331. * @hidden
  15332. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15333. */
  15334. _vrDevice: any;
  15335. /**
  15336. * The rawPose of the vrDevice.
  15337. */
  15338. rawPose: Nullable<DevicePose>;
  15339. private _onVREnabled;
  15340. private _specsVersion;
  15341. private _attached;
  15342. private _frameData;
  15343. protected _descendants: Array<Node>;
  15344. private _deviceRoomPosition;
  15345. /** @hidden */
  15346. _deviceRoomRotationQuaternion: Quaternion;
  15347. private _standingMatrix;
  15348. /**
  15349. * Represents device position in babylon space.
  15350. */
  15351. devicePosition: Vector3;
  15352. /**
  15353. * Represents device rotation in babylon space.
  15354. */
  15355. deviceRotationQuaternion: Quaternion;
  15356. /**
  15357. * The scale of the device to be used when translating from device space to babylon space.
  15358. */
  15359. deviceScaleFactor: number;
  15360. private _deviceToWorld;
  15361. private _worldToDevice;
  15362. /**
  15363. * References to the webVR controllers for the vrDevice.
  15364. */
  15365. controllers: Array<WebVRController>;
  15366. /**
  15367. * Emits an event when a controller is attached.
  15368. */
  15369. onControllersAttachedObservable: Observable<WebVRController[]>;
  15370. /**
  15371. * Emits an event when a controller's mesh has been loaded;
  15372. */
  15373. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15374. /**
  15375. * Emits an event when the HMD's pose has been updated.
  15376. */
  15377. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15378. private _poseSet;
  15379. /**
  15380. * If the rig cameras be used as parent instead of this camera.
  15381. */
  15382. rigParenting: boolean;
  15383. private _lightOnControllers;
  15384. private _defaultHeight?;
  15385. /**
  15386. * Instantiates a WebVRFreeCamera.
  15387. * @param name The name of the WebVRFreeCamera
  15388. * @param position The starting anchor position for the camera
  15389. * @param scene The scene the camera belongs to
  15390. * @param webVROptions a set of customizable options for the webVRCamera
  15391. */
  15392. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15393. /**
  15394. * Gets the device distance from the ground in meters.
  15395. * @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.
  15396. */
  15397. deviceDistanceToRoomGround(): number;
  15398. /**
  15399. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15400. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15401. */
  15402. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15403. /**
  15404. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15405. * @returns A promise with a boolean set to if the standing matrix is supported.
  15406. */
  15407. useStandingMatrixAsync(): Promise<boolean>;
  15408. /**
  15409. * Disposes the camera
  15410. */
  15411. dispose(): void;
  15412. /**
  15413. * Gets a vrController by name.
  15414. * @param name The name of the controller to retreive
  15415. * @returns the controller matching the name specified or null if not found
  15416. */
  15417. getControllerByName(name: string): Nullable<WebVRController>;
  15418. private _leftController;
  15419. /**
  15420. * The controller corresponding to the users left hand.
  15421. */
  15422. readonly leftController: Nullable<WebVRController>;
  15423. private _rightController;
  15424. /**
  15425. * The controller corresponding to the users right hand.
  15426. */
  15427. readonly rightController: Nullable<WebVRController>;
  15428. /**
  15429. * Casts a ray forward from the vrCamera's gaze.
  15430. * @param length Length of the ray (default: 100)
  15431. * @returns the ray corresponding to the gaze
  15432. */
  15433. getForwardRay(length?: number): Ray;
  15434. /**
  15435. * @hidden
  15436. * Updates the camera based on device's frame data
  15437. */
  15438. _checkInputs(): void;
  15439. /**
  15440. * Updates the poseControlled values based on the input device pose.
  15441. * @param poseData Pose coming from the device
  15442. */
  15443. updateFromDevice(poseData: DevicePose): void;
  15444. private _htmlElementAttached;
  15445. private _detachIfAttached;
  15446. /**
  15447. * WebVR's attach control will start broadcasting frames to the device.
  15448. * Note that in certain browsers (chrome for example) this function must be called
  15449. * within a user-interaction callback. Example:
  15450. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15451. *
  15452. * @param element html element to attach the vrDevice to
  15453. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15454. */
  15455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15456. /**
  15457. * Detaches the camera from the html element and disables VR
  15458. *
  15459. * @param element html element to detach from
  15460. */
  15461. detachControl(element: HTMLElement): void;
  15462. /**
  15463. * @returns the name of this class
  15464. */
  15465. getClassName(): string;
  15466. /**
  15467. * Calls resetPose on the vrDisplay
  15468. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15469. */
  15470. resetToCurrentRotation(): void;
  15471. /**
  15472. * @hidden
  15473. * Updates the rig cameras (left and right eye)
  15474. */
  15475. _updateRigCameras(): void;
  15476. private _workingVector;
  15477. private _oneVector;
  15478. private _workingMatrix;
  15479. private updateCacheCalled;
  15480. private _correctPositionIfNotTrackPosition;
  15481. /**
  15482. * @hidden
  15483. * Updates the cached values of the camera
  15484. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15485. */
  15486. _updateCache(ignoreParentClass?: boolean): void;
  15487. /**
  15488. * @hidden
  15489. * Get current device position in babylon world
  15490. */
  15491. _computeDevicePosition(): void;
  15492. /**
  15493. * Updates the current device position and rotation in the babylon world
  15494. */
  15495. update(): void;
  15496. /**
  15497. * @hidden
  15498. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15499. * @returns an identity matrix
  15500. */
  15501. _getViewMatrix(): Matrix;
  15502. private _tmpMatrix;
  15503. /**
  15504. * This function is called by the two RIG cameras.
  15505. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15506. * @hidden
  15507. */
  15508. _getWebVRViewMatrix(): Matrix;
  15509. /** @hidden */
  15510. _getWebVRProjectionMatrix(): Matrix;
  15511. private _onGamepadConnectedObserver;
  15512. private _onGamepadDisconnectedObserver;
  15513. private _updateCacheWhenTrackingDisabledObserver;
  15514. /**
  15515. * Initializes the controllers and their meshes
  15516. */
  15517. initControllers(): void;
  15518. }
  15519. }
  15520. declare module "babylonjs/PostProcesses/postProcess" {
  15521. import { Nullable } from "babylonjs/types";
  15522. import { SmartArray } from "babylonjs/Misc/smartArray";
  15523. import { Observable } from "babylonjs/Misc/observable";
  15524. import { Vector2 } from "babylonjs/Maths/math.vector";
  15525. import { Camera } from "babylonjs/Cameras/camera";
  15526. import { Effect } from "babylonjs/Materials/effect";
  15527. import "babylonjs/Shaders/postprocess.vertex";
  15528. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15529. import { Engine } from "babylonjs/Engines/engine";
  15530. import { Color4 } from "babylonjs/Maths/math.color";
  15531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15532. /**
  15533. * Size options for a post process
  15534. */
  15535. export type PostProcessOptions = {
  15536. width: number;
  15537. height: number;
  15538. };
  15539. /**
  15540. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15541. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15542. */
  15543. export class PostProcess {
  15544. /** Name of the PostProcess. */
  15545. name: string;
  15546. /**
  15547. * Gets or sets the unique id of the post process
  15548. */
  15549. uniqueId: number;
  15550. /**
  15551. * Width of the texture to apply the post process on
  15552. */
  15553. width: number;
  15554. /**
  15555. * Height of the texture to apply the post process on
  15556. */
  15557. height: number;
  15558. /**
  15559. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15560. * @hidden
  15561. */
  15562. _outputTexture: Nullable<InternalTexture>;
  15563. /**
  15564. * Sampling mode used by the shader
  15565. * See https://doc.babylonjs.com/classes/3.1/texture
  15566. */
  15567. renderTargetSamplingMode: number;
  15568. /**
  15569. * Clear color to use when screen clearing
  15570. */
  15571. clearColor: Color4;
  15572. /**
  15573. * If the buffer needs to be cleared before applying the post process. (default: true)
  15574. * Should be set to false if shader will overwrite all previous pixels.
  15575. */
  15576. autoClear: boolean;
  15577. /**
  15578. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15579. */
  15580. alphaMode: number;
  15581. /**
  15582. * Sets the setAlphaBlendConstants of the babylon engine
  15583. */
  15584. alphaConstants: Color4;
  15585. /**
  15586. * Animations to be used for the post processing
  15587. */
  15588. animations: import("babylonjs/Animations/animation").Animation[];
  15589. /**
  15590. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15591. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15592. */
  15593. enablePixelPerfectMode: boolean;
  15594. /**
  15595. * Force the postprocess to be applied without taking in account viewport
  15596. */
  15597. forceFullscreenViewport: boolean;
  15598. /**
  15599. * List of inspectable custom properties (used by the Inspector)
  15600. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15601. */
  15602. inspectableCustomProperties: IInspectable[];
  15603. /**
  15604. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15605. *
  15606. * | Value | Type | Description |
  15607. * | ----- | ----------------------------------- | ----------- |
  15608. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15609. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15610. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15611. *
  15612. */
  15613. scaleMode: number;
  15614. /**
  15615. * Force textures to be a power of two (default: false)
  15616. */
  15617. alwaysForcePOT: boolean;
  15618. private _samples;
  15619. /**
  15620. * Number of sample textures (default: 1)
  15621. */
  15622. samples: number;
  15623. /**
  15624. * Modify the scale of the post process to be the same as the viewport (default: false)
  15625. */
  15626. adaptScaleToCurrentViewport: boolean;
  15627. private _camera;
  15628. private _scene;
  15629. private _engine;
  15630. private _options;
  15631. private _reusable;
  15632. private _textureType;
  15633. /**
  15634. * Smart array of input and output textures for the post process.
  15635. * @hidden
  15636. */
  15637. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15638. /**
  15639. * The index in _textures that corresponds to the output texture.
  15640. * @hidden
  15641. */
  15642. _currentRenderTextureInd: number;
  15643. private _effect;
  15644. private _samplers;
  15645. private _fragmentUrl;
  15646. private _vertexUrl;
  15647. private _parameters;
  15648. private _scaleRatio;
  15649. protected _indexParameters: any;
  15650. private _shareOutputWithPostProcess;
  15651. private _texelSize;
  15652. private _forcedOutputTexture;
  15653. /**
  15654. * Returns the fragment url or shader name used in the post process.
  15655. * @returns the fragment url or name in the shader store.
  15656. */
  15657. getEffectName(): string;
  15658. /**
  15659. * An event triggered when the postprocess is activated.
  15660. */
  15661. onActivateObservable: Observable<Camera>;
  15662. private _onActivateObserver;
  15663. /**
  15664. * A function that is added to the onActivateObservable
  15665. */
  15666. onActivate: Nullable<(camera: Camera) => void>;
  15667. /**
  15668. * An event triggered when the postprocess changes its size.
  15669. */
  15670. onSizeChangedObservable: Observable<PostProcess>;
  15671. private _onSizeChangedObserver;
  15672. /**
  15673. * A function that is added to the onSizeChangedObservable
  15674. */
  15675. onSizeChanged: (postProcess: PostProcess) => void;
  15676. /**
  15677. * An event triggered when the postprocess applies its effect.
  15678. */
  15679. onApplyObservable: Observable<Effect>;
  15680. private _onApplyObserver;
  15681. /**
  15682. * A function that is added to the onApplyObservable
  15683. */
  15684. onApply: (effect: Effect) => void;
  15685. /**
  15686. * An event triggered before rendering the postprocess
  15687. */
  15688. onBeforeRenderObservable: Observable<Effect>;
  15689. private _onBeforeRenderObserver;
  15690. /**
  15691. * A function that is added to the onBeforeRenderObservable
  15692. */
  15693. onBeforeRender: (effect: Effect) => void;
  15694. /**
  15695. * An event triggered after rendering the postprocess
  15696. */
  15697. onAfterRenderObservable: Observable<Effect>;
  15698. private _onAfterRenderObserver;
  15699. /**
  15700. * A function that is added to the onAfterRenderObservable
  15701. */
  15702. onAfterRender: (efect: Effect) => void;
  15703. /**
  15704. * 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
  15705. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15706. */
  15707. inputTexture: InternalTexture;
  15708. /**
  15709. * Gets the camera which post process is applied to.
  15710. * @returns The camera the post process is applied to.
  15711. */
  15712. getCamera(): Camera;
  15713. /**
  15714. * Gets the texel size of the postprocess.
  15715. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15716. */
  15717. readonly texelSize: Vector2;
  15718. /**
  15719. * Creates a new instance PostProcess
  15720. * @param name The name of the PostProcess.
  15721. * @param fragmentUrl The url of the fragment shader to be used.
  15722. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15723. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15724. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15725. * @param camera The camera to apply the render pass to.
  15726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15727. * @param engine The engine which the post process will be applied. (default: current engine)
  15728. * @param reusable If the post process can be reused on the same frame. (default: false)
  15729. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15730. * @param textureType Type of textures used when performing the post process. (default: 0)
  15731. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15732. * @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
  15733. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15734. */
  15735. constructor(
  15736. /** Name of the PostProcess. */
  15737. 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);
  15738. /**
  15739. * Gets a string idenfifying the name of the class
  15740. * @returns "PostProcess" string
  15741. */
  15742. getClassName(): string;
  15743. /**
  15744. * Gets the engine which this post process belongs to.
  15745. * @returns The engine the post process was enabled with.
  15746. */
  15747. getEngine(): Engine;
  15748. /**
  15749. * The effect that is created when initializing the post process.
  15750. * @returns The created effect corresponding the the postprocess.
  15751. */
  15752. getEffect(): Effect;
  15753. /**
  15754. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15755. * @param postProcess The post process to share the output with.
  15756. * @returns This post process.
  15757. */
  15758. shareOutputWith(postProcess: PostProcess): PostProcess;
  15759. /**
  15760. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15761. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15762. */
  15763. useOwnOutput(): void;
  15764. /**
  15765. * Updates the effect with the current post process compile time values and recompiles the shader.
  15766. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15767. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15768. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15769. * @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
  15770. * @param onCompiled Called when the shader has been compiled.
  15771. * @param onError Called if there is an error when compiling a shader.
  15772. */
  15773. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15774. /**
  15775. * The post process is reusable if it can be used multiple times within one frame.
  15776. * @returns If the post process is reusable
  15777. */
  15778. isReusable(): boolean;
  15779. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15780. markTextureDirty(): void;
  15781. /**
  15782. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15783. * 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.
  15784. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15785. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15786. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15787. * @returns The target texture that was bound to be written to.
  15788. */
  15789. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15790. /**
  15791. * If the post process is supported.
  15792. */
  15793. readonly isSupported: boolean;
  15794. /**
  15795. * The aspect ratio of the output texture.
  15796. */
  15797. readonly aspectRatio: number;
  15798. /**
  15799. * Get a value indicating if the post-process is ready to be used
  15800. * @returns true if the post-process is ready (shader is compiled)
  15801. */
  15802. isReady(): boolean;
  15803. /**
  15804. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15805. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15806. */
  15807. apply(): Nullable<Effect>;
  15808. private _disposeTextures;
  15809. /**
  15810. * Disposes the post process.
  15811. * @param camera The camera to dispose the post process on.
  15812. */
  15813. dispose(camera?: Camera): void;
  15814. }
  15815. }
  15816. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15817. /** @hidden */
  15818. export var kernelBlurVaryingDeclaration: {
  15819. name: string;
  15820. shader: string;
  15821. };
  15822. }
  15823. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15824. /** @hidden */
  15825. export var kernelBlurFragment: {
  15826. name: string;
  15827. shader: string;
  15828. };
  15829. }
  15830. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15831. /** @hidden */
  15832. export var kernelBlurFragment2: {
  15833. name: string;
  15834. shader: string;
  15835. };
  15836. }
  15837. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15838. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15839. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15840. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15841. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15842. /** @hidden */
  15843. export var kernelBlurPixelShader: {
  15844. name: string;
  15845. shader: string;
  15846. };
  15847. }
  15848. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15849. /** @hidden */
  15850. export var kernelBlurVertex: {
  15851. name: string;
  15852. shader: string;
  15853. };
  15854. }
  15855. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15856. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15857. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15858. /** @hidden */
  15859. export var kernelBlurVertexShader: {
  15860. name: string;
  15861. shader: string;
  15862. };
  15863. }
  15864. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15865. import { Vector2 } from "babylonjs/Maths/math.vector";
  15866. import { Nullable } from "babylonjs/types";
  15867. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15868. import { Camera } from "babylonjs/Cameras/camera";
  15869. import { Effect } from "babylonjs/Materials/effect";
  15870. import { Engine } from "babylonjs/Engines/engine";
  15871. import "babylonjs/Shaders/kernelBlur.fragment";
  15872. import "babylonjs/Shaders/kernelBlur.vertex";
  15873. /**
  15874. * The Blur Post Process which blurs an image based on a kernel and direction.
  15875. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15876. */
  15877. export class BlurPostProcess extends PostProcess {
  15878. /** The direction in which to blur the image. */
  15879. direction: Vector2;
  15880. private blockCompilation;
  15881. protected _kernel: number;
  15882. protected _idealKernel: number;
  15883. protected _packedFloat: boolean;
  15884. private _staticDefines;
  15885. /**
  15886. * Sets the length in pixels of the blur sample region
  15887. */
  15888. /**
  15889. * Gets the length in pixels of the blur sample region
  15890. */
  15891. kernel: number;
  15892. /**
  15893. * Sets wether or not the blur needs to unpack/repack floats
  15894. */
  15895. /**
  15896. * Gets wether or not the blur is unpacking/repacking floats
  15897. */
  15898. packedFloat: boolean;
  15899. /**
  15900. * Creates a new instance BlurPostProcess
  15901. * @param name The name of the effect.
  15902. * @param direction The direction in which to blur the image.
  15903. * @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.
  15904. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15905. * @param camera The camera to apply the render pass to.
  15906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15907. * @param engine The engine which the post process will be applied. (default: current engine)
  15908. * @param reusable If the post process can be reused on the same frame. (default: false)
  15909. * @param textureType Type of textures used when performing the post process. (default: 0)
  15910. * @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)
  15911. */
  15912. constructor(name: string,
  15913. /** The direction in which to blur the image. */
  15914. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15915. /**
  15916. * Updates the effect with the current post process compile time values and recompiles the shader.
  15917. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15918. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15919. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15920. * @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
  15921. * @param onCompiled Called when the shader has been compiled.
  15922. * @param onError Called if there is an error when compiling a shader.
  15923. */
  15924. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15925. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15926. /**
  15927. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15928. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15929. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15930. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15931. * The gaps between physical kernels are compensated for in the weighting of the samples
  15932. * @param idealKernel Ideal blur kernel.
  15933. * @return Nearest best kernel.
  15934. */
  15935. protected _nearestBestKernel(idealKernel: number): number;
  15936. /**
  15937. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15938. * @param x The point on the Gaussian distribution to sample.
  15939. * @return the value of the Gaussian function at x.
  15940. */
  15941. protected _gaussianWeight(x: number): number;
  15942. /**
  15943. * Generates a string that can be used as a floating point number in GLSL.
  15944. * @param x Value to print.
  15945. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15946. * @return GLSL float string.
  15947. */
  15948. protected _glslFloat(x: number, decimalFigures?: number): string;
  15949. }
  15950. }
  15951. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15952. import { Scene } from "babylonjs/scene";
  15953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15954. import { Plane } from "babylonjs/Maths/math.plane";
  15955. /**
  15956. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15957. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15958. * You can then easily use it as a reflectionTexture on a flat surface.
  15959. * In case the surface is not a plane, please consider relying on reflection probes.
  15960. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15961. */
  15962. export class MirrorTexture extends RenderTargetTexture {
  15963. private scene;
  15964. /**
  15965. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15966. * 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.
  15967. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15968. */
  15969. mirrorPlane: Plane;
  15970. /**
  15971. * Define the blur ratio used to blur the reflection if needed.
  15972. */
  15973. blurRatio: number;
  15974. /**
  15975. * Define the adaptive blur kernel used to blur the reflection if needed.
  15976. * This will autocompute the closest best match for the `blurKernel`
  15977. */
  15978. adaptiveBlurKernel: number;
  15979. /**
  15980. * Define the blur kernel used to blur the reflection if needed.
  15981. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15982. */
  15983. blurKernel: number;
  15984. /**
  15985. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15986. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15987. */
  15988. blurKernelX: number;
  15989. /**
  15990. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15991. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15992. */
  15993. blurKernelY: number;
  15994. private _autoComputeBlurKernel;
  15995. protected _onRatioRescale(): void;
  15996. private _updateGammaSpace;
  15997. private _imageProcessingConfigChangeObserver;
  15998. private _transformMatrix;
  15999. private _mirrorMatrix;
  16000. private _savedViewMatrix;
  16001. private _blurX;
  16002. private _blurY;
  16003. private _adaptiveBlurKernel;
  16004. private _blurKernelX;
  16005. private _blurKernelY;
  16006. private _blurRatio;
  16007. /**
  16008. * Instantiates a Mirror Texture.
  16009. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16010. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16011. * You can then easily use it as a reflectionTexture on a flat surface.
  16012. * In case the surface is not a plane, please consider relying on reflection probes.
  16013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16014. * @param name
  16015. * @param size
  16016. * @param scene
  16017. * @param generateMipMaps
  16018. * @param type
  16019. * @param samplingMode
  16020. * @param generateDepthBuffer
  16021. */
  16022. constructor(name: string, size: number | {
  16023. width: number;
  16024. height: number;
  16025. } | {
  16026. ratio: number;
  16027. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16028. private _preparePostProcesses;
  16029. /**
  16030. * Clone the mirror texture.
  16031. * @returns the cloned texture
  16032. */
  16033. clone(): MirrorTexture;
  16034. /**
  16035. * Serialize the texture to a JSON representation you could use in Parse later on
  16036. * @returns the serialized JSON representation
  16037. */
  16038. serialize(): any;
  16039. /**
  16040. * Dispose the texture and release its associated resources.
  16041. */
  16042. dispose(): void;
  16043. }
  16044. }
  16045. declare module "babylonjs/Materials/Textures/texture" {
  16046. import { Observable } from "babylonjs/Misc/observable";
  16047. import { Nullable } from "babylonjs/types";
  16048. import { Scene } from "babylonjs/scene";
  16049. import { Matrix } from "babylonjs/Maths/math.vector";
  16050. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16051. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16052. import { Engine } from "babylonjs/Engines/engine";
  16053. /**
  16054. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16055. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16056. */
  16057. export class Texture extends BaseTexture {
  16058. /**
  16059. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16060. */
  16061. static SerializeBuffers: boolean;
  16062. /** @hidden */
  16063. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16064. /** @hidden */
  16065. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16066. /** @hidden */
  16067. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16068. /** nearest is mag = nearest and min = nearest and mip = linear */
  16069. static readonly NEAREST_SAMPLINGMODE: number;
  16070. /** nearest is mag = nearest and min = nearest and mip = linear */
  16071. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16072. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16073. static readonly BILINEAR_SAMPLINGMODE: number;
  16074. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16075. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16076. /** Trilinear is mag = linear and min = linear and mip = linear */
  16077. static readonly TRILINEAR_SAMPLINGMODE: number;
  16078. /** Trilinear is mag = linear and min = linear and mip = linear */
  16079. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16080. /** mag = nearest and min = nearest and mip = nearest */
  16081. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16082. /** mag = nearest and min = linear and mip = nearest */
  16083. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16084. /** mag = nearest and min = linear and mip = linear */
  16085. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16086. /** mag = nearest and min = linear and mip = none */
  16087. static readonly NEAREST_LINEAR: number;
  16088. /** mag = nearest and min = nearest and mip = none */
  16089. static readonly NEAREST_NEAREST: number;
  16090. /** mag = linear and min = nearest and mip = nearest */
  16091. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16092. /** mag = linear and min = nearest and mip = linear */
  16093. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16094. /** mag = linear and min = linear and mip = none */
  16095. static readonly LINEAR_LINEAR: number;
  16096. /** mag = linear and min = nearest and mip = none */
  16097. static readonly LINEAR_NEAREST: number;
  16098. /** Explicit coordinates mode */
  16099. static readonly EXPLICIT_MODE: number;
  16100. /** Spherical coordinates mode */
  16101. static readonly SPHERICAL_MODE: number;
  16102. /** Planar coordinates mode */
  16103. static readonly PLANAR_MODE: number;
  16104. /** Cubic coordinates mode */
  16105. static readonly CUBIC_MODE: number;
  16106. /** Projection coordinates mode */
  16107. static readonly PROJECTION_MODE: number;
  16108. /** Inverse Cubic coordinates mode */
  16109. static readonly SKYBOX_MODE: number;
  16110. /** Inverse Cubic coordinates mode */
  16111. static readonly INVCUBIC_MODE: number;
  16112. /** Equirectangular coordinates mode */
  16113. static readonly EQUIRECTANGULAR_MODE: number;
  16114. /** Equirectangular Fixed coordinates mode */
  16115. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16116. /** Equirectangular Fixed Mirrored coordinates mode */
  16117. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16118. /** Texture is not repeating outside of 0..1 UVs */
  16119. static readonly CLAMP_ADDRESSMODE: number;
  16120. /** Texture is repeating outside of 0..1 UVs */
  16121. static readonly WRAP_ADDRESSMODE: number;
  16122. /** Texture is repeating and mirrored */
  16123. static readonly MIRROR_ADDRESSMODE: number;
  16124. /**
  16125. * 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
  16126. */
  16127. static UseSerializedUrlIfAny: boolean;
  16128. /**
  16129. * Define the url of the texture.
  16130. */
  16131. url: Nullable<string>;
  16132. /**
  16133. * Define an offset on the texture to offset the u coordinates of the UVs
  16134. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16135. */
  16136. uOffset: number;
  16137. /**
  16138. * Define an offset on the texture to offset the v coordinates of the UVs
  16139. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16140. */
  16141. vOffset: number;
  16142. /**
  16143. * Define an offset on the texture to scale the u coordinates of the UVs
  16144. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16145. */
  16146. uScale: number;
  16147. /**
  16148. * Define an offset on the texture to scale the v coordinates of the UVs
  16149. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16150. */
  16151. vScale: number;
  16152. /**
  16153. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16154. * @see http://doc.babylonjs.com/how_to/more_materials
  16155. */
  16156. uAng: number;
  16157. /**
  16158. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16159. * @see http://doc.babylonjs.com/how_to/more_materials
  16160. */
  16161. vAng: number;
  16162. /**
  16163. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16164. * @see http://doc.babylonjs.com/how_to/more_materials
  16165. */
  16166. wAng: number;
  16167. /**
  16168. * Defines the center of rotation (U)
  16169. */
  16170. uRotationCenter: number;
  16171. /**
  16172. * Defines the center of rotation (V)
  16173. */
  16174. vRotationCenter: number;
  16175. /**
  16176. * Defines the center of rotation (W)
  16177. */
  16178. wRotationCenter: number;
  16179. /**
  16180. * Are mip maps generated for this texture or not.
  16181. */
  16182. readonly noMipmap: boolean;
  16183. /**
  16184. * List of inspectable custom properties (used by the Inspector)
  16185. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16186. */
  16187. inspectableCustomProperties: Nullable<IInspectable[]>;
  16188. private _noMipmap;
  16189. /** @hidden */
  16190. _invertY: boolean;
  16191. private _rowGenerationMatrix;
  16192. private _cachedTextureMatrix;
  16193. private _projectionModeMatrix;
  16194. private _t0;
  16195. private _t1;
  16196. private _t2;
  16197. private _cachedUOffset;
  16198. private _cachedVOffset;
  16199. private _cachedUScale;
  16200. private _cachedVScale;
  16201. private _cachedUAng;
  16202. private _cachedVAng;
  16203. private _cachedWAng;
  16204. private _cachedProjectionMatrixId;
  16205. private _cachedCoordinatesMode;
  16206. /** @hidden */
  16207. protected _initialSamplingMode: number;
  16208. /** @hidden */
  16209. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16210. private _deleteBuffer;
  16211. protected _format: Nullable<number>;
  16212. private _delayedOnLoad;
  16213. private _delayedOnError;
  16214. /**
  16215. * Observable triggered once the texture has been loaded.
  16216. */
  16217. onLoadObservable: Observable<Texture>;
  16218. protected _isBlocking: boolean;
  16219. /**
  16220. * Is the texture preventing material to render while loading.
  16221. * If false, a default texture will be used instead of the loading one during the preparation step.
  16222. */
  16223. isBlocking: boolean;
  16224. /**
  16225. * Get the current sampling mode associated with the texture.
  16226. */
  16227. readonly samplingMode: number;
  16228. /**
  16229. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16230. */
  16231. readonly invertY: boolean;
  16232. /**
  16233. * Instantiates a new texture.
  16234. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16235. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16236. * @param url define the url of the picture to load as a texture
  16237. * @param scene define the scene or engine the texture will belong to
  16238. * @param noMipmap define if the texture will require mip maps or not
  16239. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16240. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16241. * @param onLoad define a callback triggered when the texture has been loaded
  16242. * @param onError define a callback triggered when an error occurred during the loading session
  16243. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16244. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16245. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16246. */
  16247. 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);
  16248. /**
  16249. * Update the url (and optional buffer) of this texture if url was null during construction.
  16250. * @param url the url of the texture
  16251. * @param buffer the buffer of the texture (defaults to null)
  16252. * @param onLoad callback called when the texture is loaded (defaults to null)
  16253. */
  16254. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16255. /**
  16256. * Finish the loading sequence of a texture flagged as delayed load.
  16257. * @hidden
  16258. */
  16259. delayLoad(): void;
  16260. private _prepareRowForTextureGeneration;
  16261. /**
  16262. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16263. * @returns the transform matrix of the texture.
  16264. */
  16265. getTextureMatrix(): Matrix;
  16266. /**
  16267. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16268. * @returns The reflection texture transform
  16269. */
  16270. getReflectionTextureMatrix(): Matrix;
  16271. /**
  16272. * Clones the texture.
  16273. * @returns the cloned texture
  16274. */
  16275. clone(): Texture;
  16276. /**
  16277. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16278. * @returns The JSON representation of the texture
  16279. */
  16280. serialize(): any;
  16281. /**
  16282. * Get the current class name of the texture useful for serialization or dynamic coding.
  16283. * @returns "Texture"
  16284. */
  16285. getClassName(): string;
  16286. /**
  16287. * Dispose the texture and release its associated resources.
  16288. */
  16289. dispose(): void;
  16290. /**
  16291. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16292. * @param parsedTexture Define the JSON representation of the texture
  16293. * @param scene Define the scene the parsed texture should be instantiated in
  16294. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16295. * @returns The parsed texture if successful
  16296. */
  16297. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16298. /**
  16299. * Creates a texture from its base 64 representation.
  16300. * @param data Define the base64 payload without the data: prefix
  16301. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16302. * @param scene Define the scene the texture should belong to
  16303. * @param noMipmap Forces the texture to not create mip map information if true
  16304. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16305. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16306. * @param onLoad define a callback triggered when the texture has been loaded
  16307. * @param onError define a callback triggered when an error occurred during the loading session
  16308. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16309. * @returns the created texture
  16310. */
  16311. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16312. /**
  16313. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16314. * @param data Define the base64 payload without the data: prefix
  16315. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16316. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16317. * @param scene Define the scene the texture should belong to
  16318. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16319. * @param noMipmap Forces the texture to not create mip map information if true
  16320. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16321. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16322. * @param onLoad define a callback triggered when the texture has been loaded
  16323. * @param onError define a callback triggered when an error occurred during the loading session
  16324. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16325. * @returns the created texture
  16326. */
  16327. 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;
  16328. }
  16329. }
  16330. declare module "babylonjs/PostProcesses/postProcessManager" {
  16331. import { Nullable } from "babylonjs/types";
  16332. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16333. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16334. import { Scene } from "babylonjs/scene";
  16335. /**
  16336. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16337. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16338. */
  16339. export class PostProcessManager {
  16340. private _scene;
  16341. private _indexBuffer;
  16342. private _vertexBuffers;
  16343. /**
  16344. * Creates a new instance PostProcess
  16345. * @param scene The scene that the post process is associated with.
  16346. */
  16347. constructor(scene: Scene);
  16348. private _prepareBuffers;
  16349. private _buildIndexBuffer;
  16350. /**
  16351. * Rebuilds the vertex buffers of the manager.
  16352. * @hidden
  16353. */
  16354. _rebuild(): void;
  16355. /**
  16356. * Prepares a frame to be run through a post process.
  16357. * @param sourceTexture The input texture to the post procesess. (default: null)
  16358. * @param postProcesses An array of post processes to be run. (default: null)
  16359. * @returns True if the post processes were able to be run.
  16360. * @hidden
  16361. */
  16362. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16363. /**
  16364. * Manually render a set of post processes to a texture.
  16365. * @param postProcesses An array of post processes to be run.
  16366. * @param targetTexture The target texture to render to.
  16367. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16368. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16369. * @param lodLevel defines which lod of the texture to render to
  16370. */
  16371. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16372. /**
  16373. * Finalize the result of the output of the postprocesses.
  16374. * @param doNotPresent If true the result will not be displayed to the screen.
  16375. * @param targetTexture The target texture to render to.
  16376. * @param faceIndex The index of the face to bind the target texture to.
  16377. * @param postProcesses The array of post processes to render.
  16378. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16379. * @hidden
  16380. */
  16381. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16382. /**
  16383. * Disposes of the post process manager.
  16384. */
  16385. dispose(): void;
  16386. }
  16387. }
  16388. declare module "babylonjs/Misc/gradients" {
  16389. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16390. /** Interface used by value gradients (color, factor, ...) */
  16391. export interface IValueGradient {
  16392. /**
  16393. * Gets or sets the gradient value (between 0 and 1)
  16394. */
  16395. gradient: number;
  16396. }
  16397. /** Class used to store color4 gradient */
  16398. export class ColorGradient implements IValueGradient {
  16399. /**
  16400. * Gets or sets the gradient value (between 0 and 1)
  16401. */
  16402. gradient: number;
  16403. /**
  16404. * Gets or sets first associated color
  16405. */
  16406. color1: Color4;
  16407. /**
  16408. * Gets or sets second associated color
  16409. */
  16410. color2?: Color4;
  16411. /**
  16412. * Will get a color picked randomly between color1 and color2.
  16413. * If color2 is undefined then color1 will be used
  16414. * @param result defines the target Color4 to store the result in
  16415. */
  16416. getColorToRef(result: Color4): void;
  16417. }
  16418. /** Class used to store color 3 gradient */
  16419. export class Color3Gradient implements IValueGradient {
  16420. /**
  16421. * Gets or sets the gradient value (between 0 and 1)
  16422. */
  16423. gradient: number;
  16424. /**
  16425. * Gets or sets the associated color
  16426. */
  16427. color: Color3;
  16428. }
  16429. /** Class used to store factor gradient */
  16430. export class FactorGradient implements IValueGradient {
  16431. /**
  16432. * Gets or sets the gradient value (between 0 and 1)
  16433. */
  16434. gradient: number;
  16435. /**
  16436. * Gets or sets first associated factor
  16437. */
  16438. factor1: number;
  16439. /**
  16440. * Gets or sets second associated factor
  16441. */
  16442. factor2?: number;
  16443. /**
  16444. * Will get a number picked randomly between factor1 and factor2.
  16445. * If factor2 is undefined then factor1 will be used
  16446. * @returns the picked number
  16447. */
  16448. getFactor(): number;
  16449. }
  16450. /**
  16451. * Helper used to simplify some generic gradient tasks
  16452. */
  16453. export class GradientHelper {
  16454. /**
  16455. * Gets the current gradient from an array of IValueGradient
  16456. * @param ratio defines the current ratio to get
  16457. * @param gradients defines the array of IValueGradient
  16458. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16459. */
  16460. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16461. }
  16462. }
  16463. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16464. import { Scene } from "babylonjs/scene";
  16465. import { Texture } from "babylonjs/Materials/Textures/texture";
  16466. /**
  16467. * A class extending Texture allowing drawing on a texture
  16468. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16469. */
  16470. export class DynamicTexture extends Texture {
  16471. private _generateMipMaps;
  16472. private _canvas;
  16473. private _context;
  16474. private _engine;
  16475. /**
  16476. * Creates a DynamicTexture
  16477. * @param name defines the name of the texture
  16478. * @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
  16479. * @param scene defines the scene where you want the texture
  16480. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16481. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16482. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16483. */
  16484. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16485. /**
  16486. * Get the current class name of the texture useful for serialization or dynamic coding.
  16487. * @returns "DynamicTexture"
  16488. */
  16489. getClassName(): string;
  16490. /**
  16491. * Gets the current state of canRescale
  16492. */
  16493. readonly canRescale: boolean;
  16494. private _recreate;
  16495. /**
  16496. * Scales the texture
  16497. * @param ratio the scale factor to apply to both width and height
  16498. */
  16499. scale(ratio: number): void;
  16500. /**
  16501. * Resizes the texture
  16502. * @param width the new width
  16503. * @param height the new height
  16504. */
  16505. scaleTo(width: number, height: number): void;
  16506. /**
  16507. * Gets the context of the canvas used by the texture
  16508. * @returns the canvas context of the dynamic texture
  16509. */
  16510. getContext(): CanvasRenderingContext2D;
  16511. /**
  16512. * Clears the texture
  16513. */
  16514. clear(): void;
  16515. /**
  16516. * Updates the texture
  16517. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16518. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16519. */
  16520. update(invertY?: boolean, premulAlpha?: boolean): void;
  16521. /**
  16522. * Draws text onto the texture
  16523. * @param text defines the text to be drawn
  16524. * @param x defines the placement of the text from the left
  16525. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16526. * @param font defines the font to be used with font-style, font-size, font-name
  16527. * @param color defines the color used for the text
  16528. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16529. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16530. * @param update defines whether texture is immediately update (default is true)
  16531. */
  16532. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16533. /**
  16534. * Clones the texture
  16535. * @returns the clone of the texture.
  16536. */
  16537. clone(): DynamicTexture;
  16538. /**
  16539. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16540. * @returns a serialized dynamic texture object
  16541. */
  16542. serialize(): any;
  16543. /** @hidden */
  16544. _rebuild(): void;
  16545. }
  16546. }
  16547. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16548. import { Scene } from "babylonjs/scene";
  16549. import { ISceneComponent } from "babylonjs/sceneComponent";
  16550. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16551. module "babylonjs/abstractScene" {
  16552. interface AbstractScene {
  16553. /**
  16554. * The list of procedural textures added to the scene
  16555. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16556. */
  16557. proceduralTextures: Array<ProceduralTexture>;
  16558. }
  16559. }
  16560. /**
  16561. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16562. * in a given scene.
  16563. */
  16564. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16565. /**
  16566. * The component name helpfull to identify the component in the list of scene components.
  16567. */
  16568. readonly name: string;
  16569. /**
  16570. * The scene the component belongs to.
  16571. */
  16572. scene: Scene;
  16573. /**
  16574. * Creates a new instance of the component for the given scene
  16575. * @param scene Defines the scene to register the component in
  16576. */
  16577. constructor(scene: Scene);
  16578. /**
  16579. * Registers the component in a given scene
  16580. */
  16581. register(): void;
  16582. /**
  16583. * Rebuilds the elements related to this component in case of
  16584. * context lost for instance.
  16585. */
  16586. rebuild(): void;
  16587. /**
  16588. * Disposes the component and the associated ressources.
  16589. */
  16590. dispose(): void;
  16591. private _beforeClear;
  16592. }
  16593. }
  16594. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16595. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16596. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16597. module "babylonjs/Engines/baseEngine" {
  16598. interface BaseEngine {
  16599. /**
  16600. * Creates a new render target cube texture
  16601. * @param size defines the size of the texture
  16602. * @param options defines the options used to create the texture
  16603. * @returns a new render target cube texture stored in an InternalTexture
  16604. */
  16605. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16606. }
  16607. }
  16608. }
  16609. declare module "babylonjs/Shaders/procedural.vertex" {
  16610. /** @hidden */
  16611. export var proceduralVertexShader: {
  16612. name: string;
  16613. shader: string;
  16614. };
  16615. }
  16616. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16617. import { Observable } from "babylonjs/Misc/observable";
  16618. import { Nullable } from "babylonjs/types";
  16619. import { Scene } from "babylonjs/scene";
  16620. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16621. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16622. import { Effect } from "babylonjs/Materials/effect";
  16623. import { Texture } from "babylonjs/Materials/Textures/texture";
  16624. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16625. import "babylonjs/Shaders/procedural.vertex";
  16626. /**
  16627. * 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.
  16628. * This is the base class of any Procedural texture and contains most of the shareable code.
  16629. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16630. */
  16631. export class ProceduralTexture extends Texture {
  16632. isCube: boolean;
  16633. /**
  16634. * Define if the texture is enabled or not (disabled texture will not render)
  16635. */
  16636. isEnabled: boolean;
  16637. /**
  16638. * Define if the texture must be cleared before rendering (default is true)
  16639. */
  16640. autoClear: boolean;
  16641. /**
  16642. * Callback called when the texture is generated
  16643. */
  16644. onGenerated: () => void;
  16645. /**
  16646. * Event raised when the texture is generated
  16647. */
  16648. onGeneratedObservable: Observable<ProceduralTexture>;
  16649. /** @hidden */
  16650. _generateMipMaps: boolean;
  16651. /** @hidden **/
  16652. _effect: Effect;
  16653. /** @hidden */
  16654. _textures: {
  16655. [key: string]: Texture;
  16656. };
  16657. private _size;
  16658. private _currentRefreshId;
  16659. private _refreshRate;
  16660. private _vertexBuffers;
  16661. private _indexBuffer;
  16662. private _uniforms;
  16663. private _samplers;
  16664. private _fragment;
  16665. private _floats;
  16666. private _ints;
  16667. private _floatsArrays;
  16668. private _colors3;
  16669. private _colors4;
  16670. private _vectors2;
  16671. private _vectors3;
  16672. private _matrices;
  16673. private _fallbackTexture;
  16674. private _fallbackTextureUsed;
  16675. private _engine;
  16676. private _cachedDefines;
  16677. private _contentUpdateId;
  16678. private _contentData;
  16679. /**
  16680. * Instantiates a new procedural texture.
  16681. * 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.
  16682. * This is the base class of any Procedural texture and contains most of the shareable code.
  16683. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16684. * @param name Define the name of the texture
  16685. * @param size Define the size of the texture to create
  16686. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16687. * @param scene Define the scene the texture belongs to
  16688. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16689. * @param generateMipMaps Define if the texture should creates mip maps or not
  16690. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16691. */
  16692. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16693. /**
  16694. * The effect that is created when initializing the post process.
  16695. * @returns The created effect corresponding the the postprocess.
  16696. */
  16697. getEffect(): Effect;
  16698. /**
  16699. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16700. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16701. */
  16702. getContent(): Nullable<ArrayBufferView>;
  16703. private _createIndexBuffer;
  16704. /** @hidden */
  16705. _rebuild(): void;
  16706. /**
  16707. * Resets the texture in order to recreate its associated resources.
  16708. * This can be called in case of context loss
  16709. */
  16710. reset(): void;
  16711. protected _getDefines(): string;
  16712. /**
  16713. * Is the texture ready to be used ? (rendered at least once)
  16714. * @returns true if ready, otherwise, false.
  16715. */
  16716. isReady(): boolean;
  16717. /**
  16718. * Resets the refresh counter of the texture and start bak from scratch.
  16719. * Could be useful to regenerate the texture if it is setup to render only once.
  16720. */
  16721. resetRefreshCounter(): void;
  16722. /**
  16723. * Set the fragment shader to use in order to render the texture.
  16724. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16725. */
  16726. setFragment(fragment: any): void;
  16727. /**
  16728. * Define the refresh rate of the texture or the rendering frequency.
  16729. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16730. */
  16731. refreshRate: number;
  16732. /** @hidden */
  16733. _shouldRender(): boolean;
  16734. /**
  16735. * Get the size the texture is rendering at.
  16736. * @returns the size (texture is always squared)
  16737. */
  16738. getRenderSize(): number;
  16739. /**
  16740. * Resize the texture to new value.
  16741. * @param size Define the new size the texture should have
  16742. * @param generateMipMaps Define whether the new texture should create mip maps
  16743. */
  16744. resize(size: number, generateMipMaps: boolean): void;
  16745. private _checkUniform;
  16746. /**
  16747. * Set a texture in the shader program used to render.
  16748. * @param name Define the name of the uniform samplers as defined in the shader
  16749. * @param texture Define the texture to bind to this sampler
  16750. * @return the texture itself allowing "fluent" like uniform updates
  16751. */
  16752. setTexture(name: string, texture: Texture): ProceduralTexture;
  16753. /**
  16754. * Set a float in the shader.
  16755. * @param name Define the name of the uniform as defined in the shader
  16756. * @param value Define the value to give to the uniform
  16757. * @return the texture itself allowing "fluent" like uniform updates
  16758. */
  16759. setFloat(name: string, value: number): ProceduralTexture;
  16760. /**
  16761. * Set a int in the shader.
  16762. * @param name Define the name of the uniform as defined in the shader
  16763. * @param value Define the value to give to the uniform
  16764. * @return the texture itself allowing "fluent" like uniform updates
  16765. */
  16766. setInt(name: string, value: number): ProceduralTexture;
  16767. /**
  16768. * Set an array of floats in the shader.
  16769. * @param name Define the name of the uniform as defined in the shader
  16770. * @param value Define the value to give to the uniform
  16771. * @return the texture itself allowing "fluent" like uniform updates
  16772. */
  16773. setFloats(name: string, value: number[]): ProceduralTexture;
  16774. /**
  16775. * Set a vec3 in the shader from a Color3.
  16776. * @param name Define the name of the uniform as defined in the shader
  16777. * @param value Define the value to give to the uniform
  16778. * @return the texture itself allowing "fluent" like uniform updates
  16779. */
  16780. setColor3(name: string, value: Color3): ProceduralTexture;
  16781. /**
  16782. * Set a vec4 in the shader from a Color4.
  16783. * @param name Define the name of the uniform as defined in the shader
  16784. * @param value Define the value to give to the uniform
  16785. * @return the texture itself allowing "fluent" like uniform updates
  16786. */
  16787. setColor4(name: string, value: Color4): ProceduralTexture;
  16788. /**
  16789. * Set a vec2 in the shader from a Vector2.
  16790. * @param name Define the name of the uniform as defined in the shader
  16791. * @param value Define the value to give to the uniform
  16792. * @return the texture itself allowing "fluent" like uniform updates
  16793. */
  16794. setVector2(name: string, value: Vector2): ProceduralTexture;
  16795. /**
  16796. * Set a vec3 in the shader from a Vector3.
  16797. * @param name Define the name of the uniform as defined in the shader
  16798. * @param value Define the value to give to the uniform
  16799. * @return the texture itself allowing "fluent" like uniform updates
  16800. */
  16801. setVector3(name: string, value: Vector3): ProceduralTexture;
  16802. /**
  16803. * Set a mat4 in the shader from a MAtrix.
  16804. * @param name Define the name of the uniform as defined in the shader
  16805. * @param value Define the value to give to the uniform
  16806. * @return the texture itself allowing "fluent" like uniform updates
  16807. */
  16808. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16809. /**
  16810. * Render the texture to its associated render target.
  16811. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16812. */
  16813. render(useCameraPostProcess?: boolean): void;
  16814. /**
  16815. * Clone the texture.
  16816. * @returns the cloned texture
  16817. */
  16818. clone(): ProceduralTexture;
  16819. /**
  16820. * Dispose the texture and release its asoociated resources.
  16821. */
  16822. dispose(): void;
  16823. }
  16824. }
  16825. declare module "babylonjs/Particles/baseParticleSystem" {
  16826. import { Nullable } from "babylonjs/types";
  16827. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16829. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16830. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16831. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16832. import { Scene } from "babylonjs/scene";
  16833. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16834. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16835. import { Texture } from "babylonjs/Materials/Textures/texture";
  16836. import { Color4 } from "babylonjs/Maths/math.color";
  16837. import { Animation } from "babylonjs/Animations/animation";
  16838. /**
  16839. * This represents the base class for particle system in Babylon.
  16840. * 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.
  16841. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16842. * @example https://doc.babylonjs.com/babylon101/particles
  16843. */
  16844. export class BaseParticleSystem {
  16845. /**
  16846. * Source color is added to the destination color without alpha affecting the result
  16847. */
  16848. static BLENDMODE_ONEONE: number;
  16849. /**
  16850. * Blend current color and particle color using particle’s alpha
  16851. */
  16852. static BLENDMODE_STANDARD: number;
  16853. /**
  16854. * Add current color and particle color multiplied by particle’s alpha
  16855. */
  16856. static BLENDMODE_ADD: number;
  16857. /**
  16858. * Multiply current color with particle color
  16859. */
  16860. static BLENDMODE_MULTIPLY: number;
  16861. /**
  16862. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16863. */
  16864. static BLENDMODE_MULTIPLYADD: number;
  16865. /**
  16866. * List of animations used by the particle system.
  16867. */
  16868. animations: Animation[];
  16869. /**
  16870. * The id of the Particle system.
  16871. */
  16872. id: string;
  16873. /**
  16874. * The friendly name of the Particle system.
  16875. */
  16876. name: string;
  16877. /**
  16878. * The rendering group used by the Particle system to chose when to render.
  16879. */
  16880. renderingGroupId: number;
  16881. /**
  16882. * The emitter represents the Mesh or position we are attaching the particle system to.
  16883. */
  16884. emitter: Nullable<AbstractMesh | Vector3>;
  16885. /**
  16886. * The maximum number of particles to emit per frame
  16887. */
  16888. emitRate: number;
  16889. /**
  16890. * If you want to launch only a few particles at once, that can be done, as well.
  16891. */
  16892. manualEmitCount: number;
  16893. /**
  16894. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16895. */
  16896. updateSpeed: number;
  16897. /**
  16898. * The amount of time the particle system is running (depends of the overall update speed).
  16899. */
  16900. targetStopDuration: number;
  16901. /**
  16902. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16903. */
  16904. disposeOnStop: boolean;
  16905. /**
  16906. * Minimum power of emitting particles.
  16907. */
  16908. minEmitPower: number;
  16909. /**
  16910. * Maximum power of emitting particles.
  16911. */
  16912. maxEmitPower: number;
  16913. /**
  16914. * Minimum life time of emitting particles.
  16915. */
  16916. minLifeTime: number;
  16917. /**
  16918. * Maximum life time of emitting particles.
  16919. */
  16920. maxLifeTime: number;
  16921. /**
  16922. * Minimum Size of emitting particles.
  16923. */
  16924. minSize: number;
  16925. /**
  16926. * Maximum Size of emitting particles.
  16927. */
  16928. maxSize: number;
  16929. /**
  16930. * Minimum scale of emitting particles on X axis.
  16931. */
  16932. minScaleX: number;
  16933. /**
  16934. * Maximum scale of emitting particles on X axis.
  16935. */
  16936. maxScaleX: number;
  16937. /**
  16938. * Minimum scale of emitting particles on Y axis.
  16939. */
  16940. minScaleY: number;
  16941. /**
  16942. * Maximum scale of emitting particles on Y axis.
  16943. */
  16944. maxScaleY: number;
  16945. /**
  16946. * Gets or sets the minimal initial rotation in radians.
  16947. */
  16948. minInitialRotation: number;
  16949. /**
  16950. * Gets or sets the maximal initial rotation in radians.
  16951. */
  16952. maxInitialRotation: number;
  16953. /**
  16954. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16955. */
  16956. minAngularSpeed: number;
  16957. /**
  16958. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16959. */
  16960. maxAngularSpeed: number;
  16961. /**
  16962. * The texture used to render each particle. (this can be a spritesheet)
  16963. */
  16964. particleTexture: Nullable<Texture>;
  16965. /**
  16966. * The layer mask we are rendering the particles through.
  16967. */
  16968. layerMask: number;
  16969. /**
  16970. * This can help using your own shader to render the particle system.
  16971. * The according effect will be created
  16972. */
  16973. customShader: any;
  16974. /**
  16975. * By default particle system starts as soon as they are created. This prevents the
  16976. * automatic start to happen and let you decide when to start emitting particles.
  16977. */
  16978. preventAutoStart: boolean;
  16979. private _noiseTexture;
  16980. /**
  16981. * Gets or sets a texture used to add random noise to particle positions
  16982. */
  16983. noiseTexture: Nullable<ProceduralTexture>;
  16984. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16985. noiseStrength: Vector3;
  16986. /**
  16987. * Callback triggered when the particle animation is ending.
  16988. */
  16989. onAnimationEnd: Nullable<() => void>;
  16990. /**
  16991. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16992. */
  16993. blendMode: number;
  16994. /**
  16995. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16996. * to override the particles.
  16997. */
  16998. forceDepthWrite: boolean;
  16999. /** 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 */
  17000. preWarmCycles: number;
  17001. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17002. preWarmStepOffset: number;
  17003. /**
  17004. * 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)
  17005. */
  17006. spriteCellChangeSpeed: number;
  17007. /**
  17008. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17009. */
  17010. startSpriteCellID: number;
  17011. /**
  17012. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17013. */
  17014. endSpriteCellID: number;
  17015. /**
  17016. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17017. */
  17018. spriteCellWidth: number;
  17019. /**
  17020. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17021. */
  17022. spriteCellHeight: number;
  17023. /**
  17024. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17025. */
  17026. spriteRandomStartCell: boolean;
  17027. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17028. translationPivot: Vector2;
  17029. /** @hidden */
  17030. protected _isAnimationSheetEnabled: boolean;
  17031. /**
  17032. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17033. */
  17034. beginAnimationOnStart: boolean;
  17035. /**
  17036. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17037. */
  17038. beginAnimationFrom: number;
  17039. /**
  17040. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17041. */
  17042. beginAnimationTo: number;
  17043. /**
  17044. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17045. */
  17046. beginAnimationLoop: boolean;
  17047. /**
  17048. * Gets or sets a world offset applied to all particles
  17049. */
  17050. worldOffset: Vector3;
  17051. /**
  17052. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17053. */
  17054. isAnimationSheetEnabled: boolean;
  17055. /**
  17056. * Get hosting scene
  17057. * @returns the scene
  17058. */
  17059. getScene(): Scene;
  17060. /**
  17061. * You can use gravity if you want to give an orientation to your particles.
  17062. */
  17063. gravity: Vector3;
  17064. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17065. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17066. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17067. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17068. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17069. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17070. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17071. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17072. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17073. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17074. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17075. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17076. protected _hasTargetStopDurationDependantGradient(): Nullable<boolean>;
  17077. /**
  17078. * Defines the delay in milliseconds before starting the system (0 by default)
  17079. */
  17080. startDelay: number;
  17081. /**
  17082. * Gets the current list of drag gradients.
  17083. * You must use addDragGradient and removeDragGradient to udpate this list
  17084. * @returns the list of drag gradients
  17085. */
  17086. getDragGradients(): Nullable<Array<FactorGradient>>;
  17087. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17088. limitVelocityDamping: number;
  17089. /**
  17090. * Gets the current list of limit velocity gradients.
  17091. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17092. * @returns the list of limit velocity gradients
  17093. */
  17094. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17095. /**
  17096. * Gets the current list of color gradients.
  17097. * You must use addColorGradient and removeColorGradient to udpate this list
  17098. * @returns the list of color gradients
  17099. */
  17100. getColorGradients(): Nullable<Array<ColorGradient>>;
  17101. /**
  17102. * Gets the current list of size gradients.
  17103. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17104. * @returns the list of size gradients
  17105. */
  17106. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17107. /**
  17108. * Gets the current list of color remap gradients.
  17109. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17110. * @returns the list of color remap gradients
  17111. */
  17112. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17113. /**
  17114. * Gets the current list of alpha remap gradients.
  17115. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17116. * @returns the list of alpha remap gradients
  17117. */
  17118. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17119. /**
  17120. * Gets the current list of life time gradients.
  17121. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17122. * @returns the list of life time gradients
  17123. */
  17124. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17125. /**
  17126. * Gets the current list of angular speed gradients.
  17127. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17128. * @returns the list of angular speed gradients
  17129. */
  17130. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17131. /**
  17132. * Gets the current list of velocity gradients.
  17133. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17134. * @returns the list of velocity gradients
  17135. */
  17136. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17137. /**
  17138. * Gets the current list of start size gradients.
  17139. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17140. * @returns the list of start size gradients
  17141. */
  17142. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17143. /**
  17144. * Gets the current list of emit rate gradients.
  17145. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17146. * @returns the list of emit rate gradients
  17147. */
  17148. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17149. /**
  17150. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17151. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17152. */
  17153. direction1: Vector3;
  17154. /**
  17155. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17156. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17157. */
  17158. direction2: Vector3;
  17159. /**
  17160. * 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.
  17161. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17162. */
  17163. minEmitBox: Vector3;
  17164. /**
  17165. * 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.
  17166. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17167. */
  17168. maxEmitBox: Vector3;
  17169. /**
  17170. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17171. */
  17172. color1: Color4;
  17173. /**
  17174. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17175. */
  17176. color2: Color4;
  17177. /**
  17178. * Color the particle will have at the end of its lifetime
  17179. */
  17180. colorDead: Color4;
  17181. /**
  17182. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17183. */
  17184. textureMask: Color4;
  17185. /**
  17186. * The particle emitter type defines the emitter used by the particle system.
  17187. * It can be for example box, sphere, or cone...
  17188. */
  17189. particleEmitterType: IParticleEmitterType;
  17190. /** @hidden */
  17191. _isSubEmitter: boolean;
  17192. /**
  17193. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17194. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17195. */
  17196. billboardMode: number;
  17197. protected _isBillboardBased: boolean;
  17198. /**
  17199. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17200. */
  17201. isBillboardBased: boolean;
  17202. /**
  17203. * The scene the particle system belongs to.
  17204. */
  17205. protected _scene: Scene;
  17206. /**
  17207. * Local cache of defines for image processing.
  17208. */
  17209. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17210. /**
  17211. * Default configuration related to image processing available in the standard Material.
  17212. */
  17213. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17214. /**
  17215. * Gets the image processing configuration used either in this material.
  17216. */
  17217. /**
  17218. * Sets the Default image processing configuration used either in the this material.
  17219. *
  17220. * If sets to null, the scene one is in use.
  17221. */
  17222. imageProcessingConfiguration: ImageProcessingConfiguration;
  17223. /**
  17224. * Attaches a new image processing configuration to the Standard Material.
  17225. * @param configuration
  17226. */
  17227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17228. /** @hidden */
  17229. protected _reset(): void;
  17230. /** @hidden */
  17231. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17232. /**
  17233. * Instantiates a particle system.
  17234. * 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.
  17235. * @param name The name of the particle system
  17236. */
  17237. constructor(name: string);
  17238. /**
  17239. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17240. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17241. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17242. * @returns the emitter
  17243. */
  17244. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17245. /**
  17246. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17247. * @param radius The radius of the hemisphere to emit from
  17248. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17249. * @returns the emitter
  17250. */
  17251. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17252. /**
  17253. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17254. * @param radius The radius of the sphere to emit from
  17255. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17256. * @returns the emitter
  17257. */
  17258. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17259. /**
  17260. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17261. * @param radius The radius of the sphere to emit from
  17262. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17263. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17264. * @returns the emitter
  17265. */
  17266. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17267. /**
  17268. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17269. * @param radius The radius of the emission cylinder
  17270. * @param height The height of the emission cylinder
  17271. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17272. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17273. * @returns the emitter
  17274. */
  17275. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17276. /**
  17277. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17278. * @param radius The radius of the cylinder to emit from
  17279. * @param height The height of the emission cylinder
  17280. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17281. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17282. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17283. * @returns the emitter
  17284. */
  17285. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17286. /**
  17287. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17288. * @param radius The radius of the cone to emit from
  17289. * @param angle The base angle of the cone
  17290. * @returns the emitter
  17291. */
  17292. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17293. /**
  17294. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17295. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17296. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17297. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17298. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17299. * @returns the emitter
  17300. */
  17301. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17302. }
  17303. }
  17304. declare module "babylonjs/Particles/subEmitter" {
  17305. import { Scene } from "babylonjs/scene";
  17306. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17307. /**
  17308. * Type of sub emitter
  17309. */
  17310. export enum SubEmitterType {
  17311. /**
  17312. * Attached to the particle over it's lifetime
  17313. */
  17314. ATTACHED = 0,
  17315. /**
  17316. * Created when the particle dies
  17317. */
  17318. END = 1
  17319. }
  17320. /**
  17321. * Sub emitter class used to emit particles from an existing particle
  17322. */
  17323. export class SubEmitter {
  17324. /**
  17325. * the particle system to be used by the sub emitter
  17326. */
  17327. particleSystem: ParticleSystem;
  17328. /**
  17329. * Type of the submitter (Default: END)
  17330. */
  17331. type: SubEmitterType;
  17332. /**
  17333. * 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)
  17334. * Note: This only is supported when using an emitter of type Mesh
  17335. */
  17336. inheritDirection: boolean;
  17337. /**
  17338. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17339. */
  17340. inheritedVelocityAmount: number;
  17341. /**
  17342. * Creates a sub emitter
  17343. * @param particleSystem the particle system to be used by the sub emitter
  17344. */
  17345. constructor(
  17346. /**
  17347. * the particle system to be used by the sub emitter
  17348. */
  17349. particleSystem: ParticleSystem);
  17350. /**
  17351. * Clones the sub emitter
  17352. * @returns the cloned sub emitter
  17353. */
  17354. clone(): SubEmitter;
  17355. /**
  17356. * Serialize current object to a JSON object
  17357. * @returns the serialized object
  17358. */
  17359. serialize(): any;
  17360. /** @hidden */
  17361. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17362. /**
  17363. * Creates a new SubEmitter from a serialized JSON version
  17364. * @param serializationObject defines the JSON object to read from
  17365. * @param scene defines the hosting scene
  17366. * @param rootUrl defines the rootUrl for data loading
  17367. * @returns a new SubEmitter
  17368. */
  17369. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17370. /** Release associated resources */
  17371. dispose(): void;
  17372. }
  17373. }
  17374. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17375. /** @hidden */
  17376. export var clipPlaneFragmentDeclaration: {
  17377. name: string;
  17378. shader: string;
  17379. };
  17380. }
  17381. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17382. /** @hidden */
  17383. export var imageProcessingDeclaration: {
  17384. name: string;
  17385. shader: string;
  17386. };
  17387. }
  17388. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17389. /** @hidden */
  17390. export var imageProcessingFunctions: {
  17391. name: string;
  17392. shader: string;
  17393. };
  17394. }
  17395. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17396. /** @hidden */
  17397. export var clipPlaneFragment: {
  17398. name: string;
  17399. shader: string;
  17400. };
  17401. }
  17402. declare module "babylonjs/Shaders/particles.fragment" {
  17403. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17404. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17405. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17406. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17407. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17408. /** @hidden */
  17409. export var particlesPixelShader: {
  17410. name: string;
  17411. shader: string;
  17412. };
  17413. }
  17414. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17415. /** @hidden */
  17416. export var clipPlaneVertexDeclaration: {
  17417. name: string;
  17418. shader: string;
  17419. };
  17420. }
  17421. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17422. /** @hidden */
  17423. export var clipPlaneVertex: {
  17424. name: string;
  17425. shader: string;
  17426. };
  17427. }
  17428. declare module "babylonjs/Shaders/particles.vertex" {
  17429. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17430. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17431. /** @hidden */
  17432. export var particlesVertexShader: {
  17433. name: string;
  17434. shader: string;
  17435. };
  17436. }
  17437. declare module "babylonjs/Particles/particleSystem" {
  17438. import { Nullable } from "babylonjs/types";
  17439. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17440. import { Observable } from "babylonjs/Misc/observable";
  17441. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17442. import { Effect } from "babylonjs/Materials/effect";
  17443. import { Scene, IDisposable } from "babylonjs/scene";
  17444. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17445. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17446. import { Particle } from "babylonjs/Particles/particle";
  17447. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17449. import "babylonjs/Shaders/particles.fragment";
  17450. import "babylonjs/Shaders/particles.vertex";
  17451. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17452. /**
  17453. * This represents a particle system in Babylon.
  17454. * 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.
  17455. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17456. * @example https://doc.babylonjs.com/babylon101/particles
  17457. */
  17458. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17459. /**
  17460. * Billboard mode will only apply to Y axis
  17461. */
  17462. static readonly BILLBOARDMODE_Y: number;
  17463. /**
  17464. * Billboard mode will apply to all axes
  17465. */
  17466. static readonly BILLBOARDMODE_ALL: number;
  17467. /**
  17468. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17469. */
  17470. static readonly BILLBOARDMODE_STRETCHED: number;
  17471. /**
  17472. * This function can be defined to provide custom update for active particles.
  17473. * This function will be called instead of regular update (age, position, color, etc.).
  17474. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17475. */
  17476. updateFunction: (particles: Particle[]) => void;
  17477. private _emitterWorldMatrix;
  17478. /**
  17479. * This function can be defined to specify initial direction for every new particle.
  17480. * It by default use the emitterType defined function
  17481. */
  17482. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17483. /**
  17484. * This function can be defined to specify initial position for every new particle.
  17485. * It by default use the emitterType defined function
  17486. */
  17487. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17488. /**
  17489. * @hidden
  17490. */
  17491. _inheritedVelocityOffset: Vector3;
  17492. /**
  17493. * An event triggered when the system is disposed
  17494. */
  17495. onDisposeObservable: Observable<ParticleSystem>;
  17496. private _onDisposeObserver;
  17497. /**
  17498. * Sets a callback that will be triggered when the system is disposed
  17499. */
  17500. onDispose: () => void;
  17501. private _particles;
  17502. private _epsilon;
  17503. private _capacity;
  17504. private _stockParticles;
  17505. private _newPartsExcess;
  17506. private _vertexData;
  17507. private _vertexBuffer;
  17508. private _vertexBuffers;
  17509. private _spriteBuffer;
  17510. private _indexBuffer;
  17511. private _effect;
  17512. private _customEffect;
  17513. private _cachedDefines;
  17514. private _scaledColorStep;
  17515. private _colorDiff;
  17516. private _scaledDirection;
  17517. private _scaledGravity;
  17518. private _currentRenderId;
  17519. private _alive;
  17520. private _useInstancing;
  17521. private _started;
  17522. private _stopped;
  17523. private _actualFrame;
  17524. private _scaledUpdateSpeed;
  17525. private _vertexBufferSize;
  17526. /** @hidden */
  17527. _currentEmitRateGradient: Nullable<FactorGradient>;
  17528. /** @hidden */
  17529. _currentEmitRate1: number;
  17530. /** @hidden */
  17531. _currentEmitRate2: number;
  17532. /** @hidden */
  17533. _currentStartSizeGradient: Nullable<FactorGradient>;
  17534. /** @hidden */
  17535. _currentStartSize1: number;
  17536. /** @hidden */
  17537. _currentStartSize2: number;
  17538. private readonly _rawTextureWidth;
  17539. private _rampGradientsTexture;
  17540. private _useRampGradients;
  17541. /** Gets or sets a boolean indicating that ramp gradients must be used
  17542. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17543. */
  17544. useRampGradients: boolean;
  17545. /**
  17546. * 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.
  17547. * 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: [])
  17548. */
  17549. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17550. private _subEmitters;
  17551. /**
  17552. * @hidden
  17553. * If the particle systems emitter should be disposed when the particle system is disposed
  17554. */
  17555. _disposeEmitterOnDispose: boolean;
  17556. /**
  17557. * The current active Sub-systems, this property is used by the root particle system only.
  17558. */
  17559. activeSubSystems: Array<ParticleSystem>;
  17560. private _rootParticleSystem;
  17561. /**
  17562. * Gets the current list of active particles
  17563. */
  17564. readonly particles: Particle[];
  17565. /**
  17566. * Returns the string "ParticleSystem"
  17567. * @returns a string containing the class name
  17568. */
  17569. getClassName(): string;
  17570. /**
  17571. * Instantiates a particle system.
  17572. * 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.
  17573. * @param name The name of the particle system
  17574. * @param capacity The max number of particles alive at the same time
  17575. * @param scene The scene the particle system belongs to
  17576. * @param customEffect a custom effect used to change the way particles are rendered by default
  17577. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17578. * @param epsilon Offset used to render the particles
  17579. */
  17580. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17581. private _addFactorGradient;
  17582. private _removeFactorGradient;
  17583. /**
  17584. * Adds a new life time gradient
  17585. * @param gradient defines the gradient to use (between 0 and 1)
  17586. * @param factor defines the life time factor to affect to the specified gradient
  17587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17588. * @returns the current particle system
  17589. */
  17590. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17591. /**
  17592. * Remove a specific life time gradient
  17593. * @param gradient defines the gradient to remove
  17594. * @returns the current particle system
  17595. */
  17596. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17597. /**
  17598. * Adds a new size gradient
  17599. * @param gradient defines the gradient to use (between 0 and 1)
  17600. * @param factor defines the size factor to affect to the specified gradient
  17601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17602. * @returns the current particle system
  17603. */
  17604. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17605. /**
  17606. * Remove a specific size gradient
  17607. * @param gradient defines the gradient to remove
  17608. * @returns the current particle system
  17609. */
  17610. removeSizeGradient(gradient: number): IParticleSystem;
  17611. /**
  17612. * Adds a new color remap gradient
  17613. * @param gradient defines the gradient to use (between 0 and 1)
  17614. * @param min defines the color remap minimal range
  17615. * @param max defines the color remap maximal range
  17616. * @returns the current particle system
  17617. */
  17618. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17619. /**
  17620. * Remove a specific color remap gradient
  17621. * @param gradient defines the gradient to remove
  17622. * @returns the current particle system
  17623. */
  17624. removeColorRemapGradient(gradient: number): IParticleSystem;
  17625. /**
  17626. * Adds a new alpha remap gradient
  17627. * @param gradient defines the gradient to use (between 0 and 1)
  17628. * @param min defines the alpha remap minimal range
  17629. * @param max defines the alpha remap maximal range
  17630. * @returns the current particle system
  17631. */
  17632. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17633. /**
  17634. * Remove a specific alpha remap gradient
  17635. * @param gradient defines the gradient to remove
  17636. * @returns the current particle system
  17637. */
  17638. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17639. /**
  17640. * Adds a new angular speed gradient
  17641. * @param gradient defines the gradient to use (between 0 and 1)
  17642. * @param factor defines the angular speed to affect to the specified gradient
  17643. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17644. * @returns the current particle system
  17645. */
  17646. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17647. /**
  17648. * Remove a specific angular speed gradient
  17649. * @param gradient defines the gradient to remove
  17650. * @returns the current particle system
  17651. */
  17652. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17653. /**
  17654. * Adds a new velocity gradient
  17655. * @param gradient defines the gradient to use (between 0 and 1)
  17656. * @param factor defines the velocity to affect to the specified gradient
  17657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17658. * @returns the current particle system
  17659. */
  17660. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17661. /**
  17662. * Remove a specific velocity gradient
  17663. * @param gradient defines the gradient to remove
  17664. * @returns the current particle system
  17665. */
  17666. removeVelocityGradient(gradient: number): IParticleSystem;
  17667. /**
  17668. * Adds a new limit velocity gradient
  17669. * @param gradient defines the gradient to use (between 0 and 1)
  17670. * @param factor defines the limit velocity value to affect to the specified gradient
  17671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17672. * @returns the current particle system
  17673. */
  17674. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17675. /**
  17676. * Remove a specific limit velocity gradient
  17677. * @param gradient defines the gradient to remove
  17678. * @returns the current particle system
  17679. */
  17680. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17681. /**
  17682. * Adds a new drag gradient
  17683. * @param gradient defines the gradient to use (between 0 and 1)
  17684. * @param factor defines the drag value to affect to the specified gradient
  17685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17686. * @returns the current particle system
  17687. */
  17688. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17689. /**
  17690. * Remove a specific drag gradient
  17691. * @param gradient defines the gradient to remove
  17692. * @returns the current particle system
  17693. */
  17694. removeDragGradient(gradient: number): IParticleSystem;
  17695. /**
  17696. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17697. * @param gradient defines the gradient to use (between 0 and 1)
  17698. * @param factor defines the emit rate value to affect to the specified gradient
  17699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17700. * @returns the current particle system
  17701. */
  17702. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17703. /**
  17704. * Remove a specific emit rate gradient
  17705. * @param gradient defines the gradient to remove
  17706. * @returns the current particle system
  17707. */
  17708. removeEmitRateGradient(gradient: number): IParticleSystem;
  17709. /**
  17710. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17711. * @param gradient defines the gradient to use (between 0 and 1)
  17712. * @param factor defines the start size value to affect to the specified gradient
  17713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17714. * @returns the current particle system
  17715. */
  17716. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17717. /**
  17718. * Remove a specific start size gradient
  17719. * @param gradient defines the gradient to remove
  17720. * @returns the current particle system
  17721. */
  17722. removeStartSizeGradient(gradient: number): IParticleSystem;
  17723. private _createRampGradientTexture;
  17724. /**
  17725. * Gets the current list of ramp gradients.
  17726. * You must use addRampGradient and removeRampGradient to udpate this list
  17727. * @returns the list of ramp gradients
  17728. */
  17729. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17730. /**
  17731. * Adds a new ramp gradient used to remap particle colors
  17732. * @param gradient defines the gradient to use (between 0 and 1)
  17733. * @param color defines the color to affect to the specified gradient
  17734. * @returns the current particle system
  17735. */
  17736. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17737. /**
  17738. * Remove a specific ramp gradient
  17739. * @param gradient defines the gradient to remove
  17740. * @returns the current particle system
  17741. */
  17742. removeRampGradient(gradient: number): ParticleSystem;
  17743. /**
  17744. * Adds a new color gradient
  17745. * @param gradient defines the gradient to use (between 0 and 1)
  17746. * @param color1 defines the color to affect to the specified gradient
  17747. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17748. * @returns this particle system
  17749. */
  17750. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17751. /**
  17752. * Remove a specific color gradient
  17753. * @param gradient defines the gradient to remove
  17754. * @returns this particle system
  17755. */
  17756. removeColorGradient(gradient: number): IParticleSystem;
  17757. private _fetchR;
  17758. protected _reset(): void;
  17759. private _resetEffect;
  17760. private _createVertexBuffers;
  17761. private _createIndexBuffer;
  17762. /**
  17763. * Gets the maximum number of particles active at the same time.
  17764. * @returns The max number of active particles.
  17765. */
  17766. getCapacity(): number;
  17767. /**
  17768. * Gets whether there are still active particles in the system.
  17769. * @returns True if it is alive, otherwise false.
  17770. */
  17771. isAlive(): boolean;
  17772. /**
  17773. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17774. * @returns True if it has been started, otherwise false.
  17775. */
  17776. isStarted(): boolean;
  17777. private _prepareSubEmitterInternalArray;
  17778. /**
  17779. * Starts the particle system and begins to emit
  17780. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17781. */
  17782. start(delay?: number): void;
  17783. /**
  17784. * Stops the particle system.
  17785. * @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.
  17786. */
  17787. stop(stopSubEmitters?: boolean): void;
  17788. /**
  17789. * Remove all active particles
  17790. */
  17791. reset(): void;
  17792. /**
  17793. * @hidden (for internal use only)
  17794. */
  17795. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17796. /**
  17797. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17798. * Its lifetime will start back at 0.
  17799. */
  17800. recycleParticle: (particle: Particle) => void;
  17801. private _stopSubEmitters;
  17802. private _createParticle;
  17803. private _removeFromRoot;
  17804. private _emitFromParticle;
  17805. private _update;
  17806. /** @hidden */
  17807. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17808. /** @hidden */
  17809. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17810. /** @hidden */
  17811. private _getEffect;
  17812. /**
  17813. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17814. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17815. */
  17816. animate(preWarmOnly?: boolean): void;
  17817. private _appendParticleVertices;
  17818. /**
  17819. * Rebuilds the particle system.
  17820. */
  17821. rebuild(): void;
  17822. /**
  17823. * Is this system ready to be used/rendered
  17824. * @return true if the system is ready
  17825. */
  17826. isReady(): boolean;
  17827. private _render;
  17828. /**
  17829. * Renders the particle system in its current state.
  17830. * @returns the current number of particles
  17831. */
  17832. render(): number;
  17833. /**
  17834. * Disposes the particle system and free the associated resources
  17835. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17836. */
  17837. dispose(disposeTexture?: boolean): void;
  17838. /**
  17839. * Clones the particle system.
  17840. * @param name The name of the cloned object
  17841. * @param newEmitter The new emitter to use
  17842. * @returns the cloned particle system
  17843. */
  17844. clone(name: string, newEmitter: any): ParticleSystem;
  17845. /**
  17846. * Serializes the particle system to a JSON object.
  17847. * @returns the JSON object
  17848. */
  17849. serialize(): any;
  17850. /** @hidden */
  17851. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17852. /** @hidden */
  17853. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17854. /**
  17855. * Parses a JSON object to create a particle system.
  17856. * @param parsedParticleSystem The JSON object to parse
  17857. * @param scene The scene to create the particle system in
  17858. * @param rootUrl The root url to use to load external dependencies like texture
  17859. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17860. * @returns the Parsed particle system
  17861. */
  17862. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17863. }
  17864. }
  17865. declare module "babylonjs/Particles/particle" {
  17866. import { Nullable } from "babylonjs/types";
  17867. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17868. import { Color4 } from "babylonjs/Maths/math.color";
  17869. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17870. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17871. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17872. /**
  17873. * A particle represents one of the element emitted by a particle system.
  17874. * This is mainly define by its coordinates, direction, velocity and age.
  17875. */
  17876. export class Particle {
  17877. /**
  17878. * The particle system the particle belongs to.
  17879. */
  17880. particleSystem: ParticleSystem;
  17881. private static _Count;
  17882. /**
  17883. * Unique ID of the particle
  17884. */
  17885. id: number;
  17886. /**
  17887. * The world position of the particle in the scene.
  17888. */
  17889. position: Vector3;
  17890. /**
  17891. * The world direction of the particle in the scene.
  17892. */
  17893. direction: Vector3;
  17894. /**
  17895. * The color of the particle.
  17896. */
  17897. color: Color4;
  17898. /**
  17899. * The color change of the particle per step.
  17900. */
  17901. colorStep: Color4;
  17902. /**
  17903. * Defines how long will the life of the particle be.
  17904. */
  17905. lifeTime: number;
  17906. /**
  17907. * The current age of the particle.
  17908. */
  17909. age: number;
  17910. /**
  17911. * The current size of the particle.
  17912. */
  17913. size: number;
  17914. /**
  17915. * The current scale of the particle.
  17916. */
  17917. scale: Vector2;
  17918. /**
  17919. * The current angle of the particle.
  17920. */
  17921. angle: number;
  17922. /**
  17923. * Defines how fast is the angle changing.
  17924. */
  17925. angularSpeed: number;
  17926. /**
  17927. * Defines the cell index used by the particle to be rendered from a sprite.
  17928. */
  17929. cellIndex: number;
  17930. /**
  17931. * The information required to support color remapping
  17932. */
  17933. remapData: Vector4;
  17934. /** @hidden */
  17935. _randomCellOffset?: number;
  17936. /** @hidden */
  17937. _initialDirection: Nullable<Vector3>;
  17938. /** @hidden */
  17939. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17940. /** @hidden */
  17941. _initialStartSpriteCellID: number;
  17942. /** @hidden */
  17943. _initialEndSpriteCellID: number;
  17944. /** @hidden */
  17945. _currentColorGradient: Nullable<ColorGradient>;
  17946. /** @hidden */
  17947. _currentColor1: Color4;
  17948. /** @hidden */
  17949. _currentColor2: Color4;
  17950. /** @hidden */
  17951. _currentSizeGradient: Nullable<FactorGradient>;
  17952. /** @hidden */
  17953. _currentSize1: number;
  17954. /** @hidden */
  17955. _currentSize2: number;
  17956. /** @hidden */
  17957. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17958. /** @hidden */
  17959. _currentAngularSpeed1: number;
  17960. /** @hidden */
  17961. _currentAngularSpeed2: number;
  17962. /** @hidden */
  17963. _currentVelocityGradient: Nullable<FactorGradient>;
  17964. /** @hidden */
  17965. _currentVelocity1: number;
  17966. /** @hidden */
  17967. _currentVelocity2: number;
  17968. /** @hidden */
  17969. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17970. /** @hidden */
  17971. _currentLimitVelocity1: number;
  17972. /** @hidden */
  17973. _currentLimitVelocity2: number;
  17974. /** @hidden */
  17975. _currentDragGradient: Nullable<FactorGradient>;
  17976. /** @hidden */
  17977. _currentDrag1: number;
  17978. /** @hidden */
  17979. _currentDrag2: number;
  17980. /** @hidden */
  17981. _randomNoiseCoordinates1: Vector3;
  17982. /** @hidden */
  17983. _randomNoiseCoordinates2: Vector3;
  17984. /**
  17985. * Creates a new instance Particle
  17986. * @param particleSystem the particle system the particle belongs to
  17987. */
  17988. constructor(
  17989. /**
  17990. * The particle system the particle belongs to.
  17991. */
  17992. particleSystem: ParticleSystem);
  17993. private updateCellInfoFromSystem;
  17994. /**
  17995. * Defines how the sprite cell index is updated for the particle
  17996. */
  17997. updateCellIndex(): void;
  17998. /** @hidden */
  17999. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18000. /** @hidden */
  18001. _inheritParticleInfoToSubEmitters(): void;
  18002. /** @hidden */
  18003. _reset(): void;
  18004. /**
  18005. * Copy the properties of particle to another one.
  18006. * @param other the particle to copy the information to.
  18007. */
  18008. copyTo(other: Particle): void;
  18009. }
  18010. }
  18011. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18012. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18013. import { Effect } from "babylonjs/Materials/effect";
  18014. import { Particle } from "babylonjs/Particles/particle";
  18015. /**
  18016. * Particle emitter represents a volume emitting particles.
  18017. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18018. */
  18019. export interface IParticleEmitterType {
  18020. /**
  18021. * Called by the particle System when the direction is computed for the created particle.
  18022. * @param worldMatrix is the world matrix of the particle system
  18023. * @param directionToUpdate is the direction vector to update with the result
  18024. * @param particle is the particle we are computed the direction for
  18025. */
  18026. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18027. /**
  18028. * Called by the particle System when the position is computed for the created particle.
  18029. * @param worldMatrix is the world matrix of the particle system
  18030. * @param positionToUpdate is the position vector to update with the result
  18031. * @param particle is the particle we are computed the position for
  18032. */
  18033. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18034. /**
  18035. * Clones the current emitter and returns a copy of it
  18036. * @returns the new emitter
  18037. */
  18038. clone(): IParticleEmitterType;
  18039. /**
  18040. * Called by the GPUParticleSystem to setup the update shader
  18041. * @param effect defines the update shader
  18042. */
  18043. applyToShader(effect: Effect): void;
  18044. /**
  18045. * Returns a string to use to update the GPU particles update shader
  18046. * @returns the effect defines string
  18047. */
  18048. getEffectDefines(): string;
  18049. /**
  18050. * Returns a string representing the class name
  18051. * @returns a string containing the class name
  18052. */
  18053. getClassName(): string;
  18054. /**
  18055. * Serializes the particle system to a JSON object.
  18056. * @returns the JSON object
  18057. */
  18058. serialize(): any;
  18059. /**
  18060. * Parse properties from a JSON object
  18061. * @param serializationObject defines the JSON object
  18062. */
  18063. parse(serializationObject: any): void;
  18064. }
  18065. }
  18066. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18067. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18068. import { Effect } from "babylonjs/Materials/effect";
  18069. import { Particle } from "babylonjs/Particles/particle";
  18070. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18071. /**
  18072. * Particle emitter emitting particles from the inside of a box.
  18073. * It emits the particles randomly between 2 given directions.
  18074. */
  18075. export class BoxParticleEmitter implements IParticleEmitterType {
  18076. /**
  18077. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18078. */
  18079. direction1: Vector3;
  18080. /**
  18081. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18082. */
  18083. direction2: Vector3;
  18084. /**
  18085. * 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.
  18086. */
  18087. minEmitBox: Vector3;
  18088. /**
  18089. * 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.
  18090. */
  18091. maxEmitBox: Vector3;
  18092. /**
  18093. * Creates a new instance BoxParticleEmitter
  18094. */
  18095. constructor();
  18096. /**
  18097. * Called by the particle System when the direction is computed for the created particle.
  18098. * @param worldMatrix is the world matrix of the particle system
  18099. * @param directionToUpdate is the direction vector to update with the result
  18100. * @param particle is the particle we are computed the direction for
  18101. */
  18102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18103. /**
  18104. * Called by the particle System when the position is computed for the created particle.
  18105. * @param worldMatrix is the world matrix of the particle system
  18106. * @param positionToUpdate is the position vector to update with the result
  18107. * @param particle is the particle we are computed the position for
  18108. */
  18109. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18110. /**
  18111. * Clones the current emitter and returns a copy of it
  18112. * @returns the new emitter
  18113. */
  18114. clone(): BoxParticleEmitter;
  18115. /**
  18116. * Called by the GPUParticleSystem to setup the update shader
  18117. * @param effect defines the update shader
  18118. */
  18119. applyToShader(effect: Effect): void;
  18120. /**
  18121. * Returns a string to use to update the GPU particles update shader
  18122. * @returns a string containng the defines string
  18123. */
  18124. getEffectDefines(): string;
  18125. /**
  18126. * Returns the string "BoxParticleEmitter"
  18127. * @returns a string containing the class name
  18128. */
  18129. getClassName(): string;
  18130. /**
  18131. * Serializes the particle system to a JSON object.
  18132. * @returns the JSON object
  18133. */
  18134. serialize(): any;
  18135. /**
  18136. * Parse properties from a JSON object
  18137. * @param serializationObject defines the JSON object
  18138. */
  18139. parse(serializationObject: any): void;
  18140. }
  18141. }
  18142. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18143. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18144. import { Effect } from "babylonjs/Materials/effect";
  18145. import { Particle } from "babylonjs/Particles/particle";
  18146. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18147. /**
  18148. * Particle emitter emitting particles from the inside of a cone.
  18149. * It emits the particles alongside the cone volume from the base to the particle.
  18150. * The emission direction might be randomized.
  18151. */
  18152. export class ConeParticleEmitter implements IParticleEmitterType {
  18153. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18154. directionRandomizer: number;
  18155. private _radius;
  18156. private _angle;
  18157. private _height;
  18158. /**
  18159. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18160. */
  18161. radiusRange: number;
  18162. /**
  18163. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18164. */
  18165. heightRange: number;
  18166. /**
  18167. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18168. */
  18169. emitFromSpawnPointOnly: boolean;
  18170. /**
  18171. * Gets or sets the radius of the emission cone
  18172. */
  18173. radius: number;
  18174. /**
  18175. * Gets or sets the angle of the emission cone
  18176. */
  18177. angle: number;
  18178. private _buildHeight;
  18179. /**
  18180. * Creates a new instance ConeParticleEmitter
  18181. * @param radius the radius of the emission cone (1 by default)
  18182. * @param angle the cone base angle (PI by default)
  18183. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18184. */
  18185. constructor(radius?: number, angle?: number,
  18186. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18187. directionRandomizer?: number);
  18188. /**
  18189. * Called by the particle System when the direction is computed for the created particle.
  18190. * @param worldMatrix is the world matrix of the particle system
  18191. * @param directionToUpdate is the direction vector to update with the result
  18192. * @param particle is the particle we are computed the direction for
  18193. */
  18194. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18195. /**
  18196. * Called by the particle System when the position is computed for the created particle.
  18197. * @param worldMatrix is the world matrix of the particle system
  18198. * @param positionToUpdate is the position vector to update with the result
  18199. * @param particle is the particle we are computed the position for
  18200. */
  18201. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18202. /**
  18203. * Clones the current emitter and returns a copy of it
  18204. * @returns the new emitter
  18205. */
  18206. clone(): ConeParticleEmitter;
  18207. /**
  18208. * Called by the GPUParticleSystem to setup the update shader
  18209. * @param effect defines the update shader
  18210. */
  18211. applyToShader(effect: Effect): void;
  18212. /**
  18213. * Returns a string to use to update the GPU particles update shader
  18214. * @returns a string containng the defines string
  18215. */
  18216. getEffectDefines(): string;
  18217. /**
  18218. * Returns the string "ConeParticleEmitter"
  18219. * @returns a string containing the class name
  18220. */
  18221. getClassName(): string;
  18222. /**
  18223. * Serializes the particle system to a JSON object.
  18224. * @returns the JSON object
  18225. */
  18226. serialize(): any;
  18227. /**
  18228. * Parse properties from a JSON object
  18229. * @param serializationObject defines the JSON object
  18230. */
  18231. parse(serializationObject: any): void;
  18232. }
  18233. }
  18234. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18235. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18236. import { Effect } from "babylonjs/Materials/effect";
  18237. import { Particle } from "babylonjs/Particles/particle";
  18238. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18239. /**
  18240. * Particle emitter emitting particles from the inside of a cylinder.
  18241. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18242. */
  18243. export class CylinderParticleEmitter implements IParticleEmitterType {
  18244. /**
  18245. * The radius of the emission cylinder.
  18246. */
  18247. radius: number;
  18248. /**
  18249. * The height of the emission cylinder.
  18250. */
  18251. height: number;
  18252. /**
  18253. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18254. */
  18255. radiusRange: number;
  18256. /**
  18257. * How much to randomize the particle direction [0-1].
  18258. */
  18259. directionRandomizer: number;
  18260. /**
  18261. * Creates a new instance CylinderParticleEmitter
  18262. * @param radius the radius of the emission cylinder (1 by default)
  18263. * @param height the height of the emission cylinder (1 by default)
  18264. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18265. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18266. */
  18267. constructor(
  18268. /**
  18269. * The radius of the emission cylinder.
  18270. */
  18271. radius?: number,
  18272. /**
  18273. * The height of the emission cylinder.
  18274. */
  18275. height?: number,
  18276. /**
  18277. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18278. */
  18279. radiusRange?: number,
  18280. /**
  18281. * How much to randomize the particle direction [0-1].
  18282. */
  18283. directionRandomizer?: number);
  18284. /**
  18285. * Called by the particle System when the direction is computed for the created particle.
  18286. * @param worldMatrix is the world matrix of the particle system
  18287. * @param directionToUpdate is the direction vector to update with the result
  18288. * @param particle is the particle we are computed the direction for
  18289. */
  18290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18291. /**
  18292. * Called by the particle System when the position is computed for the created particle.
  18293. * @param worldMatrix is the world matrix of the particle system
  18294. * @param positionToUpdate is the position vector to update with the result
  18295. * @param particle is the particle we are computed the position for
  18296. */
  18297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18298. /**
  18299. * Clones the current emitter and returns a copy of it
  18300. * @returns the new emitter
  18301. */
  18302. clone(): CylinderParticleEmitter;
  18303. /**
  18304. * Called by the GPUParticleSystem to setup the update shader
  18305. * @param effect defines the update shader
  18306. */
  18307. applyToShader(effect: Effect): void;
  18308. /**
  18309. * Returns a string to use to update the GPU particles update shader
  18310. * @returns a string containng the defines string
  18311. */
  18312. getEffectDefines(): string;
  18313. /**
  18314. * Returns the string "CylinderParticleEmitter"
  18315. * @returns a string containing the class name
  18316. */
  18317. getClassName(): string;
  18318. /**
  18319. * Serializes the particle system to a JSON object.
  18320. * @returns the JSON object
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Parse properties from a JSON object
  18325. * @param serializationObject defines the JSON object
  18326. */
  18327. parse(serializationObject: any): void;
  18328. }
  18329. /**
  18330. * Particle emitter emitting particles from the inside of a cylinder.
  18331. * It emits the particles randomly between two vectors.
  18332. */
  18333. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18334. /**
  18335. * The min limit of the emission direction.
  18336. */
  18337. direction1: Vector3;
  18338. /**
  18339. * The max limit of the emission direction.
  18340. */
  18341. direction2: Vector3;
  18342. /**
  18343. * Creates a new instance CylinderDirectedParticleEmitter
  18344. * @param radius the radius of the emission cylinder (1 by default)
  18345. * @param height the height of the emission cylinder (1 by default)
  18346. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18347. * @param direction1 the min limit of the emission direction (up vector by default)
  18348. * @param direction2 the max limit of the emission direction (up vector by default)
  18349. */
  18350. constructor(radius?: number, height?: number, radiusRange?: number,
  18351. /**
  18352. * The min limit of the emission direction.
  18353. */
  18354. direction1?: Vector3,
  18355. /**
  18356. * The max limit of the emission direction.
  18357. */
  18358. direction2?: Vector3);
  18359. /**
  18360. * Called by the particle System when the direction is computed for the created particle.
  18361. * @param worldMatrix is the world matrix of the particle system
  18362. * @param directionToUpdate is the direction vector to update with the result
  18363. * @param particle is the particle we are computed the direction for
  18364. */
  18365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18366. /**
  18367. * Clones the current emitter and returns a copy of it
  18368. * @returns the new emitter
  18369. */
  18370. clone(): CylinderDirectedParticleEmitter;
  18371. /**
  18372. * Called by the GPUParticleSystem to setup the update shader
  18373. * @param effect defines the update shader
  18374. */
  18375. applyToShader(effect: Effect): void;
  18376. /**
  18377. * Returns a string to use to update the GPU particles update shader
  18378. * @returns a string containng the defines string
  18379. */
  18380. getEffectDefines(): string;
  18381. /**
  18382. * Returns the string "CylinderDirectedParticleEmitter"
  18383. * @returns a string containing the class name
  18384. */
  18385. getClassName(): string;
  18386. /**
  18387. * Serializes the particle system to a JSON object.
  18388. * @returns the JSON object
  18389. */
  18390. serialize(): any;
  18391. /**
  18392. * Parse properties from a JSON object
  18393. * @param serializationObject defines the JSON object
  18394. */
  18395. parse(serializationObject: any): void;
  18396. }
  18397. }
  18398. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18399. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18400. import { Effect } from "babylonjs/Materials/effect";
  18401. import { Particle } from "babylonjs/Particles/particle";
  18402. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18403. /**
  18404. * Particle emitter emitting particles from the inside of a hemisphere.
  18405. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18406. */
  18407. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18408. /**
  18409. * The radius of the emission hemisphere.
  18410. */
  18411. radius: number;
  18412. /**
  18413. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18414. */
  18415. radiusRange: number;
  18416. /**
  18417. * How much to randomize the particle direction [0-1].
  18418. */
  18419. directionRandomizer: number;
  18420. /**
  18421. * Creates a new instance HemisphericParticleEmitter
  18422. * @param radius the radius of the emission hemisphere (1 by default)
  18423. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18424. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18425. */
  18426. constructor(
  18427. /**
  18428. * The radius of the emission hemisphere.
  18429. */
  18430. radius?: number,
  18431. /**
  18432. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18433. */
  18434. radiusRange?: number,
  18435. /**
  18436. * How much to randomize the particle direction [0-1].
  18437. */
  18438. directionRandomizer?: number);
  18439. /**
  18440. * Called by the particle System when the direction is computed for the created particle.
  18441. * @param worldMatrix is the world matrix of the particle system
  18442. * @param directionToUpdate is the direction vector to update with the result
  18443. * @param particle is the particle we are computed the direction for
  18444. */
  18445. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18446. /**
  18447. * Called by the particle System when the position is computed for the created particle.
  18448. * @param worldMatrix is the world matrix of the particle system
  18449. * @param positionToUpdate is the position vector to update with the result
  18450. * @param particle is the particle we are computed the position for
  18451. */
  18452. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18453. /**
  18454. * Clones the current emitter and returns a copy of it
  18455. * @returns the new emitter
  18456. */
  18457. clone(): HemisphericParticleEmitter;
  18458. /**
  18459. * Called by the GPUParticleSystem to setup the update shader
  18460. * @param effect defines the update shader
  18461. */
  18462. applyToShader(effect: Effect): void;
  18463. /**
  18464. * Returns a string to use to update the GPU particles update shader
  18465. * @returns a string containng the defines string
  18466. */
  18467. getEffectDefines(): string;
  18468. /**
  18469. * Returns the string "HemisphericParticleEmitter"
  18470. * @returns a string containing the class name
  18471. */
  18472. getClassName(): string;
  18473. /**
  18474. * Serializes the particle system to a JSON object.
  18475. * @returns the JSON object
  18476. */
  18477. serialize(): any;
  18478. /**
  18479. * Parse properties from a JSON object
  18480. * @param serializationObject defines the JSON object
  18481. */
  18482. parse(serializationObject: any): void;
  18483. }
  18484. }
  18485. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18486. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18487. import { Effect } from "babylonjs/Materials/effect";
  18488. import { Particle } from "babylonjs/Particles/particle";
  18489. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18490. /**
  18491. * Particle emitter emitting particles from a point.
  18492. * It emits the particles randomly between 2 given directions.
  18493. */
  18494. export class PointParticleEmitter implements IParticleEmitterType {
  18495. /**
  18496. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18497. */
  18498. direction1: Vector3;
  18499. /**
  18500. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18501. */
  18502. direction2: Vector3;
  18503. /**
  18504. * Creates a new instance PointParticleEmitter
  18505. */
  18506. constructor();
  18507. /**
  18508. * Called by the particle System when the direction is computed for the created particle.
  18509. * @param worldMatrix is the world matrix of the particle system
  18510. * @param directionToUpdate is the direction vector to update with the result
  18511. * @param particle is the particle we are computed the direction for
  18512. */
  18513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18514. /**
  18515. * Called by the particle System when the position is computed for the created particle.
  18516. * @param worldMatrix is the world matrix of the particle system
  18517. * @param positionToUpdate is the position vector to update with the result
  18518. * @param particle is the particle we are computed the position for
  18519. */
  18520. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18521. /**
  18522. * Clones the current emitter and returns a copy of it
  18523. * @returns the new emitter
  18524. */
  18525. clone(): PointParticleEmitter;
  18526. /**
  18527. * Called by the GPUParticleSystem to setup the update shader
  18528. * @param effect defines the update shader
  18529. */
  18530. applyToShader(effect: Effect): void;
  18531. /**
  18532. * Returns a string to use to update the GPU particles update shader
  18533. * @returns a string containng the defines string
  18534. */
  18535. getEffectDefines(): string;
  18536. /**
  18537. * Returns the string "PointParticleEmitter"
  18538. * @returns a string containing the class name
  18539. */
  18540. getClassName(): string;
  18541. /**
  18542. * Serializes the particle system to a JSON object.
  18543. * @returns the JSON object
  18544. */
  18545. serialize(): any;
  18546. /**
  18547. * Parse properties from a JSON object
  18548. * @param serializationObject defines the JSON object
  18549. */
  18550. parse(serializationObject: any): void;
  18551. }
  18552. }
  18553. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18554. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18555. import { Effect } from "babylonjs/Materials/effect";
  18556. import { Particle } from "babylonjs/Particles/particle";
  18557. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18558. /**
  18559. * Particle emitter emitting particles from the inside of a sphere.
  18560. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18561. */
  18562. export class SphereParticleEmitter implements IParticleEmitterType {
  18563. /**
  18564. * The radius of the emission sphere.
  18565. */
  18566. radius: number;
  18567. /**
  18568. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18569. */
  18570. radiusRange: number;
  18571. /**
  18572. * How much to randomize the particle direction [0-1].
  18573. */
  18574. directionRandomizer: number;
  18575. /**
  18576. * Creates a new instance SphereParticleEmitter
  18577. * @param radius the radius of the emission sphere (1 by default)
  18578. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18579. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18580. */
  18581. constructor(
  18582. /**
  18583. * The radius of the emission sphere.
  18584. */
  18585. radius?: number,
  18586. /**
  18587. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18588. */
  18589. radiusRange?: number,
  18590. /**
  18591. * How much to randomize the particle direction [0-1].
  18592. */
  18593. directionRandomizer?: number);
  18594. /**
  18595. * Called by the particle System when the direction is computed for the created particle.
  18596. * @param worldMatrix is the world matrix of the particle system
  18597. * @param directionToUpdate is the direction vector to update with the result
  18598. * @param particle is the particle we are computed the direction for
  18599. */
  18600. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18601. /**
  18602. * Called by the particle System when the position is computed for the created particle.
  18603. * @param worldMatrix is the world matrix of the particle system
  18604. * @param positionToUpdate is the position vector to update with the result
  18605. * @param particle is the particle we are computed the position for
  18606. */
  18607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18608. /**
  18609. * Clones the current emitter and returns a copy of it
  18610. * @returns the new emitter
  18611. */
  18612. clone(): SphereParticleEmitter;
  18613. /**
  18614. * Called by the GPUParticleSystem to setup the update shader
  18615. * @param effect defines the update shader
  18616. */
  18617. applyToShader(effect: Effect): void;
  18618. /**
  18619. * Returns a string to use to update the GPU particles update shader
  18620. * @returns a string containng the defines string
  18621. */
  18622. getEffectDefines(): string;
  18623. /**
  18624. * Returns the string "SphereParticleEmitter"
  18625. * @returns a string containing the class name
  18626. */
  18627. getClassName(): string;
  18628. /**
  18629. * Serializes the particle system to a JSON object.
  18630. * @returns the JSON object
  18631. */
  18632. serialize(): any;
  18633. /**
  18634. * Parse properties from a JSON object
  18635. * @param serializationObject defines the JSON object
  18636. */
  18637. parse(serializationObject: any): void;
  18638. }
  18639. /**
  18640. * Particle emitter emitting particles from the inside of a sphere.
  18641. * It emits the particles randomly between two vectors.
  18642. */
  18643. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18644. /**
  18645. * The min limit of the emission direction.
  18646. */
  18647. direction1: Vector3;
  18648. /**
  18649. * The max limit of the emission direction.
  18650. */
  18651. direction2: Vector3;
  18652. /**
  18653. * Creates a new instance SphereDirectedParticleEmitter
  18654. * @param radius the radius of the emission sphere (1 by default)
  18655. * @param direction1 the min limit of the emission direction (up vector by default)
  18656. * @param direction2 the max limit of the emission direction (up vector by default)
  18657. */
  18658. constructor(radius?: number,
  18659. /**
  18660. * The min limit of the emission direction.
  18661. */
  18662. direction1?: Vector3,
  18663. /**
  18664. * The max limit of the emission direction.
  18665. */
  18666. direction2?: Vector3);
  18667. /**
  18668. * Called by the particle System when the direction is computed for the created particle.
  18669. * @param worldMatrix is the world matrix of the particle system
  18670. * @param directionToUpdate is the direction vector to update with the result
  18671. * @param particle is the particle we are computed the direction for
  18672. */
  18673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18674. /**
  18675. * Clones the current emitter and returns a copy of it
  18676. * @returns the new emitter
  18677. */
  18678. clone(): SphereDirectedParticleEmitter;
  18679. /**
  18680. * Called by the GPUParticleSystem to setup the update shader
  18681. * @param effect defines the update shader
  18682. */
  18683. applyToShader(effect: Effect): void;
  18684. /**
  18685. * Returns a string to use to update the GPU particles update shader
  18686. * @returns a string containng the defines string
  18687. */
  18688. getEffectDefines(): string;
  18689. /**
  18690. * Returns the string "SphereDirectedParticleEmitter"
  18691. * @returns a string containing the class name
  18692. */
  18693. getClassName(): string;
  18694. /**
  18695. * Serializes the particle system to a JSON object.
  18696. * @returns the JSON object
  18697. */
  18698. serialize(): any;
  18699. /**
  18700. * Parse properties from a JSON object
  18701. * @param serializationObject defines the JSON object
  18702. */
  18703. parse(serializationObject: any): void;
  18704. }
  18705. }
  18706. declare module "babylonjs/Particles/EmitterTypes/index" {
  18707. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18708. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18709. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18710. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18711. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18712. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18713. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18714. }
  18715. declare module "babylonjs/Particles/IParticleSystem" {
  18716. import { Nullable } from "babylonjs/types";
  18717. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18718. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18720. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18721. import { Texture } from "babylonjs/Materials/Textures/texture";
  18722. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18723. import { Scene } from "babylonjs/scene";
  18724. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18725. import { Animation } from "babylonjs/Animations/animation";
  18726. /**
  18727. * Interface representing a particle system in Babylon.js.
  18728. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18729. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18730. */
  18731. export interface IParticleSystem {
  18732. /**
  18733. * List of animations used by the particle system.
  18734. */
  18735. animations: Animation[];
  18736. /**
  18737. * The id of the Particle system.
  18738. */
  18739. id: string;
  18740. /**
  18741. * The name of the Particle system.
  18742. */
  18743. name: string;
  18744. /**
  18745. * The emitter represents the Mesh or position we are attaching the particle system to.
  18746. */
  18747. emitter: Nullable<AbstractMesh | Vector3>;
  18748. /**
  18749. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18750. */
  18751. isBillboardBased: boolean;
  18752. /**
  18753. * The rendering group used by the Particle system to chose when to render.
  18754. */
  18755. renderingGroupId: number;
  18756. /**
  18757. * The layer mask we are rendering the particles through.
  18758. */
  18759. layerMask: number;
  18760. /**
  18761. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18762. */
  18763. updateSpeed: number;
  18764. /**
  18765. * The amount of time the particle system is running (depends of the overall update speed).
  18766. */
  18767. targetStopDuration: number;
  18768. /**
  18769. * The texture used to render each particle. (this can be a spritesheet)
  18770. */
  18771. particleTexture: Nullable<Texture>;
  18772. /**
  18773. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18774. */
  18775. blendMode: number;
  18776. /**
  18777. * Minimum life time of emitting particles.
  18778. */
  18779. minLifeTime: number;
  18780. /**
  18781. * Maximum life time of emitting particles.
  18782. */
  18783. maxLifeTime: number;
  18784. /**
  18785. * Minimum Size of emitting particles.
  18786. */
  18787. minSize: number;
  18788. /**
  18789. * Maximum Size of emitting particles.
  18790. */
  18791. maxSize: number;
  18792. /**
  18793. * Minimum scale of emitting particles on X axis.
  18794. */
  18795. minScaleX: number;
  18796. /**
  18797. * Maximum scale of emitting particles on X axis.
  18798. */
  18799. maxScaleX: number;
  18800. /**
  18801. * Minimum scale of emitting particles on Y axis.
  18802. */
  18803. minScaleY: number;
  18804. /**
  18805. * Maximum scale of emitting particles on Y axis.
  18806. */
  18807. maxScaleY: number;
  18808. /**
  18809. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18810. */
  18811. color1: Color4;
  18812. /**
  18813. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18814. */
  18815. color2: Color4;
  18816. /**
  18817. * Color the particle will have at the end of its lifetime.
  18818. */
  18819. colorDead: Color4;
  18820. /**
  18821. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18822. */
  18823. emitRate: number;
  18824. /**
  18825. * You can use gravity if you want to give an orientation to your particles.
  18826. */
  18827. gravity: Vector3;
  18828. /**
  18829. * Minimum power of emitting particles.
  18830. */
  18831. minEmitPower: number;
  18832. /**
  18833. * Maximum power of emitting particles.
  18834. */
  18835. maxEmitPower: number;
  18836. /**
  18837. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18838. */
  18839. minAngularSpeed: number;
  18840. /**
  18841. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18842. */
  18843. maxAngularSpeed: number;
  18844. /**
  18845. * Gets or sets the minimal initial rotation in radians.
  18846. */
  18847. minInitialRotation: number;
  18848. /**
  18849. * Gets or sets the maximal initial rotation in radians.
  18850. */
  18851. maxInitialRotation: number;
  18852. /**
  18853. * The particle emitter type defines the emitter used by the particle system.
  18854. * It can be for example box, sphere, or cone...
  18855. */
  18856. particleEmitterType: Nullable<IParticleEmitterType>;
  18857. /**
  18858. * Defines the delay in milliseconds before starting the system (0 by default)
  18859. */
  18860. startDelay: number;
  18861. /**
  18862. * 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
  18863. */
  18864. preWarmCycles: number;
  18865. /**
  18866. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18867. */
  18868. preWarmStepOffset: number;
  18869. /**
  18870. * 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)
  18871. */
  18872. spriteCellChangeSpeed: number;
  18873. /**
  18874. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18875. */
  18876. startSpriteCellID: number;
  18877. /**
  18878. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18879. */
  18880. endSpriteCellID: number;
  18881. /**
  18882. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18883. */
  18884. spriteCellWidth: number;
  18885. /**
  18886. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18887. */
  18888. spriteCellHeight: number;
  18889. /**
  18890. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18891. */
  18892. spriteRandomStartCell: boolean;
  18893. /**
  18894. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18895. */
  18896. isAnimationSheetEnabled: boolean;
  18897. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18898. translationPivot: Vector2;
  18899. /**
  18900. * Gets or sets a texture used to add random noise to particle positions
  18901. */
  18902. noiseTexture: Nullable<BaseTexture>;
  18903. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18904. noiseStrength: Vector3;
  18905. /**
  18906. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18907. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18908. */
  18909. billboardMode: number;
  18910. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18911. limitVelocityDamping: number;
  18912. /**
  18913. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18914. */
  18915. beginAnimationOnStart: boolean;
  18916. /**
  18917. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18918. */
  18919. beginAnimationFrom: number;
  18920. /**
  18921. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18922. */
  18923. beginAnimationTo: number;
  18924. /**
  18925. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18926. */
  18927. beginAnimationLoop: boolean;
  18928. /**
  18929. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18930. */
  18931. disposeOnStop: boolean;
  18932. /**
  18933. * Gets the maximum number of particles active at the same time.
  18934. * @returns The max number of active particles.
  18935. */
  18936. getCapacity(): number;
  18937. /**
  18938. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18939. * @returns True if it has been started, otherwise false.
  18940. */
  18941. isStarted(): boolean;
  18942. /**
  18943. * Animates the particle system for this frame.
  18944. */
  18945. animate(): void;
  18946. /**
  18947. * Renders the particle system in its current state.
  18948. * @returns the current number of particles
  18949. */
  18950. render(): number;
  18951. /**
  18952. * Dispose the particle system and frees its associated resources.
  18953. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18954. */
  18955. dispose(disposeTexture?: boolean): void;
  18956. /**
  18957. * Clones the particle system.
  18958. * @param name The name of the cloned object
  18959. * @param newEmitter The new emitter to use
  18960. * @returns the cloned particle system
  18961. */
  18962. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18963. /**
  18964. * Serializes the particle system to a JSON object.
  18965. * @returns the JSON object
  18966. */
  18967. serialize(): any;
  18968. /**
  18969. * Rebuild the particle system
  18970. */
  18971. rebuild(): void;
  18972. /**
  18973. * Starts the particle system and begins to emit
  18974. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18975. */
  18976. start(delay?: number): void;
  18977. /**
  18978. * Stops the particle system.
  18979. */
  18980. stop(): void;
  18981. /**
  18982. * Remove all active particles
  18983. */
  18984. reset(): void;
  18985. /**
  18986. * Is this system ready to be used/rendered
  18987. * @return true if the system is ready
  18988. */
  18989. isReady(): boolean;
  18990. /**
  18991. * Adds a new color gradient
  18992. * @param gradient defines the gradient to use (between 0 and 1)
  18993. * @param color1 defines the color to affect to the specified gradient
  18994. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18995. * @returns the current particle system
  18996. */
  18997. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18998. /**
  18999. * Remove a specific color gradient
  19000. * @param gradient defines the gradient to remove
  19001. * @returns the current particle system
  19002. */
  19003. removeColorGradient(gradient: number): IParticleSystem;
  19004. /**
  19005. * Adds a new size gradient
  19006. * @param gradient defines the gradient to use (between 0 and 1)
  19007. * @param factor defines the size factor to affect to the specified gradient
  19008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19009. * @returns the current particle system
  19010. */
  19011. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19012. /**
  19013. * Remove a specific size gradient
  19014. * @param gradient defines the gradient to remove
  19015. * @returns the current particle system
  19016. */
  19017. removeSizeGradient(gradient: number): IParticleSystem;
  19018. /**
  19019. * Gets the current list of color gradients.
  19020. * You must use addColorGradient and removeColorGradient to udpate this list
  19021. * @returns the list of color gradients
  19022. */
  19023. getColorGradients(): Nullable<Array<ColorGradient>>;
  19024. /**
  19025. * Gets the current list of size gradients.
  19026. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19027. * @returns the list of size gradients
  19028. */
  19029. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19030. /**
  19031. * Gets the current list of angular speed gradients.
  19032. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19033. * @returns the list of angular speed gradients
  19034. */
  19035. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19036. /**
  19037. * Adds a new angular speed gradient
  19038. * @param gradient defines the gradient to use (between 0 and 1)
  19039. * @param factor defines the angular speed to affect to the specified gradient
  19040. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19041. * @returns the current particle system
  19042. */
  19043. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19044. /**
  19045. * Remove a specific angular speed gradient
  19046. * @param gradient defines the gradient to remove
  19047. * @returns the current particle system
  19048. */
  19049. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19050. /**
  19051. * Gets the current list of velocity gradients.
  19052. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19053. * @returns the list of velocity gradients
  19054. */
  19055. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19056. /**
  19057. * Adds a new velocity gradient
  19058. * @param gradient defines the gradient to use (between 0 and 1)
  19059. * @param factor defines the velocity to affect to the specified gradient
  19060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19061. * @returns the current particle system
  19062. */
  19063. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19064. /**
  19065. * Remove a specific velocity gradient
  19066. * @param gradient defines the gradient to remove
  19067. * @returns the current particle system
  19068. */
  19069. removeVelocityGradient(gradient: number): IParticleSystem;
  19070. /**
  19071. * Gets the current list of limit velocity gradients.
  19072. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19073. * @returns the list of limit velocity gradients
  19074. */
  19075. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19076. /**
  19077. * Adds a new limit velocity gradient
  19078. * @param gradient defines the gradient to use (between 0 and 1)
  19079. * @param factor defines the limit velocity to affect to the specified gradient
  19080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19081. * @returns the current particle system
  19082. */
  19083. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19084. /**
  19085. * Remove a specific limit velocity gradient
  19086. * @param gradient defines the gradient to remove
  19087. * @returns the current particle system
  19088. */
  19089. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19090. /**
  19091. * Adds a new drag gradient
  19092. * @param gradient defines the gradient to use (between 0 and 1)
  19093. * @param factor defines the drag to affect to the specified gradient
  19094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19095. * @returns the current particle system
  19096. */
  19097. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19098. /**
  19099. * Remove a specific drag gradient
  19100. * @param gradient defines the gradient to remove
  19101. * @returns the current particle system
  19102. */
  19103. removeDragGradient(gradient: number): IParticleSystem;
  19104. /**
  19105. * Gets the current list of drag gradients.
  19106. * You must use addDragGradient and removeDragGradient to udpate this list
  19107. * @returns the list of drag gradients
  19108. */
  19109. getDragGradients(): Nullable<Array<FactorGradient>>;
  19110. /**
  19111. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19112. * @param gradient defines the gradient to use (between 0 and 1)
  19113. * @param factor defines the emit rate to affect to the specified gradient
  19114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19115. * @returns the current particle system
  19116. */
  19117. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19118. /**
  19119. * Remove a specific emit rate gradient
  19120. * @param gradient defines the gradient to remove
  19121. * @returns the current particle system
  19122. */
  19123. removeEmitRateGradient(gradient: number): IParticleSystem;
  19124. /**
  19125. * Gets the current list of emit rate gradients.
  19126. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19127. * @returns the list of emit rate gradients
  19128. */
  19129. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19130. /**
  19131. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19132. * @param gradient defines the gradient to use (between 0 and 1)
  19133. * @param factor defines the start size to affect to the specified gradient
  19134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19135. * @returns the current particle system
  19136. */
  19137. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19138. /**
  19139. * Remove a specific start size gradient
  19140. * @param gradient defines the gradient to remove
  19141. * @returns the current particle system
  19142. */
  19143. removeStartSizeGradient(gradient: number): IParticleSystem;
  19144. /**
  19145. * Gets the current list of start size gradients.
  19146. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19147. * @returns the list of start size gradients
  19148. */
  19149. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19150. /**
  19151. * Adds a new life time gradient
  19152. * @param gradient defines the gradient to use (between 0 and 1)
  19153. * @param factor defines the life time factor to affect to the specified gradient
  19154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19155. * @returns the current particle system
  19156. */
  19157. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19158. /**
  19159. * Remove a specific life time gradient
  19160. * @param gradient defines the gradient to remove
  19161. * @returns the current particle system
  19162. */
  19163. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19164. /**
  19165. * Gets the current list of life time gradients.
  19166. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19167. * @returns the list of life time gradients
  19168. */
  19169. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19170. /**
  19171. * Gets the current list of color gradients.
  19172. * You must use addColorGradient and removeColorGradient to udpate this list
  19173. * @returns the list of color gradients
  19174. */
  19175. getColorGradients(): Nullable<Array<ColorGradient>>;
  19176. /**
  19177. * Adds a new ramp gradient used to remap particle colors
  19178. * @param gradient defines the gradient to use (between 0 and 1)
  19179. * @param color defines the color to affect to the specified gradient
  19180. * @returns the current particle system
  19181. */
  19182. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19183. /**
  19184. * Gets the current list of ramp gradients.
  19185. * You must use addRampGradient and removeRampGradient to udpate this list
  19186. * @returns the list of ramp gradients
  19187. */
  19188. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19189. /** Gets or sets a boolean indicating that ramp gradients must be used
  19190. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19191. */
  19192. useRampGradients: boolean;
  19193. /**
  19194. * Adds a new color remap gradient
  19195. * @param gradient defines the gradient to use (between 0 and 1)
  19196. * @param min defines the color remap minimal range
  19197. * @param max defines the color remap maximal range
  19198. * @returns the current particle system
  19199. */
  19200. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19201. /**
  19202. * Gets the current list of color remap gradients.
  19203. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19204. * @returns the list of color remap gradients
  19205. */
  19206. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19207. /**
  19208. * Adds a new alpha remap gradient
  19209. * @param gradient defines the gradient to use (between 0 and 1)
  19210. * @param min defines the alpha remap minimal range
  19211. * @param max defines the alpha remap maximal range
  19212. * @returns the current particle system
  19213. */
  19214. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19215. /**
  19216. * Gets the current list of alpha remap gradients.
  19217. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19218. * @returns the list of alpha remap gradients
  19219. */
  19220. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19221. /**
  19222. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19223. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19224. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19225. * @returns the emitter
  19226. */
  19227. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19228. /**
  19229. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19230. * @param radius The radius of the hemisphere to emit from
  19231. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19232. * @returns the emitter
  19233. */
  19234. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19235. /**
  19236. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19237. * @param radius The radius of the sphere to emit from
  19238. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19239. * @returns the emitter
  19240. */
  19241. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19242. /**
  19243. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19244. * @param radius The radius of the sphere to emit from
  19245. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19246. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19247. * @returns the emitter
  19248. */
  19249. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19250. /**
  19251. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19252. * @param radius The radius of the emission cylinder
  19253. * @param height The height of the emission cylinder
  19254. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19255. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19256. * @returns the emitter
  19257. */
  19258. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19259. /**
  19260. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19261. * @param radius The radius of the cylinder to emit from
  19262. * @param height The height of the emission cylinder
  19263. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19264. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19265. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19266. * @returns the emitter
  19267. */
  19268. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19269. /**
  19270. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19271. * @param radius The radius of the cone to emit from
  19272. * @param angle The base angle of the cone
  19273. * @returns the emitter
  19274. */
  19275. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19276. /**
  19277. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19278. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19279. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19280. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19281. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19282. * @returns the emitter
  19283. */
  19284. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19285. /**
  19286. * Get hosting scene
  19287. * @returns the scene
  19288. */
  19289. getScene(): Scene;
  19290. }
  19291. }
  19292. declare module "babylonjs/Meshes/instancedMesh" {
  19293. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19294. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19295. import { Camera } from "babylonjs/Cameras/camera";
  19296. import { Node } from "babylonjs/node";
  19297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19298. import { Mesh } from "babylonjs/Meshes/mesh";
  19299. import { Material } from "babylonjs/Materials/material";
  19300. import { Skeleton } from "babylonjs/Bones/skeleton";
  19301. import { Light } from "babylonjs/Lights/light";
  19302. /**
  19303. * Creates an instance based on a source mesh.
  19304. */
  19305. export class InstancedMesh extends AbstractMesh {
  19306. private _sourceMesh;
  19307. private _currentLOD;
  19308. /** @hidden */
  19309. _indexInSourceMeshInstanceArray: number;
  19310. constructor(name: string, source: Mesh);
  19311. /**
  19312. * Returns the string "InstancedMesh".
  19313. */
  19314. getClassName(): string;
  19315. /** Gets the list of lights affecting that mesh */
  19316. readonly lightSources: Light[];
  19317. _resyncLightSources(): void;
  19318. _resyncLighSource(light: Light): void;
  19319. _removeLightSource(light: Light, dispose: boolean): void;
  19320. /**
  19321. * If the source mesh receives shadows
  19322. */
  19323. readonly receiveShadows: boolean;
  19324. /**
  19325. * The material of the source mesh
  19326. */
  19327. readonly material: Nullable<Material>;
  19328. /**
  19329. * Visibility of the source mesh
  19330. */
  19331. readonly visibility: number;
  19332. /**
  19333. * Skeleton of the source mesh
  19334. */
  19335. readonly skeleton: Nullable<Skeleton>;
  19336. /**
  19337. * Rendering ground id of the source mesh
  19338. */
  19339. renderingGroupId: number;
  19340. /**
  19341. * Returns the total number of vertices (integer).
  19342. */
  19343. getTotalVertices(): number;
  19344. /**
  19345. * Returns a positive integer : the total number of indices in this mesh geometry.
  19346. * @returns the numner of indices or zero if the mesh has no geometry.
  19347. */
  19348. getTotalIndices(): number;
  19349. /**
  19350. * The source mesh of the instance
  19351. */
  19352. readonly sourceMesh: Mesh;
  19353. /**
  19354. * Is this node ready to be used/rendered
  19355. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19356. * @return {boolean} is it ready
  19357. */
  19358. isReady(completeCheck?: boolean): boolean;
  19359. /**
  19360. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19361. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19362. * @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.
  19363. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19364. */
  19365. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19366. /**
  19367. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19368. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19369. * The `data` are either a numeric array either a Float32Array.
  19370. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19371. * 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).
  19372. * Note that a new underlying VertexBuffer object is created each call.
  19373. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19374. *
  19375. * Possible `kind` values :
  19376. * - VertexBuffer.PositionKind
  19377. * - VertexBuffer.UVKind
  19378. * - VertexBuffer.UV2Kind
  19379. * - VertexBuffer.UV3Kind
  19380. * - VertexBuffer.UV4Kind
  19381. * - VertexBuffer.UV5Kind
  19382. * - VertexBuffer.UV6Kind
  19383. * - VertexBuffer.ColorKind
  19384. * - VertexBuffer.MatricesIndicesKind
  19385. * - VertexBuffer.MatricesIndicesExtraKind
  19386. * - VertexBuffer.MatricesWeightsKind
  19387. * - VertexBuffer.MatricesWeightsExtraKind
  19388. *
  19389. * Returns the Mesh.
  19390. */
  19391. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19392. /**
  19393. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19394. * If the mesh has no geometry, it is simply returned as it is.
  19395. * The `data` are either a numeric array either a Float32Array.
  19396. * No new underlying VertexBuffer object is created.
  19397. * 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.
  19398. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19399. *
  19400. * Possible `kind` values :
  19401. * - VertexBuffer.PositionKind
  19402. * - VertexBuffer.UVKind
  19403. * - VertexBuffer.UV2Kind
  19404. * - VertexBuffer.UV3Kind
  19405. * - VertexBuffer.UV4Kind
  19406. * - VertexBuffer.UV5Kind
  19407. * - VertexBuffer.UV6Kind
  19408. * - VertexBuffer.ColorKind
  19409. * - VertexBuffer.MatricesIndicesKind
  19410. * - VertexBuffer.MatricesIndicesExtraKind
  19411. * - VertexBuffer.MatricesWeightsKind
  19412. * - VertexBuffer.MatricesWeightsExtraKind
  19413. *
  19414. * Returns the Mesh.
  19415. */
  19416. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19417. /**
  19418. * Sets the mesh indices.
  19419. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19420. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19421. * This method creates a new index buffer each call.
  19422. * Returns the Mesh.
  19423. */
  19424. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19425. /**
  19426. * Boolean : True if the mesh owns the requested kind of data.
  19427. */
  19428. isVerticesDataPresent(kind: string): boolean;
  19429. /**
  19430. * Returns an array of indices (IndicesArray).
  19431. */
  19432. getIndices(): Nullable<IndicesArray>;
  19433. readonly _positions: Nullable<Vector3[]>;
  19434. /**
  19435. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19436. * This means the mesh underlying bounding box and sphere are recomputed.
  19437. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19438. * @returns the current mesh
  19439. */
  19440. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19441. /** @hidden */
  19442. _preActivate(): InstancedMesh;
  19443. /** @hidden */
  19444. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19445. /** @hidden */
  19446. _postActivate(): void;
  19447. getWorldMatrix(): Matrix;
  19448. readonly isAnInstance: boolean;
  19449. /**
  19450. * Returns the current associated LOD AbstractMesh.
  19451. */
  19452. getLOD(camera: Camera): AbstractMesh;
  19453. /** @hidden */
  19454. _syncSubMeshes(): InstancedMesh;
  19455. /** @hidden */
  19456. _generatePointsArray(): boolean;
  19457. /**
  19458. * Creates a new InstancedMesh from the current mesh.
  19459. * - name (string) : the cloned mesh name
  19460. * - newParent (optional Node) : the optional Node to parent the clone to.
  19461. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19462. *
  19463. * Returns the clone.
  19464. */
  19465. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19466. /**
  19467. * Disposes the InstancedMesh.
  19468. * Returns nothing.
  19469. */
  19470. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19471. }
  19472. }
  19473. declare module "babylonjs/Materials/shaderMaterial" {
  19474. import { Scene } from "babylonjs/scene";
  19475. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19477. import { Mesh } from "babylonjs/Meshes/mesh";
  19478. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19480. import { Texture } from "babylonjs/Materials/Textures/texture";
  19481. import { Material } from "babylonjs/Materials/material";
  19482. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19483. /**
  19484. * Defines the options associated with the creation of a shader material.
  19485. */
  19486. export interface IShaderMaterialOptions {
  19487. /**
  19488. * Does the material work in alpha blend mode
  19489. */
  19490. needAlphaBlending: boolean;
  19491. /**
  19492. * Does the material work in alpha test mode
  19493. */
  19494. needAlphaTesting: boolean;
  19495. /**
  19496. * The list of attribute names used in the shader
  19497. */
  19498. attributes: string[];
  19499. /**
  19500. * The list of unifrom names used in the shader
  19501. */
  19502. uniforms: string[];
  19503. /**
  19504. * The list of UBO names used in the shader
  19505. */
  19506. uniformBuffers: string[];
  19507. /**
  19508. * The list of sampler names used in the shader
  19509. */
  19510. samplers: string[];
  19511. /**
  19512. * The list of defines used in the shader
  19513. */
  19514. defines: string[];
  19515. }
  19516. /**
  19517. * 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.
  19518. *
  19519. * This returned material effects how the mesh will look based on the code in the shaders.
  19520. *
  19521. * @see http://doc.babylonjs.com/how_to/shader_material
  19522. */
  19523. export class ShaderMaterial extends Material {
  19524. private _shaderPath;
  19525. private _options;
  19526. private _textures;
  19527. private _textureArrays;
  19528. private _floats;
  19529. private _ints;
  19530. private _floatsArrays;
  19531. private _colors3;
  19532. private _colors3Arrays;
  19533. private _colors4;
  19534. private _colors4Arrays;
  19535. private _vectors2;
  19536. private _vectors3;
  19537. private _vectors4;
  19538. private _matrices;
  19539. private _matrices3x3;
  19540. private _matrices2x2;
  19541. private _vectors2Arrays;
  19542. private _vectors3Arrays;
  19543. private _vectors4Arrays;
  19544. private _cachedWorldViewMatrix;
  19545. private _cachedWorldViewProjectionMatrix;
  19546. private _renderId;
  19547. /**
  19548. * Instantiate a new shader material.
  19549. * 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.
  19550. * This returned material effects how the mesh will look based on the code in the shaders.
  19551. * @see http://doc.babylonjs.com/how_to/shader_material
  19552. * @param name Define the name of the material in the scene
  19553. * @param scene Define the scene the material belongs to
  19554. * @param shaderPath Defines the route to the shader code in one of three ways:
  19555. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19556. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19557. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19558. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19559. * @param options Define the options used to create the shader
  19560. */
  19561. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19562. /**
  19563. * Gets the options used to compile the shader.
  19564. * They can be modified to trigger a new compilation
  19565. */
  19566. readonly options: IShaderMaterialOptions;
  19567. /**
  19568. * Gets the current class name of the material e.g. "ShaderMaterial"
  19569. * Mainly use in serialization.
  19570. * @returns the class name
  19571. */
  19572. getClassName(): string;
  19573. /**
  19574. * Specifies if the material will require alpha blending
  19575. * @returns a boolean specifying if alpha blending is needed
  19576. */
  19577. needAlphaBlending(): boolean;
  19578. /**
  19579. * Specifies if this material should be rendered in alpha test mode
  19580. * @returns a boolean specifying if an alpha test is needed.
  19581. */
  19582. needAlphaTesting(): boolean;
  19583. private _checkUniform;
  19584. /**
  19585. * Set a texture in the shader.
  19586. * @param name Define the name of the uniform samplers as defined in the shader
  19587. * @param texture Define the texture to bind to this sampler
  19588. * @return the material itself allowing "fluent" like uniform updates
  19589. */
  19590. setTexture(name: string, texture: Texture): ShaderMaterial;
  19591. /**
  19592. * Set a texture array in the shader.
  19593. * @param name Define the name of the uniform sampler array as defined in the shader
  19594. * @param textures Define the list of textures to bind to this sampler
  19595. * @return the material itself allowing "fluent" like uniform updates
  19596. */
  19597. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19598. /**
  19599. * Set a float in the shader.
  19600. * @param name Define the name of the uniform as defined in the shader
  19601. * @param value Define the value to give to the uniform
  19602. * @return the material itself allowing "fluent" like uniform updates
  19603. */
  19604. setFloat(name: string, value: number): ShaderMaterial;
  19605. /**
  19606. * Set a int in the shader.
  19607. * @param name Define the name of the uniform as defined in the shader
  19608. * @param value Define the value to give to the uniform
  19609. * @return the material itself allowing "fluent" like uniform updates
  19610. */
  19611. setInt(name: string, value: number): ShaderMaterial;
  19612. /**
  19613. * Set an array of floats in the shader.
  19614. * @param name Define the name of the uniform as defined in the shader
  19615. * @param value Define the value to give to the uniform
  19616. * @return the material itself allowing "fluent" like uniform updates
  19617. */
  19618. setFloats(name: string, value: number[]): ShaderMaterial;
  19619. /**
  19620. * Set a vec3 in the shader from a Color3.
  19621. * @param name Define the name of the uniform as defined in the shader
  19622. * @param value Define the value to give to the uniform
  19623. * @return the material itself allowing "fluent" like uniform updates
  19624. */
  19625. setColor3(name: string, value: Color3): ShaderMaterial;
  19626. /**
  19627. * Set a vec3 array in the shader from a Color3 array.
  19628. * @param name Define the name of the uniform as defined in the shader
  19629. * @param value Define the value to give to the uniform
  19630. * @return the material itself allowing "fluent" like uniform updates
  19631. */
  19632. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19633. /**
  19634. * Set a vec4 in the shader from a Color4.
  19635. * @param name Define the name of the uniform as defined in the shader
  19636. * @param value Define the value to give to the uniform
  19637. * @return the material itself allowing "fluent" like uniform updates
  19638. */
  19639. setColor4(name: string, value: Color4): ShaderMaterial;
  19640. /**
  19641. * Set a vec4 array in the shader from a Color4 array.
  19642. * @param name Define the name of the uniform as defined in the shader
  19643. * @param value Define the value to give to the uniform
  19644. * @return the material itself allowing "fluent" like uniform updates
  19645. */
  19646. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19647. /**
  19648. * Set a vec2 in the shader from a Vector2.
  19649. * @param name Define the name of the uniform as defined in the shader
  19650. * @param value Define the value to give to the uniform
  19651. * @return the material itself allowing "fluent" like uniform updates
  19652. */
  19653. setVector2(name: string, value: Vector2): ShaderMaterial;
  19654. /**
  19655. * Set a vec3 in the shader from a Vector3.
  19656. * @param name Define the name of the uniform as defined in the shader
  19657. * @param value Define the value to give to the uniform
  19658. * @return the material itself allowing "fluent" like uniform updates
  19659. */
  19660. setVector3(name: string, value: Vector3): ShaderMaterial;
  19661. /**
  19662. * Set a vec4 in the shader from a Vector4.
  19663. * @param name Define the name of the uniform as defined in the shader
  19664. * @param value Define the value to give to the uniform
  19665. * @return the material itself allowing "fluent" like uniform updates
  19666. */
  19667. setVector4(name: string, value: Vector4): ShaderMaterial;
  19668. /**
  19669. * Set a mat4 in the shader from a Matrix.
  19670. * @param name Define the name of the uniform as defined in the shader
  19671. * @param value Define the value to give to the uniform
  19672. * @return the material itself allowing "fluent" like uniform updates
  19673. */
  19674. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19675. /**
  19676. * Set a mat3 in the shader from a Float32Array.
  19677. * @param name Define the name of the uniform as defined in the shader
  19678. * @param value Define the value to give to the uniform
  19679. * @return the material itself allowing "fluent" like uniform updates
  19680. */
  19681. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19682. /**
  19683. * Set a mat2 in the shader from a Float32Array.
  19684. * @param name Define the name of the uniform as defined in the shader
  19685. * @param value Define the value to give to the uniform
  19686. * @return the material itself allowing "fluent" like uniform updates
  19687. */
  19688. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19689. /**
  19690. * Set a vec2 array in the shader from a number array.
  19691. * @param name Define the name of the uniform as defined in the shader
  19692. * @param value Define the value to give to the uniform
  19693. * @return the material itself allowing "fluent" like uniform updates
  19694. */
  19695. setArray2(name: string, value: number[]): ShaderMaterial;
  19696. /**
  19697. * Set a vec3 array in the shader from a number array.
  19698. * @param name Define the name of the uniform as defined in the shader
  19699. * @param value Define the value to give to the uniform
  19700. * @return the material itself allowing "fluent" like uniform updates
  19701. */
  19702. setArray3(name: string, value: number[]): ShaderMaterial;
  19703. /**
  19704. * Set a vec4 array in the shader from a number array.
  19705. * @param name Define the name of the uniform as defined in the shader
  19706. * @param value Define the value to give to the uniform
  19707. * @return the material itself allowing "fluent" like uniform updates
  19708. */
  19709. setArray4(name: string, value: number[]): ShaderMaterial;
  19710. private _checkCache;
  19711. /**
  19712. * Specifies that the submesh is ready to be used
  19713. * @param mesh defines the mesh to check
  19714. * @param subMesh defines which submesh to check
  19715. * @param useInstances specifies that instances should be used
  19716. * @returns a boolean indicating that the submesh is ready or not
  19717. */
  19718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19719. /**
  19720. * Checks if the material is ready to render the requested mesh
  19721. * @param mesh Define the mesh to render
  19722. * @param useInstances Define whether or not the material is used with instances
  19723. * @returns true if ready, otherwise false
  19724. */
  19725. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19726. /**
  19727. * Binds the world matrix to the material
  19728. * @param world defines the world transformation matrix
  19729. */
  19730. bindOnlyWorldMatrix(world: Matrix): void;
  19731. /**
  19732. * Binds the material to the mesh
  19733. * @param world defines the world transformation matrix
  19734. * @param mesh defines the mesh to bind the material to
  19735. */
  19736. bind(world: Matrix, mesh?: Mesh): void;
  19737. /**
  19738. * Gets the active textures from the material
  19739. * @returns an array of textures
  19740. */
  19741. getActiveTextures(): BaseTexture[];
  19742. /**
  19743. * Specifies if the material uses a texture
  19744. * @param texture defines the texture to check against the material
  19745. * @returns a boolean specifying if the material uses the texture
  19746. */
  19747. hasTexture(texture: BaseTexture): boolean;
  19748. /**
  19749. * Makes a duplicate of the material, and gives it a new name
  19750. * @param name defines the new name for the duplicated material
  19751. * @returns the cloned material
  19752. */
  19753. clone(name: string): ShaderMaterial;
  19754. /**
  19755. * Disposes the material
  19756. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19757. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19758. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19759. */
  19760. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19761. /**
  19762. * Serializes this material in a JSON representation
  19763. * @returns the serialized material object
  19764. */
  19765. serialize(): any;
  19766. /**
  19767. * Creates a shader material from parsed shader material data
  19768. * @param source defines the JSON represnetation of the material
  19769. * @param scene defines the hosting scene
  19770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19771. * @returns a new material
  19772. */
  19773. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19774. }
  19775. }
  19776. declare module "babylonjs/Shaders/color.fragment" {
  19777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19778. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19779. /** @hidden */
  19780. export var colorPixelShader: {
  19781. name: string;
  19782. shader: string;
  19783. };
  19784. }
  19785. declare module "babylonjs/Shaders/color.vertex" {
  19786. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19787. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19788. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19789. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19790. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19792. /** @hidden */
  19793. export var colorVertexShader: {
  19794. name: string;
  19795. shader: string;
  19796. };
  19797. }
  19798. declare module "babylonjs/Meshes/linesMesh" {
  19799. import { Nullable } from "babylonjs/types";
  19800. import { Scene } from "babylonjs/scene";
  19801. import { Color3 } from "babylonjs/Maths/math.color";
  19802. import { Node } from "babylonjs/node";
  19803. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19804. import { Mesh } from "babylonjs/Meshes/mesh";
  19805. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19806. import { Effect } from "babylonjs/Materials/effect";
  19807. import { Material } from "babylonjs/Materials/material";
  19808. import "babylonjs/Shaders/color.fragment";
  19809. import "babylonjs/Shaders/color.vertex";
  19810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19811. /**
  19812. * Line mesh
  19813. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19814. */
  19815. export class LinesMesh extends Mesh {
  19816. /**
  19817. * If vertex color should be applied to the mesh
  19818. */
  19819. readonly useVertexColor?: boolean | undefined;
  19820. /**
  19821. * If vertex alpha should be applied to the mesh
  19822. */
  19823. readonly useVertexAlpha?: boolean | undefined;
  19824. /**
  19825. * Color of the line (Default: White)
  19826. */
  19827. color: Color3;
  19828. /**
  19829. * Alpha of the line (Default: 1)
  19830. */
  19831. alpha: number;
  19832. /**
  19833. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19834. * This margin is expressed in world space coordinates, so its value may vary.
  19835. * Default value is 0.1
  19836. */
  19837. intersectionThreshold: number;
  19838. private _colorShader;
  19839. private color4;
  19840. /**
  19841. * Creates a new LinesMesh
  19842. * @param name defines the name
  19843. * @param scene defines the hosting scene
  19844. * @param parent defines the parent mesh if any
  19845. * @param source defines the optional source LinesMesh used to clone data from
  19846. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19847. * When false, achieved by calling a clone(), also passing False.
  19848. * This will make creation of children, recursive.
  19849. * @param useVertexColor defines if this LinesMesh supports vertex color
  19850. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19851. */
  19852. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19853. /**
  19854. * If vertex color should be applied to the mesh
  19855. */
  19856. useVertexColor?: boolean | undefined,
  19857. /**
  19858. * If vertex alpha should be applied to the mesh
  19859. */
  19860. useVertexAlpha?: boolean | undefined);
  19861. private _addClipPlaneDefine;
  19862. private _removeClipPlaneDefine;
  19863. isReady(): boolean;
  19864. /**
  19865. * Returns the string "LineMesh"
  19866. */
  19867. getClassName(): string;
  19868. /**
  19869. * @hidden
  19870. */
  19871. /**
  19872. * @hidden
  19873. */
  19874. material: Material;
  19875. /**
  19876. * @hidden
  19877. */
  19878. readonly checkCollisions: boolean;
  19879. /** @hidden */
  19880. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19881. /** @hidden */
  19882. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19883. /**
  19884. * Disposes of the line mesh
  19885. * @param doNotRecurse If children should be disposed
  19886. */
  19887. dispose(doNotRecurse?: boolean): void;
  19888. /**
  19889. * Returns a new LineMesh object cloned from the current one.
  19890. */
  19891. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19892. /**
  19893. * Creates a new InstancedLinesMesh object from the mesh model.
  19894. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19895. * @param name defines the name of the new instance
  19896. * @returns a new InstancedLinesMesh
  19897. */
  19898. createInstance(name: string): InstancedLinesMesh;
  19899. }
  19900. /**
  19901. * Creates an instance based on a source LinesMesh
  19902. */
  19903. export class InstancedLinesMesh extends InstancedMesh {
  19904. /**
  19905. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19906. * This margin is expressed in world space coordinates, so its value may vary.
  19907. * Initilized with the intersectionThreshold value of the source LinesMesh
  19908. */
  19909. intersectionThreshold: number;
  19910. constructor(name: string, source: LinesMesh);
  19911. /**
  19912. * Returns the string "InstancedLinesMesh".
  19913. */
  19914. getClassName(): string;
  19915. }
  19916. }
  19917. declare module "babylonjs/Shaders/line.fragment" {
  19918. /** @hidden */
  19919. export var linePixelShader: {
  19920. name: string;
  19921. shader: string;
  19922. };
  19923. }
  19924. declare module "babylonjs/Shaders/line.vertex" {
  19925. /** @hidden */
  19926. export var lineVertexShader: {
  19927. name: string;
  19928. shader: string;
  19929. };
  19930. }
  19931. declare module "babylonjs/Rendering/edgesRenderer" {
  19932. import { Nullable } from "babylonjs/types";
  19933. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19935. import { Vector3 } from "babylonjs/Maths/math.vector";
  19936. import { IDisposable } from "babylonjs/scene";
  19937. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19938. import "babylonjs/Shaders/line.fragment";
  19939. import "babylonjs/Shaders/line.vertex";
  19940. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19941. module "babylonjs/Meshes/abstractMesh" {
  19942. interface AbstractMesh {
  19943. /**
  19944. * Gets the edgesRenderer associated with the mesh
  19945. */
  19946. edgesRenderer: Nullable<EdgesRenderer>;
  19947. }
  19948. }
  19949. module "babylonjs/Meshes/linesMesh" {
  19950. interface LinesMesh {
  19951. /**
  19952. * Enables the edge rendering mode on the mesh.
  19953. * This mode makes the mesh edges visible
  19954. * @param epsilon defines the maximal distance between two angles to detect a face
  19955. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19956. * @returns the currentAbstractMesh
  19957. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19958. */
  19959. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19960. }
  19961. }
  19962. module "babylonjs/Meshes/linesMesh" {
  19963. interface InstancedLinesMesh {
  19964. /**
  19965. * Enables the edge rendering mode on the mesh.
  19966. * This mode makes the mesh edges visible
  19967. * @param epsilon defines the maximal distance between two angles to detect a face
  19968. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19969. * @returns the current InstancedLinesMesh
  19970. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19971. */
  19972. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19973. }
  19974. }
  19975. /**
  19976. * Defines the minimum contract an Edges renderer should follow.
  19977. */
  19978. export interface IEdgesRenderer extends IDisposable {
  19979. /**
  19980. * Gets or sets a boolean indicating if the edgesRenderer is active
  19981. */
  19982. isEnabled: boolean;
  19983. /**
  19984. * Renders the edges of the attached mesh,
  19985. */
  19986. render(): void;
  19987. /**
  19988. * Checks wether or not the edges renderer is ready to render.
  19989. * @return true if ready, otherwise false.
  19990. */
  19991. isReady(): boolean;
  19992. }
  19993. /**
  19994. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19995. */
  19996. export class EdgesRenderer implements IEdgesRenderer {
  19997. /**
  19998. * Define the size of the edges with an orthographic camera
  19999. */
  20000. edgesWidthScalerForOrthographic: number;
  20001. /**
  20002. * Define the size of the edges with a perspective camera
  20003. */
  20004. edgesWidthScalerForPerspective: number;
  20005. protected _source: AbstractMesh;
  20006. protected _linesPositions: number[];
  20007. protected _linesNormals: number[];
  20008. protected _linesIndices: number[];
  20009. protected _epsilon: number;
  20010. protected _indicesCount: number;
  20011. protected _lineShader: ShaderMaterial;
  20012. protected _ib: DataBuffer;
  20013. protected _buffers: {
  20014. [key: string]: Nullable<VertexBuffer>;
  20015. };
  20016. protected _checkVerticesInsteadOfIndices: boolean;
  20017. private _meshRebuildObserver;
  20018. private _meshDisposeObserver;
  20019. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20020. isEnabled: boolean;
  20021. /**
  20022. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20023. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20024. * @param source Mesh used to create edges
  20025. * @param epsilon sum of angles in adjacency to check for edge
  20026. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20027. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20028. */
  20029. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20030. protected _prepareRessources(): void;
  20031. /** @hidden */
  20032. _rebuild(): void;
  20033. /**
  20034. * Releases the required resources for the edges renderer
  20035. */
  20036. dispose(): void;
  20037. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20038. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20039. /**
  20040. * Checks if the pair of p0 and p1 is en edge
  20041. * @param faceIndex
  20042. * @param edge
  20043. * @param faceNormals
  20044. * @param p0
  20045. * @param p1
  20046. * @private
  20047. */
  20048. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20049. /**
  20050. * push line into the position, normal and index buffer
  20051. * @protected
  20052. */
  20053. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20054. /**
  20055. * Generates lines edges from adjacencjes
  20056. * @private
  20057. */
  20058. _generateEdgesLines(): void;
  20059. /**
  20060. * Checks wether or not the edges renderer is ready to render.
  20061. * @return true if ready, otherwise false.
  20062. */
  20063. isReady(): boolean;
  20064. /**
  20065. * Renders the edges of the attached mesh,
  20066. */
  20067. render(): void;
  20068. }
  20069. /**
  20070. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20071. */
  20072. export class LineEdgesRenderer extends EdgesRenderer {
  20073. /**
  20074. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20075. * @param source LineMesh used to generate edges
  20076. * @param epsilon not important (specified angle for edge detection)
  20077. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20078. */
  20079. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20080. /**
  20081. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20082. */
  20083. _generateEdgesLines(): void;
  20084. }
  20085. }
  20086. declare module "babylonjs/Rendering/renderingGroup" {
  20087. import { SmartArray } from "babylonjs/Misc/smartArray";
  20088. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20090. import { Nullable } from "babylonjs/types";
  20091. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20092. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20093. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20094. import { Material } from "babylonjs/Materials/material";
  20095. import { Scene } from "babylonjs/scene";
  20096. /**
  20097. * This represents the object necessary to create a rendering group.
  20098. * This is exclusively used and created by the rendering manager.
  20099. * To modify the behavior, you use the available helpers in your scene or meshes.
  20100. * @hidden
  20101. */
  20102. export class RenderingGroup {
  20103. index: number;
  20104. private static _zeroVector;
  20105. private _scene;
  20106. private _opaqueSubMeshes;
  20107. private _transparentSubMeshes;
  20108. private _alphaTestSubMeshes;
  20109. private _depthOnlySubMeshes;
  20110. private _particleSystems;
  20111. private _spriteManagers;
  20112. private _opaqueSortCompareFn;
  20113. private _alphaTestSortCompareFn;
  20114. private _transparentSortCompareFn;
  20115. private _renderOpaque;
  20116. private _renderAlphaTest;
  20117. private _renderTransparent;
  20118. /** @hidden */
  20119. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20120. onBeforeTransparentRendering: () => void;
  20121. /**
  20122. * Set the opaque sort comparison function.
  20123. * If null the sub meshes will be render in the order they were created
  20124. */
  20125. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20126. /**
  20127. * Set the alpha test sort comparison function.
  20128. * If null the sub meshes will be render in the order they were created
  20129. */
  20130. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20131. /**
  20132. * Set the transparent sort comparison function.
  20133. * If null the sub meshes will be render in the order they were created
  20134. */
  20135. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20136. /**
  20137. * Creates a new rendering group.
  20138. * @param index The rendering group index
  20139. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20140. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20141. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20142. */
  20143. 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>);
  20144. /**
  20145. * Render all the sub meshes contained in the group.
  20146. * @param customRenderFunction Used to override the default render behaviour of the group.
  20147. * @returns true if rendered some submeshes.
  20148. */
  20149. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20150. /**
  20151. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20152. * @param subMeshes The submeshes to render
  20153. */
  20154. private renderOpaqueSorted;
  20155. /**
  20156. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20157. * @param subMeshes The submeshes to render
  20158. */
  20159. private renderAlphaTestSorted;
  20160. /**
  20161. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20162. * @param subMeshes The submeshes to render
  20163. */
  20164. private renderTransparentSorted;
  20165. /**
  20166. * Renders the submeshes in a specified order.
  20167. * @param subMeshes The submeshes to sort before render
  20168. * @param sortCompareFn The comparison function use to sort
  20169. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20170. * @param transparent Specifies to activate blending if true
  20171. */
  20172. private static renderSorted;
  20173. /**
  20174. * Renders the submeshes in the order they were dispatched (no sort applied).
  20175. * @param subMeshes The submeshes to render
  20176. */
  20177. private static renderUnsorted;
  20178. /**
  20179. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20180. * are rendered back to front if in the same alpha index.
  20181. *
  20182. * @param a The first submesh
  20183. * @param b The second submesh
  20184. * @returns The result of the comparison
  20185. */
  20186. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20187. /**
  20188. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20189. * are rendered back to front.
  20190. *
  20191. * @param a The first submesh
  20192. * @param b The second submesh
  20193. * @returns The result of the comparison
  20194. */
  20195. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20196. /**
  20197. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20198. * are rendered front to back (prevent overdraw).
  20199. *
  20200. * @param a The first submesh
  20201. * @param b The second submesh
  20202. * @returns The result of the comparison
  20203. */
  20204. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20205. /**
  20206. * Resets the different lists of submeshes to prepare a new frame.
  20207. */
  20208. prepare(): void;
  20209. dispose(): void;
  20210. /**
  20211. * Inserts the submesh in its correct queue depending on its material.
  20212. * @param subMesh The submesh to dispatch
  20213. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20214. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20215. */
  20216. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20217. dispatchSprites(spriteManager: ISpriteManager): void;
  20218. dispatchParticles(particleSystem: IParticleSystem): void;
  20219. private _renderParticles;
  20220. private _renderSprites;
  20221. }
  20222. }
  20223. declare module "babylonjs/Rendering/renderingManager" {
  20224. import { Nullable } from "babylonjs/types";
  20225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20226. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20227. import { SmartArray } from "babylonjs/Misc/smartArray";
  20228. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20229. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20230. import { Material } from "babylonjs/Materials/material";
  20231. import { Scene } from "babylonjs/scene";
  20232. import { Camera } from "babylonjs/Cameras/camera";
  20233. /**
  20234. * Interface describing the different options available in the rendering manager
  20235. * regarding Auto Clear between groups.
  20236. */
  20237. export interface IRenderingManagerAutoClearSetup {
  20238. /**
  20239. * Defines whether or not autoclear is enable.
  20240. */
  20241. autoClear: boolean;
  20242. /**
  20243. * Defines whether or not to autoclear the depth buffer.
  20244. */
  20245. depth: boolean;
  20246. /**
  20247. * Defines whether or not to autoclear the stencil buffer.
  20248. */
  20249. stencil: boolean;
  20250. }
  20251. /**
  20252. * This class is used by the onRenderingGroupObservable
  20253. */
  20254. export class RenderingGroupInfo {
  20255. /**
  20256. * The Scene that being rendered
  20257. */
  20258. scene: Scene;
  20259. /**
  20260. * The camera currently used for the rendering pass
  20261. */
  20262. camera: Nullable<Camera>;
  20263. /**
  20264. * The ID of the renderingGroup being processed
  20265. */
  20266. renderingGroupId: number;
  20267. }
  20268. /**
  20269. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20270. * It is enable to manage the different groups as well as the different necessary sort functions.
  20271. * This should not be used directly aside of the few static configurations
  20272. */
  20273. export class RenderingManager {
  20274. /**
  20275. * The max id used for rendering groups (not included)
  20276. */
  20277. static MAX_RENDERINGGROUPS: number;
  20278. /**
  20279. * The min id used for rendering groups (included)
  20280. */
  20281. static MIN_RENDERINGGROUPS: number;
  20282. /**
  20283. * Used to globally prevent autoclearing scenes.
  20284. */
  20285. static AUTOCLEAR: boolean;
  20286. /**
  20287. * @hidden
  20288. */
  20289. _useSceneAutoClearSetup: boolean;
  20290. private _scene;
  20291. private _renderingGroups;
  20292. private _depthStencilBufferAlreadyCleaned;
  20293. private _autoClearDepthStencil;
  20294. private _customOpaqueSortCompareFn;
  20295. private _customAlphaTestSortCompareFn;
  20296. private _customTransparentSortCompareFn;
  20297. private _renderingGroupInfo;
  20298. /**
  20299. * Instantiates a new rendering group for a particular scene
  20300. * @param scene Defines the scene the groups belongs to
  20301. */
  20302. constructor(scene: Scene);
  20303. private _clearDepthStencilBuffer;
  20304. /**
  20305. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20306. * @hidden
  20307. */
  20308. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20309. /**
  20310. * Resets the different information of the group to prepare a new frame
  20311. * @hidden
  20312. */
  20313. reset(): void;
  20314. /**
  20315. * Dispose and release the group and its associated resources.
  20316. * @hidden
  20317. */
  20318. dispose(): void;
  20319. /**
  20320. * Clear the info related to rendering groups preventing retention points during dispose.
  20321. */
  20322. freeRenderingGroups(): void;
  20323. private _prepareRenderingGroup;
  20324. /**
  20325. * Add a sprite manager to the rendering manager in order to render it this frame.
  20326. * @param spriteManager Define the sprite manager to render
  20327. */
  20328. dispatchSprites(spriteManager: ISpriteManager): void;
  20329. /**
  20330. * Add a particle system to the rendering manager in order to render it this frame.
  20331. * @param particleSystem Define the particle system to render
  20332. */
  20333. dispatchParticles(particleSystem: IParticleSystem): void;
  20334. /**
  20335. * Add a submesh to the manager in order to render it this frame
  20336. * @param subMesh The submesh to dispatch
  20337. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20338. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20339. */
  20340. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20341. /**
  20342. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20343. * This allowed control for front to back rendering or reversly depending of the special needs.
  20344. *
  20345. * @param renderingGroupId The rendering group id corresponding to its index
  20346. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20347. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20348. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20349. */
  20350. 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;
  20351. /**
  20352. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20353. *
  20354. * @param renderingGroupId The rendering group id corresponding to its index
  20355. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20356. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20357. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20358. */
  20359. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20360. /**
  20361. * Gets the current auto clear configuration for one rendering group of the rendering
  20362. * manager.
  20363. * @param index the rendering group index to get the information for
  20364. * @returns The auto clear setup for the requested rendering group
  20365. */
  20366. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20367. }
  20368. }
  20369. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20370. import { Observable } from "babylonjs/Misc/observable";
  20371. import { SmartArray } from "babylonjs/Misc/smartArray";
  20372. import { Nullable } from "babylonjs/types";
  20373. import { Camera } from "babylonjs/Cameras/camera";
  20374. import { Scene } from "babylonjs/scene";
  20375. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20376. import { Color4 } from "babylonjs/Maths/math.color";
  20377. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20379. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20381. import { Texture } from "babylonjs/Materials/Textures/texture";
  20382. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20383. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20384. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20385. import { Engine } from "babylonjs/Engines/engine";
  20386. /**
  20387. * This Helps creating a texture that will be created from a camera in your scene.
  20388. * It is basically a dynamic texture that could be used to create special effects for instance.
  20389. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20390. */
  20391. export class RenderTargetTexture extends Texture {
  20392. isCube: boolean;
  20393. /**
  20394. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20395. */
  20396. static readonly REFRESHRATE_RENDER_ONCE: number;
  20397. /**
  20398. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20399. */
  20400. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20401. /**
  20402. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20403. * the central point of your effect and can save a lot of performances.
  20404. */
  20405. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20406. /**
  20407. * Use this predicate to dynamically define the list of mesh you want to render.
  20408. * If set, the renderList property will be overwritten.
  20409. */
  20410. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20411. private _renderList;
  20412. /**
  20413. * Use this list to define the list of mesh you want to render.
  20414. */
  20415. renderList: Nullable<Array<AbstractMesh>>;
  20416. private _hookArray;
  20417. /**
  20418. * Define if particles should be rendered in your texture.
  20419. */
  20420. renderParticles: boolean;
  20421. /**
  20422. * Define if sprites should be rendered in your texture.
  20423. */
  20424. renderSprites: boolean;
  20425. /**
  20426. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20427. */
  20428. coordinatesMode: number;
  20429. /**
  20430. * Define the camera used to render the texture.
  20431. */
  20432. activeCamera: Nullable<Camera>;
  20433. /**
  20434. * Override the render function of the texture with your own one.
  20435. */
  20436. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20437. /**
  20438. * Define if camera post processes should be use while rendering the texture.
  20439. */
  20440. useCameraPostProcesses: boolean;
  20441. /**
  20442. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20443. */
  20444. ignoreCameraViewport: boolean;
  20445. private _postProcessManager;
  20446. private _postProcesses;
  20447. private _resizeObserver;
  20448. /**
  20449. * An event triggered when the texture is unbind.
  20450. */
  20451. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20452. /**
  20453. * An event triggered when the texture is unbind.
  20454. */
  20455. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20456. private _onAfterUnbindObserver;
  20457. /**
  20458. * Set a after unbind callback in the texture.
  20459. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20460. */
  20461. onAfterUnbind: () => void;
  20462. /**
  20463. * An event triggered before rendering the texture
  20464. */
  20465. onBeforeRenderObservable: Observable<number>;
  20466. private _onBeforeRenderObserver;
  20467. /**
  20468. * Set a before render callback in the texture.
  20469. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20470. */
  20471. onBeforeRender: (faceIndex: number) => void;
  20472. /**
  20473. * An event triggered after rendering the texture
  20474. */
  20475. onAfterRenderObservable: Observable<number>;
  20476. private _onAfterRenderObserver;
  20477. /**
  20478. * Set a after render callback in the texture.
  20479. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20480. */
  20481. onAfterRender: (faceIndex: number) => void;
  20482. /**
  20483. * An event triggered after the texture clear
  20484. */
  20485. onClearObservable: Observable<Engine>;
  20486. private _onClearObserver;
  20487. /**
  20488. * Set a clear callback in the texture.
  20489. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20490. */
  20491. onClear: (Engine: Engine) => void;
  20492. /**
  20493. * An event triggered when the texture is resized.
  20494. */
  20495. onResizeObservable: Observable<RenderTargetTexture>;
  20496. /**
  20497. * Define the clear color of the Render Target if it should be different from the scene.
  20498. */
  20499. clearColor: Color4;
  20500. protected _size: number | {
  20501. width: number;
  20502. height: number;
  20503. };
  20504. protected _initialSizeParameter: number | {
  20505. width: number;
  20506. height: number;
  20507. } | {
  20508. ratio: number;
  20509. };
  20510. protected _sizeRatio: Nullable<number>;
  20511. /** @hidden */
  20512. _generateMipMaps: boolean;
  20513. protected _renderingManager: RenderingManager;
  20514. /** @hidden */
  20515. _waitingRenderList: string[];
  20516. protected _doNotChangeAspectRatio: boolean;
  20517. protected _currentRefreshId: number;
  20518. protected _refreshRate: number;
  20519. protected _textureMatrix: Matrix;
  20520. protected _samples: number;
  20521. protected _renderTargetOptions: RenderTargetCreationOptions;
  20522. /**
  20523. * Gets render target creation options that were used.
  20524. */
  20525. readonly renderTargetOptions: RenderTargetCreationOptions;
  20526. protected _engine: Engine;
  20527. protected _onRatioRescale(): void;
  20528. /**
  20529. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20530. * It must define where the camera used to render the texture is set
  20531. */
  20532. boundingBoxPosition: Vector3;
  20533. private _boundingBoxSize;
  20534. /**
  20535. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20536. * When defined, the cubemap will switch to local mode
  20537. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20538. * @example https://www.babylonjs-playground.com/#RNASML
  20539. */
  20540. boundingBoxSize: Vector3;
  20541. /**
  20542. * In case the RTT has been created with a depth texture, get the associated
  20543. * depth texture.
  20544. * Otherwise, return null.
  20545. */
  20546. depthStencilTexture: Nullable<InternalTexture>;
  20547. /**
  20548. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20549. * or used a shadow, depth texture...
  20550. * @param name The friendly name of the texture
  20551. * @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)
  20552. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20553. * @param generateMipMaps True if mip maps need to be generated after render.
  20554. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20555. * @param type The type of the buffer in the RTT (int, half float, float...)
  20556. * @param isCube True if a cube texture needs to be created
  20557. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20558. * @param generateDepthBuffer True to generate a depth buffer
  20559. * @param generateStencilBuffer True to generate a stencil buffer
  20560. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20561. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20562. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20563. */
  20564. constructor(name: string, size: number | {
  20565. width: number;
  20566. height: number;
  20567. } | {
  20568. ratio: number;
  20569. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20570. /**
  20571. * Creates a depth stencil texture.
  20572. * This is only available in WebGL 2 or with the depth texture extension available.
  20573. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20574. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20575. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20576. */
  20577. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20578. private _processSizeParameter;
  20579. /**
  20580. * Define the number of samples to use in case of MSAA.
  20581. * It defaults to one meaning no MSAA has been enabled.
  20582. */
  20583. samples: number;
  20584. /**
  20585. * Resets the refresh counter of the texture and start bak from scratch.
  20586. * Could be useful to regenerate the texture if it is setup to render only once.
  20587. */
  20588. resetRefreshCounter(): void;
  20589. /**
  20590. * Define the refresh rate of the texture or the rendering frequency.
  20591. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20592. */
  20593. refreshRate: number;
  20594. /**
  20595. * Adds a post process to the render target rendering passes.
  20596. * @param postProcess define the post process to add
  20597. */
  20598. addPostProcess(postProcess: PostProcess): void;
  20599. /**
  20600. * Clear all the post processes attached to the render target
  20601. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20602. */
  20603. clearPostProcesses(dispose?: boolean): void;
  20604. /**
  20605. * Remove one of the post process from the list of attached post processes to the texture
  20606. * @param postProcess define the post process to remove from the list
  20607. */
  20608. removePostProcess(postProcess: PostProcess): void;
  20609. /** @hidden */
  20610. _shouldRender(): boolean;
  20611. /**
  20612. * Gets the actual render size of the texture.
  20613. * @returns the width of the render size
  20614. */
  20615. getRenderSize(): number;
  20616. /**
  20617. * Gets the actual render width of the texture.
  20618. * @returns the width of the render size
  20619. */
  20620. getRenderWidth(): number;
  20621. /**
  20622. * Gets the actual render height of the texture.
  20623. * @returns the height of the render size
  20624. */
  20625. getRenderHeight(): number;
  20626. /**
  20627. * Get if the texture can be rescaled or not.
  20628. */
  20629. readonly canRescale: boolean;
  20630. /**
  20631. * Resize the texture using a ratio.
  20632. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20633. */
  20634. scale(ratio: number): void;
  20635. /**
  20636. * Get the texture reflection matrix used to rotate/transform the reflection.
  20637. * @returns the reflection matrix
  20638. */
  20639. getReflectionTextureMatrix(): Matrix;
  20640. /**
  20641. * Resize the texture to a new desired size.
  20642. * Be carrefull as it will recreate all the data in the new texture.
  20643. * @param size Define the new size. It can be:
  20644. * - a number for squared texture,
  20645. * - an object containing { width: number, height: number }
  20646. * - or an object containing a ratio { ratio: number }
  20647. */
  20648. resize(size: number | {
  20649. width: number;
  20650. height: number;
  20651. } | {
  20652. ratio: number;
  20653. }): void;
  20654. /**
  20655. * Renders all the objects from the render list into the texture.
  20656. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20657. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20658. */
  20659. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20660. private _bestReflectionRenderTargetDimension;
  20661. /**
  20662. * @hidden
  20663. * @param faceIndex face index to bind to if this is a cubetexture
  20664. */
  20665. _bindFrameBuffer(faceIndex?: number): void;
  20666. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20667. private renderToTarget;
  20668. /**
  20669. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20670. * This allowed control for front to back rendering or reversly depending of the special needs.
  20671. *
  20672. * @param renderingGroupId The rendering group id corresponding to its index
  20673. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20674. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20675. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20676. */
  20677. 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;
  20678. /**
  20679. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20680. *
  20681. * @param renderingGroupId The rendering group id corresponding to its index
  20682. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20683. */
  20684. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20685. /**
  20686. * Clones the texture.
  20687. * @returns the cloned texture
  20688. */
  20689. clone(): RenderTargetTexture;
  20690. /**
  20691. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20692. * @returns The JSON representation of the texture
  20693. */
  20694. serialize(): any;
  20695. /**
  20696. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20697. */
  20698. disposeFramebufferObjects(): void;
  20699. /**
  20700. * Dispose the texture and release its associated resources.
  20701. */
  20702. dispose(): void;
  20703. /** @hidden */
  20704. _rebuild(): void;
  20705. /**
  20706. * Clear the info related to rendering groups preventing retention point in material dispose.
  20707. */
  20708. freeRenderingGroups(): void;
  20709. /**
  20710. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20711. * @returns the view count
  20712. */
  20713. getViewCount(): number;
  20714. }
  20715. }
  20716. declare module "babylonjs/Materials/material" {
  20717. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20718. import { SmartArray } from "babylonjs/Misc/smartArray";
  20719. import { Observable } from "babylonjs/Misc/observable";
  20720. import { Nullable } from "babylonjs/types";
  20721. import { Scene } from "babylonjs/scene";
  20722. import { Matrix } from "babylonjs/Maths/math.vector";
  20723. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20725. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20726. import { Effect } from "babylonjs/Materials/effect";
  20727. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20728. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20729. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20730. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20731. import { Mesh } from "babylonjs/Meshes/mesh";
  20732. import { Animation } from "babylonjs/Animations/animation";
  20733. /**
  20734. * Base class for the main features of a material in Babylon.js
  20735. */
  20736. export class Material implements IAnimatable {
  20737. /**
  20738. * Returns the triangle fill mode
  20739. */
  20740. static readonly TriangleFillMode: number;
  20741. /**
  20742. * Returns the wireframe mode
  20743. */
  20744. static readonly WireFrameFillMode: number;
  20745. /**
  20746. * Returns the point fill mode
  20747. */
  20748. static readonly PointFillMode: number;
  20749. /**
  20750. * Returns the point list draw mode
  20751. */
  20752. static readonly PointListDrawMode: number;
  20753. /**
  20754. * Returns the line list draw mode
  20755. */
  20756. static readonly LineListDrawMode: number;
  20757. /**
  20758. * Returns the line loop draw mode
  20759. */
  20760. static readonly LineLoopDrawMode: number;
  20761. /**
  20762. * Returns the line strip draw mode
  20763. */
  20764. static readonly LineStripDrawMode: number;
  20765. /**
  20766. * Returns the triangle strip draw mode
  20767. */
  20768. static readonly TriangleStripDrawMode: number;
  20769. /**
  20770. * Returns the triangle fan draw mode
  20771. */
  20772. static readonly TriangleFanDrawMode: number;
  20773. /**
  20774. * Stores the clock-wise side orientation
  20775. */
  20776. static readonly ClockWiseSideOrientation: number;
  20777. /**
  20778. * Stores the counter clock-wise side orientation
  20779. */
  20780. static readonly CounterClockWiseSideOrientation: number;
  20781. /**
  20782. * The dirty texture flag value
  20783. */
  20784. static readonly TextureDirtyFlag: number;
  20785. /**
  20786. * The dirty light flag value
  20787. */
  20788. static readonly LightDirtyFlag: number;
  20789. /**
  20790. * The dirty fresnel flag value
  20791. */
  20792. static readonly FresnelDirtyFlag: number;
  20793. /**
  20794. * The dirty attribute flag value
  20795. */
  20796. static readonly AttributesDirtyFlag: number;
  20797. /**
  20798. * The dirty misc flag value
  20799. */
  20800. static readonly MiscDirtyFlag: number;
  20801. /**
  20802. * The all dirty flag value
  20803. */
  20804. static readonly AllDirtyFlag: number;
  20805. /**
  20806. * The ID of the material
  20807. */
  20808. id: string;
  20809. /**
  20810. * Gets or sets the unique id of the material
  20811. */
  20812. uniqueId: number;
  20813. /**
  20814. * The name of the material
  20815. */
  20816. name: string;
  20817. /**
  20818. * Gets or sets user defined metadata
  20819. */
  20820. metadata: any;
  20821. /**
  20822. * For internal use only. Please do not use.
  20823. */
  20824. reservedDataStore: any;
  20825. /**
  20826. * Specifies if the ready state should be checked on each call
  20827. */
  20828. checkReadyOnEveryCall: boolean;
  20829. /**
  20830. * Specifies if the ready state should be checked once
  20831. */
  20832. checkReadyOnlyOnce: boolean;
  20833. /**
  20834. * The state of the material
  20835. */
  20836. state: string;
  20837. /**
  20838. * The alpha value of the material
  20839. */
  20840. protected _alpha: number;
  20841. /**
  20842. * List of inspectable custom properties (used by the Inspector)
  20843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20844. */
  20845. inspectableCustomProperties: IInspectable[];
  20846. /**
  20847. * Sets the alpha value of the material
  20848. */
  20849. /**
  20850. * Gets the alpha value of the material
  20851. */
  20852. alpha: number;
  20853. /**
  20854. * Specifies if back face culling is enabled
  20855. */
  20856. protected _backFaceCulling: boolean;
  20857. /**
  20858. * Sets the back-face culling state
  20859. */
  20860. /**
  20861. * Gets the back-face culling state
  20862. */
  20863. backFaceCulling: boolean;
  20864. /**
  20865. * Stores the value for side orientation
  20866. */
  20867. sideOrientation: number;
  20868. /**
  20869. * Callback triggered when the material is compiled
  20870. */
  20871. onCompiled: Nullable<(effect: Effect) => void>;
  20872. /**
  20873. * Callback triggered when an error occurs
  20874. */
  20875. onError: Nullable<(effect: Effect, errors: string) => void>;
  20876. /**
  20877. * Callback triggered to get the render target textures
  20878. */
  20879. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20880. /**
  20881. * Gets a boolean indicating that current material needs to register RTT
  20882. */
  20883. readonly hasRenderTargetTextures: boolean;
  20884. /**
  20885. * Specifies if the material should be serialized
  20886. */
  20887. doNotSerialize: boolean;
  20888. /**
  20889. * @hidden
  20890. */
  20891. _storeEffectOnSubMeshes: boolean;
  20892. /**
  20893. * Stores the animations for the material
  20894. */
  20895. animations: Nullable<Array<Animation>>;
  20896. /**
  20897. * An event triggered when the material is disposed
  20898. */
  20899. onDisposeObservable: Observable<Material>;
  20900. /**
  20901. * An observer which watches for dispose events
  20902. */
  20903. private _onDisposeObserver;
  20904. private _onUnBindObservable;
  20905. /**
  20906. * Called during a dispose event
  20907. */
  20908. onDispose: () => void;
  20909. private _onBindObservable;
  20910. /**
  20911. * An event triggered when the material is bound
  20912. */
  20913. readonly onBindObservable: Observable<AbstractMesh>;
  20914. /**
  20915. * An observer which watches for bind events
  20916. */
  20917. private _onBindObserver;
  20918. /**
  20919. * Called during a bind event
  20920. */
  20921. onBind: (Mesh: AbstractMesh) => void;
  20922. /**
  20923. * An event triggered when the material is unbound
  20924. */
  20925. readonly onUnBindObservable: Observable<Material>;
  20926. /**
  20927. * Stores the value of the alpha mode
  20928. */
  20929. private _alphaMode;
  20930. /**
  20931. * Sets the value of the alpha mode.
  20932. *
  20933. * | Value | Type | Description |
  20934. * | --- | --- | --- |
  20935. * | 0 | ALPHA_DISABLE | |
  20936. * | 1 | ALPHA_ADD | |
  20937. * | 2 | ALPHA_COMBINE | |
  20938. * | 3 | ALPHA_SUBTRACT | |
  20939. * | 4 | ALPHA_MULTIPLY | |
  20940. * | 5 | ALPHA_MAXIMIZED | |
  20941. * | 6 | ALPHA_ONEONE | |
  20942. * | 7 | ALPHA_PREMULTIPLIED | |
  20943. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20944. * | 9 | ALPHA_INTERPOLATE | |
  20945. * | 10 | ALPHA_SCREENMODE | |
  20946. *
  20947. */
  20948. /**
  20949. * Gets the value of the alpha mode
  20950. */
  20951. alphaMode: number;
  20952. /**
  20953. * Stores the state of the need depth pre-pass value
  20954. */
  20955. private _needDepthPrePass;
  20956. /**
  20957. * Sets the need depth pre-pass value
  20958. */
  20959. /**
  20960. * Gets the depth pre-pass value
  20961. */
  20962. needDepthPrePass: boolean;
  20963. /**
  20964. * Specifies if depth writing should be disabled
  20965. */
  20966. disableDepthWrite: boolean;
  20967. /**
  20968. * Specifies if depth writing should be forced
  20969. */
  20970. forceDepthWrite: boolean;
  20971. /**
  20972. * Specifies if there should be a separate pass for culling
  20973. */
  20974. separateCullingPass: boolean;
  20975. /**
  20976. * Stores the state specifing if fog should be enabled
  20977. */
  20978. private _fogEnabled;
  20979. /**
  20980. * Sets the state for enabling fog
  20981. */
  20982. /**
  20983. * Gets the value of the fog enabled state
  20984. */
  20985. fogEnabled: boolean;
  20986. /**
  20987. * Stores the size of points
  20988. */
  20989. pointSize: number;
  20990. /**
  20991. * Stores the z offset value
  20992. */
  20993. zOffset: number;
  20994. /**
  20995. * Gets a value specifying if wireframe mode is enabled
  20996. */
  20997. /**
  20998. * Sets the state of wireframe mode
  20999. */
  21000. wireframe: boolean;
  21001. /**
  21002. * Gets the value specifying if point clouds are enabled
  21003. */
  21004. /**
  21005. * Sets the state of point cloud mode
  21006. */
  21007. pointsCloud: boolean;
  21008. /**
  21009. * Gets the material fill mode
  21010. */
  21011. /**
  21012. * Sets the material fill mode
  21013. */
  21014. fillMode: number;
  21015. /**
  21016. * @hidden
  21017. * Stores the effects for the material
  21018. */
  21019. _effect: Nullable<Effect>;
  21020. /**
  21021. * @hidden
  21022. * Specifies if the material was previously ready
  21023. */
  21024. _wasPreviouslyReady: boolean;
  21025. /**
  21026. * Specifies if uniform buffers should be used
  21027. */
  21028. private _useUBO;
  21029. /**
  21030. * Stores a reference to the scene
  21031. */
  21032. private _scene;
  21033. /**
  21034. * Stores the fill mode state
  21035. */
  21036. private _fillMode;
  21037. /**
  21038. * Specifies if the depth write state should be cached
  21039. */
  21040. private _cachedDepthWriteState;
  21041. /**
  21042. * Stores the uniform buffer
  21043. */
  21044. protected _uniformBuffer: UniformBuffer;
  21045. /** @hidden */
  21046. _indexInSceneMaterialArray: number;
  21047. /** @hidden */
  21048. meshMap: Nullable<{
  21049. [id: string]: AbstractMesh | undefined;
  21050. }>;
  21051. /**
  21052. * Creates a material instance
  21053. * @param name defines the name of the material
  21054. * @param scene defines the scene to reference
  21055. * @param doNotAdd specifies if the material should be added to the scene
  21056. */
  21057. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21058. /**
  21059. * Returns a string representation of the current material
  21060. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21061. * @returns a string with material information
  21062. */
  21063. toString(fullDetails?: boolean): string;
  21064. /**
  21065. * Gets the class name of the material
  21066. * @returns a string with the class name of the material
  21067. */
  21068. getClassName(): string;
  21069. /**
  21070. * Specifies if updates for the material been locked
  21071. */
  21072. readonly isFrozen: boolean;
  21073. /**
  21074. * Locks updates for the material
  21075. */
  21076. freeze(): void;
  21077. /**
  21078. * Unlocks updates for the material
  21079. */
  21080. unfreeze(): void;
  21081. /**
  21082. * Specifies if the material is ready to be used
  21083. * @param mesh defines the mesh to check
  21084. * @param useInstances specifies if instances should be used
  21085. * @returns a boolean indicating if the material is ready to be used
  21086. */
  21087. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21088. /**
  21089. * Specifies that the submesh is ready to be used
  21090. * @param mesh defines the mesh to check
  21091. * @param subMesh defines which submesh to check
  21092. * @param useInstances specifies that instances should be used
  21093. * @returns a boolean indicating that the submesh is ready or not
  21094. */
  21095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21096. /**
  21097. * Returns the material effect
  21098. * @returns the effect associated with the material
  21099. */
  21100. getEffect(): Nullable<Effect>;
  21101. /**
  21102. * Returns the current scene
  21103. * @returns a Scene
  21104. */
  21105. getScene(): Scene;
  21106. /**
  21107. * Specifies if the material will require alpha blending
  21108. * @returns a boolean specifying if alpha blending is needed
  21109. */
  21110. needAlphaBlending(): boolean;
  21111. /**
  21112. * Specifies if the mesh will require alpha blending
  21113. * @param mesh defines the mesh to check
  21114. * @returns a boolean specifying if alpha blending is needed for the mesh
  21115. */
  21116. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21117. /**
  21118. * Specifies if this material should be rendered in alpha test mode
  21119. * @returns a boolean specifying if an alpha test is needed.
  21120. */
  21121. needAlphaTesting(): boolean;
  21122. /**
  21123. * Gets the texture used for the alpha test
  21124. * @returns the texture to use for alpha testing
  21125. */
  21126. getAlphaTestTexture(): Nullable<BaseTexture>;
  21127. /**
  21128. * Marks the material to indicate that it needs to be re-calculated
  21129. */
  21130. markDirty(): void;
  21131. /** @hidden */
  21132. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21133. /**
  21134. * Binds the material to the mesh
  21135. * @param world defines the world transformation matrix
  21136. * @param mesh defines the mesh to bind the material to
  21137. */
  21138. bind(world: Matrix, mesh?: Mesh): void;
  21139. /**
  21140. * Binds the submesh to the material
  21141. * @param world defines the world transformation matrix
  21142. * @param mesh defines the mesh containing the submesh
  21143. * @param subMesh defines the submesh to bind the material to
  21144. */
  21145. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21146. /**
  21147. * Binds the world matrix to the material
  21148. * @param world defines the world transformation matrix
  21149. */
  21150. bindOnlyWorldMatrix(world: Matrix): void;
  21151. /**
  21152. * Binds the scene's uniform buffer to the effect.
  21153. * @param effect defines the effect to bind to the scene uniform buffer
  21154. * @param sceneUbo defines the uniform buffer storing scene data
  21155. */
  21156. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21157. /**
  21158. * Binds the view matrix to the effect
  21159. * @param effect defines the effect to bind the view matrix to
  21160. */
  21161. bindView(effect: Effect): void;
  21162. /**
  21163. * Binds the view projection matrix to the effect
  21164. * @param effect defines the effect to bind the view projection matrix to
  21165. */
  21166. bindViewProjection(effect: Effect): void;
  21167. /**
  21168. * Specifies if material alpha testing should be turned on for the mesh
  21169. * @param mesh defines the mesh to check
  21170. */
  21171. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21172. /**
  21173. * Processes to execute after binding the material to a mesh
  21174. * @param mesh defines the rendered mesh
  21175. */
  21176. protected _afterBind(mesh?: Mesh): void;
  21177. /**
  21178. * Unbinds the material from the mesh
  21179. */
  21180. unbind(): void;
  21181. /**
  21182. * Gets the active textures from the material
  21183. * @returns an array of textures
  21184. */
  21185. getActiveTextures(): BaseTexture[];
  21186. /**
  21187. * Specifies if the material uses a texture
  21188. * @param texture defines the texture to check against the material
  21189. * @returns a boolean specifying if the material uses the texture
  21190. */
  21191. hasTexture(texture: BaseTexture): boolean;
  21192. /**
  21193. * Makes a duplicate of the material, and gives it a new name
  21194. * @param name defines the new name for the duplicated material
  21195. * @returns the cloned material
  21196. */
  21197. clone(name: string): Nullable<Material>;
  21198. /**
  21199. * Gets the meshes bound to the material
  21200. * @returns an array of meshes bound to the material
  21201. */
  21202. getBindedMeshes(): AbstractMesh[];
  21203. /**
  21204. * Force shader compilation
  21205. * @param mesh defines the mesh associated with this material
  21206. * @param onCompiled defines a function to execute once the material is compiled
  21207. * @param options defines the options to configure the compilation
  21208. */
  21209. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21210. clipPlane: boolean;
  21211. }>): void;
  21212. /**
  21213. * Force shader compilation
  21214. * @param mesh defines the mesh that will use this material
  21215. * @param options defines additional options for compiling the shaders
  21216. * @returns a promise that resolves when the compilation completes
  21217. */
  21218. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21219. clipPlane: boolean;
  21220. }>): Promise<void>;
  21221. private static readonly _AllDirtyCallBack;
  21222. private static readonly _ImageProcessingDirtyCallBack;
  21223. private static readonly _TextureDirtyCallBack;
  21224. private static readonly _FresnelDirtyCallBack;
  21225. private static readonly _MiscDirtyCallBack;
  21226. private static readonly _LightsDirtyCallBack;
  21227. private static readonly _AttributeDirtyCallBack;
  21228. private static _FresnelAndMiscDirtyCallBack;
  21229. private static _TextureAndMiscDirtyCallBack;
  21230. private static readonly _DirtyCallbackArray;
  21231. private static readonly _RunDirtyCallBacks;
  21232. /**
  21233. * Marks a define in the material to indicate that it needs to be re-computed
  21234. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21235. */
  21236. markAsDirty(flag: number): void;
  21237. /**
  21238. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21239. * @param func defines a function which checks material defines against the submeshes
  21240. */
  21241. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21242. /**
  21243. * Indicates that we need to re-calculated for all submeshes
  21244. */
  21245. protected _markAllSubMeshesAsAllDirty(): void;
  21246. /**
  21247. * Indicates that image processing needs to be re-calculated for all submeshes
  21248. */
  21249. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21250. /**
  21251. * Indicates that textures need to be re-calculated for all submeshes
  21252. */
  21253. protected _markAllSubMeshesAsTexturesDirty(): void;
  21254. /**
  21255. * Indicates that fresnel needs to be re-calculated for all submeshes
  21256. */
  21257. protected _markAllSubMeshesAsFresnelDirty(): void;
  21258. /**
  21259. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21260. */
  21261. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21262. /**
  21263. * Indicates that lights need to be re-calculated for all submeshes
  21264. */
  21265. protected _markAllSubMeshesAsLightsDirty(): void;
  21266. /**
  21267. * Indicates that attributes need to be re-calculated for all submeshes
  21268. */
  21269. protected _markAllSubMeshesAsAttributesDirty(): void;
  21270. /**
  21271. * Indicates that misc needs to be re-calculated for all submeshes
  21272. */
  21273. protected _markAllSubMeshesAsMiscDirty(): void;
  21274. /**
  21275. * Indicates that textures and misc need to be re-calculated for all submeshes
  21276. */
  21277. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21278. /**
  21279. * Disposes the material
  21280. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21281. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21282. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21283. */
  21284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21285. /** @hidden */
  21286. private releaseVertexArrayObject;
  21287. /**
  21288. * Serializes this material
  21289. * @returns the serialized material object
  21290. */
  21291. serialize(): any;
  21292. /**
  21293. * Creates a material from parsed material data
  21294. * @param parsedMaterial defines parsed material data
  21295. * @param scene defines the hosting scene
  21296. * @param rootUrl defines the root URL to use to load textures
  21297. * @returns a new material
  21298. */
  21299. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21300. }
  21301. }
  21302. declare module "babylonjs/Materials/multiMaterial" {
  21303. import { Nullable } from "babylonjs/types";
  21304. import { Scene } from "babylonjs/scene";
  21305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21306. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21308. import { Material } from "babylonjs/Materials/material";
  21309. /**
  21310. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21311. * separate meshes. This can be use to improve performances.
  21312. * @see http://doc.babylonjs.com/how_to/multi_materials
  21313. */
  21314. export class MultiMaterial extends Material {
  21315. private _subMaterials;
  21316. /**
  21317. * Gets or Sets the list of Materials used within the multi material.
  21318. * They need to be ordered according to the submeshes order in the associated mesh
  21319. */
  21320. subMaterials: Nullable<Material>[];
  21321. /**
  21322. * Function used to align with Node.getChildren()
  21323. * @returns the list of Materials used within the multi material
  21324. */
  21325. getChildren(): Nullable<Material>[];
  21326. /**
  21327. * Instantiates a new Multi Material
  21328. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21329. * separate meshes. This can be use to improve performances.
  21330. * @see http://doc.babylonjs.com/how_to/multi_materials
  21331. * @param name Define the name in the scene
  21332. * @param scene Define the scene the material belongs to
  21333. */
  21334. constructor(name: string, scene: Scene);
  21335. private _hookArray;
  21336. /**
  21337. * Get one of the submaterial by its index in the submaterials array
  21338. * @param index The index to look the sub material at
  21339. * @returns The Material if the index has been defined
  21340. */
  21341. getSubMaterial(index: number): Nullable<Material>;
  21342. /**
  21343. * Get the list of active textures for the whole sub materials list.
  21344. * @returns All the textures that will be used during the rendering
  21345. */
  21346. getActiveTextures(): BaseTexture[];
  21347. /**
  21348. * Gets the current class name of the material e.g. "MultiMaterial"
  21349. * Mainly use in serialization.
  21350. * @returns the class name
  21351. */
  21352. getClassName(): string;
  21353. /**
  21354. * Checks if the material is ready to render the requested sub mesh
  21355. * @param mesh Define the mesh the submesh belongs to
  21356. * @param subMesh Define the sub mesh to look readyness for
  21357. * @param useInstances Define whether or not the material is used with instances
  21358. * @returns true if ready, otherwise false
  21359. */
  21360. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21361. /**
  21362. * Clones the current material and its related sub materials
  21363. * @param name Define the name of the newly cloned material
  21364. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21365. * @returns the cloned material
  21366. */
  21367. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21368. /**
  21369. * Serializes the materials into a JSON representation.
  21370. * @returns the JSON representation
  21371. */
  21372. serialize(): any;
  21373. /**
  21374. * Dispose the material and release its associated resources
  21375. * @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)
  21376. * @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)
  21377. * @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)
  21378. */
  21379. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21380. /**
  21381. * Creates a MultiMaterial from parsed MultiMaterial data.
  21382. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21383. * @param scene defines the hosting scene
  21384. * @returns a new MultiMaterial
  21385. */
  21386. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21387. }
  21388. }
  21389. declare module "babylonjs/Meshes/subMesh" {
  21390. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21391. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21392. import { Engine } from "babylonjs/Engines/engine";
  21393. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21394. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21395. import { Effect } from "babylonjs/Materials/effect";
  21396. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21397. import { Plane } from "babylonjs/Maths/math.plane";
  21398. import { Collider } from "babylonjs/Collisions/collider";
  21399. import { Material } from "babylonjs/Materials/material";
  21400. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21402. import { Mesh } from "babylonjs/Meshes/mesh";
  21403. import { Ray } from "babylonjs/Culling/ray";
  21404. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21405. /**
  21406. * Base class for submeshes
  21407. */
  21408. export class BaseSubMesh {
  21409. /** @hidden */
  21410. _materialDefines: Nullable<MaterialDefines>;
  21411. /** @hidden */
  21412. _materialEffect: Nullable<Effect>;
  21413. /**
  21414. * Gets associated effect
  21415. */
  21416. readonly effect: Nullable<Effect>;
  21417. /**
  21418. * Sets associated effect (effect used to render this submesh)
  21419. * @param effect defines the effect to associate with
  21420. * @param defines defines the set of defines used to compile this effect
  21421. */
  21422. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21423. }
  21424. /**
  21425. * Defines a subdivision inside a mesh
  21426. */
  21427. export class SubMesh extends BaseSubMesh implements ICullable {
  21428. /** the material index to use */
  21429. materialIndex: number;
  21430. /** vertex index start */
  21431. verticesStart: number;
  21432. /** vertices count */
  21433. verticesCount: number;
  21434. /** index start */
  21435. indexStart: number;
  21436. /** indices count */
  21437. indexCount: number;
  21438. /** @hidden */
  21439. _linesIndexCount: number;
  21440. private _mesh;
  21441. private _renderingMesh;
  21442. private _boundingInfo;
  21443. private _linesIndexBuffer;
  21444. /** @hidden */
  21445. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21446. /** @hidden */
  21447. _trianglePlanes: Plane[];
  21448. /** @hidden */
  21449. _lastColliderTransformMatrix: Nullable<Matrix>;
  21450. /** @hidden */
  21451. _renderId: number;
  21452. /** @hidden */
  21453. _alphaIndex: number;
  21454. /** @hidden */
  21455. _distanceToCamera: number;
  21456. /** @hidden */
  21457. _id: number;
  21458. private _currentMaterial;
  21459. /**
  21460. * Add a new submesh to a mesh
  21461. * @param materialIndex defines the material index to use
  21462. * @param verticesStart defines vertex index start
  21463. * @param verticesCount defines vertices count
  21464. * @param indexStart defines index start
  21465. * @param indexCount defines indices count
  21466. * @param mesh defines the parent mesh
  21467. * @param renderingMesh defines an optional rendering mesh
  21468. * @param createBoundingBox defines if bounding box should be created for this submesh
  21469. * @returns the new submesh
  21470. */
  21471. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21472. /**
  21473. * Creates a new submesh
  21474. * @param materialIndex defines the material index to use
  21475. * @param verticesStart defines vertex index start
  21476. * @param verticesCount defines vertices count
  21477. * @param indexStart defines index start
  21478. * @param indexCount defines indices count
  21479. * @param mesh defines the parent mesh
  21480. * @param renderingMesh defines an optional rendering mesh
  21481. * @param createBoundingBox defines if bounding box should be created for this submesh
  21482. */
  21483. constructor(
  21484. /** the material index to use */
  21485. materialIndex: number,
  21486. /** vertex index start */
  21487. verticesStart: number,
  21488. /** vertices count */
  21489. verticesCount: number,
  21490. /** index start */
  21491. indexStart: number,
  21492. /** indices count */
  21493. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21494. /**
  21495. * Returns true if this submesh covers the entire parent mesh
  21496. * @ignorenaming
  21497. */
  21498. readonly IsGlobal: boolean;
  21499. /**
  21500. * Returns the submesh BoudingInfo object
  21501. * @returns current bounding info (or mesh's one if the submesh is global)
  21502. */
  21503. getBoundingInfo(): BoundingInfo;
  21504. /**
  21505. * Sets the submesh BoundingInfo
  21506. * @param boundingInfo defines the new bounding info to use
  21507. * @returns the SubMesh
  21508. */
  21509. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21510. /**
  21511. * Returns the mesh of the current submesh
  21512. * @return the parent mesh
  21513. */
  21514. getMesh(): AbstractMesh;
  21515. /**
  21516. * Returns the rendering mesh of the submesh
  21517. * @returns the rendering mesh (could be different from parent mesh)
  21518. */
  21519. getRenderingMesh(): Mesh;
  21520. /**
  21521. * Returns the submesh material
  21522. * @returns null or the current material
  21523. */
  21524. getMaterial(): Nullable<Material>;
  21525. /**
  21526. * Sets a new updated BoundingInfo object to the submesh
  21527. * @param data defines an optional position array to use to determine the bounding info
  21528. * @returns the SubMesh
  21529. */
  21530. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21531. /** @hidden */
  21532. _checkCollision(collider: Collider): boolean;
  21533. /**
  21534. * Updates the submesh BoundingInfo
  21535. * @param world defines the world matrix to use to update the bounding info
  21536. * @returns the submesh
  21537. */
  21538. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21539. /**
  21540. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21541. * @param frustumPlanes defines the frustum planes
  21542. * @returns true if the submesh is intersecting with the frustum
  21543. */
  21544. isInFrustum(frustumPlanes: Plane[]): boolean;
  21545. /**
  21546. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21547. * @param frustumPlanes defines the frustum planes
  21548. * @returns true if the submesh is inside the frustum
  21549. */
  21550. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21551. /**
  21552. * Renders the submesh
  21553. * @param enableAlphaMode defines if alpha needs to be used
  21554. * @returns the submesh
  21555. */
  21556. render(enableAlphaMode: boolean): SubMesh;
  21557. /**
  21558. * @hidden
  21559. */
  21560. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21561. /**
  21562. * Checks if the submesh intersects with a ray
  21563. * @param ray defines the ray to test
  21564. * @returns true is the passed ray intersects the submesh bounding box
  21565. */
  21566. canIntersects(ray: Ray): boolean;
  21567. /**
  21568. * Intersects current submesh with a ray
  21569. * @param ray defines the ray to test
  21570. * @param positions defines mesh's positions array
  21571. * @param indices defines mesh's indices array
  21572. * @param fastCheck defines if only bounding info should be used
  21573. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21574. * @returns intersection info or null if no intersection
  21575. */
  21576. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21577. /** @hidden */
  21578. private _intersectLines;
  21579. /** @hidden */
  21580. private _intersectUnIndexedLines;
  21581. /** @hidden */
  21582. private _intersectTriangles;
  21583. /** @hidden */
  21584. private _intersectUnIndexedTriangles;
  21585. /** @hidden */
  21586. _rebuild(): void;
  21587. /**
  21588. * Creates a new submesh from the passed mesh
  21589. * @param newMesh defines the new hosting mesh
  21590. * @param newRenderingMesh defines an optional rendering mesh
  21591. * @returns the new submesh
  21592. */
  21593. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21594. /**
  21595. * Release associated resources
  21596. */
  21597. dispose(): void;
  21598. /**
  21599. * Gets the class name
  21600. * @returns the string "SubMesh".
  21601. */
  21602. getClassName(): string;
  21603. /**
  21604. * Creates a new submesh from indices data
  21605. * @param materialIndex the index of the main mesh material
  21606. * @param startIndex the index where to start the copy in the mesh indices array
  21607. * @param indexCount the number of indices to copy then from the startIndex
  21608. * @param mesh the main mesh to create the submesh from
  21609. * @param renderingMesh the optional rendering mesh
  21610. * @returns a new submesh
  21611. */
  21612. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21613. }
  21614. }
  21615. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21616. /**
  21617. * Class used to represent data loading progression
  21618. */
  21619. export class SceneLoaderFlags {
  21620. private static _ForceFullSceneLoadingForIncremental;
  21621. private static _ShowLoadingScreen;
  21622. private static _CleanBoneMatrixWeights;
  21623. private static _loggingLevel;
  21624. /**
  21625. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21626. */
  21627. static ForceFullSceneLoadingForIncremental: boolean;
  21628. /**
  21629. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21630. */
  21631. static ShowLoadingScreen: boolean;
  21632. /**
  21633. * Defines the current logging level (while loading the scene)
  21634. * @ignorenaming
  21635. */
  21636. static loggingLevel: number;
  21637. /**
  21638. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21639. */
  21640. static CleanBoneMatrixWeights: boolean;
  21641. }
  21642. }
  21643. declare module "babylonjs/Meshes/geometry" {
  21644. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21645. import { Scene } from "babylonjs/scene";
  21646. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21647. import { Engine } from "babylonjs/Engines/engine";
  21648. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21649. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21650. import { Effect } from "babylonjs/Materials/effect";
  21651. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21652. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21653. import { Mesh } from "babylonjs/Meshes/mesh";
  21654. /**
  21655. * Class used to store geometry data (vertex buffers + index buffer)
  21656. */
  21657. export class Geometry implements IGetSetVerticesData {
  21658. /**
  21659. * Gets or sets the ID of the geometry
  21660. */
  21661. id: string;
  21662. /**
  21663. * Gets or sets the unique ID of the geometry
  21664. */
  21665. uniqueId: number;
  21666. /**
  21667. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21668. */
  21669. delayLoadState: number;
  21670. /**
  21671. * Gets the file containing the data to load when running in delay load state
  21672. */
  21673. delayLoadingFile: Nullable<string>;
  21674. /**
  21675. * Callback called when the geometry is updated
  21676. */
  21677. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21678. private _scene;
  21679. private _engine;
  21680. private _meshes;
  21681. private _totalVertices;
  21682. /** @hidden */
  21683. _indices: IndicesArray;
  21684. /** @hidden */
  21685. _vertexBuffers: {
  21686. [key: string]: VertexBuffer;
  21687. };
  21688. private _isDisposed;
  21689. private _extend;
  21690. private _boundingBias;
  21691. /** @hidden */
  21692. _delayInfo: Array<string>;
  21693. private _indexBuffer;
  21694. private _indexBufferIsUpdatable;
  21695. /** @hidden */
  21696. _boundingInfo: Nullable<BoundingInfo>;
  21697. /** @hidden */
  21698. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21699. /** @hidden */
  21700. _softwareSkinningFrameId: number;
  21701. private _vertexArrayObjects;
  21702. private _updatable;
  21703. /** @hidden */
  21704. _positions: Nullable<Vector3[]>;
  21705. /**
  21706. * 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
  21707. */
  21708. /**
  21709. * 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
  21710. */
  21711. boundingBias: Vector2;
  21712. /**
  21713. * Static function used to attach a new empty geometry to a mesh
  21714. * @param mesh defines the mesh to attach the geometry to
  21715. * @returns the new Geometry
  21716. */
  21717. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21718. /**
  21719. * Creates a new geometry
  21720. * @param id defines the unique ID
  21721. * @param scene defines the hosting scene
  21722. * @param vertexData defines the VertexData used to get geometry data
  21723. * @param updatable defines if geometry must be updatable (false by default)
  21724. * @param mesh defines the mesh that will be associated with the geometry
  21725. */
  21726. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21727. /**
  21728. * Gets the current extend of the geometry
  21729. */
  21730. readonly extend: {
  21731. minimum: Vector3;
  21732. maximum: Vector3;
  21733. };
  21734. /**
  21735. * Gets the hosting scene
  21736. * @returns the hosting Scene
  21737. */
  21738. getScene(): Scene;
  21739. /**
  21740. * Gets the hosting engine
  21741. * @returns the hosting Engine
  21742. */
  21743. getEngine(): Engine;
  21744. /**
  21745. * Defines if the geometry is ready to use
  21746. * @returns true if the geometry is ready to be used
  21747. */
  21748. isReady(): boolean;
  21749. /**
  21750. * Gets a value indicating that the geometry should not be serialized
  21751. */
  21752. readonly doNotSerialize: boolean;
  21753. /** @hidden */
  21754. _rebuild(): void;
  21755. /**
  21756. * Affects all geometry data in one call
  21757. * @param vertexData defines the geometry data
  21758. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21759. */
  21760. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21761. /**
  21762. * Set specific vertex data
  21763. * @param kind defines the data kind (Position, normal, etc...)
  21764. * @param data defines the vertex data to use
  21765. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21766. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21767. */
  21768. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21769. /**
  21770. * Removes a specific vertex data
  21771. * @param kind defines the data kind (Position, normal, etc...)
  21772. */
  21773. removeVerticesData(kind: string): void;
  21774. /**
  21775. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21776. * @param buffer defines the vertex buffer to use
  21777. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21778. */
  21779. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21780. /**
  21781. * Update a specific vertex buffer
  21782. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21783. * It will do nothing if the buffer is not updatable
  21784. * @param kind defines the data kind (Position, normal, etc...)
  21785. * @param data defines the data to use
  21786. * @param offset defines the offset in the target buffer where to store the data
  21787. * @param useBytes set to true if the offset is in bytes
  21788. */
  21789. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21790. /**
  21791. * Update a specific vertex buffer
  21792. * This function will create a new buffer if the current one is not updatable
  21793. * @param kind defines the data kind (Position, normal, etc...)
  21794. * @param data defines the data to use
  21795. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21796. */
  21797. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21798. private _updateBoundingInfo;
  21799. /** @hidden */
  21800. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21801. /**
  21802. * Gets total number of vertices
  21803. * @returns the total number of vertices
  21804. */
  21805. getTotalVertices(): number;
  21806. /**
  21807. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21808. * @param kind defines the data kind (Position, normal, etc...)
  21809. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21811. * @returns a float array containing vertex data
  21812. */
  21813. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21814. /**
  21815. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21816. * @param kind defines the data kind (Position, normal, etc...)
  21817. * @returns true if the vertex buffer with the specified kind is updatable
  21818. */
  21819. isVertexBufferUpdatable(kind: string): boolean;
  21820. /**
  21821. * Gets a specific vertex buffer
  21822. * @param kind defines the data kind (Position, normal, etc...)
  21823. * @returns a VertexBuffer
  21824. */
  21825. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21826. /**
  21827. * Returns all vertex buffers
  21828. * @return an object holding all vertex buffers indexed by kind
  21829. */
  21830. getVertexBuffers(): Nullable<{
  21831. [key: string]: VertexBuffer;
  21832. }>;
  21833. /**
  21834. * Gets a boolean indicating if specific vertex buffer is present
  21835. * @param kind defines the data kind (Position, normal, etc...)
  21836. * @returns true if data is present
  21837. */
  21838. isVerticesDataPresent(kind: string): boolean;
  21839. /**
  21840. * Gets a list of all attached data kinds (Position, normal, etc...)
  21841. * @returns a list of string containing all kinds
  21842. */
  21843. getVerticesDataKinds(): string[];
  21844. /**
  21845. * Update index buffer
  21846. * @param indices defines the indices to store in the index buffer
  21847. * @param offset defines the offset in the target buffer where to store the data
  21848. * @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)
  21849. */
  21850. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21851. /**
  21852. * Creates a new index buffer
  21853. * @param indices defines the indices to store in the index buffer
  21854. * @param totalVertices defines the total number of vertices (could be null)
  21855. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21856. */
  21857. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21858. /**
  21859. * Return the total number of indices
  21860. * @returns the total number of indices
  21861. */
  21862. getTotalIndices(): number;
  21863. /**
  21864. * Gets the index buffer array
  21865. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21866. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21867. * @returns the index buffer array
  21868. */
  21869. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21870. /**
  21871. * Gets the index buffer
  21872. * @return the index buffer
  21873. */
  21874. getIndexBuffer(): Nullable<DataBuffer>;
  21875. /** @hidden */
  21876. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21877. /**
  21878. * Release the associated resources for a specific mesh
  21879. * @param mesh defines the source mesh
  21880. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21881. */
  21882. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21883. /**
  21884. * Apply current geometry to a given mesh
  21885. * @param mesh defines the mesh to apply geometry to
  21886. */
  21887. applyToMesh(mesh: Mesh): void;
  21888. private _updateExtend;
  21889. private _applyToMesh;
  21890. private notifyUpdate;
  21891. /**
  21892. * Load the geometry if it was flagged as delay loaded
  21893. * @param scene defines the hosting scene
  21894. * @param onLoaded defines a callback called when the geometry is loaded
  21895. */
  21896. load(scene: Scene, onLoaded?: () => void): void;
  21897. private _queueLoad;
  21898. /**
  21899. * Invert the geometry to move from a right handed system to a left handed one.
  21900. */
  21901. toLeftHanded(): void;
  21902. /** @hidden */
  21903. _resetPointsArrayCache(): void;
  21904. /** @hidden */
  21905. _generatePointsArray(): boolean;
  21906. /**
  21907. * Gets a value indicating if the geometry is disposed
  21908. * @returns true if the geometry was disposed
  21909. */
  21910. isDisposed(): boolean;
  21911. private _disposeVertexArrayObjects;
  21912. /**
  21913. * Free all associated resources
  21914. */
  21915. dispose(): void;
  21916. /**
  21917. * Clone the current geometry into a new geometry
  21918. * @param id defines the unique ID of the new geometry
  21919. * @returns a new geometry object
  21920. */
  21921. copy(id: string): Geometry;
  21922. /**
  21923. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21924. * @return a JSON representation of the current geometry data (without the vertices data)
  21925. */
  21926. serialize(): any;
  21927. private toNumberArray;
  21928. /**
  21929. * Serialize all vertices data into a JSON oject
  21930. * @returns a JSON representation of the current geometry data
  21931. */
  21932. serializeVerticeData(): any;
  21933. /**
  21934. * Extracts a clone of a mesh geometry
  21935. * @param mesh defines the source mesh
  21936. * @param id defines the unique ID of the new geometry object
  21937. * @returns the new geometry object
  21938. */
  21939. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21940. /**
  21941. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21942. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21943. * Be aware Math.random() could cause collisions, but:
  21944. * "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"
  21945. * @returns a string containing a new GUID
  21946. */
  21947. static RandomId(): string;
  21948. /** @hidden */
  21949. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21950. private static _CleanMatricesWeights;
  21951. /**
  21952. * Create a new geometry from persisted data (Using .babylon file format)
  21953. * @param parsedVertexData defines the persisted data
  21954. * @param scene defines the hosting scene
  21955. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21956. * @returns the new geometry object
  21957. */
  21958. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21959. }
  21960. }
  21961. declare module "babylonjs/Meshes/mesh.vertexData" {
  21962. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21963. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21964. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21965. import { Geometry } from "babylonjs/Meshes/geometry";
  21966. import { Mesh } from "babylonjs/Meshes/mesh";
  21967. /**
  21968. * Define an interface for all classes that will get and set the data on vertices
  21969. */
  21970. export interface IGetSetVerticesData {
  21971. /**
  21972. * Gets a boolean indicating if specific vertex data is present
  21973. * @param kind defines the vertex data kind to use
  21974. * @returns true is data kind is present
  21975. */
  21976. isVerticesDataPresent(kind: string): boolean;
  21977. /**
  21978. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21979. * @param kind defines the data kind (Position, normal, etc...)
  21980. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21981. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21982. * @returns a float array containing vertex data
  21983. */
  21984. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21985. /**
  21986. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21987. * @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.
  21988. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21989. * @returns the indices array or an empty array if the mesh has no geometry
  21990. */
  21991. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21992. /**
  21993. * Set specific vertex data
  21994. * @param kind defines the data kind (Position, normal, etc...)
  21995. * @param data defines the vertex data to use
  21996. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21997. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21998. */
  21999. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22000. /**
  22001. * Update a specific associated vertex buffer
  22002. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22003. * - VertexBuffer.PositionKind
  22004. * - VertexBuffer.UVKind
  22005. * - VertexBuffer.UV2Kind
  22006. * - VertexBuffer.UV3Kind
  22007. * - VertexBuffer.UV4Kind
  22008. * - VertexBuffer.UV5Kind
  22009. * - VertexBuffer.UV6Kind
  22010. * - VertexBuffer.ColorKind
  22011. * - VertexBuffer.MatricesIndicesKind
  22012. * - VertexBuffer.MatricesIndicesExtraKind
  22013. * - VertexBuffer.MatricesWeightsKind
  22014. * - VertexBuffer.MatricesWeightsExtraKind
  22015. * @param data defines the data source
  22016. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22017. * @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)
  22018. */
  22019. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22020. /**
  22021. * Creates a new index buffer
  22022. * @param indices defines the indices to store in the index buffer
  22023. * @param totalVertices defines the total number of vertices (could be null)
  22024. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22025. */
  22026. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22027. }
  22028. /**
  22029. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22030. */
  22031. export class VertexData {
  22032. /**
  22033. * Mesh side orientation : usually the external or front surface
  22034. */
  22035. static readonly FRONTSIDE: number;
  22036. /**
  22037. * Mesh side orientation : usually the internal or back surface
  22038. */
  22039. static readonly BACKSIDE: number;
  22040. /**
  22041. * Mesh side orientation : both internal and external or front and back surfaces
  22042. */
  22043. static readonly DOUBLESIDE: number;
  22044. /**
  22045. * Mesh side orientation : by default, `FRONTSIDE`
  22046. */
  22047. static readonly DEFAULTSIDE: number;
  22048. /**
  22049. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22050. */
  22051. positions: Nullable<FloatArray>;
  22052. /**
  22053. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22054. */
  22055. normals: Nullable<FloatArray>;
  22056. /**
  22057. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22058. */
  22059. tangents: Nullable<FloatArray>;
  22060. /**
  22061. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22062. */
  22063. uvs: Nullable<FloatArray>;
  22064. /**
  22065. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22066. */
  22067. uvs2: Nullable<FloatArray>;
  22068. /**
  22069. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22070. */
  22071. uvs3: Nullable<FloatArray>;
  22072. /**
  22073. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22074. */
  22075. uvs4: Nullable<FloatArray>;
  22076. /**
  22077. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22078. */
  22079. uvs5: Nullable<FloatArray>;
  22080. /**
  22081. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22082. */
  22083. uvs6: Nullable<FloatArray>;
  22084. /**
  22085. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22086. */
  22087. colors: Nullable<FloatArray>;
  22088. /**
  22089. * 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).
  22090. */
  22091. matricesIndices: Nullable<FloatArray>;
  22092. /**
  22093. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22094. */
  22095. matricesWeights: Nullable<FloatArray>;
  22096. /**
  22097. * An array extending the number of possible indices
  22098. */
  22099. matricesIndicesExtra: Nullable<FloatArray>;
  22100. /**
  22101. * An array extending the number of possible weights when the number of indices is extended
  22102. */
  22103. matricesWeightsExtra: Nullable<FloatArray>;
  22104. /**
  22105. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22106. */
  22107. indices: Nullable<IndicesArray>;
  22108. /**
  22109. * Uses the passed data array to set the set the values for the specified kind of data
  22110. * @param data a linear array of floating numbers
  22111. * @param kind the type of data that is being set, eg positions, colors etc
  22112. */
  22113. set(data: FloatArray, kind: string): void;
  22114. /**
  22115. * Associates the vertexData to the passed Mesh.
  22116. * Sets it as updatable or not (default `false`)
  22117. * @param mesh the mesh the vertexData is applied to
  22118. * @param updatable when used and having the value true allows new data to update the vertexData
  22119. * @returns the VertexData
  22120. */
  22121. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22122. /**
  22123. * Associates the vertexData to the passed Geometry.
  22124. * Sets it as updatable or not (default `false`)
  22125. * @param geometry the geometry the vertexData is applied to
  22126. * @param updatable when used and having the value true allows new data to update the vertexData
  22127. * @returns VertexData
  22128. */
  22129. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22130. /**
  22131. * Updates the associated mesh
  22132. * @param mesh the mesh to be updated
  22133. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22134. * @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
  22135. * @returns VertexData
  22136. */
  22137. updateMesh(mesh: Mesh): VertexData;
  22138. /**
  22139. * Updates the associated geometry
  22140. * @param geometry the geometry to be updated
  22141. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22142. * @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
  22143. * @returns VertexData.
  22144. */
  22145. updateGeometry(geometry: Geometry): VertexData;
  22146. private _applyTo;
  22147. private _update;
  22148. /**
  22149. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22150. * @param matrix the transforming matrix
  22151. * @returns the VertexData
  22152. */
  22153. transform(matrix: Matrix): VertexData;
  22154. /**
  22155. * Merges the passed VertexData into the current one
  22156. * @param other the VertexData to be merged into the current one
  22157. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22158. * @returns the modified VertexData
  22159. */
  22160. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22161. private _mergeElement;
  22162. private _validate;
  22163. /**
  22164. * Serializes the VertexData
  22165. * @returns a serialized object
  22166. */
  22167. serialize(): any;
  22168. /**
  22169. * Extracts the vertexData from a mesh
  22170. * @param mesh the mesh from which to extract the VertexData
  22171. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22172. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22173. * @returns the object VertexData associated to the passed mesh
  22174. */
  22175. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22176. /**
  22177. * Extracts the vertexData from the geometry
  22178. * @param geometry the geometry from which to extract the VertexData
  22179. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22180. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22181. * @returns the object VertexData associated to the passed mesh
  22182. */
  22183. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22184. private static _ExtractFrom;
  22185. /**
  22186. * Creates the VertexData for a Ribbon
  22187. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22188. * * pathArray array of paths, each of which an array of successive Vector3
  22189. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22190. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22191. * * 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
  22192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22193. * * 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)
  22194. * * 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)
  22195. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22196. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22197. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22198. * @returns the VertexData of the ribbon
  22199. */
  22200. static CreateRibbon(options: {
  22201. pathArray: Vector3[][];
  22202. closeArray?: boolean;
  22203. closePath?: boolean;
  22204. offset?: number;
  22205. sideOrientation?: number;
  22206. frontUVs?: Vector4;
  22207. backUVs?: Vector4;
  22208. invertUV?: boolean;
  22209. uvs?: Vector2[];
  22210. colors?: Color4[];
  22211. }): VertexData;
  22212. /**
  22213. * Creates the VertexData for a box
  22214. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22215. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22216. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22217. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22218. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22219. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22220. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22221. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22222. * * 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)
  22223. * * 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)
  22224. * @returns the VertexData of the box
  22225. */
  22226. static CreateBox(options: {
  22227. size?: number;
  22228. width?: number;
  22229. height?: number;
  22230. depth?: number;
  22231. faceUV?: Vector4[];
  22232. faceColors?: Color4[];
  22233. sideOrientation?: number;
  22234. frontUVs?: Vector4;
  22235. backUVs?: Vector4;
  22236. }): VertexData;
  22237. /**
  22238. * Creates the VertexData for a tiled box
  22239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22240. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22241. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22242. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22244. * @returns the VertexData of the box
  22245. */
  22246. static CreateTiledBox(options: {
  22247. pattern?: number;
  22248. width?: number;
  22249. height?: number;
  22250. depth?: number;
  22251. tileSize?: number;
  22252. tileWidth?: number;
  22253. tileHeight?: number;
  22254. alignHorizontal?: number;
  22255. alignVertical?: number;
  22256. faceUV?: Vector4[];
  22257. faceColors?: Color4[];
  22258. sideOrientation?: number;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a tiled plane
  22262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22263. * * pattern a limited pattern arrangement depending on the number
  22264. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22265. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22266. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22268. * * 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)
  22269. * * 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)
  22270. * @returns the VertexData of the tiled plane
  22271. */
  22272. static CreateTiledPlane(options: {
  22273. pattern?: number;
  22274. tileSize?: number;
  22275. tileWidth?: number;
  22276. tileHeight?: number;
  22277. size?: number;
  22278. width?: number;
  22279. height?: number;
  22280. alignHorizontal?: number;
  22281. alignVertical?: number;
  22282. sideOrientation?: number;
  22283. frontUVs?: Vector4;
  22284. backUVs?: Vector4;
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22288. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22289. * * segments sets the number of horizontal strips optional, default 32
  22290. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22291. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22292. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22293. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22294. * * 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
  22295. * * 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
  22296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22297. * * 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)
  22298. * * 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)
  22299. * @returns the VertexData of the ellipsoid
  22300. */
  22301. static CreateSphere(options: {
  22302. segments?: number;
  22303. diameter?: number;
  22304. diameterX?: number;
  22305. diameterY?: number;
  22306. diameterZ?: number;
  22307. arc?: number;
  22308. slice?: number;
  22309. sideOrientation?: number;
  22310. frontUVs?: Vector4;
  22311. backUVs?: Vector4;
  22312. }): VertexData;
  22313. /**
  22314. * Creates the VertexData for a cylinder, cone or prism
  22315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22316. * * height sets the height (y direction) of the cylinder, optional, default 2
  22317. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22318. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22319. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22320. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22321. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22322. * * 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
  22323. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22324. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22325. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22326. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22327. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22328. * * 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)
  22329. * * 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)
  22330. * @returns the VertexData of the cylinder, cone or prism
  22331. */
  22332. static CreateCylinder(options: {
  22333. height?: number;
  22334. diameterTop?: number;
  22335. diameterBottom?: number;
  22336. diameter?: number;
  22337. tessellation?: number;
  22338. subdivisions?: number;
  22339. arc?: number;
  22340. faceColors?: Color4[];
  22341. faceUV?: Vector4[];
  22342. hasRings?: boolean;
  22343. enclose?: boolean;
  22344. sideOrientation?: number;
  22345. frontUVs?: Vector4;
  22346. backUVs?: Vector4;
  22347. }): VertexData;
  22348. /**
  22349. * Creates the VertexData for a torus
  22350. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22351. * * diameter the diameter of the torus, optional default 1
  22352. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22353. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22355. * * 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)
  22356. * * 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)
  22357. * @returns the VertexData of the torus
  22358. */
  22359. static CreateTorus(options: {
  22360. diameter?: number;
  22361. thickness?: number;
  22362. tessellation?: number;
  22363. sideOrientation?: number;
  22364. frontUVs?: Vector4;
  22365. backUVs?: Vector4;
  22366. }): VertexData;
  22367. /**
  22368. * Creates the VertexData of the LineSystem
  22369. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22370. * - lines an array of lines, each line being an array of successive Vector3
  22371. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22372. * @returns the VertexData of the LineSystem
  22373. */
  22374. static CreateLineSystem(options: {
  22375. lines: Vector3[][];
  22376. colors?: Nullable<Color4[][]>;
  22377. }): VertexData;
  22378. /**
  22379. * Create the VertexData for a DashedLines
  22380. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22381. * - points an array successive Vector3
  22382. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22383. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22384. * - dashNb the intended total number of dashes, optional, default 200
  22385. * @returns the VertexData for the DashedLines
  22386. */
  22387. static CreateDashedLines(options: {
  22388. points: Vector3[];
  22389. dashSize?: number;
  22390. gapSize?: number;
  22391. dashNb?: number;
  22392. }): VertexData;
  22393. /**
  22394. * Creates the VertexData for a Ground
  22395. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22396. * - width the width (x direction) of the ground, optional, default 1
  22397. * - height the height (z direction) of the ground, optional, default 1
  22398. * - subdivisions the number of subdivisions per side, optional, default 1
  22399. * @returns the VertexData of the Ground
  22400. */
  22401. static CreateGround(options: {
  22402. width?: number;
  22403. height?: number;
  22404. subdivisions?: number;
  22405. subdivisionsX?: number;
  22406. subdivisionsY?: number;
  22407. }): VertexData;
  22408. /**
  22409. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22410. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22411. * * xmin the ground minimum X coordinate, optional, default -1
  22412. * * zmin the ground minimum Z coordinate, optional, default -1
  22413. * * xmax the ground maximum X coordinate, optional, default 1
  22414. * * zmax the ground maximum Z coordinate, optional, default 1
  22415. * * 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}
  22416. * * 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}
  22417. * @returns the VertexData of the TiledGround
  22418. */
  22419. static CreateTiledGround(options: {
  22420. xmin: number;
  22421. zmin: number;
  22422. xmax: number;
  22423. zmax: number;
  22424. subdivisions?: {
  22425. w: number;
  22426. h: number;
  22427. };
  22428. precision?: {
  22429. w: number;
  22430. h: number;
  22431. };
  22432. }): VertexData;
  22433. /**
  22434. * Creates the VertexData of the Ground designed from a heightmap
  22435. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22436. * * width the width (x direction) of the ground
  22437. * * height the height (z direction) of the ground
  22438. * * subdivisions the number of subdivisions per side
  22439. * * minHeight the minimum altitude on the ground, optional, default 0
  22440. * * maxHeight the maximum altitude on the ground, optional default 1
  22441. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22442. * * buffer the array holding the image color data
  22443. * * bufferWidth the width of image
  22444. * * bufferHeight the height of image
  22445. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22446. * @returns the VertexData of the Ground designed from a heightmap
  22447. */
  22448. static CreateGroundFromHeightMap(options: {
  22449. width: number;
  22450. height: number;
  22451. subdivisions: number;
  22452. minHeight: number;
  22453. maxHeight: number;
  22454. colorFilter: Color3;
  22455. buffer: Uint8Array;
  22456. bufferWidth: number;
  22457. bufferHeight: number;
  22458. alphaFilter: number;
  22459. }): VertexData;
  22460. /**
  22461. * Creates the VertexData for a Plane
  22462. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22463. * * size sets the width and height of the plane to the value of size, optional default 1
  22464. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22465. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22467. * * 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)
  22468. * * 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)
  22469. * @returns the VertexData of the box
  22470. */
  22471. static CreatePlane(options: {
  22472. size?: number;
  22473. width?: number;
  22474. height?: number;
  22475. sideOrientation?: number;
  22476. frontUVs?: Vector4;
  22477. backUVs?: Vector4;
  22478. }): VertexData;
  22479. /**
  22480. * Creates the VertexData of the Disc or regular Polygon
  22481. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22482. * * radius the radius of the disc, optional default 0.5
  22483. * * tessellation the number of polygon sides, optional, default 64
  22484. * * 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
  22485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22486. * * 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)
  22487. * * 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)
  22488. * @returns the VertexData of the box
  22489. */
  22490. static CreateDisc(options: {
  22491. radius?: number;
  22492. tessellation?: number;
  22493. arc?: number;
  22494. sideOrientation?: number;
  22495. frontUVs?: Vector4;
  22496. backUVs?: Vector4;
  22497. }): VertexData;
  22498. /**
  22499. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22500. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22501. * @param polygon a mesh built from polygonTriangulation.build()
  22502. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22503. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22504. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22505. * @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)
  22506. * @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)
  22507. * @returns the VertexData of the Polygon
  22508. */
  22509. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22510. /**
  22511. * Creates the VertexData of the IcoSphere
  22512. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22513. * * radius the radius of the IcoSphere, optional default 1
  22514. * * radiusX allows stretching in the x direction, optional, default radius
  22515. * * radiusY allows stretching in the y direction, optional, default radius
  22516. * * radiusZ allows stretching in the z direction, optional, default radius
  22517. * * flat when true creates a flat shaded mesh, optional, default true
  22518. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22520. * * 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)
  22521. * * 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)
  22522. * @returns the VertexData of the IcoSphere
  22523. */
  22524. static CreateIcoSphere(options: {
  22525. radius?: number;
  22526. radiusX?: number;
  22527. radiusY?: number;
  22528. radiusZ?: number;
  22529. flat?: boolean;
  22530. subdivisions?: number;
  22531. sideOrientation?: number;
  22532. frontUVs?: Vector4;
  22533. backUVs?: Vector4;
  22534. }): VertexData;
  22535. /**
  22536. * Creates the VertexData for a Polyhedron
  22537. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22538. * * type provided types are:
  22539. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22540. * * 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)
  22541. * * size the size of the IcoSphere, optional default 1
  22542. * * sizeX allows stretching in the x direction, optional, default size
  22543. * * sizeY allows stretching in the y direction, optional, default size
  22544. * * sizeZ allows stretching in the z direction, optional, default size
  22545. * * 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
  22546. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22547. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22548. * * flat when true creates a flat shaded mesh, optional, default true
  22549. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22550. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22551. * * 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)
  22552. * * 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)
  22553. * @returns the VertexData of the Polyhedron
  22554. */
  22555. static CreatePolyhedron(options: {
  22556. type?: number;
  22557. size?: number;
  22558. sizeX?: number;
  22559. sizeY?: number;
  22560. sizeZ?: number;
  22561. custom?: any;
  22562. faceUV?: Vector4[];
  22563. faceColors?: Color4[];
  22564. flat?: boolean;
  22565. sideOrientation?: number;
  22566. frontUVs?: Vector4;
  22567. backUVs?: Vector4;
  22568. }): VertexData;
  22569. /**
  22570. * Creates the VertexData for a TorusKnot
  22571. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22572. * * radius the radius of the torus knot, optional, default 2
  22573. * * tube the thickness of the tube, optional, default 0.5
  22574. * * radialSegments the number of sides on each tube segments, optional, default 32
  22575. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22576. * * p the number of windings around the z axis, optional, default 2
  22577. * * q the number of windings around the x axis, optional, default 3
  22578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22580. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22581. * @returns the VertexData of the Torus Knot
  22582. */
  22583. static CreateTorusKnot(options: {
  22584. radius?: number;
  22585. tube?: number;
  22586. radialSegments?: number;
  22587. tubularSegments?: number;
  22588. p?: number;
  22589. q?: number;
  22590. sideOrientation?: number;
  22591. frontUVs?: Vector4;
  22592. backUVs?: Vector4;
  22593. }): VertexData;
  22594. /**
  22595. * Compute normals for given positions and indices
  22596. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22597. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22598. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22599. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22600. * * facetNormals : optional array of facet normals (vector3)
  22601. * * facetPositions : optional array of facet positions (vector3)
  22602. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22603. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22604. * * bInfo : optional bounding info, required for facetPartitioning computation
  22605. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22606. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22607. * * useRightHandedSystem: optional boolean to for right handed system computation
  22608. * * depthSort : optional boolean to enable the facet depth sort computation
  22609. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22610. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22611. */
  22612. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22613. facetNormals?: any;
  22614. facetPositions?: any;
  22615. facetPartitioning?: any;
  22616. ratio?: number;
  22617. bInfo?: any;
  22618. bbSize?: Vector3;
  22619. subDiv?: any;
  22620. useRightHandedSystem?: boolean;
  22621. depthSort?: boolean;
  22622. distanceTo?: Vector3;
  22623. depthSortedFacets?: any;
  22624. }): void;
  22625. /** @hidden */
  22626. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22627. /**
  22628. * Applies VertexData created from the imported parameters to the geometry
  22629. * @param parsedVertexData the parsed data from an imported file
  22630. * @param geometry the geometry to apply the VertexData to
  22631. */
  22632. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22633. }
  22634. }
  22635. declare module "babylonjs/Morph/morphTarget" {
  22636. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22637. import { Observable } from "babylonjs/Misc/observable";
  22638. import { Nullable, FloatArray } from "babylonjs/types";
  22639. import { Scene } from "babylonjs/scene";
  22640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22641. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22642. /**
  22643. * Defines a target to use with MorphTargetManager
  22644. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22645. */
  22646. export class MorphTarget implements IAnimatable {
  22647. /** defines the name of the target */
  22648. name: string;
  22649. /**
  22650. * Gets or sets the list of animations
  22651. */
  22652. animations: import("babylonjs/Animations/animation").Animation[];
  22653. private _scene;
  22654. private _positions;
  22655. private _normals;
  22656. private _tangents;
  22657. private _uvs;
  22658. private _influence;
  22659. /**
  22660. * Observable raised when the influence changes
  22661. */
  22662. onInfluenceChanged: Observable<boolean>;
  22663. /** @hidden */
  22664. _onDataLayoutChanged: Observable<void>;
  22665. /**
  22666. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22667. */
  22668. influence: number;
  22669. /**
  22670. * Gets or sets the id of the morph Target
  22671. */
  22672. id: string;
  22673. private _animationPropertiesOverride;
  22674. /**
  22675. * Gets or sets the animation properties override
  22676. */
  22677. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22678. /**
  22679. * Creates a new MorphTarget
  22680. * @param name defines the name of the target
  22681. * @param influence defines the influence to use
  22682. * @param scene defines the scene the morphtarget belongs to
  22683. */
  22684. constructor(
  22685. /** defines the name of the target */
  22686. name: string, influence?: number, scene?: Nullable<Scene>);
  22687. /**
  22688. * Gets a boolean defining if the target contains position data
  22689. */
  22690. readonly hasPositions: boolean;
  22691. /**
  22692. * Gets a boolean defining if the target contains normal data
  22693. */
  22694. readonly hasNormals: boolean;
  22695. /**
  22696. * Gets a boolean defining if the target contains tangent data
  22697. */
  22698. readonly hasTangents: boolean;
  22699. /**
  22700. * Gets a boolean defining if the target contains texture coordinates data
  22701. */
  22702. readonly hasUVs: boolean;
  22703. /**
  22704. * Affects position data to this target
  22705. * @param data defines the position data to use
  22706. */
  22707. setPositions(data: Nullable<FloatArray>): void;
  22708. /**
  22709. * Gets the position data stored in this target
  22710. * @returns a FloatArray containing the position data (or null if not present)
  22711. */
  22712. getPositions(): Nullable<FloatArray>;
  22713. /**
  22714. * Affects normal data to this target
  22715. * @param data defines the normal data to use
  22716. */
  22717. setNormals(data: Nullable<FloatArray>): void;
  22718. /**
  22719. * Gets the normal data stored in this target
  22720. * @returns a FloatArray containing the normal data (or null if not present)
  22721. */
  22722. getNormals(): Nullable<FloatArray>;
  22723. /**
  22724. * Affects tangent data to this target
  22725. * @param data defines the tangent data to use
  22726. */
  22727. setTangents(data: Nullable<FloatArray>): void;
  22728. /**
  22729. * Gets the tangent data stored in this target
  22730. * @returns a FloatArray containing the tangent data (or null if not present)
  22731. */
  22732. getTangents(): Nullable<FloatArray>;
  22733. /**
  22734. * Affects texture coordinates data to this target
  22735. * @param data defines the texture coordinates data to use
  22736. */
  22737. setUVs(data: Nullable<FloatArray>): void;
  22738. /**
  22739. * Gets the texture coordinates data stored in this target
  22740. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22741. */
  22742. getUVs(): Nullable<FloatArray>;
  22743. /**
  22744. * Serializes the current target into a Serialization object
  22745. * @returns the serialized object
  22746. */
  22747. serialize(): any;
  22748. /**
  22749. * Returns the string "MorphTarget"
  22750. * @returns "MorphTarget"
  22751. */
  22752. getClassName(): string;
  22753. /**
  22754. * Creates a new target from serialized data
  22755. * @param serializationObject defines the serialized data to use
  22756. * @returns a new MorphTarget
  22757. */
  22758. static Parse(serializationObject: any): MorphTarget;
  22759. /**
  22760. * Creates a MorphTarget from mesh data
  22761. * @param mesh defines the source mesh
  22762. * @param name defines the name to use for the new target
  22763. * @param influence defines the influence to attach to the target
  22764. * @returns a new MorphTarget
  22765. */
  22766. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22767. }
  22768. }
  22769. declare module "babylonjs/Morph/morphTargetManager" {
  22770. import { Nullable } from "babylonjs/types";
  22771. import { Scene } from "babylonjs/scene";
  22772. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22773. /**
  22774. * This class is used to deform meshes using morphing between different targets
  22775. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22776. */
  22777. export class MorphTargetManager {
  22778. private _targets;
  22779. private _targetInfluenceChangedObservers;
  22780. private _targetDataLayoutChangedObservers;
  22781. private _activeTargets;
  22782. private _scene;
  22783. private _influences;
  22784. private _supportsNormals;
  22785. private _supportsTangents;
  22786. private _supportsUVs;
  22787. private _vertexCount;
  22788. private _uniqueId;
  22789. private _tempInfluences;
  22790. /**
  22791. * Gets or sets a boolean indicating if normals must be morphed
  22792. */
  22793. enableNormalMorphing: boolean;
  22794. /**
  22795. * Gets or sets a boolean indicating if tangents must be morphed
  22796. */
  22797. enableTangentMorphing: boolean;
  22798. /**
  22799. * Gets or sets a boolean indicating if UV must be morphed
  22800. */
  22801. enableUVMorphing: boolean;
  22802. /**
  22803. * Creates a new MorphTargetManager
  22804. * @param scene defines the current scene
  22805. */
  22806. constructor(scene?: Nullable<Scene>);
  22807. /**
  22808. * Gets the unique ID of this manager
  22809. */
  22810. readonly uniqueId: number;
  22811. /**
  22812. * Gets the number of vertices handled by this manager
  22813. */
  22814. readonly vertexCount: number;
  22815. /**
  22816. * Gets a boolean indicating if this manager supports morphing of normals
  22817. */
  22818. readonly supportsNormals: boolean;
  22819. /**
  22820. * Gets a boolean indicating if this manager supports morphing of tangents
  22821. */
  22822. readonly supportsTangents: boolean;
  22823. /**
  22824. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22825. */
  22826. readonly supportsUVs: boolean;
  22827. /**
  22828. * Gets the number of targets stored in this manager
  22829. */
  22830. readonly numTargets: number;
  22831. /**
  22832. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22833. */
  22834. readonly numInfluencers: number;
  22835. /**
  22836. * Gets the list of influences (one per target)
  22837. */
  22838. readonly influences: Float32Array;
  22839. /**
  22840. * Gets the active target at specified index. An active target is a target with an influence > 0
  22841. * @param index defines the index to check
  22842. * @returns the requested target
  22843. */
  22844. getActiveTarget(index: number): MorphTarget;
  22845. /**
  22846. * Gets the target at specified index
  22847. * @param index defines the index to check
  22848. * @returns the requested target
  22849. */
  22850. getTarget(index: number): MorphTarget;
  22851. /**
  22852. * Add a new target to this manager
  22853. * @param target defines the target to add
  22854. */
  22855. addTarget(target: MorphTarget): void;
  22856. /**
  22857. * Removes a target from the manager
  22858. * @param target defines the target to remove
  22859. */
  22860. removeTarget(target: MorphTarget): void;
  22861. /**
  22862. * Serializes the current manager into a Serialization object
  22863. * @returns the serialized object
  22864. */
  22865. serialize(): any;
  22866. private _syncActiveTargets;
  22867. /**
  22868. * Syncrhonize the targets with all the meshes using this morph target manager
  22869. */
  22870. synchronize(): void;
  22871. /**
  22872. * Creates a new MorphTargetManager from serialized data
  22873. * @param serializationObject defines the serialized data
  22874. * @param scene defines the hosting scene
  22875. * @returns the new MorphTargetManager
  22876. */
  22877. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22878. }
  22879. }
  22880. declare module "babylonjs/Meshes/meshLODLevel" {
  22881. import { Mesh } from "babylonjs/Meshes/mesh";
  22882. import { Nullable } from "babylonjs/types";
  22883. /**
  22884. * Class used to represent a specific level of detail of a mesh
  22885. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22886. */
  22887. export class MeshLODLevel {
  22888. /** Defines the distance where this level should start being displayed */
  22889. distance: number;
  22890. /** Defines the mesh to use to render this level */
  22891. mesh: Nullable<Mesh>;
  22892. /**
  22893. * Creates a new LOD level
  22894. * @param distance defines the distance where this level should star being displayed
  22895. * @param mesh defines the mesh to use to render this level
  22896. */
  22897. constructor(
  22898. /** Defines the distance where this level should start being displayed */
  22899. distance: number,
  22900. /** Defines the mesh to use to render this level */
  22901. mesh: Nullable<Mesh>);
  22902. }
  22903. }
  22904. declare module "babylonjs/Meshes/groundMesh" {
  22905. import { Scene } from "babylonjs/scene";
  22906. import { Vector3 } from "babylonjs/Maths/math.vector";
  22907. import { Mesh } from "babylonjs/Meshes/mesh";
  22908. /**
  22909. * Mesh representing the gorund
  22910. */
  22911. export class GroundMesh extends Mesh {
  22912. /** If octree should be generated */
  22913. generateOctree: boolean;
  22914. private _heightQuads;
  22915. /** @hidden */
  22916. _subdivisionsX: number;
  22917. /** @hidden */
  22918. _subdivisionsY: number;
  22919. /** @hidden */
  22920. _width: number;
  22921. /** @hidden */
  22922. _height: number;
  22923. /** @hidden */
  22924. _minX: number;
  22925. /** @hidden */
  22926. _maxX: number;
  22927. /** @hidden */
  22928. _minZ: number;
  22929. /** @hidden */
  22930. _maxZ: number;
  22931. constructor(name: string, scene: Scene);
  22932. /**
  22933. * "GroundMesh"
  22934. * @returns "GroundMesh"
  22935. */
  22936. getClassName(): string;
  22937. /**
  22938. * The minimum of x and y subdivisions
  22939. */
  22940. readonly subdivisions: number;
  22941. /**
  22942. * X subdivisions
  22943. */
  22944. readonly subdivisionsX: number;
  22945. /**
  22946. * Y subdivisions
  22947. */
  22948. readonly subdivisionsY: number;
  22949. /**
  22950. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22951. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22952. * @param chunksCount the number of subdivisions for x and y
  22953. * @param octreeBlocksSize (Default: 32)
  22954. */
  22955. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22956. /**
  22957. * Returns a height (y) value in the Worl system :
  22958. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22959. * @param x x coordinate
  22960. * @param z z coordinate
  22961. * @returns the ground y position if (x, z) are outside the ground surface.
  22962. */
  22963. getHeightAtCoordinates(x: number, z: number): number;
  22964. /**
  22965. * Returns a normalized vector (Vector3) orthogonal to the ground
  22966. * at the ground coordinates (x, z) expressed in the World system.
  22967. * @param x x coordinate
  22968. * @param z z coordinate
  22969. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22970. */
  22971. getNormalAtCoordinates(x: number, z: number): Vector3;
  22972. /**
  22973. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22974. * at the ground coordinates (x, z) expressed in the World system.
  22975. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22976. * @param x x coordinate
  22977. * @param z z coordinate
  22978. * @param ref vector to store the result
  22979. * @returns the GroundMesh.
  22980. */
  22981. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22982. /**
  22983. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22984. * if the ground has been updated.
  22985. * This can be used in the render loop.
  22986. * @returns the GroundMesh.
  22987. */
  22988. updateCoordinateHeights(): GroundMesh;
  22989. private _getFacetAt;
  22990. private _initHeightQuads;
  22991. private _computeHeightQuads;
  22992. /**
  22993. * Serializes this ground mesh
  22994. * @param serializationObject object to write serialization to
  22995. */
  22996. serialize(serializationObject: any): void;
  22997. /**
  22998. * Parses a serialized ground mesh
  22999. * @param parsedMesh the serialized mesh
  23000. * @param scene the scene to create the ground mesh in
  23001. * @returns the created ground mesh
  23002. */
  23003. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23004. }
  23005. }
  23006. declare module "babylonjs/Physics/physicsJoint" {
  23007. import { Vector3 } from "babylonjs/Maths/math.vector";
  23008. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23009. /**
  23010. * Interface for Physics-Joint data
  23011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23012. */
  23013. export interface PhysicsJointData {
  23014. /**
  23015. * The main pivot of the joint
  23016. */
  23017. mainPivot?: Vector3;
  23018. /**
  23019. * The connected pivot of the joint
  23020. */
  23021. connectedPivot?: Vector3;
  23022. /**
  23023. * The main axis of the joint
  23024. */
  23025. mainAxis?: Vector3;
  23026. /**
  23027. * The connected axis of the joint
  23028. */
  23029. connectedAxis?: Vector3;
  23030. /**
  23031. * The collision of the joint
  23032. */
  23033. collision?: boolean;
  23034. /**
  23035. * Native Oimo/Cannon/Energy data
  23036. */
  23037. nativeParams?: any;
  23038. }
  23039. /**
  23040. * This is a holder class for the physics joint created by the physics plugin
  23041. * It holds a set of functions to control the underlying joint
  23042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23043. */
  23044. export class PhysicsJoint {
  23045. /**
  23046. * The type of the physics joint
  23047. */
  23048. type: number;
  23049. /**
  23050. * The data for the physics joint
  23051. */
  23052. jointData: PhysicsJointData;
  23053. private _physicsJoint;
  23054. protected _physicsPlugin: IPhysicsEnginePlugin;
  23055. /**
  23056. * Initializes the physics joint
  23057. * @param type The type of the physics joint
  23058. * @param jointData The data for the physics joint
  23059. */
  23060. constructor(
  23061. /**
  23062. * The type of the physics joint
  23063. */
  23064. type: number,
  23065. /**
  23066. * The data for the physics joint
  23067. */
  23068. jointData: PhysicsJointData);
  23069. /**
  23070. * Gets the physics joint
  23071. */
  23072. /**
  23073. * Sets the physics joint
  23074. */
  23075. physicsJoint: any;
  23076. /**
  23077. * Sets the physics plugin
  23078. */
  23079. physicsPlugin: IPhysicsEnginePlugin;
  23080. /**
  23081. * Execute a function that is physics-plugin specific.
  23082. * @param {Function} func the function that will be executed.
  23083. * It accepts two parameters: the physics world and the physics joint
  23084. */
  23085. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23086. /**
  23087. * Distance-Joint type
  23088. */
  23089. static DistanceJoint: number;
  23090. /**
  23091. * Hinge-Joint type
  23092. */
  23093. static HingeJoint: number;
  23094. /**
  23095. * Ball-and-Socket joint type
  23096. */
  23097. static BallAndSocketJoint: number;
  23098. /**
  23099. * Wheel-Joint type
  23100. */
  23101. static WheelJoint: number;
  23102. /**
  23103. * Slider-Joint type
  23104. */
  23105. static SliderJoint: number;
  23106. /**
  23107. * Prismatic-Joint type
  23108. */
  23109. static PrismaticJoint: number;
  23110. /**
  23111. * Universal-Joint type
  23112. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23113. */
  23114. static UniversalJoint: number;
  23115. /**
  23116. * Hinge-Joint 2 type
  23117. */
  23118. static Hinge2Joint: number;
  23119. /**
  23120. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23121. */
  23122. static PointToPointJoint: number;
  23123. /**
  23124. * Spring-Joint type
  23125. */
  23126. static SpringJoint: number;
  23127. /**
  23128. * Lock-Joint type
  23129. */
  23130. static LockJoint: number;
  23131. }
  23132. /**
  23133. * A class representing a physics distance joint
  23134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23135. */
  23136. export class DistanceJoint extends PhysicsJoint {
  23137. /**
  23138. *
  23139. * @param jointData The data for the Distance-Joint
  23140. */
  23141. constructor(jointData: DistanceJointData);
  23142. /**
  23143. * Update the predefined distance.
  23144. * @param maxDistance The maximum preferred distance
  23145. * @param minDistance The minimum preferred distance
  23146. */
  23147. updateDistance(maxDistance: number, minDistance?: number): void;
  23148. }
  23149. /**
  23150. * Represents a Motor-Enabled Joint
  23151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23152. */
  23153. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23154. /**
  23155. * Initializes the Motor-Enabled Joint
  23156. * @param type The type of the joint
  23157. * @param jointData The physica joint data for the joint
  23158. */
  23159. constructor(type: number, jointData: PhysicsJointData);
  23160. /**
  23161. * Set the motor values.
  23162. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23163. * @param force the force to apply
  23164. * @param maxForce max force for this motor.
  23165. */
  23166. setMotor(force?: number, maxForce?: number): void;
  23167. /**
  23168. * Set the motor's limits.
  23169. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23170. * @param upperLimit The upper limit of the motor
  23171. * @param lowerLimit The lower limit of the motor
  23172. */
  23173. setLimit(upperLimit: number, lowerLimit?: number): void;
  23174. }
  23175. /**
  23176. * This class represents a single physics Hinge-Joint
  23177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23178. */
  23179. export class HingeJoint extends MotorEnabledJoint {
  23180. /**
  23181. * Initializes the Hinge-Joint
  23182. * @param jointData The joint data for the Hinge-Joint
  23183. */
  23184. constructor(jointData: PhysicsJointData);
  23185. /**
  23186. * Set the motor values.
  23187. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23188. * @param {number} force the force to apply
  23189. * @param {number} maxForce max force for this motor.
  23190. */
  23191. setMotor(force?: number, maxForce?: number): void;
  23192. /**
  23193. * Set the motor's limits.
  23194. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23195. * @param upperLimit The upper limit of the motor
  23196. * @param lowerLimit The lower limit of the motor
  23197. */
  23198. setLimit(upperLimit: number, lowerLimit?: number): void;
  23199. }
  23200. /**
  23201. * This class represents a dual hinge physics joint (same as wheel joint)
  23202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23203. */
  23204. export class Hinge2Joint extends MotorEnabledJoint {
  23205. /**
  23206. * Initializes the Hinge2-Joint
  23207. * @param jointData The joint data for the Hinge2-Joint
  23208. */
  23209. constructor(jointData: PhysicsJointData);
  23210. /**
  23211. * Set the motor values.
  23212. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23213. * @param {number} targetSpeed the speed the motor is to reach
  23214. * @param {number} maxForce max force for this motor.
  23215. * @param {motorIndex} the motor's index, 0 or 1.
  23216. */
  23217. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23218. /**
  23219. * Set the motor limits.
  23220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23221. * @param {number} upperLimit the upper limit
  23222. * @param {number} lowerLimit lower limit
  23223. * @param {motorIndex} the motor's index, 0 or 1.
  23224. */
  23225. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23226. }
  23227. /**
  23228. * Interface for a motor enabled joint
  23229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23230. */
  23231. export interface IMotorEnabledJoint {
  23232. /**
  23233. * Physics joint
  23234. */
  23235. physicsJoint: any;
  23236. /**
  23237. * Sets the motor of the motor-enabled joint
  23238. * @param force The force of the motor
  23239. * @param maxForce The maximum force of the motor
  23240. * @param motorIndex The index of the motor
  23241. */
  23242. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23243. /**
  23244. * Sets the limit of the motor
  23245. * @param upperLimit The upper limit of the motor
  23246. * @param lowerLimit The lower limit of the motor
  23247. * @param motorIndex The index of the motor
  23248. */
  23249. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23250. }
  23251. /**
  23252. * Joint data for a Distance-Joint
  23253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23254. */
  23255. export interface DistanceJointData extends PhysicsJointData {
  23256. /**
  23257. * Max distance the 2 joint objects can be apart
  23258. */
  23259. maxDistance: number;
  23260. }
  23261. /**
  23262. * Joint data from a spring joint
  23263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23264. */
  23265. export interface SpringJointData extends PhysicsJointData {
  23266. /**
  23267. * Length of the spring
  23268. */
  23269. length: number;
  23270. /**
  23271. * Stiffness of the spring
  23272. */
  23273. stiffness: number;
  23274. /**
  23275. * Damping of the spring
  23276. */
  23277. damping: number;
  23278. /** this callback will be called when applying the force to the impostors. */
  23279. forceApplicationCallback: () => void;
  23280. }
  23281. }
  23282. declare module "babylonjs/Physics/physicsRaycastResult" {
  23283. import { Vector3 } from "babylonjs/Maths/math.vector";
  23284. /**
  23285. * Holds the data for the raycast result
  23286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23287. */
  23288. export class PhysicsRaycastResult {
  23289. private _hasHit;
  23290. private _hitDistance;
  23291. private _hitNormalWorld;
  23292. private _hitPointWorld;
  23293. private _rayFromWorld;
  23294. private _rayToWorld;
  23295. /**
  23296. * Gets if there was a hit
  23297. */
  23298. readonly hasHit: boolean;
  23299. /**
  23300. * Gets the distance from the hit
  23301. */
  23302. readonly hitDistance: number;
  23303. /**
  23304. * Gets the hit normal/direction in the world
  23305. */
  23306. readonly hitNormalWorld: Vector3;
  23307. /**
  23308. * Gets the hit point in the world
  23309. */
  23310. readonly hitPointWorld: Vector3;
  23311. /**
  23312. * Gets the ray "start point" of the ray in the world
  23313. */
  23314. readonly rayFromWorld: Vector3;
  23315. /**
  23316. * Gets the ray "end point" of the ray in the world
  23317. */
  23318. readonly rayToWorld: Vector3;
  23319. /**
  23320. * Sets the hit data (normal & point in world space)
  23321. * @param hitNormalWorld defines the normal in world space
  23322. * @param hitPointWorld defines the point in world space
  23323. */
  23324. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23325. /**
  23326. * Sets the distance from the start point to the hit point
  23327. * @param distance
  23328. */
  23329. setHitDistance(distance: number): void;
  23330. /**
  23331. * Calculates the distance manually
  23332. */
  23333. calculateHitDistance(): void;
  23334. /**
  23335. * Resets all the values to default
  23336. * @param from The from point on world space
  23337. * @param to The to point on world space
  23338. */
  23339. reset(from?: Vector3, to?: Vector3): void;
  23340. }
  23341. /**
  23342. * Interface for the size containing width and height
  23343. */
  23344. interface IXYZ {
  23345. /**
  23346. * X
  23347. */
  23348. x: number;
  23349. /**
  23350. * Y
  23351. */
  23352. y: number;
  23353. /**
  23354. * Z
  23355. */
  23356. z: number;
  23357. }
  23358. }
  23359. declare module "babylonjs/Physics/IPhysicsEngine" {
  23360. import { Nullable } from "babylonjs/types";
  23361. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23363. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23364. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23365. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23366. /**
  23367. * Interface used to describe a physics joint
  23368. */
  23369. export interface PhysicsImpostorJoint {
  23370. /** Defines the main impostor to which the joint is linked */
  23371. mainImpostor: PhysicsImpostor;
  23372. /** Defines the impostor that is connected to the main impostor using this joint */
  23373. connectedImpostor: PhysicsImpostor;
  23374. /** Defines the joint itself */
  23375. joint: PhysicsJoint;
  23376. }
  23377. /** @hidden */
  23378. export interface IPhysicsEnginePlugin {
  23379. world: any;
  23380. name: string;
  23381. setGravity(gravity: Vector3): void;
  23382. setTimeStep(timeStep: number): void;
  23383. getTimeStep(): number;
  23384. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23385. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23386. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23387. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23388. removePhysicsBody(impostor: PhysicsImpostor): void;
  23389. generateJoint(joint: PhysicsImpostorJoint): void;
  23390. removeJoint(joint: PhysicsImpostorJoint): void;
  23391. isSupported(): boolean;
  23392. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23393. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23394. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23395. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23396. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23397. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23398. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23399. getBodyMass(impostor: PhysicsImpostor): number;
  23400. getBodyFriction(impostor: PhysicsImpostor): number;
  23401. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23402. getBodyRestitution(impostor: PhysicsImpostor): number;
  23403. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23404. getBodyPressure?(impostor: PhysicsImpostor): number;
  23405. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23406. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23407. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23408. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23409. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23410. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23411. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23412. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23413. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23414. sleepBody(impostor: PhysicsImpostor): void;
  23415. wakeUpBody(impostor: PhysicsImpostor): void;
  23416. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23417. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23418. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23419. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23420. getRadius(impostor: PhysicsImpostor): number;
  23421. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23422. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23423. dispose(): void;
  23424. }
  23425. /**
  23426. * Interface used to define a physics engine
  23427. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23428. */
  23429. export interface IPhysicsEngine {
  23430. /**
  23431. * Gets the gravity vector used by the simulation
  23432. */
  23433. gravity: Vector3;
  23434. /**
  23435. * Sets the gravity vector used by the simulation
  23436. * @param gravity defines the gravity vector to use
  23437. */
  23438. setGravity(gravity: Vector3): void;
  23439. /**
  23440. * Set the time step of the physics engine.
  23441. * Default is 1/60.
  23442. * To slow it down, enter 1/600 for example.
  23443. * To speed it up, 1/30
  23444. * @param newTimeStep the new timestep to apply to this world.
  23445. */
  23446. setTimeStep(newTimeStep: number): void;
  23447. /**
  23448. * Get the time step of the physics engine.
  23449. * @returns the current time step
  23450. */
  23451. getTimeStep(): number;
  23452. /**
  23453. * Release all resources
  23454. */
  23455. dispose(): void;
  23456. /**
  23457. * Gets the name of the current physics plugin
  23458. * @returns the name of the plugin
  23459. */
  23460. getPhysicsPluginName(): string;
  23461. /**
  23462. * Adding a new impostor for the impostor tracking.
  23463. * This will be done by the impostor itself.
  23464. * @param impostor the impostor to add
  23465. */
  23466. addImpostor(impostor: PhysicsImpostor): void;
  23467. /**
  23468. * Remove an impostor from the engine.
  23469. * This impostor and its mesh will not longer be updated by the physics engine.
  23470. * @param impostor the impostor to remove
  23471. */
  23472. removeImpostor(impostor: PhysicsImpostor): void;
  23473. /**
  23474. * Add a joint to the physics engine
  23475. * @param mainImpostor defines the main impostor to which the joint is added.
  23476. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23477. * @param joint defines the joint that will connect both impostors.
  23478. */
  23479. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23480. /**
  23481. * Removes a joint from the simulation
  23482. * @param mainImpostor defines the impostor used with the joint
  23483. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23484. * @param joint defines the joint to remove
  23485. */
  23486. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23487. /**
  23488. * Gets the current plugin used to run the simulation
  23489. * @returns current plugin
  23490. */
  23491. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23492. /**
  23493. * Gets the list of physic impostors
  23494. * @returns an array of PhysicsImpostor
  23495. */
  23496. getImpostors(): Array<PhysicsImpostor>;
  23497. /**
  23498. * Gets the impostor for a physics enabled object
  23499. * @param object defines the object impersonated by the impostor
  23500. * @returns the PhysicsImpostor or null if not found
  23501. */
  23502. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23503. /**
  23504. * Gets the impostor for a physics body object
  23505. * @param body defines physics body used by the impostor
  23506. * @returns the PhysicsImpostor or null if not found
  23507. */
  23508. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23509. /**
  23510. * Does a raycast in the physics world
  23511. * @param from when should the ray start?
  23512. * @param to when should the ray end?
  23513. * @returns PhysicsRaycastResult
  23514. */
  23515. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23516. /**
  23517. * Called by the scene. No need to call it.
  23518. * @param delta defines the timespam between frames
  23519. */
  23520. _step(delta: number): void;
  23521. }
  23522. }
  23523. declare module "babylonjs/Physics/physicsImpostor" {
  23524. import { Nullable, IndicesArray } from "babylonjs/types";
  23525. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23526. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23528. import { Scene } from "babylonjs/scene";
  23529. import { Bone } from "babylonjs/Bones/bone";
  23530. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23531. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23532. import { Space } from "babylonjs/Maths/math.axis";
  23533. /**
  23534. * The interface for the physics imposter parameters
  23535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23536. */
  23537. export interface PhysicsImpostorParameters {
  23538. /**
  23539. * The mass of the physics imposter
  23540. */
  23541. mass: number;
  23542. /**
  23543. * The friction of the physics imposter
  23544. */
  23545. friction?: number;
  23546. /**
  23547. * The coefficient of restitution of the physics imposter
  23548. */
  23549. restitution?: number;
  23550. /**
  23551. * The native options of the physics imposter
  23552. */
  23553. nativeOptions?: any;
  23554. /**
  23555. * Specifies if the parent should be ignored
  23556. */
  23557. ignoreParent?: boolean;
  23558. /**
  23559. * Specifies if bi-directional transformations should be disabled
  23560. */
  23561. disableBidirectionalTransformation?: boolean;
  23562. /**
  23563. * The pressure inside the physics imposter, soft object only
  23564. */
  23565. pressure?: number;
  23566. /**
  23567. * The stiffness the physics imposter, soft object only
  23568. */
  23569. stiffness?: number;
  23570. /**
  23571. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23572. */
  23573. velocityIterations?: number;
  23574. /**
  23575. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23576. */
  23577. positionIterations?: number;
  23578. /**
  23579. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23580. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23581. * Add to fix multiple points
  23582. */
  23583. fixedPoints?: number;
  23584. /**
  23585. * The collision margin around a soft object
  23586. */
  23587. margin?: number;
  23588. /**
  23589. * The collision margin around a soft object
  23590. */
  23591. damping?: number;
  23592. /**
  23593. * The path for a rope based on an extrusion
  23594. */
  23595. path?: any;
  23596. /**
  23597. * The shape of an extrusion used for a rope based on an extrusion
  23598. */
  23599. shape?: any;
  23600. }
  23601. /**
  23602. * Interface for a physics-enabled object
  23603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23604. */
  23605. export interface IPhysicsEnabledObject {
  23606. /**
  23607. * The position of the physics-enabled object
  23608. */
  23609. position: Vector3;
  23610. /**
  23611. * The rotation of the physics-enabled object
  23612. */
  23613. rotationQuaternion: Nullable<Quaternion>;
  23614. /**
  23615. * The scale of the physics-enabled object
  23616. */
  23617. scaling: Vector3;
  23618. /**
  23619. * The rotation of the physics-enabled object
  23620. */
  23621. rotation?: Vector3;
  23622. /**
  23623. * The parent of the physics-enabled object
  23624. */
  23625. parent?: any;
  23626. /**
  23627. * The bounding info of the physics-enabled object
  23628. * @returns The bounding info of the physics-enabled object
  23629. */
  23630. getBoundingInfo(): BoundingInfo;
  23631. /**
  23632. * Computes the world matrix
  23633. * @param force Specifies if the world matrix should be computed by force
  23634. * @returns A world matrix
  23635. */
  23636. computeWorldMatrix(force: boolean): Matrix;
  23637. /**
  23638. * Gets the world matrix
  23639. * @returns A world matrix
  23640. */
  23641. getWorldMatrix?(): Matrix;
  23642. /**
  23643. * Gets the child meshes
  23644. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23645. * @returns An array of abstract meshes
  23646. */
  23647. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23648. /**
  23649. * Gets the vertex data
  23650. * @param kind The type of vertex data
  23651. * @returns A nullable array of numbers, or a float32 array
  23652. */
  23653. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23654. /**
  23655. * Gets the indices from the mesh
  23656. * @returns A nullable array of index arrays
  23657. */
  23658. getIndices?(): Nullable<IndicesArray>;
  23659. /**
  23660. * Gets the scene from the mesh
  23661. * @returns the indices array or null
  23662. */
  23663. getScene?(): Scene;
  23664. /**
  23665. * Gets the absolute position from the mesh
  23666. * @returns the absolute position
  23667. */
  23668. getAbsolutePosition(): Vector3;
  23669. /**
  23670. * Gets the absolute pivot point from the mesh
  23671. * @returns the absolute pivot point
  23672. */
  23673. getAbsolutePivotPoint(): Vector3;
  23674. /**
  23675. * Rotates the mesh
  23676. * @param axis The axis of rotation
  23677. * @param amount The amount of rotation
  23678. * @param space The space of the rotation
  23679. * @returns The rotation transform node
  23680. */
  23681. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23682. /**
  23683. * Translates the mesh
  23684. * @param axis The axis of translation
  23685. * @param distance The distance of translation
  23686. * @param space The space of the translation
  23687. * @returns The transform node
  23688. */
  23689. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23690. /**
  23691. * Sets the absolute position of the mesh
  23692. * @param absolutePosition The absolute position of the mesh
  23693. * @returns The transform node
  23694. */
  23695. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23696. /**
  23697. * Gets the class name of the mesh
  23698. * @returns The class name
  23699. */
  23700. getClassName(): string;
  23701. }
  23702. /**
  23703. * Represents a physics imposter
  23704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23705. */
  23706. export class PhysicsImpostor {
  23707. /**
  23708. * The physics-enabled object used as the physics imposter
  23709. */
  23710. object: IPhysicsEnabledObject;
  23711. /**
  23712. * The type of the physics imposter
  23713. */
  23714. type: number;
  23715. private _options;
  23716. private _scene?;
  23717. /**
  23718. * The default object size of the imposter
  23719. */
  23720. static DEFAULT_OBJECT_SIZE: Vector3;
  23721. /**
  23722. * The identity quaternion of the imposter
  23723. */
  23724. static IDENTITY_QUATERNION: Quaternion;
  23725. /** @hidden */
  23726. _pluginData: any;
  23727. private _physicsEngine;
  23728. private _physicsBody;
  23729. private _bodyUpdateRequired;
  23730. private _onBeforePhysicsStepCallbacks;
  23731. private _onAfterPhysicsStepCallbacks;
  23732. /** @hidden */
  23733. _onPhysicsCollideCallbacks: Array<{
  23734. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23735. otherImpostors: Array<PhysicsImpostor>;
  23736. }>;
  23737. private _deltaPosition;
  23738. private _deltaRotation;
  23739. private _deltaRotationConjugated;
  23740. /** @hidden */
  23741. _isFromLine: boolean;
  23742. private _parent;
  23743. private _isDisposed;
  23744. private static _tmpVecs;
  23745. private static _tmpQuat;
  23746. /**
  23747. * Specifies if the physics imposter is disposed
  23748. */
  23749. readonly isDisposed: boolean;
  23750. /**
  23751. * Gets the mass of the physics imposter
  23752. */
  23753. mass: number;
  23754. /**
  23755. * Gets the coefficient of friction
  23756. */
  23757. /**
  23758. * Sets the coefficient of friction
  23759. */
  23760. friction: number;
  23761. /**
  23762. * Gets the coefficient of restitution
  23763. */
  23764. /**
  23765. * Sets the coefficient of restitution
  23766. */
  23767. restitution: number;
  23768. /**
  23769. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23770. */
  23771. /**
  23772. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23773. */
  23774. pressure: number;
  23775. /**
  23776. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23777. */
  23778. /**
  23779. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23780. */
  23781. stiffness: number;
  23782. /**
  23783. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23784. */
  23785. /**
  23786. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23787. */
  23788. velocityIterations: number;
  23789. /**
  23790. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23791. */
  23792. /**
  23793. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23794. */
  23795. positionIterations: number;
  23796. /**
  23797. * The unique id of the physics imposter
  23798. * set by the physics engine when adding this impostor to the array
  23799. */
  23800. uniqueId: number;
  23801. /**
  23802. * @hidden
  23803. */
  23804. soft: boolean;
  23805. /**
  23806. * @hidden
  23807. */
  23808. segments: number;
  23809. private _joints;
  23810. /**
  23811. * Initializes the physics imposter
  23812. * @param object The physics-enabled object used as the physics imposter
  23813. * @param type The type of the physics imposter
  23814. * @param _options The options for the physics imposter
  23815. * @param _scene The Babylon scene
  23816. */
  23817. constructor(
  23818. /**
  23819. * The physics-enabled object used as the physics imposter
  23820. */
  23821. object: IPhysicsEnabledObject,
  23822. /**
  23823. * The type of the physics imposter
  23824. */
  23825. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23826. /**
  23827. * This function will completly initialize this impostor.
  23828. * It will create a new body - but only if this mesh has no parent.
  23829. * If it has, this impostor will not be used other than to define the impostor
  23830. * of the child mesh.
  23831. * @hidden
  23832. */
  23833. _init(): void;
  23834. private _getPhysicsParent;
  23835. /**
  23836. * Should a new body be generated.
  23837. * @returns boolean specifying if body initialization is required
  23838. */
  23839. isBodyInitRequired(): boolean;
  23840. /**
  23841. * Sets the updated scaling
  23842. * @param updated Specifies if the scaling is updated
  23843. */
  23844. setScalingUpdated(): void;
  23845. /**
  23846. * Force a regeneration of this or the parent's impostor's body.
  23847. * Use under cautious - This will remove all joints already implemented.
  23848. */
  23849. forceUpdate(): void;
  23850. /**
  23851. * Gets the body that holds this impostor. Either its own, or its parent.
  23852. */
  23853. /**
  23854. * Set the physics body. Used mainly by the physics engine/plugin
  23855. */
  23856. physicsBody: any;
  23857. /**
  23858. * Get the parent of the physics imposter
  23859. * @returns Physics imposter or null
  23860. */
  23861. /**
  23862. * Sets the parent of the physics imposter
  23863. */
  23864. parent: Nullable<PhysicsImpostor>;
  23865. /**
  23866. * Resets the update flags
  23867. */
  23868. resetUpdateFlags(): void;
  23869. /**
  23870. * Gets the object extend size
  23871. * @returns the object extend size
  23872. */
  23873. getObjectExtendSize(): Vector3;
  23874. /**
  23875. * Gets the object center
  23876. * @returns The object center
  23877. */
  23878. getObjectCenter(): Vector3;
  23879. /**
  23880. * Get a specific parametes from the options parameter
  23881. * @param paramName The object parameter name
  23882. * @returns The object parameter
  23883. */
  23884. getParam(paramName: string): any;
  23885. /**
  23886. * Sets a specific parameter in the options given to the physics plugin
  23887. * @param paramName The parameter name
  23888. * @param value The value of the parameter
  23889. */
  23890. setParam(paramName: string, value: number): void;
  23891. /**
  23892. * Specifically change the body's mass option. Won't recreate the physics body object
  23893. * @param mass The mass of the physics imposter
  23894. */
  23895. setMass(mass: number): void;
  23896. /**
  23897. * Gets the linear velocity
  23898. * @returns linear velocity or null
  23899. */
  23900. getLinearVelocity(): Nullable<Vector3>;
  23901. /**
  23902. * Sets the linear velocity
  23903. * @param velocity linear velocity or null
  23904. */
  23905. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23906. /**
  23907. * Gets the angular velocity
  23908. * @returns angular velocity or null
  23909. */
  23910. getAngularVelocity(): Nullable<Vector3>;
  23911. /**
  23912. * Sets the angular velocity
  23913. * @param velocity The velocity or null
  23914. */
  23915. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23916. /**
  23917. * Execute a function with the physics plugin native code
  23918. * Provide a function the will have two variables - the world object and the physics body object
  23919. * @param func The function to execute with the physics plugin native code
  23920. */
  23921. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23922. /**
  23923. * Register a function that will be executed before the physics world is stepping forward
  23924. * @param func The function to execute before the physics world is stepped forward
  23925. */
  23926. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23927. /**
  23928. * Unregister a function that will be executed before the physics world is stepping forward
  23929. * @param func The function to execute before the physics world is stepped forward
  23930. */
  23931. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23932. /**
  23933. * Register a function that will be executed after the physics step
  23934. * @param func The function to execute after physics step
  23935. */
  23936. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23937. /**
  23938. * Unregisters a function that will be executed after the physics step
  23939. * @param func The function to execute after physics step
  23940. */
  23941. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23942. /**
  23943. * register a function that will be executed when this impostor collides against a different body
  23944. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23945. * @param func Callback that is executed on collision
  23946. */
  23947. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23948. /**
  23949. * Unregisters the physics imposter on contact
  23950. * @param collideAgainst The physics object to collide against
  23951. * @param func Callback to execute on collision
  23952. */
  23953. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23954. private _tmpQuat;
  23955. private _tmpQuat2;
  23956. /**
  23957. * Get the parent rotation
  23958. * @returns The parent rotation
  23959. */
  23960. getParentsRotation(): Quaternion;
  23961. /**
  23962. * this function is executed by the physics engine.
  23963. */
  23964. beforeStep: () => void;
  23965. /**
  23966. * this function is executed by the physics engine
  23967. */
  23968. afterStep: () => void;
  23969. /**
  23970. * Legacy collision detection event support
  23971. */
  23972. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23973. /**
  23974. * event and body object due to cannon's event-based architecture.
  23975. */
  23976. onCollide: (e: {
  23977. body: any;
  23978. }) => void;
  23979. /**
  23980. * Apply a force
  23981. * @param force The force to apply
  23982. * @param contactPoint The contact point for the force
  23983. * @returns The physics imposter
  23984. */
  23985. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23986. /**
  23987. * Apply an impulse
  23988. * @param force The impulse force
  23989. * @param contactPoint The contact point for the impulse force
  23990. * @returns The physics imposter
  23991. */
  23992. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23993. /**
  23994. * A help function to create a joint
  23995. * @param otherImpostor A physics imposter used to create a joint
  23996. * @param jointType The type of joint
  23997. * @param jointData The data for the joint
  23998. * @returns The physics imposter
  23999. */
  24000. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24001. /**
  24002. * Add a joint to this impostor with a different impostor
  24003. * @param otherImpostor A physics imposter used to add a joint
  24004. * @param joint The joint to add
  24005. * @returns The physics imposter
  24006. */
  24007. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24008. /**
  24009. * Add an anchor to a cloth impostor
  24010. * @param otherImpostor rigid impostor to anchor to
  24011. * @param width ratio across width from 0 to 1
  24012. * @param height ratio up height from 0 to 1
  24013. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24014. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24015. * @returns impostor the soft imposter
  24016. */
  24017. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24018. /**
  24019. * Add a hook to a rope impostor
  24020. * @param otherImpostor rigid impostor to anchor to
  24021. * @param length ratio across rope from 0 to 1
  24022. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24023. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24024. * @returns impostor the rope imposter
  24025. */
  24026. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24027. /**
  24028. * Will keep this body still, in a sleep mode.
  24029. * @returns the physics imposter
  24030. */
  24031. sleep(): PhysicsImpostor;
  24032. /**
  24033. * Wake the body up.
  24034. * @returns The physics imposter
  24035. */
  24036. wakeUp(): PhysicsImpostor;
  24037. /**
  24038. * Clones the physics imposter
  24039. * @param newObject The physics imposter clones to this physics-enabled object
  24040. * @returns A nullable physics imposter
  24041. */
  24042. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24043. /**
  24044. * Disposes the physics imposter
  24045. */
  24046. dispose(): void;
  24047. /**
  24048. * Sets the delta position
  24049. * @param position The delta position amount
  24050. */
  24051. setDeltaPosition(position: Vector3): void;
  24052. /**
  24053. * Sets the delta rotation
  24054. * @param rotation The delta rotation amount
  24055. */
  24056. setDeltaRotation(rotation: Quaternion): void;
  24057. /**
  24058. * Gets the box size of the physics imposter and stores the result in the input parameter
  24059. * @param result Stores the box size
  24060. * @returns The physics imposter
  24061. */
  24062. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24063. /**
  24064. * Gets the radius of the physics imposter
  24065. * @returns Radius of the physics imposter
  24066. */
  24067. getRadius(): number;
  24068. /**
  24069. * Sync a bone with this impostor
  24070. * @param bone The bone to sync to the impostor.
  24071. * @param boneMesh The mesh that the bone is influencing.
  24072. * @param jointPivot The pivot of the joint / bone in local space.
  24073. * @param distToJoint Optional distance from the impostor to the joint.
  24074. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24075. */
  24076. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24077. /**
  24078. * Sync impostor to a bone
  24079. * @param bone The bone that the impostor will be synced to.
  24080. * @param boneMesh The mesh that the bone is influencing.
  24081. * @param jointPivot The pivot of the joint / bone in local space.
  24082. * @param distToJoint Optional distance from the impostor to the joint.
  24083. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24084. * @param boneAxis Optional vector3 axis the bone is aligned with
  24085. */
  24086. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24087. /**
  24088. * No-Imposter type
  24089. */
  24090. static NoImpostor: number;
  24091. /**
  24092. * Sphere-Imposter type
  24093. */
  24094. static SphereImpostor: number;
  24095. /**
  24096. * Box-Imposter type
  24097. */
  24098. static BoxImpostor: number;
  24099. /**
  24100. * Plane-Imposter type
  24101. */
  24102. static PlaneImpostor: number;
  24103. /**
  24104. * Mesh-imposter type
  24105. */
  24106. static MeshImpostor: number;
  24107. /**
  24108. * Capsule-Impostor type (Ammo.js plugin only)
  24109. */
  24110. static CapsuleImpostor: number;
  24111. /**
  24112. * Cylinder-Imposter type
  24113. */
  24114. static CylinderImpostor: number;
  24115. /**
  24116. * Particle-Imposter type
  24117. */
  24118. static ParticleImpostor: number;
  24119. /**
  24120. * Heightmap-Imposter type
  24121. */
  24122. static HeightmapImpostor: number;
  24123. /**
  24124. * ConvexHull-Impostor type (Ammo.js plugin only)
  24125. */
  24126. static ConvexHullImpostor: number;
  24127. /**
  24128. * Rope-Imposter type
  24129. */
  24130. static RopeImpostor: number;
  24131. /**
  24132. * Cloth-Imposter type
  24133. */
  24134. static ClothImpostor: number;
  24135. /**
  24136. * Softbody-Imposter type
  24137. */
  24138. static SoftbodyImpostor: number;
  24139. }
  24140. }
  24141. declare module "babylonjs/Meshes/mesh" {
  24142. import { Observable } from "babylonjs/Misc/observable";
  24143. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24144. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24145. import { Camera } from "babylonjs/Cameras/camera";
  24146. import { Scene } from "babylonjs/scene";
  24147. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24148. import { Color4 } from "babylonjs/Maths/math.color";
  24149. import { Engine } from "babylonjs/Engines/engine";
  24150. import { Node } from "babylonjs/node";
  24151. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24152. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24153. import { Buffer } from "babylonjs/Meshes/buffer";
  24154. import { Geometry } from "babylonjs/Meshes/geometry";
  24155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24156. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24157. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24158. import { Effect } from "babylonjs/Materials/effect";
  24159. import { Material } from "babylonjs/Materials/material";
  24160. import { Skeleton } from "babylonjs/Bones/skeleton";
  24161. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24162. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24163. import { Path3D } from "babylonjs/Maths/math.path";
  24164. import { Plane } from "babylonjs/Maths/math.plane";
  24165. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24166. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24167. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24168. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24169. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24170. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24171. /**
  24172. * @hidden
  24173. **/
  24174. export class _CreationDataStorage {
  24175. closePath?: boolean;
  24176. closeArray?: boolean;
  24177. idx: number[];
  24178. dashSize: number;
  24179. gapSize: number;
  24180. path3D: Path3D;
  24181. pathArray: Vector3[][];
  24182. arc: number;
  24183. radius: number;
  24184. cap: number;
  24185. tessellation: number;
  24186. }
  24187. /**
  24188. * @hidden
  24189. **/
  24190. class _InstanceDataStorage {
  24191. visibleInstances: any;
  24192. batchCache: _InstancesBatch;
  24193. instancesBufferSize: number;
  24194. instancesBuffer: Nullable<Buffer>;
  24195. instancesData: Float32Array;
  24196. overridenInstanceCount: number;
  24197. isFrozen: boolean;
  24198. previousBatch: Nullable<_InstancesBatch>;
  24199. hardwareInstancedRendering: boolean;
  24200. sideOrientation: number;
  24201. }
  24202. /**
  24203. * @hidden
  24204. **/
  24205. export class _InstancesBatch {
  24206. mustReturn: boolean;
  24207. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24208. renderSelf: boolean[];
  24209. hardwareInstancedRendering: boolean[];
  24210. }
  24211. /**
  24212. * Class used to represent renderable models
  24213. */
  24214. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24215. /**
  24216. * Mesh side orientation : usually the external or front surface
  24217. */
  24218. static readonly FRONTSIDE: number;
  24219. /**
  24220. * Mesh side orientation : usually the internal or back surface
  24221. */
  24222. static readonly BACKSIDE: number;
  24223. /**
  24224. * Mesh side orientation : both internal and external or front and back surfaces
  24225. */
  24226. static readonly DOUBLESIDE: number;
  24227. /**
  24228. * Mesh side orientation : by default, `FRONTSIDE`
  24229. */
  24230. static readonly DEFAULTSIDE: number;
  24231. /**
  24232. * Mesh cap setting : no cap
  24233. */
  24234. static readonly NO_CAP: number;
  24235. /**
  24236. * Mesh cap setting : one cap at the beginning of the mesh
  24237. */
  24238. static readonly CAP_START: number;
  24239. /**
  24240. * Mesh cap setting : one cap at the end of the mesh
  24241. */
  24242. static readonly CAP_END: number;
  24243. /**
  24244. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24245. */
  24246. static readonly CAP_ALL: number;
  24247. /**
  24248. * Mesh pattern setting : no flip or rotate
  24249. */
  24250. static readonly NO_FLIP: number;
  24251. /**
  24252. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24253. */
  24254. static readonly FLIP_TILE: number;
  24255. /**
  24256. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24257. */
  24258. static readonly ROTATE_TILE: number;
  24259. /**
  24260. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24261. */
  24262. static readonly FLIP_ROW: number;
  24263. /**
  24264. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24265. */
  24266. static readonly ROTATE_ROW: number;
  24267. /**
  24268. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24269. */
  24270. static readonly FLIP_N_ROTATE_TILE: number;
  24271. /**
  24272. * Mesh pattern setting : rotate pattern and rotate
  24273. */
  24274. static readonly FLIP_N_ROTATE_ROW: number;
  24275. /**
  24276. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24277. */
  24278. static readonly CENTER: number;
  24279. /**
  24280. * Mesh tile positioning : part tiles on left
  24281. */
  24282. static readonly LEFT: number;
  24283. /**
  24284. * Mesh tile positioning : part tiles on right
  24285. */
  24286. static readonly RIGHT: number;
  24287. /**
  24288. * Mesh tile positioning : part tiles on top
  24289. */
  24290. static readonly TOP: number;
  24291. /**
  24292. * Mesh tile positioning : part tiles on bottom
  24293. */
  24294. static readonly BOTTOM: number;
  24295. /**
  24296. * Gets the default side orientation.
  24297. * @param orientation the orientation to value to attempt to get
  24298. * @returns the default orientation
  24299. * @hidden
  24300. */
  24301. static _GetDefaultSideOrientation(orientation?: number): number;
  24302. private _internalMeshDataInfo;
  24303. /**
  24304. * An event triggered before rendering the mesh
  24305. */
  24306. readonly onBeforeRenderObservable: Observable<Mesh>;
  24307. /**
  24308. * An event triggered before binding the mesh
  24309. */
  24310. readonly onBeforeBindObservable: Observable<Mesh>;
  24311. /**
  24312. * An event triggered after rendering the mesh
  24313. */
  24314. readonly onAfterRenderObservable: Observable<Mesh>;
  24315. /**
  24316. * An event triggered before drawing the mesh
  24317. */
  24318. readonly onBeforeDrawObservable: Observable<Mesh>;
  24319. private _onBeforeDrawObserver;
  24320. /**
  24321. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24322. */
  24323. onBeforeDraw: () => void;
  24324. readonly hasInstances: boolean;
  24325. /**
  24326. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24327. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24328. */
  24329. delayLoadState: number;
  24330. /**
  24331. * Gets the list of instances created from this mesh
  24332. * it is not supposed to be modified manually.
  24333. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24334. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24335. */
  24336. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24337. /**
  24338. * Gets the file containing delay loading data for this mesh
  24339. */
  24340. delayLoadingFile: string;
  24341. /** @hidden */
  24342. _binaryInfo: any;
  24343. /**
  24344. * User defined function used to change how LOD level selection is done
  24345. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24346. */
  24347. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24348. /**
  24349. * Gets or sets the morph target manager
  24350. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24351. */
  24352. morphTargetManager: Nullable<MorphTargetManager>;
  24353. /** @hidden */
  24354. _creationDataStorage: Nullable<_CreationDataStorage>;
  24355. /** @hidden */
  24356. _geometry: Nullable<Geometry>;
  24357. /** @hidden */
  24358. _delayInfo: Array<string>;
  24359. /** @hidden */
  24360. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24361. /** @hidden */
  24362. _instanceDataStorage: _InstanceDataStorage;
  24363. private _effectiveMaterial;
  24364. /** @hidden */
  24365. _shouldGenerateFlatShading: boolean;
  24366. /** @hidden */
  24367. _originalBuilderSideOrientation: number;
  24368. /**
  24369. * Use this property to change the original side orientation defined at construction time
  24370. */
  24371. overrideMaterialSideOrientation: Nullable<number>;
  24372. /**
  24373. * Gets the source mesh (the one used to clone this one from)
  24374. */
  24375. readonly source: Nullable<Mesh>;
  24376. /**
  24377. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24378. */
  24379. isUnIndexed: boolean;
  24380. /**
  24381. * @constructor
  24382. * @param name The value used by scene.getMeshByName() to do a lookup.
  24383. * @param scene The scene to add this mesh to.
  24384. * @param parent The parent of this mesh, if it has one
  24385. * @param source An optional Mesh from which geometry is shared, cloned.
  24386. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24387. * When false, achieved by calling a clone(), also passing False.
  24388. * This will make creation of children, recursive.
  24389. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24390. */
  24391. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24392. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24393. /**
  24394. * Gets the class name
  24395. * @returns the string "Mesh".
  24396. */
  24397. getClassName(): string;
  24398. /** @hidden */
  24399. readonly _isMesh: boolean;
  24400. /**
  24401. * Returns a description of this mesh
  24402. * @param fullDetails define if full details about this mesh must be used
  24403. * @returns a descriptive string representing this mesh
  24404. */
  24405. toString(fullDetails?: boolean): string;
  24406. /** @hidden */
  24407. _unBindEffect(): void;
  24408. /**
  24409. * Gets a boolean indicating if this mesh has LOD
  24410. */
  24411. readonly hasLODLevels: boolean;
  24412. /**
  24413. * Gets the list of MeshLODLevel associated with the current mesh
  24414. * @returns an array of MeshLODLevel
  24415. */
  24416. getLODLevels(): MeshLODLevel[];
  24417. private _sortLODLevels;
  24418. /**
  24419. * Add a mesh as LOD level triggered at the given distance.
  24420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24421. * @param distance The distance from the center of the object to show this level
  24422. * @param mesh The mesh to be added as LOD level (can be null)
  24423. * @return This mesh (for chaining)
  24424. */
  24425. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24426. /**
  24427. * Returns the LOD level mesh at the passed distance or null if not found.
  24428. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24429. * @param distance The distance from the center of the object to show this level
  24430. * @returns a Mesh or `null`
  24431. */
  24432. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24433. /**
  24434. * Remove a mesh from the LOD array
  24435. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24436. * @param mesh defines the mesh to be removed
  24437. * @return This mesh (for chaining)
  24438. */
  24439. removeLODLevel(mesh: Mesh): Mesh;
  24440. /**
  24441. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24442. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24443. * @param camera defines the camera to use to compute distance
  24444. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24445. * @return This mesh (for chaining)
  24446. */
  24447. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24448. /**
  24449. * Gets the mesh internal Geometry object
  24450. */
  24451. readonly geometry: Nullable<Geometry>;
  24452. /**
  24453. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24454. * @returns the total number of vertices
  24455. */
  24456. getTotalVertices(): number;
  24457. /**
  24458. * Returns the content of an associated vertex buffer
  24459. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24460. * - VertexBuffer.PositionKind
  24461. * - VertexBuffer.UVKind
  24462. * - VertexBuffer.UV2Kind
  24463. * - VertexBuffer.UV3Kind
  24464. * - VertexBuffer.UV4Kind
  24465. * - VertexBuffer.UV5Kind
  24466. * - VertexBuffer.UV6Kind
  24467. * - VertexBuffer.ColorKind
  24468. * - VertexBuffer.MatricesIndicesKind
  24469. * - VertexBuffer.MatricesIndicesExtraKind
  24470. * - VertexBuffer.MatricesWeightsKind
  24471. * - VertexBuffer.MatricesWeightsExtraKind
  24472. * @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
  24473. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24474. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24475. */
  24476. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24477. /**
  24478. * Returns the mesh VertexBuffer object from the requested `kind`
  24479. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24480. * - VertexBuffer.PositionKind
  24481. * - VertexBuffer.NormalKind
  24482. * - VertexBuffer.UVKind
  24483. * - VertexBuffer.UV2Kind
  24484. * - VertexBuffer.UV3Kind
  24485. * - VertexBuffer.UV4Kind
  24486. * - VertexBuffer.UV5Kind
  24487. * - VertexBuffer.UV6Kind
  24488. * - VertexBuffer.ColorKind
  24489. * - VertexBuffer.MatricesIndicesKind
  24490. * - VertexBuffer.MatricesIndicesExtraKind
  24491. * - VertexBuffer.MatricesWeightsKind
  24492. * - VertexBuffer.MatricesWeightsExtraKind
  24493. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24494. */
  24495. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24496. /**
  24497. * Tests if a specific vertex buffer is associated with this mesh
  24498. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24499. * - VertexBuffer.PositionKind
  24500. * - VertexBuffer.NormalKind
  24501. * - VertexBuffer.UVKind
  24502. * - VertexBuffer.UV2Kind
  24503. * - VertexBuffer.UV3Kind
  24504. * - VertexBuffer.UV4Kind
  24505. * - VertexBuffer.UV5Kind
  24506. * - VertexBuffer.UV6Kind
  24507. * - VertexBuffer.ColorKind
  24508. * - VertexBuffer.MatricesIndicesKind
  24509. * - VertexBuffer.MatricesIndicesExtraKind
  24510. * - VertexBuffer.MatricesWeightsKind
  24511. * - VertexBuffer.MatricesWeightsExtraKind
  24512. * @returns a boolean
  24513. */
  24514. isVerticesDataPresent(kind: string): boolean;
  24515. /**
  24516. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24517. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24518. * - VertexBuffer.PositionKind
  24519. * - VertexBuffer.UVKind
  24520. * - VertexBuffer.UV2Kind
  24521. * - VertexBuffer.UV3Kind
  24522. * - VertexBuffer.UV4Kind
  24523. * - VertexBuffer.UV5Kind
  24524. * - VertexBuffer.UV6Kind
  24525. * - VertexBuffer.ColorKind
  24526. * - VertexBuffer.MatricesIndicesKind
  24527. * - VertexBuffer.MatricesIndicesExtraKind
  24528. * - VertexBuffer.MatricesWeightsKind
  24529. * - VertexBuffer.MatricesWeightsExtraKind
  24530. * @returns a boolean
  24531. */
  24532. isVertexBufferUpdatable(kind: string): boolean;
  24533. /**
  24534. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24535. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24536. * - VertexBuffer.PositionKind
  24537. * - VertexBuffer.NormalKind
  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. * @returns an array of strings
  24550. */
  24551. getVerticesDataKinds(): string[];
  24552. /**
  24553. * Returns a positive integer : the total number of indices in this mesh geometry.
  24554. * @returns the numner of indices or zero if the mesh has no geometry.
  24555. */
  24556. getTotalIndices(): number;
  24557. /**
  24558. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24559. * @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.
  24560. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24561. * @returns the indices array or an empty array if the mesh has no geometry
  24562. */
  24563. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24564. readonly isBlocked: boolean;
  24565. /**
  24566. * Determine if the current mesh is ready to be rendered
  24567. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24568. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24569. * @returns true if all associated assets are ready (material, textures, shaders)
  24570. */
  24571. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24572. /**
  24573. * 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.
  24574. */
  24575. readonly areNormalsFrozen: boolean;
  24576. /**
  24577. * 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.
  24578. * @returns the current mesh
  24579. */
  24580. freezeNormals(): Mesh;
  24581. /**
  24582. * 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
  24583. * @returns the current mesh
  24584. */
  24585. unfreezeNormals(): Mesh;
  24586. /**
  24587. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24588. */
  24589. overridenInstanceCount: number;
  24590. /** @hidden */
  24591. _preActivate(): Mesh;
  24592. /** @hidden */
  24593. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24594. /** @hidden */
  24595. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24596. /**
  24597. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24598. * This means the mesh underlying bounding box and sphere are recomputed.
  24599. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24600. * @returns the current mesh
  24601. */
  24602. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24603. /** @hidden */
  24604. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24605. /**
  24606. * This function will subdivide the mesh into multiple submeshes
  24607. * @param count defines the expected number of submeshes
  24608. */
  24609. subdivide(count: number): void;
  24610. /**
  24611. * Copy a FloatArray into a specific associated vertex buffer
  24612. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24613. * - VertexBuffer.PositionKind
  24614. * - VertexBuffer.UVKind
  24615. * - VertexBuffer.UV2Kind
  24616. * - VertexBuffer.UV3Kind
  24617. * - VertexBuffer.UV4Kind
  24618. * - VertexBuffer.UV5Kind
  24619. * - VertexBuffer.UV6Kind
  24620. * - VertexBuffer.ColorKind
  24621. * - VertexBuffer.MatricesIndicesKind
  24622. * - VertexBuffer.MatricesIndicesExtraKind
  24623. * - VertexBuffer.MatricesWeightsKind
  24624. * - VertexBuffer.MatricesWeightsExtraKind
  24625. * @param data defines the data source
  24626. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24627. * @param stride defines the data stride size (can be null)
  24628. * @returns the current mesh
  24629. */
  24630. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24631. /**
  24632. * Flags an associated vertex buffer as updatable
  24633. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24634. * - VertexBuffer.PositionKind
  24635. * - VertexBuffer.UVKind
  24636. * - VertexBuffer.UV2Kind
  24637. * - VertexBuffer.UV3Kind
  24638. * - VertexBuffer.UV4Kind
  24639. * - VertexBuffer.UV5Kind
  24640. * - VertexBuffer.UV6Kind
  24641. * - VertexBuffer.ColorKind
  24642. * - VertexBuffer.MatricesIndicesKind
  24643. * - VertexBuffer.MatricesIndicesExtraKind
  24644. * - VertexBuffer.MatricesWeightsKind
  24645. * - VertexBuffer.MatricesWeightsExtraKind
  24646. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24647. */
  24648. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24649. /**
  24650. * Sets the mesh global Vertex Buffer
  24651. * @param buffer defines the buffer to use
  24652. * @returns the current mesh
  24653. */
  24654. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24655. /**
  24656. * Update a specific associated vertex buffer
  24657. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24658. * - VertexBuffer.PositionKind
  24659. * - VertexBuffer.UVKind
  24660. * - VertexBuffer.UV2Kind
  24661. * - VertexBuffer.UV3Kind
  24662. * - VertexBuffer.UV4Kind
  24663. * - VertexBuffer.UV5Kind
  24664. * - VertexBuffer.UV6Kind
  24665. * - VertexBuffer.ColorKind
  24666. * - VertexBuffer.MatricesIndicesKind
  24667. * - VertexBuffer.MatricesIndicesExtraKind
  24668. * - VertexBuffer.MatricesWeightsKind
  24669. * - VertexBuffer.MatricesWeightsExtraKind
  24670. * @param data defines the data source
  24671. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24672. * @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)
  24673. * @returns the current mesh
  24674. */
  24675. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24676. /**
  24677. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24678. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24679. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24680. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24681. * @returns the current mesh
  24682. */
  24683. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24684. /**
  24685. * Creates a un-shared specific occurence of the geometry for the mesh.
  24686. * @returns the current mesh
  24687. */
  24688. makeGeometryUnique(): Mesh;
  24689. /**
  24690. * Set the index buffer of this mesh
  24691. * @param indices defines the source data
  24692. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24693. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24694. * @returns the current mesh
  24695. */
  24696. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24697. /**
  24698. * Update the current index buffer
  24699. * @param indices defines the source data
  24700. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24701. * @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)
  24702. * @returns the current mesh
  24703. */
  24704. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24705. /**
  24706. * Invert the geometry to move from a right handed system to a left handed one.
  24707. * @returns the current mesh
  24708. */
  24709. toLeftHanded(): Mesh;
  24710. /** @hidden */
  24711. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24712. /** @hidden */
  24713. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24714. /**
  24715. * Registers for this mesh a javascript function called just before the rendering process
  24716. * @param func defines the function to call before rendering this mesh
  24717. * @returns the current mesh
  24718. */
  24719. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24720. /**
  24721. * Disposes a previously registered javascript function called before the rendering
  24722. * @param func defines the function to remove
  24723. * @returns the current mesh
  24724. */
  24725. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24726. /**
  24727. * Registers for this mesh a javascript function called just after the rendering is complete
  24728. * @param func defines the function to call after rendering this mesh
  24729. * @returns the current mesh
  24730. */
  24731. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24732. /**
  24733. * Disposes a previously registered javascript function called after the rendering.
  24734. * @param func defines the function to remove
  24735. * @returns the current mesh
  24736. */
  24737. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24738. /** @hidden */
  24739. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24740. /** @hidden */
  24741. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24742. /** @hidden */
  24743. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24744. /** @hidden */
  24745. _rebuild(): void;
  24746. /** @hidden */
  24747. _freeze(): void;
  24748. /** @hidden */
  24749. _unFreeze(): void;
  24750. /**
  24751. * 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
  24752. * @param subMesh defines the subMesh to render
  24753. * @param enableAlphaMode defines if alpha mode can be changed
  24754. * @returns the current mesh
  24755. */
  24756. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24757. private _onBeforeDraw;
  24758. /**
  24759. * Renormalize the mesh and patch it up if there are no weights
  24760. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24761. * However in the case of zero weights then we set just a single influence to 1.
  24762. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24763. */
  24764. cleanMatrixWeights(): void;
  24765. private normalizeSkinFourWeights;
  24766. private normalizeSkinWeightsAndExtra;
  24767. /**
  24768. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24769. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24770. * the user know there was an issue with importing the mesh
  24771. * @returns a validation object with skinned, valid and report string
  24772. */
  24773. validateSkinning(): {
  24774. skinned: boolean;
  24775. valid: boolean;
  24776. report: string;
  24777. };
  24778. /** @hidden */
  24779. _checkDelayState(): Mesh;
  24780. private _queueLoad;
  24781. /**
  24782. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24783. * A mesh is in the frustum if its bounding box intersects the frustum
  24784. * @param frustumPlanes defines the frustum to test
  24785. * @returns true if the mesh is in the frustum planes
  24786. */
  24787. isInFrustum(frustumPlanes: Plane[]): boolean;
  24788. /**
  24789. * Sets the mesh material by the material or multiMaterial `id` property
  24790. * @param id is a string identifying the material or the multiMaterial
  24791. * @returns the current mesh
  24792. */
  24793. setMaterialByID(id: string): Mesh;
  24794. /**
  24795. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24796. * @returns an array of IAnimatable
  24797. */
  24798. getAnimatables(): IAnimatable[];
  24799. /**
  24800. * Modifies the mesh geometry according to the passed transformation matrix.
  24801. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24802. * The mesh normals are modified using the same transformation.
  24803. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24804. * @param transform defines the transform matrix to use
  24805. * @see http://doc.babylonjs.com/resources/baking_transformations
  24806. * @returns the current mesh
  24807. */
  24808. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24809. /**
  24810. * Modifies the mesh geometry according to its own current World Matrix.
  24811. * The mesh World Matrix is then reset.
  24812. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24813. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24814. * @see http://doc.babylonjs.com/resources/baking_transformations
  24815. * @returns the current mesh
  24816. */
  24817. bakeCurrentTransformIntoVertices(): Mesh;
  24818. /** @hidden */
  24819. readonly _positions: Nullable<Vector3[]>;
  24820. /** @hidden */
  24821. _resetPointsArrayCache(): Mesh;
  24822. /** @hidden */
  24823. _generatePointsArray(): boolean;
  24824. /**
  24825. * Returns a new Mesh object generated from the current mesh properties.
  24826. * This method must not get confused with createInstance()
  24827. * @param name is a string, the name given to the new mesh
  24828. * @param newParent can be any Node object (default `null`)
  24829. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24830. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24831. * @returns a new mesh
  24832. */
  24833. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24834. /**
  24835. * Releases resources associated with this mesh.
  24836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24838. */
  24839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24840. /**
  24841. * Modifies the mesh geometry according to a displacement map.
  24842. * 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.
  24843. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24844. * @param url is a string, the URL from the image file is to be downloaded.
  24845. * @param minHeight is the lower limit of the displacement.
  24846. * @param maxHeight is the upper limit of the displacement.
  24847. * @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.
  24848. * @param uvOffset is an optional vector2 used to offset UV.
  24849. * @param uvScale is an optional vector2 used to scale UV.
  24850. * @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.
  24851. * @returns the Mesh.
  24852. */
  24853. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24854. /**
  24855. * Modifies the mesh geometry according to a displacementMap buffer.
  24856. * 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.
  24857. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24858. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24859. * @param heightMapWidth is the width of the buffer image.
  24860. * @param heightMapHeight is the height of the buffer image.
  24861. * @param minHeight is the lower limit of the displacement.
  24862. * @param maxHeight is the upper limit of the displacement.
  24863. * @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.
  24864. * @param uvOffset is an optional vector2 used to offset UV.
  24865. * @param uvScale is an optional vector2 used to scale UV.
  24866. * @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.
  24867. * @returns the Mesh.
  24868. */
  24869. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24870. /**
  24871. * Modify the mesh to get a flat shading rendering.
  24872. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24873. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24874. * @returns current mesh
  24875. */
  24876. convertToFlatShadedMesh(): Mesh;
  24877. /**
  24878. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24879. * In other words, more vertices, no more indices and a single bigger VBO.
  24880. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24881. * @returns current mesh
  24882. */
  24883. convertToUnIndexedMesh(): Mesh;
  24884. /**
  24885. * Inverses facet orientations.
  24886. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24887. * @param flipNormals will also inverts the normals
  24888. * @returns current mesh
  24889. */
  24890. flipFaces(flipNormals?: boolean): Mesh;
  24891. /**
  24892. * Increase the number of facets and hence vertices in a mesh
  24893. * Vertex normals are interpolated from existing vertex normals
  24894. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24895. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24896. */
  24897. increaseVertices(numberPerEdge: number): void;
  24898. /**
  24899. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24900. * This will undo any application of covertToFlatShadedMesh
  24901. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24902. */
  24903. forceSharedVertices(): void;
  24904. /** @hidden */
  24905. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24906. /** @hidden */
  24907. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24908. /**
  24909. * Creates a new InstancedMesh object from the mesh model.
  24910. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24911. * @param name defines the name of the new instance
  24912. * @returns a new InstancedMesh
  24913. */
  24914. createInstance(name: string): InstancedMesh;
  24915. /**
  24916. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24917. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24918. * @returns the current mesh
  24919. */
  24920. synchronizeInstances(): Mesh;
  24921. /**
  24922. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24923. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24924. * This should be used together with the simplification to avoid disappearing triangles.
  24925. * @param successCallback an optional success callback to be called after the optimization finished.
  24926. * @returns the current mesh
  24927. */
  24928. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24929. /**
  24930. * Serialize current mesh
  24931. * @param serializationObject defines the object which will receive the serialization data
  24932. */
  24933. serialize(serializationObject: any): void;
  24934. /** @hidden */
  24935. _syncGeometryWithMorphTargetManager(): void;
  24936. /** @hidden */
  24937. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24938. /**
  24939. * Returns a new Mesh object parsed from the source provided.
  24940. * @param parsedMesh is the source
  24941. * @param scene defines the hosting scene
  24942. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24943. * @returns a new Mesh
  24944. */
  24945. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24946. /**
  24947. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24948. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24949. * @param name defines the name of the mesh to create
  24950. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24951. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24952. * @param closePath creates a seam between the first and the last points of each path of the path array
  24953. * @param offset is taken in account only if the `pathArray` is containing a single path
  24954. * @param scene defines the hosting scene
  24955. * @param updatable defines if the mesh must be flagged as updatable
  24956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24957. * @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)
  24958. * @returns a new Mesh
  24959. */
  24960. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24961. /**
  24962. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24963. * @param name defines the name of the mesh to create
  24964. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24965. * @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
  24966. * @param scene defines the hosting scene
  24967. * @param updatable defines if the mesh must be flagged as updatable
  24968. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24969. * @returns a new Mesh
  24970. */
  24971. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24972. /**
  24973. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24974. * @param name defines the name of the mesh to create
  24975. * @param size sets the size (float) of each box side (default 1)
  24976. * @param scene defines the hosting scene
  24977. * @param updatable defines if the mesh must be flagged as updatable
  24978. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24979. * @returns a new Mesh
  24980. */
  24981. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24982. /**
  24983. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24984. * @param name defines the name of the mesh to create
  24985. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24986. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24987. * @param scene defines the hosting scene
  24988. * @param updatable defines if the mesh must be flagged as updatable
  24989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24990. * @returns a new Mesh
  24991. */
  24992. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24993. /**
  24994. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24995. * @param name defines the name of the mesh to create
  24996. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24997. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24998. * @param scene defines the hosting scene
  24999. * @returns a new Mesh
  25000. */
  25001. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25002. /**
  25003. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25004. * @param name defines the name of the mesh to create
  25005. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25006. * @param diameterTop set the top cap diameter (floats, default 1)
  25007. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25008. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25009. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25010. * @param scene defines the hosting scene
  25011. * @param updatable defines if the mesh must be flagged as updatable
  25012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25013. * @returns a new Mesh
  25014. */
  25015. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25016. /**
  25017. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25018. * @param name defines the name of the mesh to create
  25019. * @param diameter sets the diameter size (float) of the torus (default 1)
  25020. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25021. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25022. * @param scene defines the hosting scene
  25023. * @param updatable defines if the mesh must be flagged as updatable
  25024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25025. * @returns a new Mesh
  25026. */
  25027. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25028. /**
  25029. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25030. * @param name defines the name of the mesh to create
  25031. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25032. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25033. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25034. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25035. * @param p the number of windings on X axis (positive integers, default 2)
  25036. * @param q the number of windings on Y axis (positive integers, default 3)
  25037. * @param scene defines the hosting scene
  25038. * @param updatable defines if the mesh must be flagged as updatable
  25039. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25040. * @returns a new Mesh
  25041. */
  25042. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25043. /**
  25044. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25045. * @param name defines the name of the mesh to create
  25046. * @param points is an array successive Vector3
  25047. * @param scene defines the hosting scene
  25048. * @param updatable defines if the mesh must be flagged as updatable
  25049. * @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).
  25050. * @returns a new Mesh
  25051. */
  25052. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25053. /**
  25054. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25055. * @param name defines the name of the mesh to create
  25056. * @param points is an array successive Vector3
  25057. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25058. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25059. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25060. * @param scene defines the hosting scene
  25061. * @param updatable defines if the mesh must be flagged as updatable
  25062. * @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)
  25063. * @returns a new Mesh
  25064. */
  25065. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25066. /**
  25067. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25069. * 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.
  25070. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25071. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25072. * Remember you can only change the shape positions, not their number when updating a polygon.
  25073. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25074. * @param name defines the name of the mesh to create
  25075. * @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
  25076. * @param scene defines the hosting scene
  25077. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25078. * @param updatable defines if the mesh must be flagged as updatable
  25079. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25080. * @param earcutInjection can be used to inject your own earcut reference
  25081. * @returns a new Mesh
  25082. */
  25083. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25084. /**
  25085. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25086. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25087. * @param name defines the name of the mesh to create
  25088. * @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
  25089. * @param depth defines the height of extrusion
  25090. * @param scene defines the hosting scene
  25091. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25092. * @param updatable defines if the mesh must be flagged as updatable
  25093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25094. * @param earcutInjection can be used to inject your own earcut reference
  25095. * @returns a new Mesh
  25096. */
  25097. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25098. /**
  25099. * Creates an extruded shape mesh.
  25100. * 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
  25101. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25102. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25103. * @param name defines the name of the mesh to create
  25104. * @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
  25105. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25106. * @param scale is the value to scale the shape
  25107. * @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
  25108. * @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
  25109. * @param scene defines the hosting scene
  25110. * @param updatable defines if the mesh must be flagged as updatable
  25111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25112. * @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)
  25113. * @returns a new Mesh
  25114. */
  25115. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25116. /**
  25117. * Creates an custom extruded shape mesh.
  25118. * The custom extrusion is a parametric shape.
  25119. * It has no predefined shape. Its final shape will depend on the input parameters.
  25120. * Please consider using the same method from the MeshBuilder class instead
  25121. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25122. * @param name defines the name of the mesh to create
  25123. * @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
  25124. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25125. * @param scaleFunction is a custom Javascript function called on each path point
  25126. * @param rotationFunction is a custom Javascript function called on each path point
  25127. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25128. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25129. * @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
  25130. * @param scene defines the hosting scene
  25131. * @param updatable defines if the mesh must be flagged as updatable
  25132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25133. * @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)
  25134. * @returns a new Mesh
  25135. */
  25136. 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;
  25137. /**
  25138. * Creates lathe mesh.
  25139. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25140. * Please consider using the same method from the MeshBuilder class instead
  25141. * @param name defines the name of the mesh to create
  25142. * @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
  25143. * @param radius is the radius value of the lathe
  25144. * @param tessellation is the side number of the lathe.
  25145. * @param scene defines the hosting scene
  25146. * @param updatable defines if the mesh must be flagged as updatable
  25147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25148. * @returns a new Mesh
  25149. */
  25150. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25151. /**
  25152. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25153. * @param name defines the name of the mesh to create
  25154. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25155. * @param scene defines the hosting scene
  25156. * @param updatable defines if the mesh must be flagged as updatable
  25157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25158. * @returns a new Mesh
  25159. */
  25160. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25161. /**
  25162. * Creates a ground mesh.
  25163. * Please consider using the same method from the MeshBuilder class instead
  25164. * @param name defines the name of the mesh to create
  25165. * @param width set the width of the ground
  25166. * @param height set the height of the ground
  25167. * @param subdivisions sets the number of subdivisions per side
  25168. * @param scene defines the hosting scene
  25169. * @param updatable defines if the mesh must be flagged as updatable
  25170. * @returns a new Mesh
  25171. */
  25172. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25173. /**
  25174. * Creates a tiled ground mesh.
  25175. * Please consider using the same method from the MeshBuilder class instead
  25176. * @param name defines the name of the mesh to create
  25177. * @param xmin set the ground minimum X coordinate
  25178. * @param zmin set the ground minimum Y coordinate
  25179. * @param xmax set the ground maximum X coordinate
  25180. * @param zmax set the ground maximum Z coordinate
  25181. * @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
  25182. * @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
  25183. * @param scene defines the hosting scene
  25184. * @param updatable defines if the mesh must be flagged as updatable
  25185. * @returns a new Mesh
  25186. */
  25187. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25188. w: number;
  25189. h: number;
  25190. }, precision: {
  25191. w: number;
  25192. h: number;
  25193. }, scene: Scene, updatable?: boolean): Mesh;
  25194. /**
  25195. * Creates a ground mesh from a height map.
  25196. * Please consider using the same method from the MeshBuilder class instead
  25197. * @see http://doc.babylonjs.com/babylon101/height_map
  25198. * @param name defines the name of the mesh to create
  25199. * @param url sets the URL of the height map image resource
  25200. * @param width set the ground width size
  25201. * @param height set the ground height size
  25202. * @param subdivisions sets the number of subdivision per side
  25203. * @param minHeight is the minimum altitude on the ground
  25204. * @param maxHeight is the maximum altitude on the ground
  25205. * @param scene defines the hosting scene
  25206. * @param updatable defines if the mesh must be flagged as updatable
  25207. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25208. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25209. * @returns a new Mesh
  25210. */
  25211. 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;
  25212. /**
  25213. * Creates a tube mesh.
  25214. * The tube is a parametric shape.
  25215. * It has no predefined shape. Its final shape will depend on the input parameters.
  25216. * Please consider using the same method from the MeshBuilder class instead
  25217. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25218. * @param name defines the name of the mesh to create
  25219. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25220. * @param radius sets the tube radius size
  25221. * @param tessellation is the number of sides on the tubular surface
  25222. * @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
  25223. * @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
  25224. * @param scene defines the hosting scene
  25225. * @param updatable defines if the mesh must be flagged as updatable
  25226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25227. * @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)
  25228. * @returns a new Mesh
  25229. */
  25230. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25231. (i: number, distance: number): number;
  25232. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25233. /**
  25234. * Creates a polyhedron mesh.
  25235. * Please consider using the same method from the MeshBuilder class instead.
  25236. * * 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
  25237. * * The parameter `size` (positive float, default 1) sets the polygon size
  25238. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25239. * * 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`
  25240. * * 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
  25241. * * 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)`)
  25242. * * 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
  25243. * * 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
  25244. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25245. * * If you create a double-sided mesh, you can choose what parts of 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
  25246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25247. * @param name defines the name of the mesh to create
  25248. * @param options defines the options used to create the mesh
  25249. * @param scene defines the hosting scene
  25250. * @returns a new Mesh
  25251. */
  25252. static CreatePolyhedron(name: string, options: {
  25253. type?: number;
  25254. size?: number;
  25255. sizeX?: number;
  25256. sizeY?: number;
  25257. sizeZ?: number;
  25258. custom?: any;
  25259. faceUV?: Vector4[];
  25260. faceColors?: Color4[];
  25261. updatable?: boolean;
  25262. sideOrientation?: number;
  25263. }, scene: Scene): Mesh;
  25264. /**
  25265. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25266. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25267. * * 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`)
  25268. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25269. * * 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
  25270. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25271. * * If you create a double-sided mesh, you can choose what parts of 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
  25272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25273. * @param name defines the name of the mesh
  25274. * @param options defines the options used to create the mesh
  25275. * @param scene defines the hosting scene
  25276. * @returns a new Mesh
  25277. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25278. */
  25279. static CreateIcoSphere(name: string, options: {
  25280. radius?: number;
  25281. flat?: boolean;
  25282. subdivisions?: number;
  25283. sideOrientation?: number;
  25284. updatable?: boolean;
  25285. }, scene: Scene): Mesh;
  25286. /**
  25287. * Creates a decal mesh.
  25288. * Please consider using the same method from the MeshBuilder class instead.
  25289. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25290. * @param name defines the name of the mesh
  25291. * @param sourceMesh defines the mesh receiving the decal
  25292. * @param position sets the position of the decal in world coordinates
  25293. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25294. * @param size sets the decal scaling
  25295. * @param angle sets the angle to rotate the decal
  25296. * @returns a new Mesh
  25297. */
  25298. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25299. /**
  25300. * Prepare internal position array for software CPU skinning
  25301. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25302. */
  25303. setPositionsForCPUSkinning(): Float32Array;
  25304. /**
  25305. * Prepare internal normal array for software CPU skinning
  25306. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25307. */
  25308. setNormalsForCPUSkinning(): Float32Array;
  25309. /**
  25310. * Updates the vertex buffer by applying transformation from the bones
  25311. * @param skeleton defines the skeleton to apply to current mesh
  25312. * @returns the current mesh
  25313. */
  25314. applySkeleton(skeleton: Skeleton): Mesh;
  25315. /**
  25316. * 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
  25317. * @param meshes defines the list of meshes to scan
  25318. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25319. */
  25320. static MinMax(meshes: AbstractMesh[]): {
  25321. min: Vector3;
  25322. max: Vector3;
  25323. };
  25324. /**
  25325. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25326. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25327. * @returns a vector3
  25328. */
  25329. static Center(meshesOrMinMaxVector: {
  25330. min: Vector3;
  25331. max: Vector3;
  25332. } | AbstractMesh[]): Vector3;
  25333. /**
  25334. * Merge the array of meshes into a single mesh for performance reasons.
  25335. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25336. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25337. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25338. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25339. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25340. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25341. * @returns a new mesh
  25342. */
  25343. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25344. /** @hidden */
  25345. addInstance(instance: InstancedMesh): void;
  25346. /** @hidden */
  25347. removeInstance(instance: InstancedMesh): void;
  25348. }
  25349. }
  25350. declare module "babylonjs/Cameras/camera" {
  25351. import { SmartArray } from "babylonjs/Misc/smartArray";
  25352. import { Observable } from "babylonjs/Misc/observable";
  25353. import { Nullable } from "babylonjs/types";
  25354. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25355. import { Scene } from "babylonjs/scene";
  25356. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25357. import { Node } from "babylonjs/node";
  25358. import { Mesh } from "babylonjs/Meshes/mesh";
  25359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25360. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25361. import { Viewport } from "babylonjs/Maths/math.viewport";
  25362. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25364. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25365. import { Ray } from "babylonjs/Culling/ray";
  25366. /**
  25367. * This is the base class of all the camera used in the application.
  25368. * @see http://doc.babylonjs.com/features/cameras
  25369. */
  25370. export class Camera extends Node {
  25371. /** @hidden */
  25372. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25373. /**
  25374. * This is the default projection mode used by the cameras.
  25375. * It helps recreating a feeling of perspective and better appreciate depth.
  25376. * This is the best way to simulate real life cameras.
  25377. */
  25378. static readonly PERSPECTIVE_CAMERA: number;
  25379. /**
  25380. * This helps creating camera with an orthographic mode.
  25381. * 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.
  25382. */
  25383. static readonly ORTHOGRAPHIC_CAMERA: number;
  25384. /**
  25385. * This is the default FOV mode for perspective cameras.
  25386. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25387. */
  25388. static readonly FOVMODE_VERTICAL_FIXED: number;
  25389. /**
  25390. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25391. */
  25392. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25393. /**
  25394. * This specifies ther is no need for a camera rig.
  25395. * Basically only one eye is rendered corresponding to the camera.
  25396. */
  25397. static readonly RIG_MODE_NONE: number;
  25398. /**
  25399. * Simulates a camera Rig with one blue eye and one red eye.
  25400. * This can be use with 3d blue and red glasses.
  25401. */
  25402. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25403. /**
  25404. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25405. */
  25406. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25407. /**
  25408. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25409. */
  25410. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25411. /**
  25412. * Defines that both eyes of the camera will be rendered over under each other.
  25413. */
  25414. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25415. /**
  25416. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25417. */
  25418. static readonly RIG_MODE_VR: number;
  25419. /**
  25420. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25421. */
  25422. static readonly RIG_MODE_WEBVR: number;
  25423. /**
  25424. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25425. */
  25426. static readonly RIG_MODE_CUSTOM: number;
  25427. /**
  25428. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25429. */
  25430. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25431. /**
  25432. * Define the input manager associated with the camera.
  25433. */
  25434. inputs: CameraInputsManager<Camera>;
  25435. /** @hidden */
  25436. _position: Vector3;
  25437. /**
  25438. * Define the current local position of the camera in the scene
  25439. */
  25440. position: Vector3;
  25441. /**
  25442. * The vector the camera should consider as up.
  25443. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25444. */
  25445. upVector: Vector3;
  25446. /**
  25447. * Define the current limit on the left side for an orthographic camera
  25448. * In scene unit
  25449. */
  25450. orthoLeft: Nullable<number>;
  25451. /**
  25452. * Define the current limit on the right side for an orthographic camera
  25453. * In scene unit
  25454. */
  25455. orthoRight: Nullable<number>;
  25456. /**
  25457. * Define the current limit on the bottom side for an orthographic camera
  25458. * In scene unit
  25459. */
  25460. orthoBottom: Nullable<number>;
  25461. /**
  25462. * Define the current limit on the top side for an orthographic camera
  25463. * In scene unit
  25464. */
  25465. orthoTop: Nullable<number>;
  25466. /**
  25467. * Field Of View is set in Radians. (default is 0.8)
  25468. */
  25469. fov: number;
  25470. /**
  25471. * Define the minimum distance the camera can see from.
  25472. * This is important to note that the depth buffer are not infinite and the closer it starts
  25473. * the more your scene might encounter depth fighting issue.
  25474. */
  25475. minZ: number;
  25476. /**
  25477. * Define the maximum distance the camera can see to.
  25478. * This is important to note that the depth buffer are not infinite and the further it end
  25479. * the more your scene might encounter depth fighting issue.
  25480. */
  25481. maxZ: number;
  25482. /**
  25483. * Define the default inertia of the camera.
  25484. * This helps giving a smooth feeling to the camera movement.
  25485. */
  25486. inertia: number;
  25487. /**
  25488. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25489. */
  25490. mode: number;
  25491. /**
  25492. * Define wether the camera is intermediate.
  25493. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25494. */
  25495. isIntermediate: boolean;
  25496. /**
  25497. * Define the viewport of the camera.
  25498. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25499. */
  25500. viewport: Viewport;
  25501. /**
  25502. * Restricts the camera to viewing objects with the same layerMask.
  25503. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25504. */
  25505. layerMask: number;
  25506. /**
  25507. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25508. */
  25509. fovMode: number;
  25510. /**
  25511. * Rig mode of the camera.
  25512. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25513. * This is normally controlled byt the camera themselves as internal use.
  25514. */
  25515. cameraRigMode: number;
  25516. /**
  25517. * Defines the distance between both "eyes" in case of a RIG
  25518. */
  25519. interaxialDistance: number;
  25520. /**
  25521. * Defines if stereoscopic rendering is done side by side or over under.
  25522. */
  25523. isStereoscopicSideBySide: boolean;
  25524. /**
  25525. * 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
  25526. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25527. * else in the scene. (Eg. security camera)
  25528. *
  25529. * 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)
  25530. */
  25531. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25532. /**
  25533. * When set, the camera will render to this render target instead of the default canvas
  25534. *
  25535. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25536. */
  25537. outputRenderTarget: Nullable<RenderTargetTexture>;
  25538. /**
  25539. * Observable triggered when the camera view matrix has changed.
  25540. */
  25541. onViewMatrixChangedObservable: Observable<Camera>;
  25542. /**
  25543. * Observable triggered when the camera Projection matrix has changed.
  25544. */
  25545. onProjectionMatrixChangedObservable: Observable<Camera>;
  25546. /**
  25547. * Observable triggered when the inputs have been processed.
  25548. */
  25549. onAfterCheckInputsObservable: Observable<Camera>;
  25550. /**
  25551. * Observable triggered when reset has been called and applied to the camera.
  25552. */
  25553. onRestoreStateObservable: Observable<Camera>;
  25554. /** @hidden */
  25555. _cameraRigParams: any;
  25556. /** @hidden */
  25557. _rigCameras: Camera[];
  25558. /** @hidden */
  25559. _rigPostProcess: Nullable<PostProcess>;
  25560. protected _webvrViewMatrix: Matrix;
  25561. /** @hidden */
  25562. _skipRendering: boolean;
  25563. /** @hidden */
  25564. _projectionMatrix: Matrix;
  25565. /** @hidden */
  25566. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25567. /** @hidden */
  25568. _activeMeshes: SmartArray<AbstractMesh>;
  25569. protected _globalPosition: Vector3;
  25570. /** @hidden */
  25571. _computedViewMatrix: Matrix;
  25572. private _doNotComputeProjectionMatrix;
  25573. private _transformMatrix;
  25574. private _frustumPlanes;
  25575. private _refreshFrustumPlanes;
  25576. private _storedFov;
  25577. private _stateStored;
  25578. /**
  25579. * Instantiates a new camera object.
  25580. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25581. * @see http://doc.babylonjs.com/features/cameras
  25582. * @param name Defines the name of the camera in the scene
  25583. * @param position Defines the position of the camera
  25584. * @param scene Defines the scene the camera belongs too
  25585. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25586. */
  25587. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25588. /**
  25589. * Store current camera state (fov, position, etc..)
  25590. * @returns the camera
  25591. */
  25592. storeState(): Camera;
  25593. /**
  25594. * Restores the camera state values if it has been stored. You must call storeState() first
  25595. */
  25596. protected _restoreStateValues(): boolean;
  25597. /**
  25598. * Restored camera state. You must call storeState() first.
  25599. * @returns true if restored and false otherwise
  25600. */
  25601. restoreState(): boolean;
  25602. /**
  25603. * Gets the class name of the camera.
  25604. * @returns the class name
  25605. */
  25606. getClassName(): string;
  25607. /** @hidden */
  25608. readonly _isCamera: boolean;
  25609. /**
  25610. * Gets a string representation of the camera useful for debug purpose.
  25611. * @param fullDetails Defines that a more verboe level of logging is required
  25612. * @returns the string representation
  25613. */
  25614. toString(fullDetails?: boolean): string;
  25615. /**
  25616. * Gets the current world space position of the camera.
  25617. */
  25618. readonly globalPosition: Vector3;
  25619. /**
  25620. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25621. * @returns the active meshe list
  25622. */
  25623. getActiveMeshes(): SmartArray<AbstractMesh>;
  25624. /**
  25625. * Check wether a mesh is part of the current active mesh list of the camera
  25626. * @param mesh Defines the mesh to check
  25627. * @returns true if active, false otherwise
  25628. */
  25629. isActiveMesh(mesh: Mesh): boolean;
  25630. /**
  25631. * Is this camera ready to be used/rendered
  25632. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25633. * @return true if the camera is ready
  25634. */
  25635. isReady(completeCheck?: boolean): boolean;
  25636. /** @hidden */
  25637. _initCache(): void;
  25638. /** @hidden */
  25639. _updateCache(ignoreParentClass?: boolean): void;
  25640. /** @hidden */
  25641. _isSynchronized(): boolean;
  25642. /** @hidden */
  25643. _isSynchronizedViewMatrix(): boolean;
  25644. /** @hidden */
  25645. _isSynchronizedProjectionMatrix(): boolean;
  25646. /**
  25647. * Attach the input controls to a specific dom element to get the input from.
  25648. * @param element Defines the element the controls should be listened from
  25649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25650. */
  25651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25652. /**
  25653. * Detach the current controls from the specified dom element.
  25654. * @param element Defines the element to stop listening the inputs from
  25655. */
  25656. detachControl(element: HTMLElement): void;
  25657. /**
  25658. * Update the camera state according to the different inputs gathered during the frame.
  25659. */
  25660. update(): void;
  25661. /** @hidden */
  25662. _checkInputs(): void;
  25663. /** @hidden */
  25664. readonly rigCameras: Camera[];
  25665. /**
  25666. * Gets the post process used by the rig cameras
  25667. */
  25668. readonly rigPostProcess: Nullable<PostProcess>;
  25669. /**
  25670. * Internal, gets the first post proces.
  25671. * @returns the first post process to be run on this camera.
  25672. */
  25673. _getFirstPostProcess(): Nullable<PostProcess>;
  25674. private _cascadePostProcessesToRigCams;
  25675. /**
  25676. * Attach a post process to the camera.
  25677. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25678. * @param postProcess The post process to attach to the camera
  25679. * @param insertAt The position of the post process in case several of them are in use in the scene
  25680. * @returns the position the post process has been inserted at
  25681. */
  25682. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25683. /**
  25684. * Detach a post process to the camera.
  25685. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25686. * @param postProcess The post process to detach from the camera
  25687. */
  25688. detachPostProcess(postProcess: PostProcess): void;
  25689. /**
  25690. * Gets the current world matrix of the camera
  25691. */
  25692. getWorldMatrix(): Matrix;
  25693. /** @hidden */
  25694. _getViewMatrix(): Matrix;
  25695. /**
  25696. * Gets the current view matrix of the camera.
  25697. * @param force forces the camera to recompute the matrix without looking at the cached state
  25698. * @returns the view matrix
  25699. */
  25700. getViewMatrix(force?: boolean): Matrix;
  25701. /**
  25702. * Freeze the projection matrix.
  25703. * It will prevent the cache check of the camera projection compute and can speed up perf
  25704. * if no parameter of the camera are meant to change
  25705. * @param projection Defines manually a projection if necessary
  25706. */
  25707. freezeProjectionMatrix(projection?: Matrix): void;
  25708. /**
  25709. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25710. */
  25711. unfreezeProjectionMatrix(): void;
  25712. /**
  25713. * Gets the current projection matrix of the camera.
  25714. * @param force forces the camera to recompute the matrix without looking at the cached state
  25715. * @returns the projection matrix
  25716. */
  25717. getProjectionMatrix(force?: boolean): Matrix;
  25718. /**
  25719. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25720. * @returns a Matrix
  25721. */
  25722. getTransformationMatrix(): Matrix;
  25723. private _updateFrustumPlanes;
  25724. /**
  25725. * Checks if a cullable object (mesh...) is in the camera frustum
  25726. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25727. * @param target The object to check
  25728. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25729. * @returns true if the object is in frustum otherwise false
  25730. */
  25731. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25732. /**
  25733. * Checks if a cullable object (mesh...) is in the camera frustum
  25734. * Unlike isInFrustum this cheks the full bounding box
  25735. * @param target The object to check
  25736. * @returns true if the object is in frustum otherwise false
  25737. */
  25738. isCompletelyInFrustum(target: ICullable): boolean;
  25739. /**
  25740. * Gets a ray in the forward direction from the camera.
  25741. * @param length Defines the length of the ray to create
  25742. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25743. * @param origin Defines the start point of the ray which defaults to the camera position
  25744. * @returns the forward ray
  25745. */
  25746. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25747. /**
  25748. * Releases resources associated with this node.
  25749. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25750. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25751. */
  25752. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25753. /** @hidden */
  25754. _isLeftCamera: boolean;
  25755. /**
  25756. * Gets the left camera of a rig setup in case of Rigged Camera
  25757. */
  25758. readonly isLeftCamera: boolean;
  25759. /** @hidden */
  25760. _isRightCamera: boolean;
  25761. /**
  25762. * Gets the right camera of a rig setup in case of Rigged Camera
  25763. */
  25764. readonly isRightCamera: boolean;
  25765. /**
  25766. * Gets the left camera of a rig setup in case of Rigged Camera
  25767. */
  25768. readonly leftCamera: Nullable<FreeCamera>;
  25769. /**
  25770. * Gets the right camera of a rig setup in case of Rigged Camera
  25771. */
  25772. readonly rightCamera: Nullable<FreeCamera>;
  25773. /**
  25774. * Gets the left camera target of a rig setup in case of Rigged Camera
  25775. * @returns the target position
  25776. */
  25777. getLeftTarget(): Nullable<Vector3>;
  25778. /**
  25779. * Gets the right camera target of a rig setup in case of Rigged Camera
  25780. * @returns the target position
  25781. */
  25782. getRightTarget(): Nullable<Vector3>;
  25783. /**
  25784. * @hidden
  25785. */
  25786. setCameraRigMode(mode: number, rigParams: any): void;
  25787. /** @hidden */
  25788. static _setStereoscopicRigMode(camera: Camera): void;
  25789. /** @hidden */
  25790. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25791. /** @hidden */
  25792. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25793. /** @hidden */
  25794. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25795. /** @hidden */
  25796. _getVRProjectionMatrix(): Matrix;
  25797. protected _updateCameraRotationMatrix(): void;
  25798. protected _updateWebVRCameraRotationMatrix(): void;
  25799. /**
  25800. * This function MUST be overwritten by the different WebVR cameras available.
  25801. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25802. * @hidden
  25803. */
  25804. _getWebVRProjectionMatrix(): Matrix;
  25805. /**
  25806. * This function MUST be overwritten by the different WebVR cameras available.
  25807. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25808. * @hidden
  25809. */
  25810. _getWebVRViewMatrix(): Matrix;
  25811. /** @hidden */
  25812. setCameraRigParameter(name: string, value: any): void;
  25813. /**
  25814. * needs to be overridden by children so sub has required properties to be copied
  25815. * @hidden
  25816. */
  25817. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25818. /**
  25819. * May need to be overridden by children
  25820. * @hidden
  25821. */
  25822. _updateRigCameras(): void;
  25823. /** @hidden */
  25824. _setupInputs(): void;
  25825. /**
  25826. * Serialiaze the camera setup to a json represention
  25827. * @returns the JSON representation
  25828. */
  25829. serialize(): any;
  25830. /**
  25831. * Clones the current camera.
  25832. * @param name The cloned camera name
  25833. * @returns the cloned camera
  25834. */
  25835. clone(name: string): Camera;
  25836. /**
  25837. * Gets the direction of the camera relative to a given local axis.
  25838. * @param localAxis Defines the reference axis to provide a relative direction.
  25839. * @return the direction
  25840. */
  25841. getDirection(localAxis: Vector3): Vector3;
  25842. /**
  25843. * Returns the current camera absolute rotation
  25844. */
  25845. readonly absoluteRotation: Quaternion;
  25846. /**
  25847. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25848. * @param localAxis Defines the reference axis to provide a relative direction.
  25849. * @param result Defines the vector to store the result in
  25850. */
  25851. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25852. /**
  25853. * Gets a camera constructor for a given camera type
  25854. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25855. * @param name The name of the camera the result will be able to instantiate
  25856. * @param scene The scene the result will construct the camera in
  25857. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25858. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25859. * @returns a factory method to construc the camera
  25860. */
  25861. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25862. /**
  25863. * Compute the world matrix of the camera.
  25864. * @returns the camera workd matrix
  25865. */
  25866. computeWorldMatrix(): Matrix;
  25867. /**
  25868. * Parse a JSON and creates the camera from the parsed information
  25869. * @param parsedCamera The JSON to parse
  25870. * @param scene The scene to instantiate the camera in
  25871. * @returns the newly constructed camera
  25872. */
  25873. static Parse(parsedCamera: any, scene: Scene): Camera;
  25874. }
  25875. }
  25876. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25877. import { Nullable } from "babylonjs/types";
  25878. import { Scene } from "babylonjs/scene";
  25879. import { Vector4 } from "babylonjs/Maths/math.vector";
  25880. import { Mesh } from "babylonjs/Meshes/mesh";
  25881. /**
  25882. * Class containing static functions to help procedurally build meshes
  25883. */
  25884. export class DiscBuilder {
  25885. /**
  25886. * Creates a plane polygonal mesh. By default, this is a disc
  25887. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25888. * * 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
  25889. * * 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
  25890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25893. * @param name defines the name of the mesh
  25894. * @param options defines the options used to create the mesh
  25895. * @param scene defines the hosting scene
  25896. * @returns the plane polygonal mesh
  25897. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25898. */
  25899. static CreateDisc(name: string, options: {
  25900. radius?: number;
  25901. tessellation?: number;
  25902. arc?: number;
  25903. updatable?: boolean;
  25904. sideOrientation?: number;
  25905. frontUVs?: Vector4;
  25906. backUVs?: Vector4;
  25907. }, scene?: Nullable<Scene>): Mesh;
  25908. }
  25909. }
  25910. declare module "babylonjs/Particles/solidParticleSystem" {
  25911. import { Vector3 } from "babylonjs/Maths/math.vector";
  25912. import { Mesh } from "babylonjs/Meshes/mesh";
  25913. import { Scene, IDisposable } from "babylonjs/scene";
  25914. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25915. /**
  25916. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25917. *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.
  25918. * The SPS is also a particle system. It provides some methods to manage the particles.
  25919. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25920. *
  25921. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25922. */
  25923. export class SolidParticleSystem implements IDisposable {
  25924. /**
  25925. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25926. * Example : var p = SPS.particles[i];
  25927. */
  25928. particles: SolidParticle[];
  25929. /**
  25930. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25931. */
  25932. nbParticles: number;
  25933. /**
  25934. * If the particles must ever face the camera (default false). Useful for planar particles.
  25935. */
  25936. billboard: boolean;
  25937. /**
  25938. * Recompute normals when adding a shape
  25939. */
  25940. recomputeNormals: boolean;
  25941. /**
  25942. * This a counter ofr your own usage. It's not set by any SPS functions.
  25943. */
  25944. counter: number;
  25945. /**
  25946. * The SPS name. This name is also given to the underlying mesh.
  25947. */
  25948. name: string;
  25949. /**
  25950. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25951. */
  25952. mesh: Mesh;
  25953. /**
  25954. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25955. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25956. */
  25957. vars: any;
  25958. /**
  25959. * This array is populated when the SPS is set as 'pickable'.
  25960. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25961. * Each element of this array is an object `{idx: int, faceId: int}`.
  25962. * `idx` is the picked particle index in the `SPS.particles` array
  25963. * `faceId` is the picked face index counted within this particle.
  25964. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25965. */
  25966. pickedParticles: {
  25967. idx: number;
  25968. faceId: number;
  25969. }[];
  25970. /**
  25971. * This array is populated when `enableDepthSort` is set to true.
  25972. * Each element of this array is an instance of the class DepthSortedParticle.
  25973. */
  25974. depthSortedParticles: DepthSortedParticle[];
  25975. /**
  25976. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25977. * @hidden
  25978. */
  25979. _bSphereOnly: boolean;
  25980. /**
  25981. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25982. * @hidden
  25983. */
  25984. _bSphereRadiusFactor: number;
  25985. private _scene;
  25986. private _positions;
  25987. private _indices;
  25988. private _normals;
  25989. private _colors;
  25990. private _uvs;
  25991. private _indices32;
  25992. private _positions32;
  25993. private _normals32;
  25994. private _fixedNormal32;
  25995. private _colors32;
  25996. private _uvs32;
  25997. private _index;
  25998. private _updatable;
  25999. private _pickable;
  26000. private _isVisibilityBoxLocked;
  26001. private _alwaysVisible;
  26002. private _depthSort;
  26003. private _shapeCounter;
  26004. private _copy;
  26005. private _color;
  26006. private _computeParticleColor;
  26007. private _computeParticleTexture;
  26008. private _computeParticleRotation;
  26009. private _computeParticleVertex;
  26010. private _computeBoundingBox;
  26011. private _depthSortParticles;
  26012. private _camera;
  26013. private _mustUnrotateFixedNormals;
  26014. private _particlesIntersect;
  26015. private _needs32Bits;
  26016. /**
  26017. * Creates a SPS (Solid Particle System) object.
  26018. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26019. * @param scene (Scene) is the scene in which the SPS is added.
  26020. * @param options defines the options of the sps e.g.
  26021. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26022. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26023. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26024. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26025. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26026. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26027. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26028. */
  26029. constructor(name: string, scene: Scene, options?: {
  26030. updatable?: boolean;
  26031. isPickable?: boolean;
  26032. enableDepthSort?: boolean;
  26033. particleIntersection?: boolean;
  26034. boundingSphereOnly?: boolean;
  26035. bSphereRadiusFactor?: number;
  26036. });
  26037. /**
  26038. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26039. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26040. * @returns the created mesh
  26041. */
  26042. buildMesh(): Mesh;
  26043. /**
  26044. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26045. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26046. * Thus the particles generated from `digest()` have their property `position` set yet.
  26047. * @param mesh ( Mesh ) is the mesh to be digested
  26048. * @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
  26049. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26050. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26051. * @returns the current SPS
  26052. */
  26053. digest(mesh: Mesh, options?: {
  26054. facetNb?: number;
  26055. number?: number;
  26056. delta?: number;
  26057. }): SolidParticleSystem;
  26058. private _unrotateFixedNormals;
  26059. private _resetCopy;
  26060. private _meshBuilder;
  26061. private _posToShape;
  26062. private _uvsToShapeUV;
  26063. private _addParticle;
  26064. /**
  26065. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26066. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26067. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26068. * @param nb (positive integer) the number of particles to be created from this model
  26069. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26070. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26071. * @returns the number of shapes in the system
  26072. */
  26073. addShape(mesh: Mesh, nb: number, options?: {
  26074. positionFunction?: any;
  26075. vertexFunction?: any;
  26076. }): number;
  26077. private _rebuildParticle;
  26078. /**
  26079. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26080. * @returns the SPS.
  26081. */
  26082. rebuildMesh(): SolidParticleSystem;
  26083. /**
  26084. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26085. * This method calls `updateParticle()` for each particle of the SPS.
  26086. * For an animated SPS, it is usually called within the render loop.
  26087. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26088. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26089. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26090. * @returns the SPS.
  26091. */
  26092. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26093. /**
  26094. * Disposes the SPS.
  26095. */
  26096. dispose(): void;
  26097. /**
  26098. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26099. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26100. * @returns the SPS.
  26101. */
  26102. refreshVisibleSize(): SolidParticleSystem;
  26103. /**
  26104. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26105. * @param size the size (float) of the visibility box
  26106. * note : this doesn't lock the SPS mesh bounding box.
  26107. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26108. */
  26109. setVisibilityBox(size: number): void;
  26110. /**
  26111. * Gets whether the SPS as always visible or not
  26112. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26113. */
  26114. /**
  26115. * Sets the SPS as always visible or not
  26116. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26117. */
  26118. isAlwaysVisible: boolean;
  26119. /**
  26120. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26121. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26122. */
  26123. /**
  26124. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26125. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26126. */
  26127. isVisibilityBoxLocked: boolean;
  26128. /**
  26129. * Tells to `setParticles()` to compute the particle rotations or not.
  26130. * Default value : true. The SPS is faster when it's set to false.
  26131. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26132. */
  26133. /**
  26134. * Gets if `setParticles()` computes the particle rotations or not.
  26135. * Default value : true. The SPS is faster when it's set to false.
  26136. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26137. */
  26138. computeParticleRotation: boolean;
  26139. /**
  26140. * Tells to `setParticles()` to compute the particle colors or not.
  26141. * Default value : true. The SPS is faster when it's set to false.
  26142. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26143. */
  26144. /**
  26145. * Gets if `setParticles()` computes the particle colors or not.
  26146. * Default value : true. The SPS is faster when it's set to false.
  26147. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26148. */
  26149. computeParticleColor: boolean;
  26150. /**
  26151. * Gets if `setParticles()` computes the particle textures or not.
  26152. * Default value : true. The SPS is faster when it's set to false.
  26153. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26154. */
  26155. computeParticleTexture: boolean;
  26156. /**
  26157. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26158. * Default value : false. The SPS is faster when it's set to false.
  26159. * Note : the particle custom vertex positions aren't stored values.
  26160. */
  26161. /**
  26162. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26163. * Default value : false. The SPS is faster when it's set to false.
  26164. * Note : the particle custom vertex positions aren't stored values.
  26165. */
  26166. computeParticleVertex: boolean;
  26167. /**
  26168. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26169. */
  26170. /**
  26171. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26172. */
  26173. computeBoundingBox: boolean;
  26174. /**
  26175. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26176. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26177. * Default : `true`
  26178. */
  26179. /**
  26180. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26181. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26182. * Default : `true`
  26183. */
  26184. depthSortParticles: boolean;
  26185. /**
  26186. * This function does nothing. It may be overwritten to set all the particle first values.
  26187. * The SPS doesn't call this function, you may have to call it by your own.
  26188. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26189. */
  26190. initParticles(): void;
  26191. /**
  26192. * This function does nothing. It may be overwritten to recycle a particle.
  26193. * The SPS doesn't call this function, you may have to call it by your own.
  26194. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26195. * @param particle The particle to recycle
  26196. * @returns the recycled particle
  26197. */
  26198. recycleParticle(particle: SolidParticle): SolidParticle;
  26199. /**
  26200. * Updates a particle : this function should be overwritten by the user.
  26201. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26202. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26203. * @example : just set a particle position or velocity and recycle conditions
  26204. * @param particle The particle to update
  26205. * @returns the updated particle
  26206. */
  26207. updateParticle(particle: SolidParticle): SolidParticle;
  26208. /**
  26209. * Updates a vertex of a particle : it can be overwritten by the user.
  26210. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26211. * @param particle the current particle
  26212. * @param vertex the current index of the current particle
  26213. * @param pt the index of the current vertex in the particle shape
  26214. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26215. * @example : just set a vertex particle position
  26216. * @returns the updated vertex
  26217. */
  26218. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26219. /**
  26220. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26221. * This does nothing and may be overwritten by the user.
  26222. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26223. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26224. * @param update the boolean update value actually passed to setParticles()
  26225. */
  26226. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26227. /**
  26228. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26229. * This will be passed three parameters.
  26230. * This does nothing and may be overwritten by the user.
  26231. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26232. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26233. * @param update the boolean update value actually passed to setParticles()
  26234. */
  26235. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26236. }
  26237. }
  26238. declare module "babylonjs/Particles/solidParticle" {
  26239. import { Nullable } from "babylonjs/types";
  26240. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26241. import { Color4 } from "babylonjs/Maths/math.color";
  26242. import { Mesh } from "babylonjs/Meshes/mesh";
  26243. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26244. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26245. import { Plane } from "babylonjs/Maths/math.plane";
  26246. /**
  26247. * Represents one particle of a solid particle system.
  26248. */
  26249. export class SolidParticle {
  26250. /**
  26251. * particle global index
  26252. */
  26253. idx: number;
  26254. /**
  26255. * The color of the particle
  26256. */
  26257. color: Nullable<Color4>;
  26258. /**
  26259. * The world space position of the particle.
  26260. */
  26261. position: Vector3;
  26262. /**
  26263. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26264. */
  26265. rotation: Vector3;
  26266. /**
  26267. * The world space rotation quaternion of the particle.
  26268. */
  26269. rotationQuaternion: Nullable<Quaternion>;
  26270. /**
  26271. * The scaling of the particle.
  26272. */
  26273. scaling: Vector3;
  26274. /**
  26275. * The uvs of the particle.
  26276. */
  26277. uvs: Vector4;
  26278. /**
  26279. * The current speed of the particle.
  26280. */
  26281. velocity: Vector3;
  26282. /**
  26283. * The pivot point in the particle local space.
  26284. */
  26285. pivot: Vector3;
  26286. /**
  26287. * Must the particle be translated from its pivot point in its local space ?
  26288. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26289. * Default : false
  26290. */
  26291. translateFromPivot: boolean;
  26292. /**
  26293. * Is the particle active or not ?
  26294. */
  26295. alive: boolean;
  26296. /**
  26297. * Is the particle visible or not ?
  26298. */
  26299. isVisible: boolean;
  26300. /**
  26301. * Index of this particle in the global "positions" array (Internal use)
  26302. * @hidden
  26303. */
  26304. _pos: number;
  26305. /**
  26306. * @hidden Index of this particle in the global "indices" array (Internal use)
  26307. */
  26308. _ind: number;
  26309. /**
  26310. * @hidden ModelShape of this particle (Internal use)
  26311. */
  26312. _model: ModelShape;
  26313. /**
  26314. * ModelShape id of this particle
  26315. */
  26316. shapeId: number;
  26317. /**
  26318. * Index of the particle in its shape id
  26319. */
  26320. idxInShape: number;
  26321. /**
  26322. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26323. */
  26324. _modelBoundingInfo: BoundingInfo;
  26325. /**
  26326. * @hidden Particle BoundingInfo object (Internal use)
  26327. */
  26328. _boundingInfo: BoundingInfo;
  26329. /**
  26330. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26331. */
  26332. _sps: SolidParticleSystem;
  26333. /**
  26334. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26335. */
  26336. _stillInvisible: boolean;
  26337. /**
  26338. * @hidden Last computed particle rotation matrix
  26339. */
  26340. _rotationMatrix: number[];
  26341. /**
  26342. * Parent particle Id, if any.
  26343. * Default null.
  26344. */
  26345. parentId: Nullable<number>;
  26346. /**
  26347. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26348. * The possible values are :
  26349. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26350. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26351. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26352. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26353. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26354. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26355. * */
  26356. cullingStrategy: number;
  26357. /**
  26358. * @hidden Internal global position in the SPS.
  26359. */
  26360. _globalPosition: Vector3;
  26361. /**
  26362. * Creates a Solid Particle object.
  26363. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26364. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26365. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26366. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26367. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26368. * @param shapeId (integer) is the model shape identifier in the SPS.
  26369. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26370. * @param sps defines the sps it is associated to
  26371. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26372. */
  26373. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26374. /**
  26375. * Legacy support, changed scale to scaling
  26376. */
  26377. /**
  26378. * Legacy support, changed scale to scaling
  26379. */
  26380. scale: Vector3;
  26381. /**
  26382. * Legacy support, changed quaternion to rotationQuaternion
  26383. */
  26384. /**
  26385. * Legacy support, changed quaternion to rotationQuaternion
  26386. */
  26387. quaternion: Nullable<Quaternion>;
  26388. /**
  26389. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26390. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26391. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26392. * @returns true if it intersects
  26393. */
  26394. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26395. /**
  26396. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26397. * A particle is in the frustum if its bounding box intersects the frustum
  26398. * @param frustumPlanes defines the frustum to test
  26399. * @returns true if the particle is in the frustum planes
  26400. */
  26401. isInFrustum(frustumPlanes: Plane[]): boolean;
  26402. /**
  26403. * get the rotation matrix of the particle
  26404. * @hidden
  26405. */
  26406. getRotationMatrix(m: Matrix): void;
  26407. }
  26408. /**
  26409. * Represents the shape of the model used by one particle of a solid particle system.
  26410. * SPS internal tool, don't use it manually.
  26411. */
  26412. export class ModelShape {
  26413. /**
  26414. * The shape id
  26415. * @hidden
  26416. */
  26417. shapeID: number;
  26418. /**
  26419. * flat array of model positions (internal use)
  26420. * @hidden
  26421. */
  26422. _shape: Vector3[];
  26423. /**
  26424. * flat array of model UVs (internal use)
  26425. * @hidden
  26426. */
  26427. _shapeUV: number[];
  26428. /**
  26429. * length of the shape in the model indices array (internal use)
  26430. * @hidden
  26431. */
  26432. _indicesLength: number;
  26433. /**
  26434. * Custom position function (internal use)
  26435. * @hidden
  26436. */
  26437. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26438. /**
  26439. * Custom vertex function (internal use)
  26440. * @hidden
  26441. */
  26442. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26443. /**
  26444. * 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.
  26445. * SPS internal tool, don't use it manually.
  26446. * @hidden
  26447. */
  26448. 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>);
  26449. }
  26450. /**
  26451. * Represents a Depth Sorted Particle in the solid particle system.
  26452. */
  26453. export class DepthSortedParticle {
  26454. /**
  26455. * Index of the particle in the "indices" array
  26456. */
  26457. ind: number;
  26458. /**
  26459. * Length of the particle shape in the "indices" array
  26460. */
  26461. indicesLength: number;
  26462. /**
  26463. * Squared distance from the particle to the camera
  26464. */
  26465. sqDistance: number;
  26466. }
  26467. }
  26468. declare module "babylonjs/Collisions/meshCollisionData" {
  26469. import { Collider } from "babylonjs/Collisions/collider";
  26470. import { Vector3 } from "babylonjs/Maths/math.vector";
  26471. import { Nullable } from "babylonjs/types";
  26472. import { Observer } from "babylonjs/Misc/observable";
  26473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26474. /**
  26475. * @hidden
  26476. */
  26477. export class _MeshCollisionData {
  26478. _checkCollisions: boolean;
  26479. _collisionMask: number;
  26480. _collisionGroup: number;
  26481. _collider: Nullable<Collider>;
  26482. _oldPositionForCollisions: Vector3;
  26483. _diffPositionForCollisions: Vector3;
  26484. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26485. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26486. }
  26487. }
  26488. declare module "babylonjs/Meshes/abstractMesh" {
  26489. import { Observable } from "babylonjs/Misc/observable";
  26490. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26491. import { Camera } from "babylonjs/Cameras/camera";
  26492. import { Scene, IDisposable } from "babylonjs/scene";
  26493. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26494. import { Node } from "babylonjs/node";
  26495. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26496. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26497. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26498. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26499. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26500. import { Material } from "babylonjs/Materials/material";
  26501. import { Light } from "babylonjs/Lights/light";
  26502. import { Skeleton } from "babylonjs/Bones/skeleton";
  26503. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26504. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26505. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26506. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26507. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26508. import { Plane } from "babylonjs/Maths/math.plane";
  26509. import { Ray } from "babylonjs/Culling/ray";
  26510. import { Collider } from "babylonjs/Collisions/collider";
  26511. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26512. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26513. /** @hidden */
  26514. class _FacetDataStorage {
  26515. facetPositions: Vector3[];
  26516. facetNormals: Vector3[];
  26517. facetPartitioning: number[][];
  26518. facetNb: number;
  26519. partitioningSubdivisions: number;
  26520. partitioningBBoxRatio: number;
  26521. facetDataEnabled: boolean;
  26522. facetParameters: any;
  26523. bbSize: Vector3;
  26524. subDiv: {
  26525. max: number;
  26526. X: number;
  26527. Y: number;
  26528. Z: number;
  26529. };
  26530. facetDepthSort: boolean;
  26531. facetDepthSortEnabled: boolean;
  26532. depthSortedIndices: IndicesArray;
  26533. depthSortedFacets: {
  26534. ind: number;
  26535. sqDistance: number;
  26536. }[];
  26537. facetDepthSortFunction: (f1: {
  26538. ind: number;
  26539. sqDistance: number;
  26540. }, f2: {
  26541. ind: number;
  26542. sqDistance: number;
  26543. }) => number;
  26544. facetDepthSortFrom: Vector3;
  26545. facetDepthSortOrigin: Vector3;
  26546. invertedMatrix: Matrix;
  26547. }
  26548. /**
  26549. * @hidden
  26550. **/
  26551. class _InternalAbstractMeshDataInfo {
  26552. _hasVertexAlpha: boolean;
  26553. _useVertexColors: boolean;
  26554. _numBoneInfluencers: number;
  26555. _applyFog: boolean;
  26556. _receiveShadows: boolean;
  26557. _facetData: _FacetDataStorage;
  26558. _visibility: number;
  26559. _skeleton: Nullable<Skeleton>;
  26560. _layerMask: number;
  26561. _computeBonesUsingShaders: boolean;
  26562. _isActive: boolean;
  26563. _onlyForInstances: boolean;
  26564. _isActiveIntermediate: boolean;
  26565. _onlyForInstancesIntermediate: boolean;
  26566. }
  26567. /**
  26568. * Class used to store all common mesh properties
  26569. */
  26570. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26571. /** No occlusion */
  26572. static OCCLUSION_TYPE_NONE: number;
  26573. /** Occlusion set to optimisitic */
  26574. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26575. /** Occlusion set to strict */
  26576. static OCCLUSION_TYPE_STRICT: number;
  26577. /** Use an accurante occlusion algorithm */
  26578. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26579. /** Use a conservative occlusion algorithm */
  26580. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26581. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26582. * Test order :
  26583. * Is the bounding sphere outside the frustum ?
  26584. * If not, are the bounding box vertices outside the frustum ?
  26585. * It not, then the cullable object is in the frustum.
  26586. */
  26587. static readonly CULLINGSTRATEGY_STANDARD: number;
  26588. /** Culling strategy : Bounding Sphere Only.
  26589. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26590. * It's also less accurate than the standard because some not visible objects can still be selected.
  26591. * Test : is the bounding sphere outside the frustum ?
  26592. * If not, then the cullable object is in the frustum.
  26593. */
  26594. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26595. /** Culling strategy : Optimistic Inclusion.
  26596. * This in an inclusion test first, then the standard exclusion test.
  26597. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26598. * 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.
  26599. * Anyway, it's as accurate as the standard strategy.
  26600. * Test :
  26601. * Is the cullable object bounding sphere center in the frustum ?
  26602. * If not, apply the default culling strategy.
  26603. */
  26604. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26605. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26606. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26607. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26608. * 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.
  26609. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26610. * Test :
  26611. * Is the cullable object bounding sphere center in the frustum ?
  26612. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26613. */
  26614. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26615. /**
  26616. * No billboard
  26617. */
  26618. static readonly BILLBOARDMODE_NONE: number;
  26619. /** Billboard on X axis */
  26620. static readonly BILLBOARDMODE_X: number;
  26621. /** Billboard on Y axis */
  26622. static readonly BILLBOARDMODE_Y: number;
  26623. /** Billboard on Z axis */
  26624. static readonly BILLBOARDMODE_Z: number;
  26625. /** Billboard on all axes */
  26626. static readonly BILLBOARDMODE_ALL: number;
  26627. /** Billboard on using position instead of orientation */
  26628. static readonly BILLBOARDMODE_USE_POSITION: number;
  26629. /** @hidden */
  26630. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26631. /**
  26632. * The culling strategy to use to check whether the mesh must be rendered or not.
  26633. * This value can be changed at any time and will be used on the next render mesh selection.
  26634. * The possible values are :
  26635. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26636. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26637. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26638. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26639. * Please read each static variable documentation to get details about the culling process.
  26640. * */
  26641. cullingStrategy: number;
  26642. /**
  26643. * Gets the number of facets in the mesh
  26644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26645. */
  26646. readonly facetNb: number;
  26647. /**
  26648. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26650. */
  26651. partitioningSubdivisions: number;
  26652. /**
  26653. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26654. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26655. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26656. */
  26657. partitioningBBoxRatio: number;
  26658. /**
  26659. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26660. * Works only for updatable meshes.
  26661. * Doesn't work with multi-materials
  26662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26663. */
  26664. mustDepthSortFacets: boolean;
  26665. /**
  26666. * The location (Vector3) where the facet depth sort must be computed from.
  26667. * By default, the active camera position.
  26668. * Used only when facet depth sort is enabled
  26669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26670. */
  26671. facetDepthSortFrom: Vector3;
  26672. /**
  26673. * gets a boolean indicating if facetData is enabled
  26674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26675. */
  26676. readonly isFacetDataEnabled: boolean;
  26677. /** @hidden */
  26678. _updateNonUniformScalingState(value: boolean): boolean;
  26679. /**
  26680. * An event triggered when this mesh collides with another one
  26681. */
  26682. onCollideObservable: Observable<AbstractMesh>;
  26683. /** Set a function to call when this mesh collides with another one */
  26684. onCollide: () => void;
  26685. /**
  26686. * An event triggered when the collision's position changes
  26687. */
  26688. onCollisionPositionChangeObservable: Observable<Vector3>;
  26689. /** Set a function to call when the collision's position changes */
  26690. onCollisionPositionChange: () => void;
  26691. /**
  26692. * An event triggered when material is changed
  26693. */
  26694. onMaterialChangedObservable: Observable<AbstractMesh>;
  26695. /**
  26696. * Gets or sets the orientation for POV movement & rotation
  26697. */
  26698. definedFacingForward: boolean;
  26699. /** @hidden */
  26700. _occlusionQuery: Nullable<WebGLQuery>;
  26701. /** @hidden */
  26702. _renderingGroup: Nullable<RenderingGroup>;
  26703. /**
  26704. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26705. */
  26706. /**
  26707. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26708. */
  26709. visibility: number;
  26710. /** Gets or sets the alpha index used to sort transparent meshes
  26711. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26712. */
  26713. alphaIndex: number;
  26714. /**
  26715. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26716. */
  26717. isVisible: boolean;
  26718. /**
  26719. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26720. */
  26721. isPickable: boolean;
  26722. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26723. showSubMeshesBoundingBox: boolean;
  26724. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26725. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26726. */
  26727. isBlocker: boolean;
  26728. /**
  26729. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26730. */
  26731. enablePointerMoveEvents: boolean;
  26732. /**
  26733. * Specifies the rendering group id for this mesh (0 by default)
  26734. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26735. */
  26736. renderingGroupId: number;
  26737. private _material;
  26738. /** Gets or sets current material */
  26739. material: Nullable<Material>;
  26740. /**
  26741. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26742. * @see http://doc.babylonjs.com/babylon101/shadows
  26743. */
  26744. receiveShadows: boolean;
  26745. /** Defines color to use when rendering outline */
  26746. outlineColor: Color3;
  26747. /** Define width to use when rendering outline */
  26748. outlineWidth: number;
  26749. /** Defines color to use when rendering overlay */
  26750. overlayColor: Color3;
  26751. /** Defines alpha to use when rendering overlay */
  26752. overlayAlpha: number;
  26753. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26754. hasVertexAlpha: boolean;
  26755. /** 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) */
  26756. useVertexColors: boolean;
  26757. /**
  26758. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26759. */
  26760. computeBonesUsingShaders: boolean;
  26761. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26762. numBoneInfluencers: number;
  26763. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26764. applyFog: boolean;
  26765. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26766. useOctreeForRenderingSelection: boolean;
  26767. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26768. useOctreeForPicking: boolean;
  26769. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26770. useOctreeForCollisions: boolean;
  26771. /**
  26772. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26773. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26774. */
  26775. layerMask: number;
  26776. /**
  26777. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26778. */
  26779. alwaysSelectAsActiveMesh: boolean;
  26780. /**
  26781. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26782. */
  26783. doNotSyncBoundingInfo: boolean;
  26784. /**
  26785. * Gets or sets the current action manager
  26786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26787. */
  26788. actionManager: Nullable<AbstractActionManager>;
  26789. private _meshCollisionData;
  26790. /**
  26791. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26792. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26793. */
  26794. ellipsoid: Vector3;
  26795. /**
  26796. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26797. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26798. */
  26799. ellipsoidOffset: Vector3;
  26800. /**
  26801. * Gets or sets a collision mask used to mask collisions (default is -1).
  26802. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26803. */
  26804. collisionMask: number;
  26805. /**
  26806. * Gets or sets the current collision group mask (-1 by default).
  26807. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26808. */
  26809. collisionGroup: number;
  26810. /**
  26811. * Defines edge width used when edgesRenderer is enabled
  26812. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26813. */
  26814. edgesWidth: number;
  26815. /**
  26816. * Defines edge color used when edgesRenderer is enabled
  26817. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26818. */
  26819. edgesColor: Color4;
  26820. /** @hidden */
  26821. _edgesRenderer: Nullable<IEdgesRenderer>;
  26822. /** @hidden */
  26823. _masterMesh: Nullable<AbstractMesh>;
  26824. /** @hidden */
  26825. _boundingInfo: Nullable<BoundingInfo>;
  26826. /** @hidden */
  26827. _renderId: number;
  26828. /**
  26829. * Gets or sets the list of subMeshes
  26830. * @see http://doc.babylonjs.com/how_to/multi_materials
  26831. */
  26832. subMeshes: SubMesh[];
  26833. /** @hidden */
  26834. _intersectionsInProgress: AbstractMesh[];
  26835. /** @hidden */
  26836. _unIndexed: boolean;
  26837. /** @hidden */
  26838. _lightSources: Light[];
  26839. /** Gets the list of lights affecting that mesh */
  26840. readonly lightSources: Light[];
  26841. /** @hidden */
  26842. readonly _positions: Nullable<Vector3[]>;
  26843. /** @hidden */
  26844. _waitingData: {
  26845. lods: Nullable<any>;
  26846. actions: Nullable<any>;
  26847. freezeWorldMatrix: Nullable<boolean>;
  26848. };
  26849. /** @hidden */
  26850. _bonesTransformMatrices: Nullable<Float32Array>;
  26851. /** @hidden */
  26852. _transformMatrixTexture: Nullable<RawTexture>;
  26853. /**
  26854. * Gets or sets a skeleton to apply skining transformations
  26855. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26856. */
  26857. skeleton: Nullable<Skeleton>;
  26858. /**
  26859. * An event triggered when the mesh is rebuilt.
  26860. */
  26861. onRebuildObservable: Observable<AbstractMesh>;
  26862. /**
  26863. * Creates a new AbstractMesh
  26864. * @param name defines the name of the mesh
  26865. * @param scene defines the hosting scene
  26866. */
  26867. constructor(name: string, scene?: Nullable<Scene>);
  26868. /**
  26869. * Returns the string "AbstractMesh"
  26870. * @returns "AbstractMesh"
  26871. */
  26872. getClassName(): string;
  26873. /**
  26874. * Gets a string representation of the current mesh
  26875. * @param fullDetails defines a boolean indicating if full details must be included
  26876. * @returns a string representation of the current mesh
  26877. */
  26878. toString(fullDetails?: boolean): string;
  26879. /**
  26880. * @hidden
  26881. */
  26882. protected _getEffectiveParent(): Nullable<Node>;
  26883. /** @hidden */
  26884. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26885. /** @hidden */
  26886. _rebuild(): void;
  26887. /** @hidden */
  26888. _resyncLightSources(): void;
  26889. /** @hidden */
  26890. _resyncLighSource(light: Light): void;
  26891. /** @hidden */
  26892. _unBindEffect(): void;
  26893. /** @hidden */
  26894. _removeLightSource(light: Light, dispose: boolean): void;
  26895. private _markSubMeshesAsDirty;
  26896. /** @hidden */
  26897. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26898. /** @hidden */
  26899. _markSubMeshesAsAttributesDirty(): void;
  26900. /** @hidden */
  26901. _markSubMeshesAsMiscDirty(): void;
  26902. /**
  26903. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26904. */
  26905. scaling: Vector3;
  26906. /**
  26907. * Returns true if the mesh is blocked. Implemented by child classes
  26908. */
  26909. readonly isBlocked: boolean;
  26910. /**
  26911. * Returns the mesh itself by default. Implemented by child classes
  26912. * @param camera defines the camera to use to pick the right LOD level
  26913. * @returns the currentAbstractMesh
  26914. */
  26915. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26916. /**
  26917. * Returns 0 by default. Implemented by child classes
  26918. * @returns an integer
  26919. */
  26920. getTotalVertices(): number;
  26921. /**
  26922. * Returns a positive integer : the total number of indices in this mesh geometry.
  26923. * @returns the numner of indices or zero if the mesh has no geometry.
  26924. */
  26925. getTotalIndices(): number;
  26926. /**
  26927. * Returns null by default. Implemented by child classes
  26928. * @returns null
  26929. */
  26930. getIndices(): Nullable<IndicesArray>;
  26931. /**
  26932. * Returns the array of the requested vertex data kind. Implemented by child classes
  26933. * @param kind defines the vertex data kind to use
  26934. * @returns null
  26935. */
  26936. getVerticesData(kind: string): Nullable<FloatArray>;
  26937. /**
  26938. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26939. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26940. * Note that a new underlying VertexBuffer object is created each call.
  26941. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26942. * @param kind defines vertex data kind:
  26943. * * VertexBuffer.PositionKind
  26944. * * VertexBuffer.UVKind
  26945. * * VertexBuffer.UV2Kind
  26946. * * VertexBuffer.UV3Kind
  26947. * * VertexBuffer.UV4Kind
  26948. * * VertexBuffer.UV5Kind
  26949. * * VertexBuffer.UV6Kind
  26950. * * VertexBuffer.ColorKind
  26951. * * VertexBuffer.MatricesIndicesKind
  26952. * * VertexBuffer.MatricesIndicesExtraKind
  26953. * * VertexBuffer.MatricesWeightsKind
  26954. * * VertexBuffer.MatricesWeightsExtraKind
  26955. * @param data defines the data source
  26956. * @param updatable defines if the data must be flagged as updatable (or static)
  26957. * @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
  26958. * @returns the current mesh
  26959. */
  26960. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26961. /**
  26962. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26963. * If the mesh has no geometry, it is simply returned as it is.
  26964. * @param kind defines vertex data kind:
  26965. * * VertexBuffer.PositionKind
  26966. * * VertexBuffer.UVKind
  26967. * * VertexBuffer.UV2Kind
  26968. * * VertexBuffer.UV3Kind
  26969. * * VertexBuffer.UV4Kind
  26970. * * VertexBuffer.UV5Kind
  26971. * * VertexBuffer.UV6Kind
  26972. * * VertexBuffer.ColorKind
  26973. * * VertexBuffer.MatricesIndicesKind
  26974. * * VertexBuffer.MatricesIndicesExtraKind
  26975. * * VertexBuffer.MatricesWeightsKind
  26976. * * VertexBuffer.MatricesWeightsExtraKind
  26977. * @param data defines the data source
  26978. * @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
  26979. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26980. * @returns the current mesh
  26981. */
  26982. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26983. /**
  26984. * Sets the mesh indices,
  26985. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26986. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26987. * @param totalVertices Defines the total number of vertices
  26988. * @returns the current mesh
  26989. */
  26990. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26991. /**
  26992. * Gets a boolean indicating if specific vertex data is present
  26993. * @param kind defines the vertex data kind to use
  26994. * @returns true is data kind is present
  26995. */
  26996. isVerticesDataPresent(kind: string): boolean;
  26997. /**
  26998. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26999. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27000. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27001. * @returns a BoundingInfo
  27002. */
  27003. getBoundingInfo(): BoundingInfo;
  27004. /**
  27005. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27006. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27007. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27008. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27009. * @returns the current mesh
  27010. */
  27011. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27012. /**
  27013. * Overwrite the current bounding info
  27014. * @param boundingInfo defines the new bounding info
  27015. * @returns the current mesh
  27016. */
  27017. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27018. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27019. readonly useBones: boolean;
  27020. /** @hidden */
  27021. _preActivate(): void;
  27022. /** @hidden */
  27023. _preActivateForIntermediateRendering(renderId: number): void;
  27024. /** @hidden */
  27025. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27026. /** @hidden */
  27027. _postActivate(): void;
  27028. /** @hidden */
  27029. _freeze(): void;
  27030. /** @hidden */
  27031. _unFreeze(): void;
  27032. /**
  27033. * Gets the current world matrix
  27034. * @returns a Matrix
  27035. */
  27036. getWorldMatrix(): Matrix;
  27037. /** @hidden */
  27038. _getWorldMatrixDeterminant(): number;
  27039. /**
  27040. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27041. */
  27042. readonly isAnInstance: boolean;
  27043. /**
  27044. * Gets a boolean indicating if this mesh has instances
  27045. */
  27046. readonly hasInstances: boolean;
  27047. /**
  27048. * Perform relative position change from the point of view of behind the front of the mesh.
  27049. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27050. * Supports definition of mesh facing forward or backward
  27051. * @param amountRight defines the distance on the right axis
  27052. * @param amountUp defines the distance on the up axis
  27053. * @param amountForward defines the distance on the forward axis
  27054. * @returns the current mesh
  27055. */
  27056. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27057. /**
  27058. * Calculate relative position change from the point of view of behind the front of the mesh.
  27059. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27060. * Supports definition of mesh facing forward or backward
  27061. * @param amountRight defines the distance on the right axis
  27062. * @param amountUp defines the distance on the up axis
  27063. * @param amountForward defines the distance on the forward axis
  27064. * @returns the new displacement vector
  27065. */
  27066. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27067. /**
  27068. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27069. * Supports definition of mesh facing forward or backward
  27070. * @param flipBack defines the flip
  27071. * @param twirlClockwise defines the twirl
  27072. * @param tiltRight defines the tilt
  27073. * @returns the current mesh
  27074. */
  27075. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27076. /**
  27077. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27078. * Supports definition of mesh facing forward or backward.
  27079. * @param flipBack defines the flip
  27080. * @param twirlClockwise defines the twirl
  27081. * @param tiltRight defines the tilt
  27082. * @returns the new rotation vector
  27083. */
  27084. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27085. /**
  27086. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27087. * This means the mesh underlying bounding box and sphere are recomputed.
  27088. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27089. * @returns the current mesh
  27090. */
  27091. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27092. /** @hidden */
  27093. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27094. /** @hidden */
  27095. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27096. /** @hidden */
  27097. _updateBoundingInfo(): AbstractMesh;
  27098. /** @hidden */
  27099. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27100. /** @hidden */
  27101. protected _afterComputeWorldMatrix(): void;
  27102. /** @hidden */
  27103. readonly _effectiveMesh: AbstractMesh;
  27104. /**
  27105. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27106. * A mesh is in the frustum if its bounding box intersects the frustum
  27107. * @param frustumPlanes defines the frustum to test
  27108. * @returns true if the mesh is in the frustum planes
  27109. */
  27110. isInFrustum(frustumPlanes: Plane[]): boolean;
  27111. /**
  27112. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27113. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27114. * @param frustumPlanes defines the frustum to test
  27115. * @returns true if the mesh is completely in the frustum planes
  27116. */
  27117. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27118. /**
  27119. * True if the mesh intersects another mesh or a SolidParticle object
  27120. * @param mesh defines a target mesh or SolidParticle to test
  27121. * @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)
  27122. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27123. * @returns true if there is an intersection
  27124. */
  27125. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27126. /**
  27127. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27128. * @param point defines the point to test
  27129. * @returns true if there is an intersection
  27130. */
  27131. intersectsPoint(point: Vector3): boolean;
  27132. /**
  27133. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27134. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27135. */
  27136. checkCollisions: boolean;
  27137. /**
  27138. * Gets Collider object used to compute collisions (not physics)
  27139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27140. */
  27141. readonly collider: Nullable<Collider>;
  27142. /**
  27143. * Move the mesh using collision engine
  27144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27145. * @param displacement defines the requested displacement vector
  27146. * @returns the current mesh
  27147. */
  27148. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27149. private _onCollisionPositionChange;
  27150. /** @hidden */
  27151. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27152. /** @hidden */
  27153. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27154. /** @hidden */
  27155. _checkCollision(collider: Collider): AbstractMesh;
  27156. /** @hidden */
  27157. _generatePointsArray(): boolean;
  27158. /**
  27159. * Checks if the passed Ray intersects with the mesh
  27160. * @param ray defines the ray to use
  27161. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27162. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27163. * @returns the picking info
  27164. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27165. */
  27166. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27167. /**
  27168. * Clones the current mesh
  27169. * @param name defines the mesh name
  27170. * @param newParent defines the new mesh parent
  27171. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27172. * @returns the new mesh
  27173. */
  27174. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27175. /**
  27176. * Disposes all the submeshes of the current meshnp
  27177. * @returns the current mesh
  27178. */
  27179. releaseSubMeshes(): AbstractMesh;
  27180. /**
  27181. * Releases resources associated with this abstract mesh.
  27182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27184. */
  27185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27186. /**
  27187. * Adds the passed mesh as a child to the current mesh
  27188. * @param mesh defines the child mesh
  27189. * @returns the current mesh
  27190. */
  27191. addChild(mesh: AbstractMesh): AbstractMesh;
  27192. /**
  27193. * Removes the passed mesh from the current mesh children list
  27194. * @param mesh defines the child mesh
  27195. * @returns the current mesh
  27196. */
  27197. removeChild(mesh: AbstractMesh): AbstractMesh;
  27198. /** @hidden */
  27199. private _initFacetData;
  27200. /**
  27201. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27202. * This method can be called within the render loop.
  27203. * 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
  27204. * @returns the current mesh
  27205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27206. */
  27207. updateFacetData(): AbstractMesh;
  27208. /**
  27209. * Returns the facetLocalNormals array.
  27210. * The normals are expressed in the mesh local spac
  27211. * @returns an array of Vector3
  27212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27213. */
  27214. getFacetLocalNormals(): Vector3[];
  27215. /**
  27216. * Returns the facetLocalPositions array.
  27217. * The facet positions are expressed in the mesh local space
  27218. * @returns an array of Vector3
  27219. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27220. */
  27221. getFacetLocalPositions(): Vector3[];
  27222. /**
  27223. * Returns the facetLocalPartioning array
  27224. * @returns an array of array of numbers
  27225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27226. */
  27227. getFacetLocalPartitioning(): number[][];
  27228. /**
  27229. * Returns the i-th facet position in the world system.
  27230. * This method allocates a new Vector3 per call
  27231. * @param i defines the facet index
  27232. * @returns a new Vector3
  27233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27234. */
  27235. getFacetPosition(i: number): Vector3;
  27236. /**
  27237. * Sets the reference Vector3 with the i-th facet position in the world system
  27238. * @param i defines the facet index
  27239. * @param ref defines the target vector
  27240. * @returns the current mesh
  27241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27242. */
  27243. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27244. /**
  27245. * Returns the i-th facet normal in the world system.
  27246. * This method allocates a new Vector3 per call
  27247. * @param i defines the facet index
  27248. * @returns a new Vector3
  27249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27250. */
  27251. getFacetNormal(i: number): Vector3;
  27252. /**
  27253. * Sets the reference Vector3 with the i-th facet normal in the world system
  27254. * @param i defines the facet index
  27255. * @param ref defines the target vector
  27256. * @returns the current mesh
  27257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27258. */
  27259. getFacetNormalToRef(i: number, ref: Vector3): this;
  27260. /**
  27261. * 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)
  27262. * @param x defines x coordinate
  27263. * @param y defines y coordinate
  27264. * @param z defines z coordinate
  27265. * @returns the array of facet indexes
  27266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27267. */
  27268. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27269. /**
  27270. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27271. * @param projected sets as the (x,y,z) world projection on the facet
  27272. * @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
  27273. * @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
  27274. * @param x defines x coordinate
  27275. * @param y defines y coordinate
  27276. * @param z defines z coordinate
  27277. * @returns the face index if found (or null instead)
  27278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27279. */
  27280. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27281. /**
  27282. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27283. * @param projected sets as the (x,y,z) local projection on the facet
  27284. * @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
  27285. * @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
  27286. * @param x defines x coordinate
  27287. * @param y defines y coordinate
  27288. * @param z defines z coordinate
  27289. * @returns the face index if found (or null instead)
  27290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27291. */
  27292. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27293. /**
  27294. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27295. * @returns the parameters
  27296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27297. */
  27298. getFacetDataParameters(): any;
  27299. /**
  27300. * Disables the feature FacetData and frees the related memory
  27301. * @returns the current mesh
  27302. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27303. */
  27304. disableFacetData(): AbstractMesh;
  27305. /**
  27306. * Updates the AbstractMesh indices array
  27307. * @param indices defines the data source
  27308. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27309. * @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)
  27310. * @returns the current mesh
  27311. */
  27312. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27313. /**
  27314. * Creates new normals data for the mesh
  27315. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27316. * @returns the current mesh
  27317. */
  27318. createNormals(updatable: boolean): AbstractMesh;
  27319. /**
  27320. * Align the mesh with a normal
  27321. * @param normal defines the normal to use
  27322. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27323. * @returns the current mesh
  27324. */
  27325. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27326. /** @hidden */
  27327. _checkOcclusionQuery(): boolean;
  27328. /**
  27329. * Disables the mesh edge rendering mode
  27330. * @returns the currentAbstractMesh
  27331. */
  27332. disableEdgesRendering(): AbstractMesh;
  27333. /**
  27334. * Enables the edge rendering mode on the mesh.
  27335. * This mode makes the mesh edges visible
  27336. * @param epsilon defines the maximal distance between two angles to detect a face
  27337. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27338. * @returns the currentAbstractMesh
  27339. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27340. */
  27341. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27342. }
  27343. }
  27344. declare module "babylonjs/Actions/actionEvent" {
  27345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27346. import { Nullable } from "babylonjs/types";
  27347. import { Sprite } from "babylonjs/Sprites/sprite";
  27348. import { Scene } from "babylonjs/scene";
  27349. import { Vector2 } from "babylonjs/Maths/math.vector";
  27350. /**
  27351. * Interface used to define ActionEvent
  27352. */
  27353. export interface IActionEvent {
  27354. /** The mesh or sprite that triggered the action */
  27355. source: any;
  27356. /** The X mouse cursor position at the time of the event */
  27357. pointerX: number;
  27358. /** The Y mouse cursor position at the time of the event */
  27359. pointerY: number;
  27360. /** The mesh that is currently pointed at (can be null) */
  27361. meshUnderPointer: Nullable<AbstractMesh>;
  27362. /** the original (browser) event that triggered the ActionEvent */
  27363. sourceEvent?: any;
  27364. /** additional data for the event */
  27365. additionalData?: any;
  27366. }
  27367. /**
  27368. * ActionEvent is the event being sent when an action is triggered.
  27369. */
  27370. export class ActionEvent implements IActionEvent {
  27371. /** The mesh or sprite that triggered the action */
  27372. source: any;
  27373. /** The X mouse cursor position at the time of the event */
  27374. pointerX: number;
  27375. /** The Y mouse cursor position at the time of the event */
  27376. pointerY: number;
  27377. /** The mesh that is currently pointed at (can be null) */
  27378. meshUnderPointer: Nullable<AbstractMesh>;
  27379. /** the original (browser) event that triggered the ActionEvent */
  27380. sourceEvent?: any;
  27381. /** additional data for the event */
  27382. additionalData?: any;
  27383. /**
  27384. * Creates a new ActionEvent
  27385. * @param source The mesh or sprite that triggered the action
  27386. * @param pointerX The X mouse cursor position at the time of the event
  27387. * @param pointerY The Y mouse cursor position at the time of the event
  27388. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27389. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27390. * @param additionalData additional data for the event
  27391. */
  27392. constructor(
  27393. /** The mesh or sprite that triggered the action */
  27394. source: any,
  27395. /** The X mouse cursor position at the time of the event */
  27396. pointerX: number,
  27397. /** The Y mouse cursor position at the time of the event */
  27398. pointerY: number,
  27399. /** The mesh that is currently pointed at (can be null) */
  27400. meshUnderPointer: Nullable<AbstractMesh>,
  27401. /** the original (browser) event that triggered the ActionEvent */
  27402. sourceEvent?: any,
  27403. /** additional data for the event */
  27404. additionalData?: any);
  27405. /**
  27406. * Helper function to auto-create an ActionEvent from a source mesh.
  27407. * @param source The source mesh that triggered the event
  27408. * @param evt The original (browser) event
  27409. * @param additionalData additional data for the event
  27410. * @returns the new ActionEvent
  27411. */
  27412. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27413. /**
  27414. * Helper function to auto-create an ActionEvent from a source sprite
  27415. * @param source The source sprite that triggered the event
  27416. * @param scene Scene associated with the sprite
  27417. * @param evt The original (browser) event
  27418. * @param additionalData additional data for the event
  27419. * @returns the new ActionEvent
  27420. */
  27421. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27422. /**
  27423. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27424. * @param scene the scene where the event occurred
  27425. * @param evt The original (browser) event
  27426. * @returns the new ActionEvent
  27427. */
  27428. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27429. /**
  27430. * Helper function to auto-create an ActionEvent from a primitive
  27431. * @param prim defines the target primitive
  27432. * @param pointerPos defines the pointer position
  27433. * @param evt The original (browser) event
  27434. * @param additionalData additional data for the event
  27435. * @returns the new ActionEvent
  27436. */
  27437. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27438. }
  27439. }
  27440. declare module "babylonjs/Actions/abstractActionManager" {
  27441. import { IDisposable } from "babylonjs/scene";
  27442. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27443. import { IAction } from "babylonjs/Actions/action";
  27444. import { Nullable } from "babylonjs/types";
  27445. /**
  27446. * Abstract class used to decouple action Manager from scene and meshes.
  27447. * Do not instantiate.
  27448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27449. */
  27450. export abstract class AbstractActionManager implements IDisposable {
  27451. /** Gets the list of active triggers */
  27452. static Triggers: {
  27453. [key: string]: number;
  27454. };
  27455. /** Gets the cursor to use when hovering items */
  27456. hoverCursor: string;
  27457. /** Gets the list of actions */
  27458. actions: IAction[];
  27459. /**
  27460. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27461. */
  27462. isRecursive: boolean;
  27463. /**
  27464. * Releases all associated resources
  27465. */
  27466. abstract dispose(): void;
  27467. /**
  27468. * Does this action manager has pointer triggers
  27469. */
  27470. abstract readonly hasPointerTriggers: boolean;
  27471. /**
  27472. * Does this action manager has pick triggers
  27473. */
  27474. abstract readonly hasPickTriggers: boolean;
  27475. /**
  27476. * Process a specific trigger
  27477. * @param trigger defines the trigger to process
  27478. * @param evt defines the event details to be processed
  27479. */
  27480. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27481. /**
  27482. * Does this action manager handles actions of any of the given triggers
  27483. * @param triggers defines the triggers to be tested
  27484. * @return a boolean indicating whether one (or more) of the triggers is handled
  27485. */
  27486. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27487. /**
  27488. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27489. * speed.
  27490. * @param triggerA defines the trigger to be tested
  27491. * @param triggerB defines the trigger to be tested
  27492. * @return a boolean indicating whether one (or more) of the triggers is handled
  27493. */
  27494. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27495. /**
  27496. * Does this action manager handles actions of a given trigger
  27497. * @param trigger defines the trigger to be tested
  27498. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27499. * @return whether the trigger is handled
  27500. */
  27501. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27502. /**
  27503. * Serialize this manager to a JSON object
  27504. * @param name defines the property name to store this manager
  27505. * @returns a JSON representation of this manager
  27506. */
  27507. abstract serialize(name: string): any;
  27508. /**
  27509. * Registers an action to this action manager
  27510. * @param action defines the action to be registered
  27511. * @return the action amended (prepared) after registration
  27512. */
  27513. abstract registerAction(action: IAction): Nullable<IAction>;
  27514. /**
  27515. * Unregisters an action to this action manager
  27516. * @param action defines the action to be unregistered
  27517. * @return a boolean indicating whether the action has been unregistered
  27518. */
  27519. abstract unregisterAction(action: IAction): Boolean;
  27520. /**
  27521. * Does exist one action manager with at least one trigger
  27522. **/
  27523. static readonly HasTriggers: boolean;
  27524. /**
  27525. * Does exist one action manager with at least one pick trigger
  27526. **/
  27527. static readonly HasPickTriggers: boolean;
  27528. /**
  27529. * Does exist one action manager that handles actions of a given trigger
  27530. * @param trigger defines the trigger to be tested
  27531. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27532. **/
  27533. static HasSpecificTrigger(trigger: number): boolean;
  27534. }
  27535. }
  27536. declare module "babylonjs/node" {
  27537. import { Scene } from "babylonjs/scene";
  27538. import { Nullable } from "babylonjs/types";
  27539. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27540. import { Engine } from "babylonjs/Engines/engine";
  27541. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27542. import { Observable } from "babylonjs/Misc/observable";
  27543. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27544. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27545. import { Animatable } from "babylonjs/Animations/animatable";
  27546. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27547. import { Animation } from "babylonjs/Animations/animation";
  27548. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27550. /**
  27551. * Defines how a node can be built from a string name.
  27552. */
  27553. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27554. /**
  27555. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27556. */
  27557. export class Node implements IBehaviorAware<Node> {
  27558. /** @hidden */
  27559. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27560. private static _NodeConstructors;
  27561. /**
  27562. * Add a new node constructor
  27563. * @param type defines the type name of the node to construct
  27564. * @param constructorFunc defines the constructor function
  27565. */
  27566. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27567. /**
  27568. * Returns a node constructor based on type name
  27569. * @param type defines the type name
  27570. * @param name defines the new node name
  27571. * @param scene defines the hosting scene
  27572. * @param options defines optional options to transmit to constructors
  27573. * @returns the new constructor or null
  27574. */
  27575. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27576. /**
  27577. * Gets or sets the name of the node
  27578. */
  27579. name: string;
  27580. /**
  27581. * Gets or sets the id of the node
  27582. */
  27583. id: string;
  27584. /**
  27585. * Gets or sets the unique id of the node
  27586. */
  27587. uniqueId: number;
  27588. /**
  27589. * Gets or sets a string used to store user defined state for the node
  27590. */
  27591. state: string;
  27592. /**
  27593. * Gets or sets an object used to store user defined information for the node
  27594. */
  27595. metadata: any;
  27596. /**
  27597. * For internal use only. Please do not use.
  27598. */
  27599. reservedDataStore: any;
  27600. /**
  27601. * List of inspectable custom properties (used by the Inspector)
  27602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27603. */
  27604. inspectableCustomProperties: IInspectable[];
  27605. /**
  27606. * Gets or sets a boolean used to define if the node must be serialized
  27607. */
  27608. doNotSerialize: boolean;
  27609. /** @hidden */
  27610. _isDisposed: boolean;
  27611. /**
  27612. * Gets a list of Animations associated with the node
  27613. */
  27614. animations: import("babylonjs/Animations/animation").Animation[];
  27615. protected _ranges: {
  27616. [name: string]: Nullable<AnimationRange>;
  27617. };
  27618. /**
  27619. * Callback raised when the node is ready to be used
  27620. */
  27621. onReady: Nullable<(node: Node) => void>;
  27622. private _isEnabled;
  27623. private _isParentEnabled;
  27624. private _isReady;
  27625. /** @hidden */
  27626. _currentRenderId: number;
  27627. private _parentUpdateId;
  27628. /** @hidden */
  27629. _childUpdateId: number;
  27630. /** @hidden */
  27631. _waitingParentId: Nullable<string>;
  27632. /** @hidden */
  27633. _scene: Scene;
  27634. /** @hidden */
  27635. _cache: any;
  27636. private _parentNode;
  27637. private _children;
  27638. /** @hidden */
  27639. _worldMatrix: Matrix;
  27640. /** @hidden */
  27641. _worldMatrixDeterminant: number;
  27642. /** @hidden */
  27643. _worldMatrixDeterminantIsDirty: boolean;
  27644. /** @hidden */
  27645. private _sceneRootNodesIndex;
  27646. /**
  27647. * Gets a boolean indicating if the node has been disposed
  27648. * @returns true if the node was disposed
  27649. */
  27650. isDisposed(): boolean;
  27651. /**
  27652. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27653. * @see https://doc.babylonjs.com/how_to/parenting
  27654. */
  27655. parent: Nullable<Node>;
  27656. private addToSceneRootNodes;
  27657. private removeFromSceneRootNodes;
  27658. private _animationPropertiesOverride;
  27659. /**
  27660. * Gets or sets the animation properties override
  27661. */
  27662. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27663. /**
  27664. * Gets a string idenfifying the name of the class
  27665. * @returns "Node" string
  27666. */
  27667. getClassName(): string;
  27668. /** @hidden */
  27669. readonly _isNode: boolean;
  27670. /**
  27671. * An event triggered when the mesh is disposed
  27672. */
  27673. onDisposeObservable: Observable<Node>;
  27674. private _onDisposeObserver;
  27675. /**
  27676. * Sets a callback that will be raised when the node will be disposed
  27677. */
  27678. onDispose: () => void;
  27679. /**
  27680. * Creates a new Node
  27681. * @param name the name and id to be given to this node
  27682. * @param scene the scene this node will be added to
  27683. * @param addToRootNodes the node will be added to scene.rootNodes
  27684. */
  27685. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27686. /**
  27687. * Gets the scene of the node
  27688. * @returns a scene
  27689. */
  27690. getScene(): Scene;
  27691. /**
  27692. * Gets the engine of the node
  27693. * @returns a Engine
  27694. */
  27695. getEngine(): Engine;
  27696. private _behaviors;
  27697. /**
  27698. * Attach a behavior to the node
  27699. * @see http://doc.babylonjs.com/features/behaviour
  27700. * @param behavior defines the behavior to attach
  27701. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27702. * @returns the current Node
  27703. */
  27704. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27705. /**
  27706. * Remove an attached behavior
  27707. * @see http://doc.babylonjs.com/features/behaviour
  27708. * @param behavior defines the behavior to attach
  27709. * @returns the current Node
  27710. */
  27711. removeBehavior(behavior: Behavior<Node>): Node;
  27712. /**
  27713. * Gets the list of attached behaviors
  27714. * @see http://doc.babylonjs.com/features/behaviour
  27715. */
  27716. readonly behaviors: Behavior<Node>[];
  27717. /**
  27718. * Gets an attached behavior by name
  27719. * @param name defines the name of the behavior to look for
  27720. * @see http://doc.babylonjs.com/features/behaviour
  27721. * @returns null if behavior was not found else the requested behavior
  27722. */
  27723. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27724. /**
  27725. * Returns the latest update of the World matrix
  27726. * @returns a Matrix
  27727. */
  27728. getWorldMatrix(): Matrix;
  27729. /** @hidden */
  27730. _getWorldMatrixDeterminant(): number;
  27731. /**
  27732. * Returns directly the latest state of the mesh World matrix.
  27733. * A Matrix is returned.
  27734. */
  27735. readonly worldMatrixFromCache: Matrix;
  27736. /** @hidden */
  27737. _initCache(): void;
  27738. /** @hidden */
  27739. updateCache(force?: boolean): void;
  27740. /** @hidden */
  27741. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27742. /** @hidden */
  27743. _updateCache(ignoreParentClass?: boolean): void;
  27744. /** @hidden */
  27745. _isSynchronized(): boolean;
  27746. /** @hidden */
  27747. _markSyncedWithParent(): void;
  27748. /** @hidden */
  27749. isSynchronizedWithParent(): boolean;
  27750. /** @hidden */
  27751. isSynchronized(): boolean;
  27752. /**
  27753. * Is this node ready to be used/rendered
  27754. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27755. * @return true if the node is ready
  27756. */
  27757. isReady(completeCheck?: boolean): boolean;
  27758. /**
  27759. * Is this node enabled?
  27760. * 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
  27761. * @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
  27762. * @return whether this node (and its parent) is enabled
  27763. */
  27764. isEnabled(checkAncestors?: boolean): boolean;
  27765. /** @hidden */
  27766. protected _syncParentEnabledState(): void;
  27767. /**
  27768. * Set the enabled state of this node
  27769. * @param value defines the new enabled state
  27770. */
  27771. setEnabled(value: boolean): void;
  27772. /**
  27773. * Is this node a descendant of the given node?
  27774. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27775. * @param ancestor defines the parent node to inspect
  27776. * @returns a boolean indicating if this node is a descendant of the given node
  27777. */
  27778. isDescendantOf(ancestor: Node): boolean;
  27779. /** @hidden */
  27780. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27781. /**
  27782. * Will return all nodes that have this node as ascendant
  27783. * @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
  27784. * @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
  27785. * @return all children nodes of all types
  27786. */
  27787. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27788. /**
  27789. * Get all child-meshes of this node
  27790. * @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)
  27791. * @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
  27792. * @returns an array of AbstractMesh
  27793. */
  27794. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27795. /**
  27796. * Get all direct children of this node
  27797. * @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
  27798. * @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)
  27799. * @returns an array of Node
  27800. */
  27801. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27802. /** @hidden */
  27803. _setReady(state: boolean): void;
  27804. /**
  27805. * Get an animation by name
  27806. * @param name defines the name of the animation to look for
  27807. * @returns null if not found else the requested animation
  27808. */
  27809. getAnimationByName(name: string): Nullable<Animation>;
  27810. /**
  27811. * Creates an animation range for this node
  27812. * @param name defines the name of the range
  27813. * @param from defines the starting key
  27814. * @param to defines the end key
  27815. */
  27816. createAnimationRange(name: string, from: number, to: number): void;
  27817. /**
  27818. * Delete a specific animation range
  27819. * @param name defines the name of the range to delete
  27820. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27821. */
  27822. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27823. /**
  27824. * Get an animation range by name
  27825. * @param name defines the name of the animation range to look for
  27826. * @returns null if not found else the requested animation range
  27827. */
  27828. getAnimationRange(name: string): Nullable<AnimationRange>;
  27829. /**
  27830. * Gets the list of all animation ranges defined on this node
  27831. * @returns an array
  27832. */
  27833. getAnimationRanges(): Nullable<AnimationRange>[];
  27834. /**
  27835. * Will start the animation sequence
  27836. * @param name defines the range frames for animation sequence
  27837. * @param loop defines if the animation should loop (false by default)
  27838. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27839. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27840. * @returns the object created for this animation. If range does not exist, it will return null
  27841. */
  27842. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27843. /**
  27844. * Serialize animation ranges into a JSON compatible object
  27845. * @returns serialization object
  27846. */
  27847. serializeAnimationRanges(): any;
  27848. /**
  27849. * Computes the world matrix of the node
  27850. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27851. * @returns the world matrix
  27852. */
  27853. computeWorldMatrix(force?: boolean): Matrix;
  27854. /**
  27855. * Releases resources associated with this node.
  27856. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27857. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27858. */
  27859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27860. /**
  27861. * Parse animation range data from a serialization object and store them into a given node
  27862. * @param node defines where to store the animation ranges
  27863. * @param parsedNode defines the serialization object to read data from
  27864. * @param scene defines the hosting scene
  27865. */
  27866. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27867. /**
  27868. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27869. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27870. * @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
  27871. * @returns the new bounding vectors
  27872. */
  27873. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27874. min: Vector3;
  27875. max: Vector3;
  27876. };
  27877. }
  27878. }
  27879. declare module "babylonjs/Animations/animation" {
  27880. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27881. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27882. import { Color3 } from "babylonjs/Maths/math.color";
  27883. import { Nullable } from "babylonjs/types";
  27884. import { Scene } from "babylonjs/scene";
  27885. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27886. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27887. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27888. import { Node } from "babylonjs/node";
  27889. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27890. import { Size } from "babylonjs/Maths/math.size";
  27891. import { Animatable } from "babylonjs/Animations/animatable";
  27892. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27893. /**
  27894. * @hidden
  27895. */
  27896. export class _IAnimationState {
  27897. key: number;
  27898. repeatCount: number;
  27899. workValue?: any;
  27900. loopMode?: number;
  27901. offsetValue?: any;
  27902. highLimitValue?: any;
  27903. }
  27904. /**
  27905. * Class used to store any kind of animation
  27906. */
  27907. export class Animation {
  27908. /**Name of the animation */
  27909. name: string;
  27910. /**Property to animate */
  27911. targetProperty: string;
  27912. /**The frames per second of the animation */
  27913. framePerSecond: number;
  27914. /**The data type of the animation */
  27915. dataType: number;
  27916. /**The loop mode of the animation */
  27917. loopMode?: number | undefined;
  27918. /**Specifies if blending should be enabled */
  27919. enableBlending?: boolean | undefined;
  27920. /**
  27921. * Use matrix interpolation instead of using direct key value when animating matrices
  27922. */
  27923. static AllowMatricesInterpolation: boolean;
  27924. /**
  27925. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27926. */
  27927. static AllowMatrixDecomposeForInterpolation: boolean;
  27928. /**
  27929. * Stores the key frames of the animation
  27930. */
  27931. private _keys;
  27932. /**
  27933. * Stores the easing function of the animation
  27934. */
  27935. private _easingFunction;
  27936. /**
  27937. * @hidden Internal use only
  27938. */
  27939. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27940. /**
  27941. * The set of event that will be linked to this animation
  27942. */
  27943. private _events;
  27944. /**
  27945. * Stores an array of target property paths
  27946. */
  27947. targetPropertyPath: string[];
  27948. /**
  27949. * Stores the blending speed of the animation
  27950. */
  27951. blendingSpeed: number;
  27952. /**
  27953. * Stores the animation ranges for the animation
  27954. */
  27955. private _ranges;
  27956. /**
  27957. * @hidden Internal use
  27958. */
  27959. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27960. /**
  27961. * Sets up an animation
  27962. * @param property The property to animate
  27963. * @param animationType The animation type to apply
  27964. * @param framePerSecond The frames per second of the animation
  27965. * @param easingFunction The easing function used in the animation
  27966. * @returns The created animation
  27967. */
  27968. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27969. /**
  27970. * Create and start an animation on a node
  27971. * @param name defines the name of the global animation that will be run on all nodes
  27972. * @param node defines the root node where the animation will take place
  27973. * @param targetProperty defines property to animate
  27974. * @param framePerSecond defines the number of frame per second yo use
  27975. * @param totalFrame defines the number of frames in total
  27976. * @param from defines the initial value
  27977. * @param to defines the final value
  27978. * @param loopMode defines which loop mode you want to use (off by default)
  27979. * @param easingFunction defines the easing function to use (linear by default)
  27980. * @param onAnimationEnd defines the callback to call when animation end
  27981. * @returns the animatable created for this animation
  27982. */
  27983. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27984. /**
  27985. * Create and start an animation on a node and its descendants
  27986. * @param name defines the name of the global animation that will be run on all nodes
  27987. * @param node defines the root node where the animation will take place
  27988. * @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
  27989. * @param targetProperty defines property to animate
  27990. * @param framePerSecond defines the number of frame per second to use
  27991. * @param totalFrame defines the number of frames in total
  27992. * @param from defines the initial value
  27993. * @param to defines the final value
  27994. * @param loopMode defines which loop mode you want to use (off by default)
  27995. * @param easingFunction defines the easing function to use (linear by default)
  27996. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27997. * @returns the list of animatables created for all nodes
  27998. * @example https://www.babylonjs-playground.com/#MH0VLI
  27999. */
  28000. 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[]>;
  28001. /**
  28002. * Creates a new animation, merges it with the existing animations and starts it
  28003. * @param name Name of the animation
  28004. * @param node Node which contains the scene that begins the animations
  28005. * @param targetProperty Specifies which property to animate
  28006. * @param framePerSecond The frames per second of the animation
  28007. * @param totalFrame The total number of frames
  28008. * @param from The frame at the beginning of the animation
  28009. * @param to The frame at the end of the animation
  28010. * @param loopMode Specifies the loop mode of the animation
  28011. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28012. * @param onAnimationEnd Callback to run once the animation is complete
  28013. * @returns Nullable animation
  28014. */
  28015. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28016. /**
  28017. * Transition property of an host to the target Value
  28018. * @param property The property to transition
  28019. * @param targetValue The target Value of the property
  28020. * @param host The object where the property to animate belongs
  28021. * @param scene Scene used to run the animation
  28022. * @param frameRate Framerate (in frame/s) to use
  28023. * @param transition The transition type we want to use
  28024. * @param duration The duration of the animation, in milliseconds
  28025. * @param onAnimationEnd Callback trigger at the end of the animation
  28026. * @returns Nullable animation
  28027. */
  28028. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28029. /**
  28030. * Return the array of runtime animations currently using this animation
  28031. */
  28032. readonly runtimeAnimations: RuntimeAnimation[];
  28033. /**
  28034. * Specifies if any of the runtime animations are currently running
  28035. */
  28036. readonly hasRunningRuntimeAnimations: boolean;
  28037. /**
  28038. * Initializes the animation
  28039. * @param name Name of the animation
  28040. * @param targetProperty Property to animate
  28041. * @param framePerSecond The frames per second of the animation
  28042. * @param dataType The data type of the animation
  28043. * @param loopMode The loop mode of the animation
  28044. * @param enableBlending Specifies if blending should be enabled
  28045. */
  28046. constructor(
  28047. /**Name of the animation */
  28048. name: string,
  28049. /**Property to animate */
  28050. targetProperty: string,
  28051. /**The frames per second of the animation */
  28052. framePerSecond: number,
  28053. /**The data type of the animation */
  28054. dataType: number,
  28055. /**The loop mode of the animation */
  28056. loopMode?: number | undefined,
  28057. /**Specifies if blending should be enabled */
  28058. enableBlending?: boolean | undefined);
  28059. /**
  28060. * Converts the animation to a string
  28061. * @param fullDetails support for multiple levels of logging within scene loading
  28062. * @returns String form of the animation
  28063. */
  28064. toString(fullDetails?: boolean): string;
  28065. /**
  28066. * Add an event to this animation
  28067. * @param event Event to add
  28068. */
  28069. addEvent(event: AnimationEvent): void;
  28070. /**
  28071. * Remove all events found at the given frame
  28072. * @param frame The frame to remove events from
  28073. */
  28074. removeEvents(frame: number): void;
  28075. /**
  28076. * Retrieves all the events from the animation
  28077. * @returns Events from the animation
  28078. */
  28079. getEvents(): AnimationEvent[];
  28080. /**
  28081. * Creates an animation range
  28082. * @param name Name of the animation range
  28083. * @param from Starting frame of the animation range
  28084. * @param to Ending frame of the animation
  28085. */
  28086. createRange(name: string, from: number, to: number): void;
  28087. /**
  28088. * Deletes an animation range by name
  28089. * @param name Name of the animation range to delete
  28090. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28091. */
  28092. deleteRange(name: string, deleteFrames?: boolean): void;
  28093. /**
  28094. * Gets the animation range by name, or null if not defined
  28095. * @param name Name of the animation range
  28096. * @returns Nullable animation range
  28097. */
  28098. getRange(name: string): Nullable<AnimationRange>;
  28099. /**
  28100. * Gets the key frames from the animation
  28101. * @returns The key frames of the animation
  28102. */
  28103. getKeys(): Array<IAnimationKey>;
  28104. /**
  28105. * Gets the highest frame rate of the animation
  28106. * @returns Highest frame rate of the animation
  28107. */
  28108. getHighestFrame(): number;
  28109. /**
  28110. * Gets the easing function of the animation
  28111. * @returns Easing function of the animation
  28112. */
  28113. getEasingFunction(): IEasingFunction;
  28114. /**
  28115. * Sets the easing function of the animation
  28116. * @param easingFunction A custom mathematical formula for animation
  28117. */
  28118. setEasingFunction(easingFunction: EasingFunction): void;
  28119. /**
  28120. * Interpolates a scalar linearly
  28121. * @param startValue Start value of the animation curve
  28122. * @param endValue End value of the animation curve
  28123. * @param gradient Scalar amount to interpolate
  28124. * @returns Interpolated scalar value
  28125. */
  28126. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28127. /**
  28128. * Interpolates a scalar cubically
  28129. * @param startValue Start value of the animation curve
  28130. * @param outTangent End tangent of the animation
  28131. * @param endValue End value of the animation curve
  28132. * @param inTangent Start tangent of the animation curve
  28133. * @param gradient Scalar amount to interpolate
  28134. * @returns Interpolated scalar value
  28135. */
  28136. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28137. /**
  28138. * Interpolates a quaternion using a spherical linear interpolation
  28139. * @param startValue Start value of the animation curve
  28140. * @param endValue End value of the animation curve
  28141. * @param gradient Scalar amount to interpolate
  28142. * @returns Interpolated quaternion value
  28143. */
  28144. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28145. /**
  28146. * Interpolates a quaternion cubically
  28147. * @param startValue Start value of the animation curve
  28148. * @param outTangent End tangent of the animation curve
  28149. * @param endValue End value of the animation curve
  28150. * @param inTangent Start tangent of the animation curve
  28151. * @param gradient Scalar amount to interpolate
  28152. * @returns Interpolated quaternion value
  28153. */
  28154. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28155. /**
  28156. * Interpolates a Vector3 linearl
  28157. * @param startValue Start value of the animation curve
  28158. * @param endValue End value of the animation curve
  28159. * @param gradient Scalar amount to interpolate
  28160. * @returns Interpolated scalar value
  28161. */
  28162. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28163. /**
  28164. * Interpolates a Vector3 cubically
  28165. * @param startValue Start value of the animation curve
  28166. * @param outTangent End tangent of the animation
  28167. * @param endValue End value of the animation curve
  28168. * @param inTangent Start tangent of the animation curve
  28169. * @param gradient Scalar amount to interpolate
  28170. * @returns InterpolatedVector3 value
  28171. */
  28172. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28173. /**
  28174. * Interpolates a Vector2 linearly
  28175. * @param startValue Start value of the animation curve
  28176. * @param endValue End value of the animation curve
  28177. * @param gradient Scalar amount to interpolate
  28178. * @returns Interpolated Vector2 value
  28179. */
  28180. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28181. /**
  28182. * Interpolates a Vector2 cubically
  28183. * @param startValue Start value of the animation curve
  28184. * @param outTangent End tangent of the animation
  28185. * @param endValue End value of the animation curve
  28186. * @param inTangent Start tangent of the animation curve
  28187. * @param gradient Scalar amount to interpolate
  28188. * @returns Interpolated Vector2 value
  28189. */
  28190. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28191. /**
  28192. * Interpolates a size linearly
  28193. * @param startValue Start value of the animation curve
  28194. * @param endValue End value of the animation curve
  28195. * @param gradient Scalar amount to interpolate
  28196. * @returns Interpolated Size value
  28197. */
  28198. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28199. /**
  28200. * Interpolates a Color3 linearly
  28201. * @param startValue Start value of the animation curve
  28202. * @param endValue End value of the animation curve
  28203. * @param gradient Scalar amount to interpolate
  28204. * @returns Interpolated Color3 value
  28205. */
  28206. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28207. /**
  28208. * @hidden Internal use only
  28209. */
  28210. _getKeyValue(value: any): any;
  28211. /**
  28212. * @hidden Internal use only
  28213. */
  28214. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28215. /**
  28216. * Defines the function to use to interpolate matrices
  28217. * @param startValue defines the start matrix
  28218. * @param endValue defines the end matrix
  28219. * @param gradient defines the gradient between both matrices
  28220. * @param result defines an optional target matrix where to store the interpolation
  28221. * @returns the interpolated matrix
  28222. */
  28223. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28224. /**
  28225. * Makes a copy of the animation
  28226. * @returns Cloned animation
  28227. */
  28228. clone(): Animation;
  28229. /**
  28230. * Sets the key frames of the animation
  28231. * @param values The animation key frames to set
  28232. */
  28233. setKeys(values: Array<IAnimationKey>): void;
  28234. /**
  28235. * Serializes the animation to an object
  28236. * @returns Serialized object
  28237. */
  28238. serialize(): any;
  28239. /**
  28240. * Float animation type
  28241. */
  28242. private static _ANIMATIONTYPE_FLOAT;
  28243. /**
  28244. * Vector3 animation type
  28245. */
  28246. private static _ANIMATIONTYPE_VECTOR3;
  28247. /**
  28248. * Quaternion animation type
  28249. */
  28250. private static _ANIMATIONTYPE_QUATERNION;
  28251. /**
  28252. * Matrix animation type
  28253. */
  28254. private static _ANIMATIONTYPE_MATRIX;
  28255. /**
  28256. * Color3 animation type
  28257. */
  28258. private static _ANIMATIONTYPE_COLOR3;
  28259. /**
  28260. * Vector2 animation type
  28261. */
  28262. private static _ANIMATIONTYPE_VECTOR2;
  28263. /**
  28264. * Size animation type
  28265. */
  28266. private static _ANIMATIONTYPE_SIZE;
  28267. /**
  28268. * Relative Loop Mode
  28269. */
  28270. private static _ANIMATIONLOOPMODE_RELATIVE;
  28271. /**
  28272. * Cycle Loop Mode
  28273. */
  28274. private static _ANIMATIONLOOPMODE_CYCLE;
  28275. /**
  28276. * Constant Loop Mode
  28277. */
  28278. private static _ANIMATIONLOOPMODE_CONSTANT;
  28279. /**
  28280. * Get the float animation type
  28281. */
  28282. static readonly ANIMATIONTYPE_FLOAT: number;
  28283. /**
  28284. * Get the Vector3 animation type
  28285. */
  28286. static readonly ANIMATIONTYPE_VECTOR3: number;
  28287. /**
  28288. * Get the Vector2 animation type
  28289. */
  28290. static readonly ANIMATIONTYPE_VECTOR2: number;
  28291. /**
  28292. * Get the Size animation type
  28293. */
  28294. static readonly ANIMATIONTYPE_SIZE: number;
  28295. /**
  28296. * Get the Quaternion animation type
  28297. */
  28298. static readonly ANIMATIONTYPE_QUATERNION: number;
  28299. /**
  28300. * Get the Matrix animation type
  28301. */
  28302. static readonly ANIMATIONTYPE_MATRIX: number;
  28303. /**
  28304. * Get the Color3 animation type
  28305. */
  28306. static readonly ANIMATIONTYPE_COLOR3: number;
  28307. /**
  28308. * Get the Relative Loop Mode
  28309. */
  28310. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28311. /**
  28312. * Get the Cycle Loop Mode
  28313. */
  28314. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28315. /**
  28316. * Get the Constant Loop Mode
  28317. */
  28318. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28319. /** @hidden */
  28320. static _UniversalLerp(left: any, right: any, amount: number): any;
  28321. /**
  28322. * Parses an animation object and creates an animation
  28323. * @param parsedAnimation Parsed animation object
  28324. * @returns Animation object
  28325. */
  28326. static Parse(parsedAnimation: any): Animation;
  28327. /**
  28328. * Appends the serialized animations from the source animations
  28329. * @param source Source containing the animations
  28330. * @param destination Target to store the animations
  28331. */
  28332. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28333. }
  28334. }
  28335. declare module "babylonjs/Animations/animatable.interface" {
  28336. import { Nullable } from "babylonjs/types";
  28337. import { Animation } from "babylonjs/Animations/animation";
  28338. /**
  28339. * Interface containing an array of animations
  28340. */
  28341. export interface IAnimatable {
  28342. /**
  28343. * Array of animations
  28344. */
  28345. animations: Nullable<Array<Animation>>;
  28346. }
  28347. }
  28348. declare module "babylonjs/Materials/fresnelParameters" {
  28349. import { Color3 } from "babylonjs/Maths/math.color";
  28350. /**
  28351. * This represents all the required information to add a fresnel effect on a material:
  28352. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28353. */
  28354. export class FresnelParameters {
  28355. private _isEnabled;
  28356. /**
  28357. * Define if the fresnel effect is enable or not.
  28358. */
  28359. isEnabled: boolean;
  28360. /**
  28361. * Define the color used on edges (grazing angle)
  28362. */
  28363. leftColor: Color3;
  28364. /**
  28365. * Define the color used on center
  28366. */
  28367. rightColor: Color3;
  28368. /**
  28369. * Define bias applied to computed fresnel term
  28370. */
  28371. bias: number;
  28372. /**
  28373. * Defined the power exponent applied to fresnel term
  28374. */
  28375. power: number;
  28376. /**
  28377. * Clones the current fresnel and its valuues
  28378. * @returns a clone fresnel configuration
  28379. */
  28380. clone(): FresnelParameters;
  28381. /**
  28382. * Serializes the current fresnel parameters to a JSON representation.
  28383. * @return the JSON serialization
  28384. */
  28385. serialize(): any;
  28386. /**
  28387. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28388. * @param parsedFresnelParameters Define the JSON representation
  28389. * @returns the parsed parameters
  28390. */
  28391. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28392. }
  28393. }
  28394. declare module "babylonjs/Misc/decorators" {
  28395. import { Nullable } from "babylonjs/types";
  28396. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28397. import { Scene } from "babylonjs/scene";
  28398. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28399. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28400. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28401. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28402. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28403. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28404. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28405. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28406. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28407. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28408. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28409. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28410. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28411. /**
  28412. * Decorator used to define property that can be serialized as reference to a camera
  28413. * @param sourceName defines the name of the property to decorate
  28414. */
  28415. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28416. /**
  28417. * Class used to help serialization objects
  28418. */
  28419. export class SerializationHelper {
  28420. /** @hidden */
  28421. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28422. /** @hidden */
  28423. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28424. /** @hidden */
  28425. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28426. /** @hidden */
  28427. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28428. /**
  28429. * Appends the serialized animations from the source animations
  28430. * @param source Source containing the animations
  28431. * @param destination Target to store the animations
  28432. */
  28433. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28434. /**
  28435. * Static function used to serialized a specific entity
  28436. * @param entity defines the entity to serialize
  28437. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28438. * @returns a JSON compatible object representing the serialization of the entity
  28439. */
  28440. static Serialize<T>(entity: T, serializationObject?: any): any;
  28441. /**
  28442. * Creates a new entity from a serialization data object
  28443. * @param creationFunction defines a function used to instanciated the new entity
  28444. * @param source defines the source serialization data
  28445. * @param scene defines the hosting scene
  28446. * @param rootUrl defines the root url for resources
  28447. * @returns a new entity
  28448. */
  28449. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28450. /**
  28451. * Clones an object
  28452. * @param creationFunction defines the function used to instanciate the new object
  28453. * @param source defines the source object
  28454. * @returns the cloned object
  28455. */
  28456. static Clone<T>(creationFunction: () => T, source: T): T;
  28457. /**
  28458. * Instanciates a new object based on a source one (some data will be shared between both object)
  28459. * @param creationFunction defines the function used to instanciate the new object
  28460. * @param source defines the source object
  28461. * @returns the new object
  28462. */
  28463. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28464. }
  28465. }
  28466. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28467. import { Nullable } from "babylonjs/types";
  28468. /**
  28469. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28470. */
  28471. export interface CubeMapInfo {
  28472. /**
  28473. * The pixel array for the front face.
  28474. * This is stored in format, left to right, up to down format.
  28475. */
  28476. front: Nullable<ArrayBufferView>;
  28477. /**
  28478. * The pixel array for the back face.
  28479. * This is stored in format, left to right, up to down format.
  28480. */
  28481. back: Nullable<ArrayBufferView>;
  28482. /**
  28483. * The pixel array for the left face.
  28484. * This is stored in format, left to right, up to down format.
  28485. */
  28486. left: Nullable<ArrayBufferView>;
  28487. /**
  28488. * The pixel array for the right face.
  28489. * This is stored in format, left to right, up to down format.
  28490. */
  28491. right: Nullable<ArrayBufferView>;
  28492. /**
  28493. * The pixel array for the up face.
  28494. * This is stored in format, left to right, up to down format.
  28495. */
  28496. up: Nullable<ArrayBufferView>;
  28497. /**
  28498. * The pixel array for the down face.
  28499. * This is stored in format, left to right, up to down format.
  28500. */
  28501. down: Nullable<ArrayBufferView>;
  28502. /**
  28503. * The size of the cubemap stored.
  28504. *
  28505. * Each faces will be size * size pixels.
  28506. */
  28507. size: number;
  28508. /**
  28509. * The format of the texture.
  28510. *
  28511. * RGBA, RGB.
  28512. */
  28513. format: number;
  28514. /**
  28515. * The type of the texture data.
  28516. *
  28517. * UNSIGNED_INT, FLOAT.
  28518. */
  28519. type: number;
  28520. /**
  28521. * Specifies whether the texture is in gamma space.
  28522. */
  28523. gammaSpace: boolean;
  28524. }
  28525. /**
  28526. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28527. */
  28528. export class PanoramaToCubeMapTools {
  28529. private static FACE_FRONT;
  28530. private static FACE_BACK;
  28531. private static FACE_RIGHT;
  28532. private static FACE_LEFT;
  28533. private static FACE_DOWN;
  28534. private static FACE_UP;
  28535. /**
  28536. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28537. *
  28538. * @param float32Array The source data.
  28539. * @param inputWidth The width of the input panorama.
  28540. * @param inputHeight The height of the input panorama.
  28541. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28542. * @return The cubemap data
  28543. */
  28544. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28545. private static CreateCubemapTexture;
  28546. private static CalcProjectionSpherical;
  28547. }
  28548. }
  28549. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28550. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28552. import { Nullable } from "babylonjs/types";
  28553. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28554. /**
  28555. * Helper class dealing with the extraction of spherical polynomial dataArray
  28556. * from a cube map.
  28557. */
  28558. export class CubeMapToSphericalPolynomialTools {
  28559. private static FileFaces;
  28560. /**
  28561. * Converts a texture to the according Spherical Polynomial data.
  28562. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28563. *
  28564. * @param texture The texture to extract the information from.
  28565. * @return The Spherical Polynomial data.
  28566. */
  28567. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28568. /**
  28569. * Converts a cubemap to the according Spherical Polynomial data.
  28570. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28571. *
  28572. * @param cubeInfo The Cube map to extract the information from.
  28573. * @return The Spherical Polynomial data.
  28574. */
  28575. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28576. }
  28577. }
  28578. declare module "babylonjs/Misc/guid" {
  28579. /**
  28580. * Class used to manipulate GUIDs
  28581. */
  28582. export class GUID {
  28583. /**
  28584. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28585. * Be aware Math.random() could cause collisions, but:
  28586. * "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"
  28587. * @returns a pseudo random id
  28588. */
  28589. static RandomId(): string;
  28590. }
  28591. }
  28592. declare module "babylonjs/Materials/Textures/baseTexture" {
  28593. import { Observable } from "babylonjs/Misc/observable";
  28594. import { Nullable } from "babylonjs/types";
  28595. import { Scene } from "babylonjs/scene";
  28596. import { Matrix } from "babylonjs/Maths/math.vector";
  28597. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28598. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28599. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28600. import { ISize } from "babylonjs/Maths/math.size";
  28601. /**
  28602. * Base class of all the textures in babylon.
  28603. * It groups all the common properties the materials, post process, lights... might need
  28604. * in order to make a correct use of the texture.
  28605. */
  28606. export class BaseTexture implements IAnimatable {
  28607. /**
  28608. * Default anisotropic filtering level for the application.
  28609. * It is set to 4 as a good tradeoff between perf and quality.
  28610. */
  28611. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28612. /**
  28613. * Gets or sets the unique id of the texture
  28614. */
  28615. uniqueId: number;
  28616. /**
  28617. * Define the name of the texture.
  28618. */
  28619. name: string;
  28620. /**
  28621. * Gets or sets an object used to store user defined information.
  28622. */
  28623. metadata: any;
  28624. /**
  28625. * For internal use only. Please do not use.
  28626. */
  28627. reservedDataStore: any;
  28628. private _hasAlpha;
  28629. /**
  28630. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28631. */
  28632. hasAlpha: boolean;
  28633. /**
  28634. * Defines if the alpha value should be determined via the rgb values.
  28635. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28636. */
  28637. getAlphaFromRGB: boolean;
  28638. /**
  28639. * Intensity or strength of the texture.
  28640. * It is commonly used by materials to fine tune the intensity of the texture
  28641. */
  28642. level: number;
  28643. /**
  28644. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28645. * This is part of the texture as textures usually maps to one uv set.
  28646. */
  28647. coordinatesIndex: number;
  28648. private _coordinatesMode;
  28649. /**
  28650. * How a texture is mapped.
  28651. *
  28652. * | Value | Type | Description |
  28653. * | ----- | ----------------------------------- | ----------- |
  28654. * | 0 | EXPLICIT_MODE | |
  28655. * | 1 | SPHERICAL_MODE | |
  28656. * | 2 | PLANAR_MODE | |
  28657. * | 3 | CUBIC_MODE | |
  28658. * | 4 | PROJECTION_MODE | |
  28659. * | 5 | SKYBOX_MODE | |
  28660. * | 6 | INVCUBIC_MODE | |
  28661. * | 7 | EQUIRECTANGULAR_MODE | |
  28662. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28663. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28664. */
  28665. coordinatesMode: number;
  28666. /**
  28667. * | Value | Type | Description |
  28668. * | ----- | ------------------ | ----------- |
  28669. * | 0 | CLAMP_ADDRESSMODE | |
  28670. * | 1 | WRAP_ADDRESSMODE | |
  28671. * | 2 | MIRROR_ADDRESSMODE | |
  28672. */
  28673. wrapU: number;
  28674. /**
  28675. * | Value | Type | Description |
  28676. * | ----- | ------------------ | ----------- |
  28677. * | 0 | CLAMP_ADDRESSMODE | |
  28678. * | 1 | WRAP_ADDRESSMODE | |
  28679. * | 2 | MIRROR_ADDRESSMODE | |
  28680. */
  28681. wrapV: number;
  28682. /**
  28683. * | Value | Type | Description |
  28684. * | ----- | ------------------ | ----------- |
  28685. * | 0 | CLAMP_ADDRESSMODE | |
  28686. * | 1 | WRAP_ADDRESSMODE | |
  28687. * | 2 | MIRROR_ADDRESSMODE | |
  28688. */
  28689. wrapR: number;
  28690. /**
  28691. * With compliant hardware and browser (supporting anisotropic filtering)
  28692. * this defines the level of anisotropic filtering in the texture.
  28693. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28694. */
  28695. anisotropicFilteringLevel: number;
  28696. /**
  28697. * Define if the texture is a cube texture or if false a 2d texture.
  28698. */
  28699. isCube: boolean;
  28700. /**
  28701. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28702. */
  28703. is3D: boolean;
  28704. /**
  28705. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28706. * HDR texture are usually stored in linear space.
  28707. * This only impacts the PBR and Background materials
  28708. */
  28709. gammaSpace: boolean;
  28710. /**
  28711. * Gets or sets whether or not the texture contains RGBD data.
  28712. */
  28713. isRGBD: boolean;
  28714. /**
  28715. * Is Z inverted in the texture (useful in a cube texture).
  28716. */
  28717. invertZ: boolean;
  28718. /**
  28719. * Are mip maps generated for this texture or not.
  28720. */
  28721. readonly noMipmap: boolean;
  28722. /**
  28723. * @hidden
  28724. */
  28725. lodLevelInAlpha: boolean;
  28726. /**
  28727. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28728. */
  28729. lodGenerationOffset: number;
  28730. /**
  28731. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28732. */
  28733. lodGenerationScale: number;
  28734. /**
  28735. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28736. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28737. * average roughness values.
  28738. */
  28739. linearSpecularLOD: boolean;
  28740. /**
  28741. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28742. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28743. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28744. */
  28745. irradianceTexture: Nullable<BaseTexture>;
  28746. /**
  28747. * Define if the texture is a render target.
  28748. */
  28749. isRenderTarget: boolean;
  28750. /**
  28751. * Define the unique id of the texture in the scene.
  28752. */
  28753. readonly uid: string;
  28754. /**
  28755. * Return a string representation of the texture.
  28756. * @returns the texture as a string
  28757. */
  28758. toString(): string;
  28759. /**
  28760. * Get the class name of the texture.
  28761. * @returns "BaseTexture"
  28762. */
  28763. getClassName(): string;
  28764. /**
  28765. * Define the list of animation attached to the texture.
  28766. */
  28767. animations: import("babylonjs/Animations/animation").Animation[];
  28768. /**
  28769. * An event triggered when the texture is disposed.
  28770. */
  28771. onDisposeObservable: Observable<BaseTexture>;
  28772. private _onDisposeObserver;
  28773. /**
  28774. * Callback triggered when the texture has been disposed.
  28775. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28776. */
  28777. onDispose: () => void;
  28778. /**
  28779. * Define the current state of the loading sequence when in delayed load mode.
  28780. */
  28781. delayLoadState: number;
  28782. private _scene;
  28783. /** @hidden */
  28784. _texture: Nullable<InternalTexture>;
  28785. private _uid;
  28786. /**
  28787. * Define if the texture is preventinga material to render or not.
  28788. * If not and the texture is not ready, the engine will use a default black texture instead.
  28789. */
  28790. readonly isBlocking: boolean;
  28791. /**
  28792. * Instantiates a new BaseTexture.
  28793. * Base class of all the textures in babylon.
  28794. * It groups all the common properties the materials, post process, lights... might need
  28795. * in order to make a correct use of the texture.
  28796. * @param scene Define the scene the texture blongs to
  28797. */
  28798. constructor(scene: Nullable<Scene>);
  28799. /**
  28800. * Get the scene the texture belongs to.
  28801. * @returns the scene or null if undefined
  28802. */
  28803. getScene(): Nullable<Scene>;
  28804. /**
  28805. * Get the texture transform matrix used to offset tile the texture for istance.
  28806. * @returns the transformation matrix
  28807. */
  28808. getTextureMatrix(): Matrix;
  28809. /**
  28810. * Get the texture reflection matrix used to rotate/transform the reflection.
  28811. * @returns the reflection matrix
  28812. */
  28813. getReflectionTextureMatrix(): Matrix;
  28814. /**
  28815. * Get the underlying lower level texture from Babylon.
  28816. * @returns the insternal texture
  28817. */
  28818. getInternalTexture(): Nullable<InternalTexture>;
  28819. /**
  28820. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28821. * @returns true if ready or not blocking
  28822. */
  28823. isReadyOrNotBlocking(): boolean;
  28824. /**
  28825. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28826. * @returns true if fully ready
  28827. */
  28828. isReady(): boolean;
  28829. private _cachedSize;
  28830. /**
  28831. * Get the size of the texture.
  28832. * @returns the texture size.
  28833. */
  28834. getSize(): ISize;
  28835. /**
  28836. * Get the base size of the texture.
  28837. * It can be different from the size if the texture has been resized for POT for instance
  28838. * @returns the base size
  28839. */
  28840. getBaseSize(): ISize;
  28841. /**
  28842. * Update the sampling mode of the texture.
  28843. * Default is Trilinear mode.
  28844. *
  28845. * | Value | Type | Description |
  28846. * | ----- | ------------------ | ----------- |
  28847. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28848. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28849. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28850. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28851. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28852. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28853. * | 7 | NEAREST_LINEAR | |
  28854. * | 8 | NEAREST_NEAREST | |
  28855. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28856. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28857. * | 11 | LINEAR_LINEAR | |
  28858. * | 12 | LINEAR_NEAREST | |
  28859. *
  28860. * > _mag_: magnification filter (close to the viewer)
  28861. * > _min_: minification filter (far from the viewer)
  28862. * > _mip_: filter used between mip map levels
  28863. *@param samplingMode Define the new sampling mode of the texture
  28864. */
  28865. updateSamplingMode(samplingMode: number): void;
  28866. /**
  28867. * Scales the texture if is `canRescale()`
  28868. * @param ratio the resize factor we want to use to rescale
  28869. */
  28870. scale(ratio: number): void;
  28871. /**
  28872. * Get if the texture can rescale.
  28873. */
  28874. readonly canRescale: boolean;
  28875. /** @hidden */
  28876. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28877. /** @hidden */
  28878. _rebuild(): void;
  28879. /**
  28880. * Triggers the load sequence in delayed load mode.
  28881. */
  28882. delayLoad(): void;
  28883. /**
  28884. * Clones the texture.
  28885. * @returns the cloned texture
  28886. */
  28887. clone(): Nullable<BaseTexture>;
  28888. /**
  28889. * Get the texture underlying type (INT, FLOAT...)
  28890. */
  28891. readonly textureType: number;
  28892. /**
  28893. * Get the texture underlying format (RGB, RGBA...)
  28894. */
  28895. readonly textureFormat: number;
  28896. /**
  28897. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28898. * This will returns an RGBA array buffer containing either in values (0-255) or
  28899. * float values (0-1) depending of the underlying buffer type.
  28900. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28901. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28902. * @param buffer defines a user defined buffer to fill with data (can be null)
  28903. * @returns The Array buffer containing the pixels data.
  28904. */
  28905. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28906. /**
  28907. * Release and destroy the underlying lower level texture aka internalTexture.
  28908. */
  28909. releaseInternalTexture(): void;
  28910. /**
  28911. * Get the polynomial representation of the texture data.
  28912. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28913. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28914. */
  28915. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28916. /** @hidden */
  28917. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28918. /** @hidden */
  28919. readonly _lodTextureMid: Nullable<BaseTexture>;
  28920. /** @hidden */
  28921. readonly _lodTextureLow: Nullable<BaseTexture>;
  28922. /**
  28923. * Dispose the texture and release its associated resources.
  28924. */
  28925. dispose(): void;
  28926. /**
  28927. * Serialize the texture into a JSON representation that can be parsed later on.
  28928. * @returns the JSON representation of the texture
  28929. */
  28930. serialize(): any;
  28931. /**
  28932. * Helper function to be called back once a list of texture contains only ready textures.
  28933. * @param textures Define the list of textures to wait for
  28934. * @param callback Define the callback triggered once the entire list will be ready
  28935. */
  28936. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28937. }
  28938. }
  28939. declare module "babylonjs/Materials/effect" {
  28940. import { Observable } from "babylonjs/Misc/observable";
  28941. import { Nullable } from "babylonjs/types";
  28942. import { IDisposable } from "babylonjs/scene";
  28943. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28944. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28945. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28946. import { BaseEngine } from "babylonjs/Engines/baseEngine";
  28947. import { Engine } from "babylonjs/Engines/engine";
  28948. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28950. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28951. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28953. /**
  28954. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28955. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28956. */
  28957. export class EffectFallbacks {
  28958. private _defines;
  28959. private _currentRank;
  28960. private _maxRank;
  28961. private _mesh;
  28962. /**
  28963. * Removes the fallback from the bound mesh.
  28964. */
  28965. unBindMesh(): void;
  28966. /**
  28967. * Adds a fallback on the specified property.
  28968. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28969. * @param define The name of the define in the shader
  28970. */
  28971. addFallback(rank: number, define: string): void;
  28972. /**
  28973. * Sets the mesh to use CPU skinning when needing to fallback.
  28974. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28975. * @param mesh The mesh to use the fallbacks.
  28976. */
  28977. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28978. /**
  28979. * Checks to see if more fallbacks are still availible.
  28980. */
  28981. readonly hasMoreFallbacks: boolean;
  28982. /**
  28983. * Removes the defines that should be removed when falling back.
  28984. * @param currentDefines defines the current define statements for the shader.
  28985. * @param effect defines the current effect we try to compile
  28986. * @returns The resulting defines with defines of the current rank removed.
  28987. */
  28988. reduce(currentDefines: string, effect: Effect): string;
  28989. }
  28990. /**
  28991. * Options to be used when creating an effect.
  28992. */
  28993. export class EffectCreationOptions {
  28994. /**
  28995. * Atrributes that will be used in the shader.
  28996. */
  28997. attributes: string[];
  28998. /**
  28999. * Uniform varible names that will be set in the shader.
  29000. */
  29001. uniformsNames: string[];
  29002. /**
  29003. * Uniform buffer varible names that will be set in the shader.
  29004. */
  29005. uniformBuffersNames: string[];
  29006. /**
  29007. * Sampler texture variable names that will be set in the shader.
  29008. */
  29009. samplers: string[];
  29010. /**
  29011. * Define statements that will be set in the shader.
  29012. */
  29013. defines: any;
  29014. /**
  29015. * Possible fallbacks for this effect to improve performance when needed.
  29016. */
  29017. fallbacks: Nullable<EffectFallbacks>;
  29018. /**
  29019. * Callback that will be called when the shader is compiled.
  29020. */
  29021. onCompiled: Nullable<(effect: Effect) => void>;
  29022. /**
  29023. * Callback that will be called if an error occurs during shader compilation.
  29024. */
  29025. onError: Nullable<(effect: Effect, errors: string) => void>;
  29026. /**
  29027. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29028. */
  29029. indexParameters: any;
  29030. /**
  29031. * Max number of lights that can be used in the shader.
  29032. */
  29033. maxSimultaneousLights: number;
  29034. /**
  29035. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29036. */
  29037. transformFeedbackVaryings: Nullable<string[]>;
  29038. }
  29039. /**
  29040. * Effect containing vertex and fragment shader that can be executed on an object.
  29041. */
  29042. export class Effect implements IDisposable {
  29043. /**
  29044. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29045. */
  29046. static ShadersRepository: string;
  29047. /**
  29048. * Name of the effect.
  29049. */
  29050. name: any;
  29051. /**
  29052. * String container all the define statements that should be set on the shader.
  29053. */
  29054. defines: string;
  29055. /**
  29056. * Callback that will be called when the shader is compiled.
  29057. */
  29058. onCompiled: Nullable<(effect: Effect) => void>;
  29059. /**
  29060. * Callback that will be called if an error occurs during shader compilation.
  29061. */
  29062. onError: Nullable<(effect: Effect, errors: string) => void>;
  29063. /**
  29064. * Callback that will be called when effect is bound.
  29065. */
  29066. onBind: Nullable<(effect: Effect) => void>;
  29067. /**
  29068. * Unique ID of the effect.
  29069. */
  29070. uniqueId: number;
  29071. /**
  29072. * Observable that will be called when the shader is compiled.
  29073. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29074. */
  29075. onCompileObservable: Observable<Effect>;
  29076. /**
  29077. * Observable that will be called if an error occurs during shader compilation.
  29078. */
  29079. onErrorObservable: Observable<Effect>;
  29080. /** @hidden */
  29081. _onBindObservable: Nullable<Observable<Effect>>;
  29082. /**
  29083. * Observable that will be called when effect is bound.
  29084. */
  29085. readonly onBindObservable: Observable<Effect>;
  29086. /** @hidden */
  29087. _bonesComputationForcedToCPU: boolean;
  29088. private static _uniqueIdSeed;
  29089. private _engine;
  29090. private _uniformBuffersNames;
  29091. private _uniformsNames;
  29092. private _samplerList;
  29093. private _samplers;
  29094. private _isReady;
  29095. private _compilationError;
  29096. private _attributesNames;
  29097. private _attributes;
  29098. private _uniforms;
  29099. /**
  29100. * Key for the effect.
  29101. * @hidden
  29102. */
  29103. _key: string;
  29104. private _indexParameters;
  29105. private _fallbacks;
  29106. private _vertexSourceCode;
  29107. private _fragmentSourceCode;
  29108. private _vertexSourceCodeOverride;
  29109. private _fragmentSourceCodeOverride;
  29110. private _transformFeedbackVaryings;
  29111. /**
  29112. * Compiled shader to webGL program.
  29113. * @hidden
  29114. */
  29115. _pipelineContext: Nullable<IPipelineContext>;
  29116. private _valueCache;
  29117. private static _baseCache;
  29118. /**
  29119. * Instantiates an effect.
  29120. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29121. * @param baseName Name of the effect.
  29122. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29123. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29124. * @param samplers List of sampler variables that will be passed to the shader.
  29125. * @param engine Engine to be used to render the effect
  29126. * @param defines Define statements to be added to the shader.
  29127. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29128. * @param onCompiled Callback that will be called when the shader is compiled.
  29129. * @param onError Callback that will be called if an error occurs during shader compilation.
  29130. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29131. */
  29132. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | BaseEngine, samplers?: Nullable<string[]>, engine?: BaseEngine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29133. private _useFinalCode;
  29134. /**
  29135. * Unique key for this effect
  29136. */
  29137. readonly key: string;
  29138. /**
  29139. * If the effect has been compiled and prepared.
  29140. * @returns if the effect is compiled and prepared.
  29141. */
  29142. isReady(): boolean;
  29143. private _isReadyInternal;
  29144. /**
  29145. * The engine the effect was initialized with.
  29146. * @returns the engine.
  29147. */
  29148. getEngine(): Engine;
  29149. /**
  29150. * The pipeline context for this effect
  29151. * @returns the associated pipeline context
  29152. */
  29153. getPipelineContext(): Nullable<IPipelineContext>;
  29154. /**
  29155. * The set of names of attribute variables for the shader.
  29156. * @returns An array of attribute names.
  29157. */
  29158. getAttributesNames(): string[];
  29159. /**
  29160. * Returns the attribute at the given index.
  29161. * @param index The index of the attribute.
  29162. * @returns The location of the attribute.
  29163. */
  29164. getAttributeLocation(index: number): number;
  29165. /**
  29166. * Returns the attribute based on the name of the variable.
  29167. * @param name of the attribute to look up.
  29168. * @returns the attribute location.
  29169. */
  29170. getAttributeLocationByName(name: string): number;
  29171. /**
  29172. * The number of attributes.
  29173. * @returns the numnber of attributes.
  29174. */
  29175. getAttributesCount(): number;
  29176. /**
  29177. * Gets the index of a uniform variable.
  29178. * @param uniformName of the uniform to look up.
  29179. * @returns the index.
  29180. */
  29181. getUniformIndex(uniformName: string): number;
  29182. /**
  29183. * Returns the attribute based on the name of the variable.
  29184. * @param uniformName of the uniform to look up.
  29185. * @returns the location of the uniform.
  29186. */
  29187. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29188. /**
  29189. * Returns an array of sampler variable names
  29190. * @returns The array of sampler variable neames.
  29191. */
  29192. getSamplers(): string[];
  29193. /**
  29194. * The error from the last compilation.
  29195. * @returns the error string.
  29196. */
  29197. getCompilationError(): string;
  29198. /**
  29199. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29200. * @param func The callback to be used.
  29201. */
  29202. executeWhenCompiled(func: (effect: Effect) => void): void;
  29203. private _checkIsReady;
  29204. /** @hidden */
  29205. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29206. /** @hidden */
  29207. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29208. /** @hidden */
  29209. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29210. /**
  29211. * Recompiles the webGL program
  29212. * @param vertexSourceCode The source code for the vertex shader.
  29213. * @param fragmentSourceCode The source code for the fragment shader.
  29214. * @param onCompiled Callback called when completed.
  29215. * @param onError Callback called on error.
  29216. * @hidden
  29217. */
  29218. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29219. /**
  29220. * Prepares the effect
  29221. * @hidden
  29222. */
  29223. _prepareEffect(): void;
  29224. private _processCompilationErrors;
  29225. /**
  29226. * Checks if the effect is supported. (Must be called after compilation)
  29227. */
  29228. readonly isSupported: boolean;
  29229. /**
  29230. * Binds a texture to the engine to be used as output of the shader.
  29231. * @param channel Name of the output variable.
  29232. * @param texture Texture to bind.
  29233. * @hidden
  29234. */
  29235. _bindTexture(channel: string, texture: InternalTexture): void;
  29236. /**
  29237. * Sets a texture on the engine to be used in the shader.
  29238. * @param channel Name of the sampler variable.
  29239. * @param texture Texture to set.
  29240. */
  29241. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29242. /**
  29243. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29244. * @param channel Name of the sampler variable.
  29245. * @param texture Texture to set.
  29246. */
  29247. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29248. /**
  29249. * Sets an array of textures on the engine to be used in the shader.
  29250. * @param channel Name of the variable.
  29251. * @param textures Textures to set.
  29252. */
  29253. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29254. /**
  29255. * 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)
  29256. * @param channel Name of the sampler variable.
  29257. * @param postProcess Post process to get the input texture from.
  29258. */
  29259. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29260. /**
  29261. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29262. * 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)
  29263. * @param channel Name of the sampler variable.
  29264. * @param postProcess Post process to get the output texture from.
  29265. */
  29266. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29267. /** @hidden */
  29268. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29269. /** @hidden */
  29270. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29271. /** @hidden */
  29272. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29273. /** @hidden */
  29274. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29275. /**
  29276. * Binds a buffer to a uniform.
  29277. * @param buffer Buffer to bind.
  29278. * @param name Name of the uniform variable to bind to.
  29279. */
  29280. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29281. /**
  29282. * Binds block to a uniform.
  29283. * @param blockName Name of the block to bind.
  29284. * @param index Index to bind.
  29285. */
  29286. bindUniformBlock(blockName: string, index: number): void;
  29287. /**
  29288. * Sets an interger value on a uniform variable.
  29289. * @param uniformName Name of the variable.
  29290. * @param value Value to be set.
  29291. * @returns this effect.
  29292. */
  29293. setInt(uniformName: string, value: number): Effect;
  29294. /**
  29295. * Sets an int array on a uniform variable.
  29296. * @param uniformName Name of the variable.
  29297. * @param array array to be set.
  29298. * @returns this effect.
  29299. */
  29300. setIntArray(uniformName: string, array: Int32Array): Effect;
  29301. /**
  29302. * 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)
  29303. * @param uniformName Name of the variable.
  29304. * @param array array to be set.
  29305. * @returns this effect.
  29306. */
  29307. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29308. /**
  29309. * 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)
  29310. * @param uniformName Name of the variable.
  29311. * @param array array to be set.
  29312. * @returns this effect.
  29313. */
  29314. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29315. /**
  29316. * 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)
  29317. * @param uniformName Name of the variable.
  29318. * @param array array to be set.
  29319. * @returns this effect.
  29320. */
  29321. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29322. /**
  29323. * Sets an float array on a uniform variable.
  29324. * @param uniformName Name of the variable.
  29325. * @param array array to be set.
  29326. * @returns this effect.
  29327. */
  29328. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29329. /**
  29330. * 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)
  29331. * @param uniformName Name of the variable.
  29332. * @param array array to be set.
  29333. * @returns this effect.
  29334. */
  29335. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29336. /**
  29337. * 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)
  29338. * @param uniformName Name of the variable.
  29339. * @param array array to be set.
  29340. * @returns this effect.
  29341. */
  29342. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29343. /**
  29344. * 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)
  29345. * @param uniformName Name of the variable.
  29346. * @param array array to be set.
  29347. * @returns this effect.
  29348. */
  29349. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29350. /**
  29351. * Sets an array on a uniform variable.
  29352. * @param uniformName Name of the variable.
  29353. * @param array array to be set.
  29354. * @returns this effect.
  29355. */
  29356. setArray(uniformName: string, array: number[]): Effect;
  29357. /**
  29358. * 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)
  29359. * @param uniformName Name of the variable.
  29360. * @param array array to be set.
  29361. * @returns this effect.
  29362. */
  29363. setArray2(uniformName: string, array: number[]): Effect;
  29364. /**
  29365. * 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)
  29366. * @param uniformName Name of the variable.
  29367. * @param array array to be set.
  29368. * @returns this effect.
  29369. */
  29370. setArray3(uniformName: string, array: number[]): Effect;
  29371. /**
  29372. * 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)
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setArray4(uniformName: string, array: number[]): Effect;
  29378. /**
  29379. * Sets matrices on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param matrices matrices to be set.
  29382. * @returns this effect.
  29383. */
  29384. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29385. /**
  29386. * Sets matrix on a uniform variable.
  29387. * @param uniformName Name of the variable.
  29388. * @param matrix matrix to be set.
  29389. * @returns this effect.
  29390. */
  29391. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29392. /**
  29393. * 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)
  29394. * @param uniformName Name of the variable.
  29395. * @param matrix matrix to be set.
  29396. * @returns this effect.
  29397. */
  29398. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29399. /**
  29400. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29401. * @param uniformName Name of the variable.
  29402. * @param matrix matrix to be set.
  29403. * @returns this effect.
  29404. */
  29405. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29406. /**
  29407. * Sets a float on a uniform variable.
  29408. * @param uniformName Name of the variable.
  29409. * @param value value to be set.
  29410. * @returns this effect.
  29411. */
  29412. setFloat(uniformName: string, value: number): Effect;
  29413. /**
  29414. * Sets a boolean on a uniform variable.
  29415. * @param uniformName Name of the variable.
  29416. * @param bool value to be set.
  29417. * @returns this effect.
  29418. */
  29419. setBool(uniformName: string, bool: boolean): Effect;
  29420. /**
  29421. * Sets a Vector2 on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param vector2 vector2 to be set.
  29424. * @returns this effect.
  29425. */
  29426. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29427. /**
  29428. * Sets a float2 on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param x First float in float2.
  29431. * @param y Second float in float2.
  29432. * @returns this effect.
  29433. */
  29434. setFloat2(uniformName: string, x: number, y: number): Effect;
  29435. /**
  29436. * Sets a Vector3 on a uniform variable.
  29437. * @param uniformName Name of the variable.
  29438. * @param vector3 Value to be set.
  29439. * @returns this effect.
  29440. */
  29441. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29442. /**
  29443. * Sets a float3 on a uniform variable.
  29444. * @param uniformName Name of the variable.
  29445. * @param x First float in float3.
  29446. * @param y Second float in float3.
  29447. * @param z Third float in float3.
  29448. * @returns this effect.
  29449. */
  29450. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29451. /**
  29452. * Sets a Vector4 on a uniform variable.
  29453. * @param uniformName Name of the variable.
  29454. * @param vector4 Value to be set.
  29455. * @returns this effect.
  29456. */
  29457. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29458. /**
  29459. * Sets a float4 on a uniform variable.
  29460. * @param uniformName Name of the variable.
  29461. * @param x First float in float4.
  29462. * @param y Second float in float4.
  29463. * @param z Third float in float4.
  29464. * @param w Fourth float in float4.
  29465. * @returns this effect.
  29466. */
  29467. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29468. /**
  29469. * Sets a Color3 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param color3 Value to be set.
  29472. * @returns this effect.
  29473. */
  29474. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29475. /**
  29476. * Sets a Color4 on a uniform variable.
  29477. * @param uniformName Name of the variable.
  29478. * @param color3 Value to be set.
  29479. * @param alpha Alpha value to be set.
  29480. * @returns this effect.
  29481. */
  29482. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29483. /**
  29484. * Sets a Color4 on a uniform variable
  29485. * @param uniformName defines the name of the variable
  29486. * @param color4 defines the value to be set
  29487. * @returns this effect.
  29488. */
  29489. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29490. /** Release all associated resources */
  29491. dispose(): void;
  29492. /**
  29493. * This function will add a new shader to the shader store
  29494. * @param name the name of the shader
  29495. * @param pixelShader optional pixel shader content
  29496. * @param vertexShader optional vertex shader content
  29497. */
  29498. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29499. /**
  29500. * Store of each shader (The can be looked up using effect.key)
  29501. */
  29502. static ShadersStore: {
  29503. [key: string]: string;
  29504. };
  29505. /**
  29506. * Store of each included file for a shader (The can be looked up using effect.key)
  29507. */
  29508. static IncludesShadersStore: {
  29509. [key: string]: string;
  29510. };
  29511. /**
  29512. * Resets the cache of effects.
  29513. */
  29514. static ResetCache(): void;
  29515. }
  29516. }
  29517. declare module "babylonjs/Engines/engineCapabilities" {
  29518. import { Nullable } from "babylonjs/types";
  29519. /**
  29520. * Class used to describe the capabilities of the engine relatively to the current browser
  29521. */
  29522. export class EngineCapabilities {
  29523. /** Maximum textures units per fragment shader */
  29524. maxTexturesImageUnits: number;
  29525. /** Maximum texture units per vertex shader */
  29526. maxVertexTextureImageUnits: number;
  29527. /** Maximum textures units in the entire pipeline */
  29528. maxCombinedTexturesImageUnits: number;
  29529. /** Maximum texture size */
  29530. maxTextureSize: number;
  29531. /** Maximum cube texture size */
  29532. maxCubemapTextureSize: number;
  29533. /** Maximum render texture size */
  29534. maxRenderTextureSize: number;
  29535. /** Maximum number of vertex attributes */
  29536. maxVertexAttribs: number;
  29537. /** Maximum number of varyings */
  29538. maxVaryingVectors: number;
  29539. /** Maximum number of uniforms per vertex shader */
  29540. maxVertexUniformVectors: number;
  29541. /** Maximum number of uniforms per fragment shader */
  29542. maxFragmentUniformVectors: number;
  29543. /** Defines if standard derivates (dx/dy) are supported */
  29544. standardDerivatives: boolean;
  29545. /** Defines if s3tc texture compression is supported */
  29546. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29547. /** Defines if pvrtc texture compression is supported */
  29548. pvrtc: any;
  29549. /** Defines if etc1 texture compression is supported */
  29550. etc1: any;
  29551. /** Defines if etc2 texture compression is supported */
  29552. etc2: any;
  29553. /** Defines if astc texture compression is supported */
  29554. astc: any;
  29555. /** Defines if float textures are supported */
  29556. textureFloat: boolean;
  29557. /** Defines if vertex array objects are supported */
  29558. vertexArrayObject: boolean;
  29559. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29560. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29561. /** Gets the maximum level of anisotropy supported */
  29562. maxAnisotropy: number;
  29563. /** Defines if instancing is supported */
  29564. instancedArrays: boolean;
  29565. /** Defines if 32 bits indices are supported */
  29566. uintIndices: boolean;
  29567. /** Defines if high precision shaders are supported */
  29568. highPrecisionShaderSupported: boolean;
  29569. /** Defines if depth reading in the fragment shader is supported */
  29570. fragmentDepthSupported: boolean;
  29571. /** Defines if float texture linear filtering is supported*/
  29572. textureFloatLinearFiltering: boolean;
  29573. /** Defines if rendering to float textures is supported */
  29574. textureFloatRender: boolean;
  29575. /** Defines if half float textures are supported*/
  29576. textureHalfFloat: boolean;
  29577. /** Defines if half float texture linear filtering is supported*/
  29578. textureHalfFloatLinearFiltering: boolean;
  29579. /** Defines if rendering to half float textures is supported */
  29580. textureHalfFloatRender: boolean;
  29581. /** Defines if textureLOD shader command is supported */
  29582. textureLOD: boolean;
  29583. /** Defines if draw buffers extension is supported */
  29584. drawBuffersExtension: boolean;
  29585. /** Defines if depth textures are supported */
  29586. depthTextureExtension: boolean;
  29587. /** Defines if float color buffer are supported */
  29588. colorBufferFloat: boolean;
  29589. /** Gets disjoint timer query extension (null if not supported) */
  29590. timerQuery: EXT_disjoint_timer_query;
  29591. /** Defines if timestamp can be used with timer query */
  29592. canUseTimestampForTimerQuery: boolean;
  29593. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29594. multiview: any;
  29595. /** Function used to let the system compiles shaders in background */
  29596. parallelShaderCompile: {
  29597. COMPLETION_STATUS_KHR: number;
  29598. };
  29599. /** Max number of texture samples for MSAA */
  29600. maxMSAASamples: number;
  29601. /** Defines if the blend min max extension is supported */
  29602. blendMinMax: boolean;
  29603. }
  29604. }
  29605. declare module "babylonjs/Misc/perfCounter" {
  29606. /**
  29607. * This class is used to track a performance counter which is number based.
  29608. * The user has access to many properties which give statistics of different nature.
  29609. *
  29610. * The implementer can track two kinds of Performance Counter: time and count.
  29611. * 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.
  29612. * 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.
  29613. */
  29614. export class PerfCounter {
  29615. /**
  29616. * Gets or sets a global boolean to turn on and off all the counters
  29617. */
  29618. static Enabled: boolean;
  29619. /**
  29620. * Returns the smallest value ever
  29621. */
  29622. readonly min: number;
  29623. /**
  29624. * Returns the biggest value ever
  29625. */
  29626. readonly max: number;
  29627. /**
  29628. * Returns the average value since the performance counter is running
  29629. */
  29630. readonly average: number;
  29631. /**
  29632. * Returns the average value of the last second the counter was monitored
  29633. */
  29634. readonly lastSecAverage: number;
  29635. /**
  29636. * Returns the current value
  29637. */
  29638. readonly current: number;
  29639. /**
  29640. * Gets the accumulated total
  29641. */
  29642. readonly total: number;
  29643. /**
  29644. * Gets the total value count
  29645. */
  29646. readonly count: number;
  29647. /**
  29648. * Creates a new counter
  29649. */
  29650. constructor();
  29651. /**
  29652. * Call this method to start monitoring a new frame.
  29653. * 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.
  29654. */
  29655. fetchNewFrame(): void;
  29656. /**
  29657. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29658. * @param newCount the count value to add to the monitored count
  29659. * @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.
  29660. */
  29661. addCount(newCount: number, fetchResult: boolean): void;
  29662. /**
  29663. * Start monitoring this performance counter
  29664. */
  29665. beginMonitoring(): void;
  29666. /**
  29667. * Compute the time lapsed since the previous beginMonitoring() call.
  29668. * @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
  29669. */
  29670. endMonitoring(newFrame?: boolean): void;
  29671. private _fetchResult;
  29672. private _startMonitoringTime;
  29673. private _min;
  29674. private _max;
  29675. private _average;
  29676. private _current;
  29677. private _totalValueCount;
  29678. private _totalAccumulated;
  29679. private _lastSecAverage;
  29680. private _lastSecAccumulated;
  29681. private _lastSecTime;
  29682. private _lastSecValueCount;
  29683. }
  29684. }
  29685. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29686. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29687. /** @hidden */
  29688. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29689. attributeProcessor(attribute: string): string;
  29690. varyingProcessor(varying: string, isFragment: boolean): string;
  29691. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29692. }
  29693. }
  29694. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  29695. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29696. /** @hidden */
  29697. export class WebGLDataBuffer extends DataBuffer {
  29698. private _buffer;
  29699. constructor(resource: WebGLBuffer);
  29700. readonly underlyingResource: any;
  29701. }
  29702. }
  29703. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  29704. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29705. import { Nullable } from "babylonjs/types";
  29706. import { BaseEngine } from "babylonjs/Engines/baseEngine";
  29707. /** @hidden */
  29708. export class WebGLPipelineContext implements IPipelineContext {
  29709. engine: BaseEngine;
  29710. program: Nullable<WebGLProgram>;
  29711. context?: WebGLRenderingContext;
  29712. vertexShader?: WebGLShader;
  29713. fragmentShader?: WebGLShader;
  29714. isParallelCompiled: boolean;
  29715. onCompiled?: () => void;
  29716. transformFeedback?: WebGLTransformFeedback | null;
  29717. readonly isAsync: boolean;
  29718. readonly isReady: boolean;
  29719. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29720. }
  29721. }
  29722. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29723. /**
  29724. * Interface for attribute information associated with buffer instanciation
  29725. */
  29726. export class InstancingAttributeInfo {
  29727. /**
  29728. * Index/offset of the attribute in the vertex shader
  29729. */
  29730. index: number;
  29731. /**
  29732. * size of the attribute, 1, 2, 3 or 4
  29733. */
  29734. attributeSize: number;
  29735. /**
  29736. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29737. * default is FLOAT
  29738. */
  29739. attribyteType: number;
  29740. /**
  29741. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29742. */
  29743. normalized: boolean;
  29744. /**
  29745. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29746. */
  29747. offset: number;
  29748. /**
  29749. * Name of the GLSL attribute, for debugging purpose only
  29750. */
  29751. attributeName: string;
  29752. }
  29753. }
  29754. declare module "babylonjs/Materials/Textures/videoTexture" {
  29755. import { Observable } from "babylonjs/Misc/observable";
  29756. import { Nullable } from "babylonjs/types";
  29757. import { Scene } from "babylonjs/scene";
  29758. import { Texture } from "babylonjs/Materials/Textures/texture";
  29759. /**
  29760. * Settings for finer control over video usage
  29761. */
  29762. export interface VideoTextureSettings {
  29763. /**
  29764. * Applies `autoplay` to video, if specified
  29765. */
  29766. autoPlay?: boolean;
  29767. /**
  29768. * Applies `loop` to video, if specified
  29769. */
  29770. loop?: boolean;
  29771. /**
  29772. * Automatically updates internal texture from video at every frame in the render loop
  29773. */
  29774. autoUpdateTexture: boolean;
  29775. /**
  29776. * Image src displayed during the video loading or until the user interacts with the video.
  29777. */
  29778. poster?: string;
  29779. }
  29780. /**
  29781. * If you want to display a video in your scene, this is the special texture for that.
  29782. * This special texture works similar to other textures, with the exception of a few parameters.
  29783. * @see https://doc.babylonjs.com/how_to/video_texture
  29784. */
  29785. export class VideoTexture extends Texture {
  29786. /**
  29787. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29788. */
  29789. readonly autoUpdateTexture: boolean;
  29790. /**
  29791. * The video instance used by the texture internally
  29792. */
  29793. readonly video: HTMLVideoElement;
  29794. private _onUserActionRequestedObservable;
  29795. /**
  29796. * Event triggerd when a dom action is required by the user to play the video.
  29797. * This happens due to recent changes in browser policies preventing video to auto start.
  29798. */
  29799. readonly onUserActionRequestedObservable: Observable<Texture>;
  29800. private _generateMipMaps;
  29801. private _engine;
  29802. private _stillImageCaptured;
  29803. private _displayingPosterTexture;
  29804. private _settings;
  29805. private _createInternalTextureOnEvent;
  29806. private _frameId;
  29807. /**
  29808. * Creates a video texture.
  29809. * If you want to display a video in your scene, this is the special texture for that.
  29810. * This special texture works similar to other textures, with the exception of a few parameters.
  29811. * @see https://doc.babylonjs.com/how_to/video_texture
  29812. * @param name optional name, will detect from video source, if not defined
  29813. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29814. * @param scene is obviously the current scene.
  29815. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29816. * @param invertY is false by default but can be used to invert video on Y axis
  29817. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29818. * @param settings allows finer control over video usage
  29819. */
  29820. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29821. private _getName;
  29822. private _getVideo;
  29823. private _createInternalTexture;
  29824. private reset;
  29825. /**
  29826. * @hidden Internal method to initiate `update`.
  29827. */
  29828. _rebuild(): void;
  29829. /**
  29830. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29831. */
  29832. update(): void;
  29833. /**
  29834. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29835. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29836. */
  29837. updateTexture(isVisible: boolean): void;
  29838. protected _updateInternalTexture: () => void;
  29839. /**
  29840. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29841. * @param url New url.
  29842. */
  29843. updateURL(url: string): void;
  29844. /**
  29845. * Dispose the texture and release its associated resources.
  29846. */
  29847. dispose(): void;
  29848. /**
  29849. * Creates a video texture straight from a stream.
  29850. * @param scene Define the scene the texture should be created in
  29851. * @param stream Define the stream the texture should be created from
  29852. * @returns The created video texture as a promise
  29853. */
  29854. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29855. /**
  29856. * Creates a video texture straight from your WebCam video feed.
  29857. * @param scene Define the scene the texture should be created in
  29858. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29859. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29860. * @returns The created video texture as a promise
  29861. */
  29862. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29863. minWidth: number;
  29864. maxWidth: number;
  29865. minHeight: number;
  29866. maxHeight: number;
  29867. deviceId: string;
  29868. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29869. /**
  29870. * Creates a video texture straight from your WebCam video feed.
  29871. * @param scene Define the scene the texture should be created in
  29872. * @param onReady Define a callback to triggered once the texture will be ready
  29873. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29874. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29875. */
  29876. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29877. minWidth: number;
  29878. maxWidth: number;
  29879. minHeight: number;
  29880. maxHeight: number;
  29881. deviceId: string;
  29882. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29883. }
  29884. }
  29885. declare module "babylonjs/Engines/baseEngine" {
  29886. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29887. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  29888. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29889. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29890. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  29891. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29892. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  29893. import { Observable } from "babylonjs/Misc/observable";
  29894. import { _DepthCullingState } from "babylonjs/States/depthCullingState";
  29895. import { _StencilState } from "babylonjs/States/stencilState";
  29896. import { _AlphaState } from "babylonjs/States/alphaCullingState";
  29897. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29898. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29899. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29900. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29901. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29902. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29903. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29904. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29905. import { WebRequest } from "babylonjs/Misc/webRequest";
  29906. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29907. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29909. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29910. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29911. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29912. /**
  29913. * Defines the interface used by objects containing a viewport (like a camera)
  29914. */
  29915. interface IViewportOwnerLike {
  29916. /**
  29917. * Gets or sets the viewport
  29918. */
  29919. viewport: IViewportLike;
  29920. }
  29921. /**
  29922. * Defines the interface used by objects working like Scene
  29923. * @hidden
  29924. */
  29925. interface ISceneLike {
  29926. _addPendingData(data: any): void;
  29927. _removePendingData(data: any): void;
  29928. offlineProvider: IOfflineProvider;
  29929. }
  29930. /** Interface defining initialization parameters for Engine class */
  29931. export interface EngineOptions extends WebGLContextAttributes {
  29932. /**
  29933. * Defines if the engine should no exceed a specified device ratio
  29934. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29935. */
  29936. limitDeviceRatio?: number;
  29937. /**
  29938. * Defines if webvr should be enabled automatically
  29939. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29940. */
  29941. autoEnableWebVR?: boolean;
  29942. /**
  29943. * Defines if webgl2 should be turned off even if supported
  29944. * @see http://doc.babylonjs.com/features/webgl2
  29945. */
  29946. disableWebGL2Support?: boolean;
  29947. /**
  29948. * Defines if webaudio should be initialized as well
  29949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29950. */
  29951. audioEngine?: boolean;
  29952. /**
  29953. * Defines if animations should run using a deterministic lock step
  29954. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29955. */
  29956. deterministicLockstep?: boolean;
  29957. /** Defines the maximum steps to use with deterministic lock step mode */
  29958. lockstepMaxSteps?: number;
  29959. /**
  29960. * Defines that engine should ignore context lost events
  29961. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29962. */
  29963. doNotHandleContextLost?: boolean;
  29964. /**
  29965. * Defines that engine should ignore modifying touch action attribute and style
  29966. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29967. */
  29968. doNotHandleTouchAction?: boolean;
  29969. /**
  29970. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29971. */
  29972. useHighPrecisionFloats?: boolean;
  29973. }
  29974. /**
  29975. * The base engine class (root of all engines)
  29976. */
  29977. export class BaseEngine {
  29978. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29979. static ExceptionList: ({
  29980. key: string;
  29981. capture: string;
  29982. captureConstraint: number;
  29983. targets: string[];
  29984. } | {
  29985. key: string;
  29986. capture: null;
  29987. captureConstraint: null;
  29988. targets: string[];
  29989. })[];
  29990. /** @hidden */
  29991. static _TextureLoaders: IInternalTextureLoader[];
  29992. /**
  29993. * Returns the current npm package of the sdk
  29994. */
  29995. static readonly NpmPackage: string;
  29996. /**
  29997. * Returns the current version of the framework
  29998. */
  29999. static readonly Version: string;
  30000. /**
  30001. * Returns a string describing the current engine
  30002. */
  30003. readonly description: string;
  30004. /**
  30005. * Gets or sets the epsilon value used by collision engine
  30006. */
  30007. static CollisionsEpsilon: number;
  30008. /**
  30009. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30010. */
  30011. static ShadersRepository: string;
  30012. /** @hidden */
  30013. _shaderProcessor: IShaderProcessor;
  30014. /**
  30015. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30016. */
  30017. forcePOTTextures: boolean;
  30018. /**
  30019. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30020. */
  30021. isFullscreen: boolean;
  30022. /**
  30023. * Gets a boolean indicating if the pointer is currently locked
  30024. */
  30025. isPointerLock: boolean;
  30026. /**
  30027. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30028. */
  30029. cullBackFaces: boolean;
  30030. /**
  30031. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30032. */
  30033. renderEvenInBackground: boolean;
  30034. /**
  30035. * Gets or sets a boolean indicating that cache can be kept between frames
  30036. */
  30037. preventCacheWipeBetweenFrames: boolean;
  30038. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30039. validateShaderPrograms: boolean;
  30040. /**
  30041. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30042. */
  30043. disableUniformBuffers: boolean;
  30044. /** @hidden */
  30045. _uniformBuffers: UniformBuffer[];
  30046. /**
  30047. * Gets a boolean indicating that the engine supports uniform buffers
  30048. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30049. */
  30050. readonly supportsUniformBuffers: boolean;
  30051. /** @hidden */
  30052. _gl: WebGLRenderingContext;
  30053. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30054. protected _windowIsBackground: boolean;
  30055. protected _webGLVersion: number;
  30056. protected _highPrecisionShadersAllowed: boolean;
  30057. /** @hidden */
  30058. readonly _shouldUseHighPrecisionShader: boolean;
  30059. /**
  30060. * Gets a boolean indicating that only power of 2 textures are supported
  30061. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30062. */
  30063. readonly needPOTTextures: boolean;
  30064. /** @hidden */
  30065. _badOS: boolean;
  30066. /** @hidden */
  30067. _badDesktopOS: boolean;
  30068. private _hardwareScalingLevel;
  30069. /** @hidden */
  30070. _caps: EngineCapabilities;
  30071. private _isStencilEnable;
  30072. protected _colorWrite: boolean;
  30073. /** @hidden */
  30074. _drawCalls: PerfCounter;
  30075. private _glVersion;
  30076. private _glRenderer;
  30077. private _glVendor;
  30078. private _videoTextureSupported;
  30079. protected _renderingQueueLaunched: boolean;
  30080. protected _activeRenderLoops: (() => void)[];
  30081. private _deterministicLockstep;
  30082. private _lockstepMaxSteps;
  30083. /**
  30084. * Observable signaled when a context lost event is raised
  30085. */
  30086. onContextLostObservable: Observable<BaseEngine>;
  30087. /**
  30088. * Observable signaled when a context restored event is raised
  30089. */
  30090. onContextRestoredObservable: Observable<BaseEngine>;
  30091. private _onContextLost;
  30092. private _onContextRestored;
  30093. protected _contextWasLost: boolean;
  30094. /** @hidden */
  30095. _doNotHandleContextLost: boolean;
  30096. /**
  30097. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30099. */
  30100. doNotHandleContextLost: boolean;
  30101. /**
  30102. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30103. */
  30104. disableVertexArrayObjects: boolean;
  30105. /** @hidden */
  30106. protected _depthCullingState: _DepthCullingState;
  30107. /** @hidden */
  30108. protected _stencilState: _StencilState;
  30109. /** @hidden */
  30110. protected _alphaState: _AlphaState;
  30111. /** @hidden */
  30112. protected _alphaMode: number;
  30113. /** @hidden */
  30114. protected _alphaEquation: number;
  30115. /** @hidden */
  30116. _internalTexturesCache: InternalTexture[];
  30117. /** @hidden */
  30118. protected _activeChannel: number;
  30119. private _currentTextureChannel;
  30120. /** @hidden */
  30121. protected _boundTexturesCache: {
  30122. [key: string]: Nullable<InternalTexture>;
  30123. };
  30124. /** @hidden */
  30125. protected _currentEffect: Nullable<Effect>;
  30126. /** @hidden */
  30127. protected _currentProgram: Nullable<WebGLProgram>;
  30128. private _compiledEffects;
  30129. private _vertexAttribArraysEnabled;
  30130. /** @hidden */
  30131. protected _cachedViewport: Nullable<IViewportLike>;
  30132. private _cachedVertexArrayObject;
  30133. /** @hidden */
  30134. protected _cachedVertexBuffers: any;
  30135. /** @hidden */
  30136. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30137. /** @hidden */
  30138. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30139. /** @hidden */
  30140. _currentRenderTarget: Nullable<InternalTexture>;
  30141. private _uintIndicesCurrentlySet;
  30142. private _currentBoundBuffer;
  30143. /** @hidden */
  30144. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30145. private _currentBufferPointers;
  30146. private _currentInstanceLocations;
  30147. private _currentInstanceBuffers;
  30148. private _textureUnits;
  30149. /** @hidden */
  30150. _workingCanvas: Nullable<HTMLCanvasElement>;
  30151. /** @hidden */
  30152. _workingContext: Nullable<CanvasRenderingContext2D>;
  30153. /** @hidden */
  30154. _bindedRenderFunction: any;
  30155. private _vaoRecordInProgress;
  30156. private _mustWipeVertexAttributes;
  30157. private _emptyTexture;
  30158. private _emptyCubeTexture;
  30159. private _emptyTexture3D;
  30160. /** @hidden */
  30161. _frameHandler: number;
  30162. private _nextFreeTextureSlots;
  30163. private _maxSimultaneousTextures;
  30164. private _activeRequests;
  30165. private _texturesSupported;
  30166. /** @hidden */
  30167. _textureFormatInUse: Nullable<string>;
  30168. protected readonly _supportsHardwareTextureRescaling: boolean;
  30169. /**
  30170. * Gets the list of texture formats supported
  30171. */
  30172. readonly texturesSupported: Array<string>;
  30173. /**
  30174. * Gets the list of texture formats in use
  30175. */
  30176. readonly textureFormatInUse: Nullable<string>;
  30177. /**
  30178. * Gets the current viewport
  30179. */
  30180. readonly currentViewport: Nullable<IViewportLike>;
  30181. /**
  30182. * Gets the default empty texture
  30183. */
  30184. readonly emptyTexture: InternalTexture;
  30185. /**
  30186. * Gets the default empty 3D texture
  30187. */
  30188. readonly emptyTexture3D: InternalTexture;
  30189. /**
  30190. * Gets the default empty cube texture
  30191. */
  30192. readonly emptyCubeTexture: InternalTexture;
  30193. /**
  30194. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30195. */
  30196. readonly premultipliedAlpha: boolean;
  30197. /**
  30198. * Creates a new engine
  30199. * @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
  30200. * @param antialias defines enable antialiasing (default: false)
  30201. * @param options defines further options to be sent to the getContext() function
  30202. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30203. */
  30204. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30205. private _disableTouchAction;
  30206. private _rebuildInternalTextures;
  30207. private _rebuildEffects;
  30208. /**
  30209. * Gets a boolean indicating if all created effects are ready
  30210. * @returns true if all effects are ready
  30211. */
  30212. areAllEffectsReady(): boolean;
  30213. protected _rebuildBuffers(): void;
  30214. private _initGLContext;
  30215. /**
  30216. * Gets version of the current webGL context
  30217. */
  30218. readonly webGLVersion: number;
  30219. /**
  30220. * Gets a string idenfifying the name of the class
  30221. * @returns "Engine" string
  30222. */
  30223. getClassName(): string;
  30224. /**
  30225. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30226. */
  30227. readonly isStencilEnable: boolean;
  30228. /** @hidden */
  30229. _prepareWorkingCanvas(): void;
  30230. /**
  30231. * Reset the texture cache to empty state
  30232. */
  30233. resetTextureCache(): void;
  30234. /**
  30235. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30237. * @returns true if engine is in deterministic lock step mode
  30238. */
  30239. isDeterministicLockStep(): boolean;
  30240. /**
  30241. * Gets the max steps when engine is running in deterministic lock step
  30242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30243. * @returns the max steps
  30244. */
  30245. getLockstepMaxSteps(): number;
  30246. /**
  30247. * Gets an object containing information about the current webGL context
  30248. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30249. */
  30250. getGlInfo(): {
  30251. vendor: string;
  30252. renderer: string;
  30253. version: string;
  30254. };
  30255. /**
  30256. * Gets current aspect ratio
  30257. * @param viewportOwner defines the camera to use to get the aspect ratio
  30258. * @param useScreen defines if screen size must be used (or the current render target if any)
  30259. * @returns a number defining the aspect ratio
  30260. */
  30261. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30262. /**
  30263. * Gets current screen aspect ratio
  30264. * @returns a number defining the aspect ratio
  30265. */
  30266. getScreenAspectRatio(): number;
  30267. /**
  30268. * Gets the current render width
  30269. * @param useScreen defines if screen size must be used (or the current render target if any)
  30270. * @returns a number defining the current render width
  30271. */
  30272. getRenderWidth(useScreen?: boolean): number;
  30273. /**
  30274. * Gets the current render height
  30275. * @param useScreen defines if screen size must be used (or the current render target if any)
  30276. * @returns a number defining the current render height
  30277. */
  30278. getRenderHeight(useScreen?: boolean): number;
  30279. /**
  30280. * Gets the HTML canvas attached with the current webGL context
  30281. * @returns a HTML canvas
  30282. */
  30283. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30284. /**
  30285. * Gets host window
  30286. * @returns the host window object
  30287. */
  30288. getHostWindow(): Window;
  30289. /**
  30290. * Gets host document
  30291. * @returns the host document object
  30292. */
  30293. getHostDocument(): Document;
  30294. /**
  30295. * Gets the client rect of the HTML canvas attached with the current webGL context
  30296. * @returns a client rectanglee
  30297. */
  30298. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30299. /**
  30300. * Defines the hardware scaling level.
  30301. * By default the hardware scaling level is computed from the window device ratio.
  30302. * 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.
  30303. * @param level defines the level to use
  30304. */
  30305. setHardwareScalingLevel(level: number): void;
  30306. /**
  30307. * Gets the current hardware scaling level.
  30308. * By default the hardware scaling level is computed from the window device ratio.
  30309. * 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.
  30310. * @returns a number indicating the current hardware scaling level
  30311. */
  30312. getHardwareScalingLevel(): number;
  30313. /**
  30314. * Gets the list of loaded textures
  30315. * @returns an array containing all loaded textures
  30316. */
  30317. getLoadedTexturesCache(): InternalTexture[];
  30318. /**
  30319. * Gets the object containing all engine capabilities
  30320. * @returns the EngineCapabilities object
  30321. */
  30322. getCaps(): EngineCapabilities;
  30323. /**
  30324. * Gets the current depth function
  30325. * @returns a number defining the depth function
  30326. */
  30327. getDepthFunction(): Nullable<number>;
  30328. /**
  30329. * Sets the current depth function
  30330. * @param depthFunc defines the function to use
  30331. */
  30332. setDepthFunction(depthFunc: number): void;
  30333. /**
  30334. * Sets the current depth function to GREATER
  30335. */
  30336. setDepthFunctionToGreater(): void;
  30337. /**
  30338. * Sets the current depth function to GEQUAL
  30339. */
  30340. setDepthFunctionToGreaterOrEqual(): void;
  30341. /**
  30342. * Sets the current depth function to LESS
  30343. */
  30344. setDepthFunctionToLess(): void;
  30345. private _cachedStencilBuffer;
  30346. private _cachedStencilFunction;
  30347. private _cachedStencilMask;
  30348. private _cachedStencilOperationPass;
  30349. private _cachedStencilOperationFail;
  30350. private _cachedStencilOperationDepthFail;
  30351. private _cachedStencilReference;
  30352. /**
  30353. * Caches the the state of the stencil buffer
  30354. */
  30355. cacheStencilState(): void;
  30356. /**
  30357. * Restores the state of the stencil buffer
  30358. */
  30359. restoreStencilState(): void;
  30360. /**
  30361. * Sets the current depth function to LEQUAL
  30362. */
  30363. setDepthFunctionToLessOrEqual(): void;
  30364. /**
  30365. * Gets a boolean indicating if stencil buffer is enabled
  30366. * @returns the current stencil buffer state
  30367. */
  30368. getStencilBuffer(): boolean;
  30369. /**
  30370. * Enable or disable the stencil buffer
  30371. * @param enable defines if the stencil buffer must be enabled or disabled
  30372. */
  30373. setStencilBuffer(enable: boolean): void;
  30374. /**
  30375. * Gets the current stencil mask
  30376. * @returns a number defining the new stencil mask to use
  30377. */
  30378. getStencilMask(): number;
  30379. /**
  30380. * Sets the current stencil mask
  30381. * @param mask defines the new stencil mask to use
  30382. */
  30383. setStencilMask(mask: number): void;
  30384. /**
  30385. * Gets the current stencil function
  30386. * @returns a number defining the stencil function to use
  30387. */
  30388. getStencilFunction(): number;
  30389. /**
  30390. * Gets the current stencil reference value
  30391. * @returns a number defining the stencil reference value to use
  30392. */
  30393. getStencilFunctionReference(): number;
  30394. /**
  30395. * Gets the current stencil mask
  30396. * @returns a number defining the stencil mask to use
  30397. */
  30398. getStencilFunctionMask(): number;
  30399. /**
  30400. * Sets the current stencil function
  30401. * @param stencilFunc defines the new stencil function to use
  30402. */
  30403. setStencilFunction(stencilFunc: number): void;
  30404. /**
  30405. * Sets the current stencil reference
  30406. * @param reference defines the new stencil reference to use
  30407. */
  30408. setStencilFunctionReference(reference: number): void;
  30409. /**
  30410. * Sets the current stencil mask
  30411. * @param mask defines the new stencil mask to use
  30412. */
  30413. setStencilFunctionMask(mask: number): void;
  30414. /**
  30415. * Gets the current stencil operation when stencil fails
  30416. * @returns a number defining stencil operation to use when stencil fails
  30417. */
  30418. getStencilOperationFail(): number;
  30419. /**
  30420. * Gets the current stencil operation when depth fails
  30421. * @returns a number defining stencil operation to use when depth fails
  30422. */
  30423. getStencilOperationDepthFail(): number;
  30424. /**
  30425. * Gets the current stencil operation when stencil passes
  30426. * @returns a number defining stencil operation to use when stencil passes
  30427. */
  30428. getStencilOperationPass(): number;
  30429. /**
  30430. * Sets the stencil operation to use when stencil fails
  30431. * @param operation defines the stencil operation to use when stencil fails
  30432. */
  30433. setStencilOperationFail(operation: number): void;
  30434. /**
  30435. * Sets the stencil operation to use when depth fails
  30436. * @param operation defines the stencil operation to use when depth fails
  30437. */
  30438. setStencilOperationDepthFail(operation: number): void;
  30439. /**
  30440. * Sets the stencil operation to use when stencil passes
  30441. * @param operation defines the stencil operation to use when stencil passes
  30442. */
  30443. setStencilOperationPass(operation: number): void;
  30444. /**
  30445. * Sets a boolean indicating if the dithering state is enabled or disabled
  30446. * @param value defines the dithering state
  30447. */
  30448. setDitheringState(value: boolean): void;
  30449. /**
  30450. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30451. * @param value defines the rasterizer state
  30452. */
  30453. setRasterizerState(value: boolean): void;
  30454. /**
  30455. * stop executing a render loop function and remove it from the execution array
  30456. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30457. */
  30458. stopRenderLoop(renderFunction?: () => void): void;
  30459. /** @hidden */
  30460. _renderLoop(): void;
  30461. /**
  30462. * Can be used to override the current requestAnimationFrame requester.
  30463. * @hidden
  30464. */
  30465. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30466. /**
  30467. * Register and execute a render loop. The engine can have more than one render function
  30468. * @param renderFunction defines the function to continuously execute
  30469. */
  30470. runRenderLoop(renderFunction: () => void): void;
  30471. /**
  30472. * Clear the current render buffer or the current render target (if any is set up)
  30473. * @param color defines the color to use
  30474. * @param backBuffer defines if the back buffer must be cleared
  30475. * @param depth defines if the depth buffer must be cleared
  30476. * @param stencil defines if the stencil buffer must be cleared
  30477. */
  30478. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30479. /**
  30480. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30481. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30482. * @param y defines the y-coordinate of the corner of the clear rectangle
  30483. * @param width defines the width of the clear rectangle
  30484. * @param height defines the height of the clear rectangle
  30485. * @param clearColor defines the clear color
  30486. */
  30487. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30488. /**
  30489. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30490. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30491. * @param y defines the y-coordinate of the corner of the clear rectangle
  30492. * @param width defines the width of the clear rectangle
  30493. * @param height defines the height of the clear rectangle
  30494. */
  30495. enableScissor(x: number, y: number, width: number, height: number): void;
  30496. /**
  30497. * Disable previously set scissor test rectangle
  30498. */
  30499. disableScissor(): void;
  30500. private _viewportCached;
  30501. /** @hidden */
  30502. _viewport(x: number, y: number, width: number, height: number): void;
  30503. /**
  30504. * Set the WebGL's viewport
  30505. * @param viewport defines the viewport element to be used
  30506. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30507. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30508. */
  30509. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30510. /**
  30511. * Directly set the WebGL Viewport
  30512. * @param x defines the x coordinate of the viewport (in screen space)
  30513. * @param y defines the y coordinate of the viewport (in screen space)
  30514. * @param width defines the width of the viewport (in screen space)
  30515. * @param height defines the height of the viewport (in screen space)
  30516. * @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
  30517. */
  30518. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30519. /**
  30520. * Begin a new frame
  30521. */
  30522. beginFrame(): void;
  30523. /**
  30524. * Enf the current frame
  30525. */
  30526. endFrame(): void;
  30527. /**
  30528. * Resize the view according to the canvas' size
  30529. */
  30530. resize(): void;
  30531. /**
  30532. * Force a specific size of the canvas
  30533. * @param width defines the new canvas' width
  30534. * @param height defines the new canvas' height
  30535. */
  30536. setSize(width: number, height: number): void;
  30537. /**
  30538. * Binds the frame buffer to the specified texture.
  30539. * @param texture The texture to render to or null for the default canvas
  30540. * @param faceIndex The face of the texture to render to in case of cube texture
  30541. * @param requiredWidth The width of the target to render to
  30542. * @param requiredHeight The height of the target to render to
  30543. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30544. * @param depthStencilTexture The depth stencil texture to use to render
  30545. * @param lodLevel defines le lod level to bind to the frame buffer
  30546. */
  30547. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30548. /** @hidden */
  30549. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30550. /**
  30551. * Unbind the current render target texture from the webGL context
  30552. * @param texture defines the render target texture to unbind
  30553. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30554. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30555. */
  30556. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30557. /**
  30558. * Force the mipmap generation for the given render target texture
  30559. * @param texture defines the render target texture to use
  30560. */
  30561. generateMipMapsForCubemap(texture: InternalTexture): void;
  30562. /**
  30563. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30564. */
  30565. flushFramebuffer(): void;
  30566. /**
  30567. * Unbind the current render target and bind the default framebuffer
  30568. */
  30569. restoreDefaultFramebuffer(): void;
  30570. /**
  30571. * Create an uniform buffer
  30572. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30573. * @param elements defines the content of the uniform buffer
  30574. * @returns the webGL uniform buffer
  30575. */
  30576. createUniformBuffer(elements: FloatArray): DataBuffer;
  30577. /**
  30578. * Create a dynamic uniform buffer
  30579. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30580. * @param elements defines the content of the uniform buffer
  30581. * @returns the webGL uniform buffer
  30582. */
  30583. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30584. /**
  30585. * Update an existing uniform buffer
  30586. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30587. * @param uniformBuffer defines the target uniform buffer
  30588. * @param elements defines the content to update
  30589. * @param offset defines the offset in the uniform buffer where update should start
  30590. * @param count defines the size of the data to update
  30591. */
  30592. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30593. private _resetVertexBufferBinding;
  30594. /**
  30595. * Creates a vertex buffer
  30596. * @param data the data for the vertex buffer
  30597. * @returns the new WebGL static buffer
  30598. */
  30599. createVertexBuffer(data: DataArray): DataBuffer;
  30600. private _createVertexBuffer;
  30601. /**
  30602. * Creates a dynamic vertex buffer
  30603. * @param data the data for the dynamic vertex buffer
  30604. * @returns the new WebGL dynamic buffer
  30605. */
  30606. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30607. /**
  30608. * Update a dynamic index buffer
  30609. * @param indexBuffer defines the target index buffer
  30610. * @param indices defines the data to update
  30611. * @param offset defines the offset in the target index buffer where update should start
  30612. */
  30613. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30614. /**
  30615. * Updates a dynamic vertex buffer.
  30616. * @param vertexBuffer the vertex buffer to update
  30617. * @param data the data used to update the vertex buffer
  30618. * @param byteOffset the byte offset of the data
  30619. * @param byteLength the byte length of the data
  30620. */
  30621. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30622. private _resetIndexBufferBinding;
  30623. /**
  30624. * Creates a new index buffer
  30625. * @param indices defines the content of the index buffer
  30626. * @param updatable defines if the index buffer must be updatable
  30627. * @returns a new webGL buffer
  30628. */
  30629. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30630. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30631. /**
  30632. * Bind a webGL buffer to the webGL context
  30633. * @param buffer defines the buffer to bind
  30634. */
  30635. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30636. /**
  30637. * Bind an uniform buffer to the current webGL context
  30638. * @param buffer defines the buffer to bind
  30639. */
  30640. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30641. /**
  30642. * Bind a buffer to the current webGL context at a given location
  30643. * @param buffer defines the buffer to bind
  30644. * @param location defines the index where to bind the buffer
  30645. */
  30646. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30647. /**
  30648. * Bind a specific block at a given index in a specific shader program
  30649. * @param pipelineContext defines the pipeline context to use
  30650. * @param blockName defines the block name
  30651. * @param index defines the index where to bind the block
  30652. */
  30653. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30654. private bindIndexBuffer;
  30655. private bindBuffer;
  30656. /**
  30657. * update the bound buffer with the given data
  30658. * @param data defines the data to update
  30659. */
  30660. updateArrayBuffer(data: Float32Array): void;
  30661. private _vertexAttribPointer;
  30662. private _bindIndexBufferWithCache;
  30663. private _bindVertexBuffersAttributes;
  30664. /**
  30665. * Records a vertex array object
  30666. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30667. * @param vertexBuffers defines the list of vertex buffers to store
  30668. * @param indexBuffer defines the index buffer to store
  30669. * @param effect defines the effect to store
  30670. * @returns the new vertex array object
  30671. */
  30672. recordVertexArrayObject(vertexBuffers: {
  30673. [key: string]: VertexBuffer;
  30674. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30675. /**
  30676. * Bind a specific vertex array object
  30677. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30678. * @param vertexArrayObject defines the vertex array object to bind
  30679. * @param indexBuffer defines the index buffer to bind
  30680. */
  30681. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30682. /**
  30683. * Bind webGl buffers directly to the webGL context
  30684. * @param vertexBuffer defines the vertex buffer to bind
  30685. * @param indexBuffer defines the index buffer to bind
  30686. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30687. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30688. * @param effect defines the effect associated with the vertex buffer
  30689. */
  30690. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30691. private _unbindVertexArrayObject;
  30692. /**
  30693. * Bind a list of vertex buffers to the webGL context
  30694. * @param vertexBuffers defines the list of vertex buffers to bind
  30695. * @param indexBuffer defines the index buffer to bind
  30696. * @param effect defines the effect associated with the vertex buffers
  30697. */
  30698. bindBuffers(vertexBuffers: {
  30699. [key: string]: Nullable<VertexBuffer>;
  30700. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30701. /**
  30702. * Unbind all instance attributes
  30703. */
  30704. unbindInstanceAttributes(): void;
  30705. /**
  30706. * Release and free the memory of a vertex array object
  30707. * @param vao defines the vertex array object to delete
  30708. */
  30709. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30710. /** @hidden */
  30711. _releaseBuffer(buffer: DataBuffer): boolean;
  30712. protected _deleteBuffer(buffer: DataBuffer): void;
  30713. /**
  30714. * Creates a webGL buffer to use with instanciation
  30715. * @param capacity defines the size of the buffer
  30716. * @returns the webGL buffer
  30717. */
  30718. createInstancesBuffer(capacity: number): DataBuffer;
  30719. /**
  30720. * Delete a webGL buffer used with instanciation
  30721. * @param buffer defines the webGL buffer to delete
  30722. */
  30723. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30724. /**
  30725. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30726. * @param instancesBuffer defines the webGL buffer to update and bind
  30727. * @param data defines the data to store in the buffer
  30728. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30729. */
  30730. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30731. /**
  30732. * Apply all cached states (depth, culling, stencil and alpha)
  30733. */
  30734. applyStates(): void;
  30735. /**
  30736. * Send a draw order
  30737. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30738. * @param indexStart defines the starting index
  30739. * @param indexCount defines the number of index to draw
  30740. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30741. */
  30742. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30743. /**
  30744. * Draw a list of points
  30745. * @param verticesStart defines the index of first vertex to draw
  30746. * @param verticesCount defines the count of vertices to draw
  30747. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30748. */
  30749. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30750. /**
  30751. * Draw a list of unindexed primitives
  30752. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30753. * @param verticesStart defines the index of first vertex to draw
  30754. * @param verticesCount defines the count of vertices to draw
  30755. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30756. */
  30757. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30758. /**
  30759. * Draw a list of indexed primitives
  30760. * @param fillMode defines the primitive to use
  30761. * @param indexStart defines the starting index
  30762. * @param indexCount defines the number of index to draw
  30763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30764. */
  30765. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30766. /**
  30767. * Draw a list of unindexed primitives
  30768. * @param fillMode defines the primitive to use
  30769. * @param verticesStart defines the index of first vertex to draw
  30770. * @param verticesCount defines the count of vertices to draw
  30771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30772. */
  30773. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30774. private _drawMode;
  30775. /** @hidden */
  30776. _releaseEffect(effect: Effect): void;
  30777. /** @hidden */
  30778. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30779. /**
  30780. * Create a new effect (used to store vertex/fragment shaders)
  30781. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30782. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30783. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30784. * @param samplers defines an array of string used to represent textures
  30785. * @param defines defines the string containing the defines to use to compile the shaders
  30786. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30787. * @param onCompiled defines a function to call when the effect creation is successful
  30788. * @param onError defines a function to call when the effect creation has failed
  30789. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30790. * @returns the new Effect
  30791. */
  30792. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | BaseEngine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30793. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30794. private _compileShader;
  30795. private _compileRawShader;
  30796. /**
  30797. * Directly creates a webGL program
  30798. * @param pipelineContext defines the pipeline context to attach to
  30799. * @param vertexCode defines the vertex shader code to use
  30800. * @param fragmentCode defines the fragment shader code to use
  30801. * @param context defines the webGL context to use (if not set, the current one will be used)
  30802. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30803. * @returns the new webGL program
  30804. */
  30805. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30806. /**
  30807. * Creates a webGL program
  30808. * @param pipelineContext defines the pipeline context to attach to
  30809. * @param vertexCode defines the vertex shader code to use
  30810. * @param fragmentCode defines the fragment shader code to use
  30811. * @param defines defines the string containing the defines to use to compile the shaders
  30812. * @param context defines the webGL context to use (if not set, the current one will be used)
  30813. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30814. * @returns the new webGL program
  30815. */
  30816. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30817. /**
  30818. * Creates a new pipeline context
  30819. * @returns the new pipeline
  30820. */
  30821. createPipelineContext(): IPipelineContext;
  30822. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30823. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30824. /** @hidden */
  30825. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30826. /** @hidden */
  30827. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30828. /** @hidden */
  30829. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30830. /**
  30831. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30832. * @param pipelineContext defines the pipeline context to use
  30833. * @param uniformsNames defines the list of uniform names
  30834. * @returns an array of webGL uniform locations
  30835. */
  30836. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30837. /**
  30838. * Gets the lsit of active attributes for a given webGL program
  30839. * @param pipelineContext defines the pipeline context to use
  30840. * @param attributesNames defines the list of attribute names to get
  30841. * @returns an array of indices indicating the offset of each attribute
  30842. */
  30843. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30844. /**
  30845. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30846. * @param effect defines the effect to activate
  30847. */
  30848. enableEffect(effect: Nullable<Effect>): void;
  30849. /**
  30850. * Set the value of an uniform to an array of int32
  30851. * @param uniform defines the webGL uniform location where to store the value
  30852. * @param array defines the array of int32 to store
  30853. */
  30854. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30855. /**
  30856. * Set the value of an uniform to an array of int32 (stored as vec2)
  30857. * @param uniform defines the webGL uniform location where to store the value
  30858. * @param array defines the array of int32 to store
  30859. */
  30860. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30861. /**
  30862. * Set the value of an uniform to an array of int32 (stored as vec3)
  30863. * @param uniform defines the webGL uniform location where to store the value
  30864. * @param array defines the array of int32 to store
  30865. */
  30866. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30867. /**
  30868. * Set the value of an uniform to an array of int32 (stored as vec4)
  30869. * @param uniform defines the webGL uniform location where to store the value
  30870. * @param array defines the array of int32 to store
  30871. */
  30872. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30873. /**
  30874. * Set the value of an uniform to an array of float32
  30875. * @param uniform defines the webGL uniform location where to store the value
  30876. * @param array defines the array of float32 to store
  30877. */
  30878. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30879. /**
  30880. * Set the value of an uniform to an array of float32 (stored as vec2)
  30881. * @param uniform defines the webGL uniform location where to store the value
  30882. * @param array defines the array of float32 to store
  30883. */
  30884. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30885. /**
  30886. * Set the value of an uniform to an array of float32 (stored as vec3)
  30887. * @param uniform defines the webGL uniform location where to store the value
  30888. * @param array defines the array of float32 to store
  30889. */
  30890. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30891. /**
  30892. * Set the value of an uniform to an array of float32 (stored as vec4)
  30893. * @param uniform defines the webGL uniform location where to store the value
  30894. * @param array defines the array of float32 to store
  30895. */
  30896. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30897. /**
  30898. * Set the value of an uniform to an array of number
  30899. * @param uniform defines the webGL uniform location where to store the value
  30900. * @param array defines the array of number to store
  30901. */
  30902. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30903. /**
  30904. * Set the value of an uniform to an array of number (stored as vec2)
  30905. * @param uniform defines the webGL uniform location where to store the value
  30906. * @param array defines the array of number to store
  30907. */
  30908. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30909. /**
  30910. * Set the value of an uniform to an array of number (stored as vec3)
  30911. * @param uniform defines the webGL uniform location where to store the value
  30912. * @param array defines the array of number to store
  30913. */
  30914. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30915. /**
  30916. * Set the value of an uniform to an array of number (stored as vec4)
  30917. * @param uniform defines the webGL uniform location where to store the value
  30918. * @param array defines the array of number to store
  30919. */
  30920. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30921. /**
  30922. * Set the value of an uniform to an array of float32 (stored as matrices)
  30923. * @param uniform defines the webGL uniform location where to store the value
  30924. * @param matrices defines the array of float32 to store
  30925. */
  30926. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30927. /**
  30928. * Set the value of an uniform to a matrix (3x3)
  30929. * @param uniform defines the webGL uniform location where to store the value
  30930. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30931. */
  30932. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30933. /**
  30934. * Set the value of an uniform to a matrix (2x2)
  30935. * @param uniform defines the webGL uniform location where to store the value
  30936. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30937. */
  30938. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30939. /**
  30940. * Set the value of an uniform to a number (int)
  30941. * @param uniform defines the webGL uniform location where to store the value
  30942. * @param value defines the int number to store
  30943. */
  30944. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30945. /**
  30946. * Set the value of an uniform to a number (float)
  30947. * @param uniform defines the webGL uniform location where to store the value
  30948. * @param value defines the float number to store
  30949. */
  30950. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30951. /**
  30952. * Set the value of an uniform to a vec2
  30953. * @param uniform defines the webGL uniform location where to store the value
  30954. * @param x defines the 1st component of the value
  30955. * @param y defines the 2nd component of the value
  30956. */
  30957. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30958. /**
  30959. * Set the value of an uniform to a vec3
  30960. * @param uniform defines the webGL uniform location where to store the value
  30961. * @param x defines the 1st component of the value
  30962. * @param y defines the 2nd component of the value
  30963. * @param z defines the 3rd component of the value
  30964. */
  30965. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30966. /**
  30967. * Set the value of an uniform to a boolean
  30968. * @param uniform defines the webGL uniform location where to store the value
  30969. * @param bool defines the boolean to store
  30970. */
  30971. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30972. /**
  30973. * Set the value of an uniform to a vec4
  30974. * @param uniform defines the webGL uniform location where to store the value
  30975. * @param x defines the 1st component of the value
  30976. * @param y defines the 2nd component of the value
  30977. * @param z defines the 3rd component of the value
  30978. * @param w defines the 4th component of the value
  30979. */
  30980. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30981. /**
  30982. * Sets a Color4 on a uniform variable
  30983. * @param uniform defines the uniform location
  30984. * @param color4 defines the value to be set
  30985. */
  30986. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30987. /**
  30988. * Set various states to the webGL context
  30989. * @param culling defines backface culling state
  30990. * @param zOffset defines the value to apply to zOffset (0 by default)
  30991. * @param force defines if states must be applied even if cache is up to date
  30992. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30993. */
  30994. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30995. /**
  30996. * Set the z offset to apply to current rendering
  30997. * @param value defines the offset to apply
  30998. */
  30999. setZOffset(value: number): void;
  31000. /**
  31001. * Gets the current value of the zOffset
  31002. * @returns the current zOffset state
  31003. */
  31004. getZOffset(): number;
  31005. /**
  31006. * Enable or disable depth buffering
  31007. * @param enable defines the state to set
  31008. */
  31009. setDepthBuffer(enable: boolean): void;
  31010. /**
  31011. * Gets a boolean indicating if depth writing is enabled
  31012. * @returns the current depth writing state
  31013. */
  31014. getDepthWrite(): boolean;
  31015. /**
  31016. * Enable or disable depth writing
  31017. * @param enable defines the state to set
  31018. */
  31019. setDepthWrite(enable: boolean): void;
  31020. /**
  31021. * Enable or disable color writing
  31022. * @param enable defines the state to set
  31023. */
  31024. setColorWrite(enable: boolean): void;
  31025. /**
  31026. * Gets a boolean indicating if color writing is enabled
  31027. * @returns the current color writing state
  31028. */
  31029. getColorWrite(): boolean;
  31030. /**
  31031. * Sets alpha constants used by some alpha blending modes
  31032. * @param r defines the red component
  31033. * @param g defines the green component
  31034. * @param b defines the blue component
  31035. * @param a defines the alpha component
  31036. */
  31037. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31038. /**
  31039. * Sets the current alpha mode
  31040. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31041. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31042. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31043. */
  31044. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31045. /**
  31046. * Gets the current alpha mode
  31047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31048. * @returns the current alpha mode
  31049. */
  31050. getAlphaMode(): number;
  31051. /**
  31052. * Sets the current alpha equation
  31053. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31054. */
  31055. setAlphaEquation(equation: number): void;
  31056. /**
  31057. * Gets the current alpha equation.
  31058. * @returns the current alpha equation
  31059. */
  31060. getAlphaEquation(): number;
  31061. /**
  31062. * Clears the list of texture accessible through engine.
  31063. * This can help preventing texture load conflict due to name collision.
  31064. */
  31065. clearInternalTexturesCache(): void;
  31066. /**
  31067. * Force the entire cache to be cleared
  31068. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31069. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31070. */
  31071. wipeCaches(bruteForce?: boolean): void;
  31072. /**
  31073. * Set the compressed texture format to use, based on the formats you have, and the formats
  31074. * supported by the hardware / browser.
  31075. *
  31076. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31077. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31078. * to API arguments needed to compressed textures. This puts the burden on the container
  31079. * generator to house the arcane code for determining these for current & future formats.
  31080. *
  31081. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31082. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31083. *
  31084. * Note: The result of this call is not taken into account when a texture is base64.
  31085. *
  31086. * @param formatsAvailable defines the list of those format families you have created
  31087. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31088. *
  31089. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31090. * @returns The extension selected.
  31091. */
  31092. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31093. /** @hidden */
  31094. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31095. min: number;
  31096. mag: number;
  31097. };
  31098. /** @hidden */
  31099. _createTexture(): WebGLTexture;
  31100. /**
  31101. * Usually called from Texture.ts.
  31102. * Passed information to create a WebGLTexture
  31103. * @param urlArg defines a value which contains one of the following:
  31104. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31105. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31106. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31107. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31108. * @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)
  31109. * @param scene needed for loading to the correct scene
  31110. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31111. * @param onLoad optional callback to be called upon successful completion
  31112. * @param onError optional callback to be called upon failure
  31113. * @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
  31114. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31115. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31116. * @param forcedExtension defines the extension to use to pick the right loader
  31117. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31118. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31119. */
  31120. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31121. /**
  31122. * @hidden
  31123. */
  31124. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31125. private _unpackFlipYCached;
  31126. /**
  31127. * In case you are sharing the context with other applications, it might
  31128. * be interested to not cache the unpack flip y state to ensure a consistent
  31129. * value would be set.
  31130. */
  31131. enableUnpackFlipYCached: boolean;
  31132. /** @hidden */
  31133. _unpackFlipY(value: boolean): void;
  31134. /** @hidden */
  31135. _getUnpackAlignement(): number;
  31136. /**
  31137. * Creates a dynamic texture
  31138. * @param width defines the width of the texture
  31139. * @param height defines the height of the texture
  31140. * @param generateMipMaps defines if the engine should generate the mip levels
  31141. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31142. * @returns the dynamic texture inside an InternalTexture
  31143. */
  31144. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31145. /**
  31146. * Update the sampling mode of a given texture
  31147. * @param samplingMode defines the required sampling mode
  31148. * @param texture defines the texture to update
  31149. */
  31150. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31151. /**
  31152. * Update the content of a dynamic texture
  31153. * @param texture defines the texture to update
  31154. * @param canvas defines the canvas containing the source
  31155. * @param invertY defines if data must be stored with Y axis inverted
  31156. * @param premulAlpha defines if alpha is stored as premultiplied
  31157. * @param format defines the format of the data
  31158. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31159. */
  31160. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31161. /**
  31162. * Update a video texture
  31163. * @param texture defines the texture to update
  31164. * @param video defines the video element to use
  31165. * @param invertY defines if data must be stored with Y axis inverted
  31166. */
  31167. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31168. /**
  31169. * Updates a depth texture Comparison Mode and Function.
  31170. * If the comparison Function is equal to 0, the mode will be set to none.
  31171. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31172. * @param texture The texture to set the comparison function for
  31173. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31174. */
  31175. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31176. /** @hidden */
  31177. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31178. width: number;
  31179. height: number;
  31180. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31181. /**
  31182. * Creates a depth stencil texture.
  31183. * This is only available in WebGL 2 or with the depth texture extension available.
  31184. * @param size The size of face edge in the texture.
  31185. * @param options The options defining the texture.
  31186. * @returns The texture
  31187. */
  31188. createDepthStencilTexture(size: number | {
  31189. width: number;
  31190. height: number;
  31191. }, options: DepthTextureCreationOptions): InternalTexture;
  31192. /**
  31193. * Creates a depth stencil texture.
  31194. * This is only available in WebGL 2 or with the depth texture extension available.
  31195. * @param size The size of face edge in the texture.
  31196. * @param options The options defining the texture.
  31197. * @returns The texture
  31198. */
  31199. private _createDepthStencilTexture;
  31200. /**
  31201. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31202. * @param renderTarget The render target to set the frame buffer for
  31203. */
  31204. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31205. /**
  31206. * Creates a new render target texture
  31207. * @param size defines the size of the texture
  31208. * @param options defines the options used to create the texture
  31209. * @returns a new render target texture stored in an InternalTexture
  31210. */
  31211. createRenderTargetTexture(size: number | {
  31212. width: number;
  31213. height: number;
  31214. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31215. /** @hidden */
  31216. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31217. /**
  31218. * Updates the sample count of a render target texture
  31219. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31220. * @param texture defines the texture to update
  31221. * @param samples defines the sample count to set
  31222. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31223. */
  31224. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31225. /** @hidden */
  31226. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31227. /** @hidden */
  31228. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31229. /** @hidden */
  31230. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31231. /** @hidden */
  31232. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31233. /**
  31234. * @hidden
  31235. */
  31236. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31237. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31238. private _prepareWebGLTexture;
  31239. /** @hidden */
  31240. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31241. /** @hidden */
  31242. _releaseFramebufferObjects(texture: InternalTexture): void;
  31243. /** @hidden */
  31244. _releaseTexture(texture: InternalTexture): void;
  31245. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31246. protected _setProgram(program: WebGLProgram): void;
  31247. protected _boundUniforms: {
  31248. [key: number]: WebGLUniformLocation;
  31249. };
  31250. /**
  31251. * Binds an effect to the webGL context
  31252. * @param effect defines the effect to bind
  31253. */
  31254. bindSamplers(effect: Effect): void;
  31255. private _activateCurrentTexture;
  31256. /** @hidden */
  31257. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31258. /** @hidden */
  31259. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31260. /**
  31261. * Sets a texture to the webGL context from a postprocess
  31262. * @param channel defines the channel to use
  31263. * @param postProcess defines the source postprocess
  31264. */
  31265. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31266. /**
  31267. * Binds the output of the passed in post process to the texture channel specified
  31268. * @param channel The channel the texture should be bound to
  31269. * @param postProcess The post process which's output should be bound
  31270. */
  31271. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31272. /**
  31273. * Unbind all textures from the webGL context
  31274. */
  31275. unbindAllTextures(): void;
  31276. /**
  31277. * Sets a texture to the according uniform.
  31278. * @param channel The texture channel
  31279. * @param uniform The uniform to set
  31280. * @param texture The texture to apply
  31281. */
  31282. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31283. /**
  31284. * Sets a depth stencil texture from a render target to the according uniform.
  31285. * @param channel The texture channel
  31286. * @param uniform The uniform to set
  31287. * @param texture The render target texture containing the depth stencil texture to apply
  31288. */
  31289. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31290. private _bindSamplerUniformToChannel;
  31291. private _getTextureWrapMode;
  31292. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31293. /**
  31294. * Sets an array of texture to the webGL context
  31295. * @param channel defines the channel where the texture array must be set
  31296. * @param uniform defines the associated uniform location
  31297. * @param textures defines the array of textures to bind
  31298. */
  31299. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31300. /** @hidden */
  31301. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31302. private _setTextureParameterFloat;
  31303. private _setTextureParameterInteger;
  31304. /**
  31305. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31306. * @param x defines the x coordinate of the rectangle where pixels must be read
  31307. * @param y defines the y coordinate of the rectangle where pixels must be read
  31308. * @param width defines the width of the rectangle where pixels must be read
  31309. * @param height defines the height of the rectangle where pixels must be read
  31310. * @returns a Uint8Array containing RGBA colors
  31311. */
  31312. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31313. /**
  31314. * Unbind all vertex attributes from the webGL context
  31315. */
  31316. unbindAllAttributes(): void;
  31317. /**
  31318. * 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
  31319. */
  31320. releaseEffects(): void;
  31321. /**
  31322. * Dispose and release all associated resources
  31323. */
  31324. dispose(): void;
  31325. /**
  31326. * Attach a new callback raised when context lost event is fired
  31327. * @param callback defines the callback to call
  31328. */
  31329. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31330. /**
  31331. * Attach a new callback raised when context restored event is fired
  31332. * @param callback defines the callback to call
  31333. */
  31334. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31335. /**
  31336. * Gets the source code of the vertex shader associated with a specific webGL program
  31337. * @param program defines the program to use
  31338. * @returns a string containing the source code of the vertex shader associated with the program
  31339. */
  31340. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31341. /**
  31342. * Gets the source code of the fragment shader associated with a specific webGL program
  31343. * @param program defines the program to use
  31344. * @returns a string containing the source code of the fragment shader associated with the program
  31345. */
  31346. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31347. /**
  31348. * Get the current error code of the webGL context
  31349. * @returns the error code
  31350. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31351. */
  31352. getError(): number;
  31353. private _canRenderToFloatFramebuffer;
  31354. private _canRenderToHalfFloatFramebuffer;
  31355. private _canRenderToFramebuffer;
  31356. /** @hidden */
  31357. _getWebGLTextureType(type: number): number;
  31358. /** @hidden */
  31359. _getInternalFormat(format: number): number;
  31360. /** @hidden */
  31361. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31362. /** @hidden */
  31363. _getRGBAMultiSampleBufferFormat(type: number): number;
  31364. /** @hidden */
  31365. _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;
  31366. /** @hidden */
  31367. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31368. /**
  31369. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31370. * @returns true if the engine can be created
  31371. * @ignorenaming
  31372. */
  31373. static isSupported(): boolean;
  31374. /**
  31375. * Find the next highest power of two.
  31376. * @param x Number to start search from.
  31377. * @return Next highest power of two.
  31378. */
  31379. static CeilingPOT(x: number): number;
  31380. /**
  31381. * Find the next lowest power of two.
  31382. * @param x Number to start search from.
  31383. * @return Next lowest power of two.
  31384. */
  31385. static FloorPOT(x: number): number;
  31386. /**
  31387. * Find the nearest power of two.
  31388. * @param x Number to start search from.
  31389. * @return Next nearest power of two.
  31390. */
  31391. static NearestPOT(x: number): number;
  31392. /**
  31393. * Get the closest exponent of two
  31394. * @param value defines the value to approximate
  31395. * @param max defines the maximum value to return
  31396. * @param mode defines how to define the closest value
  31397. * @returns closest exponent of two of the given value
  31398. */
  31399. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31400. /**
  31401. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31402. * @param func - the function to be called
  31403. * @param requester - the object that will request the next frame. Falls back to window.
  31404. * @returns frame number
  31405. */
  31406. static QueueNewFrame(func: () => void, requester?: any): number;
  31407. /**
  31408. * Ask the browser to promote the current element to pointerlock mode
  31409. * @param element defines the DOM element to promote
  31410. */
  31411. static _RequestPointerlock(element: HTMLElement): void;
  31412. /**
  31413. * Asks the browser to exit pointerlock mode
  31414. */
  31415. static _ExitPointerlock(): void;
  31416. /**
  31417. * Ask the browser to promote the current element to fullscreen rendering mode
  31418. * @param element defines the DOM element to promote
  31419. */
  31420. static _RequestFullscreen(element: HTMLElement): void;
  31421. /**
  31422. * Asks the browser to exit fullscreen mode
  31423. */
  31424. static _ExitFullscreen(): void;
  31425. }
  31426. }
  31427. declare module "babylonjs/Materials/Textures/internalTexture" {
  31428. import { Observable } from "babylonjs/Misc/observable";
  31429. import { Nullable, int } from "babylonjs/types";
  31430. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31431. import { BaseEngine } from "babylonjs/Engines/baseEngine";
  31432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31433. /**
  31434. * Class used to store data associated with WebGL texture data for the engine
  31435. * This class should not be used directly
  31436. */
  31437. export class InternalTexture {
  31438. /** @hidden */
  31439. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31440. /**
  31441. * The source of the texture data is unknown
  31442. */
  31443. static DATASOURCE_UNKNOWN: number;
  31444. /**
  31445. * Texture data comes from an URL
  31446. */
  31447. static DATASOURCE_URL: number;
  31448. /**
  31449. * Texture data is only used for temporary storage
  31450. */
  31451. static DATASOURCE_TEMP: number;
  31452. /**
  31453. * Texture data comes from raw data (ArrayBuffer)
  31454. */
  31455. static DATASOURCE_RAW: number;
  31456. /**
  31457. * Texture content is dynamic (video or dynamic texture)
  31458. */
  31459. static DATASOURCE_DYNAMIC: number;
  31460. /**
  31461. * Texture content is generated by rendering to it
  31462. */
  31463. static DATASOURCE_RENDERTARGET: number;
  31464. /**
  31465. * Texture content is part of a multi render target process
  31466. */
  31467. static DATASOURCE_MULTIRENDERTARGET: number;
  31468. /**
  31469. * Texture data comes from a cube data file
  31470. */
  31471. static DATASOURCE_CUBE: number;
  31472. /**
  31473. * Texture data comes from a raw cube data
  31474. */
  31475. static DATASOURCE_CUBERAW: number;
  31476. /**
  31477. * Texture data come from a prefiltered cube data file
  31478. */
  31479. static DATASOURCE_CUBEPREFILTERED: number;
  31480. /**
  31481. * Texture content is raw 3D data
  31482. */
  31483. static DATASOURCE_RAW3D: number;
  31484. /**
  31485. * Texture content is a depth texture
  31486. */
  31487. static DATASOURCE_DEPTHTEXTURE: number;
  31488. /**
  31489. * Texture data comes from a raw cube data encoded with RGBD
  31490. */
  31491. static DATASOURCE_CUBERAW_RGBD: number;
  31492. /**
  31493. * Defines if the texture is ready
  31494. */
  31495. isReady: boolean;
  31496. /**
  31497. * Defines if the texture is a cube texture
  31498. */
  31499. isCube: boolean;
  31500. /**
  31501. * Defines if the texture contains 3D data
  31502. */
  31503. is3D: boolean;
  31504. /**
  31505. * Defines if the texture contains multiview data
  31506. */
  31507. isMultiview: boolean;
  31508. /**
  31509. * Gets the URL used to load this texture
  31510. */
  31511. url: string;
  31512. /**
  31513. * Gets the sampling mode of the texture
  31514. */
  31515. samplingMode: number;
  31516. /**
  31517. * Gets a boolean indicating if the texture needs mipmaps generation
  31518. */
  31519. generateMipMaps: boolean;
  31520. /**
  31521. * Gets the number of samples used by the texture (WebGL2+ only)
  31522. */
  31523. samples: number;
  31524. /**
  31525. * Gets the type of the texture (int, float...)
  31526. */
  31527. type: number;
  31528. /**
  31529. * Gets the format of the texture (RGB, RGBA...)
  31530. */
  31531. format: number;
  31532. /**
  31533. * Observable called when the texture is loaded
  31534. */
  31535. onLoadedObservable: Observable<InternalTexture>;
  31536. /**
  31537. * Gets the width of the texture
  31538. */
  31539. width: number;
  31540. /**
  31541. * Gets the height of the texture
  31542. */
  31543. height: number;
  31544. /**
  31545. * Gets the depth of the texture
  31546. */
  31547. depth: number;
  31548. /**
  31549. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31550. */
  31551. baseWidth: number;
  31552. /**
  31553. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31554. */
  31555. baseHeight: number;
  31556. /**
  31557. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31558. */
  31559. baseDepth: number;
  31560. /**
  31561. * Gets a boolean indicating if the texture is inverted on Y axis
  31562. */
  31563. invertY: boolean;
  31564. /** @hidden */
  31565. _invertVScale: boolean;
  31566. /** @hidden */
  31567. _associatedChannel: number;
  31568. /** @hidden */
  31569. _dataSource: number;
  31570. /** @hidden */
  31571. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31572. /** @hidden */
  31573. _bufferView: Nullable<ArrayBufferView>;
  31574. /** @hidden */
  31575. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31576. /** @hidden */
  31577. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31578. /** @hidden */
  31579. _size: number;
  31580. /** @hidden */
  31581. _extension: string;
  31582. /** @hidden */
  31583. _files: Nullable<string[]>;
  31584. /** @hidden */
  31585. _workingCanvas: Nullable<HTMLCanvasElement>;
  31586. /** @hidden */
  31587. _workingContext: Nullable<CanvasRenderingContext2D>;
  31588. /** @hidden */
  31589. _framebuffer: Nullable<WebGLFramebuffer>;
  31590. /** @hidden */
  31591. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31592. /** @hidden */
  31593. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31594. /** @hidden */
  31595. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31596. /** @hidden */
  31597. _attachments: Nullable<number[]>;
  31598. /** @hidden */
  31599. _cachedCoordinatesMode: Nullable<number>;
  31600. /** @hidden */
  31601. _cachedWrapU: Nullable<number>;
  31602. /** @hidden */
  31603. _cachedWrapV: Nullable<number>;
  31604. /** @hidden */
  31605. _cachedWrapR: Nullable<number>;
  31606. /** @hidden */
  31607. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31608. /** @hidden */
  31609. _isDisabled: boolean;
  31610. /** @hidden */
  31611. _compression: Nullable<string>;
  31612. /** @hidden */
  31613. _generateStencilBuffer: boolean;
  31614. /** @hidden */
  31615. _generateDepthBuffer: boolean;
  31616. /** @hidden */
  31617. _comparisonFunction: number;
  31618. /** @hidden */
  31619. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31620. /** @hidden */
  31621. _lodGenerationScale: number;
  31622. /** @hidden */
  31623. _lodGenerationOffset: number;
  31624. /** @hidden */
  31625. _colorTextureArray: Nullable<WebGLTexture>;
  31626. /** @hidden */
  31627. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31628. /** @hidden */
  31629. _lodTextureHigh: Nullable<BaseTexture>;
  31630. /** @hidden */
  31631. _lodTextureMid: Nullable<BaseTexture>;
  31632. /** @hidden */
  31633. _lodTextureLow: Nullable<BaseTexture>;
  31634. /** @hidden */
  31635. _isRGBD: boolean;
  31636. /** @hidden */
  31637. _linearSpecularLOD: boolean;
  31638. /** @hidden */
  31639. _irradianceTexture: Nullable<BaseTexture>;
  31640. /** @hidden */
  31641. _webGLTexture: Nullable<WebGLTexture>;
  31642. /** @hidden */
  31643. _references: number;
  31644. private _engine;
  31645. /**
  31646. * Gets the Engine the texture belongs to.
  31647. * @returns The babylon engine
  31648. */
  31649. getEngine(): BaseEngine;
  31650. /**
  31651. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  31652. */
  31653. readonly dataSource: number;
  31654. /**
  31655. * Creates a new InternalTexture
  31656. * @param engine defines the engine to use
  31657. * @param dataSource defines the type of data that will be used
  31658. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31659. */
  31660. constructor(engine: BaseEngine, dataSource: number, delayAllocation?: boolean);
  31661. /**
  31662. * Increments the number of references (ie. the number of Texture that point to it)
  31663. */
  31664. incrementReferences(): void;
  31665. /**
  31666. * Change the size of the texture (not the size of the content)
  31667. * @param width defines the new width
  31668. * @param height defines the new height
  31669. * @param depth defines the new depth (1 by default)
  31670. */
  31671. updateSize(width: int, height: int, depth?: int): void;
  31672. /** @hidden */
  31673. _rebuild(): void;
  31674. /** @hidden */
  31675. _swapAndDie(target: InternalTexture): void;
  31676. /**
  31677. * Dispose the current allocated resources
  31678. */
  31679. dispose(): void;
  31680. }
  31681. }
  31682. declare module "babylonjs/Audio/analyser" {
  31683. import { Scene } from "babylonjs/scene";
  31684. /**
  31685. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31687. */
  31688. export class Analyser {
  31689. /**
  31690. * Gets or sets the smoothing
  31691. * @ignorenaming
  31692. */
  31693. SMOOTHING: number;
  31694. /**
  31695. * Gets or sets the FFT table size
  31696. * @ignorenaming
  31697. */
  31698. FFT_SIZE: number;
  31699. /**
  31700. * Gets or sets the bar graph amplitude
  31701. * @ignorenaming
  31702. */
  31703. BARGRAPHAMPLITUDE: number;
  31704. /**
  31705. * Gets or sets the position of the debug canvas
  31706. * @ignorenaming
  31707. */
  31708. DEBUGCANVASPOS: {
  31709. x: number;
  31710. y: number;
  31711. };
  31712. /**
  31713. * Gets or sets the debug canvas size
  31714. * @ignorenaming
  31715. */
  31716. DEBUGCANVASSIZE: {
  31717. width: number;
  31718. height: number;
  31719. };
  31720. private _byteFreqs;
  31721. private _byteTime;
  31722. private _floatFreqs;
  31723. private _webAudioAnalyser;
  31724. private _debugCanvas;
  31725. private _debugCanvasContext;
  31726. private _scene;
  31727. private _registerFunc;
  31728. private _audioEngine;
  31729. /**
  31730. * Creates a new analyser
  31731. * @param scene defines hosting scene
  31732. */
  31733. constructor(scene: Scene);
  31734. /**
  31735. * Get the number of data values you will have to play with for the visualization
  31736. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31737. * @returns a number
  31738. */
  31739. getFrequencyBinCount(): number;
  31740. /**
  31741. * Gets the current frequency data as a byte array
  31742. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31743. * @returns a Uint8Array
  31744. */
  31745. getByteFrequencyData(): Uint8Array;
  31746. /**
  31747. * Gets the current waveform as a byte array
  31748. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31749. * @returns a Uint8Array
  31750. */
  31751. getByteTimeDomainData(): Uint8Array;
  31752. /**
  31753. * Gets the current frequency data as a float array
  31754. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31755. * @returns a Float32Array
  31756. */
  31757. getFloatFrequencyData(): Float32Array;
  31758. /**
  31759. * Renders the debug canvas
  31760. */
  31761. drawDebugCanvas(): void;
  31762. /**
  31763. * Stops rendering the debug canvas and removes it
  31764. */
  31765. stopDebugCanvas(): void;
  31766. /**
  31767. * Connects two audio nodes
  31768. * @param inputAudioNode defines first node to connect
  31769. * @param outputAudioNode defines second node to connect
  31770. */
  31771. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31772. /**
  31773. * Releases all associated resources
  31774. */
  31775. dispose(): void;
  31776. }
  31777. }
  31778. declare module "babylonjs/Audio/audioEngine" {
  31779. import { IDisposable } from "babylonjs/scene";
  31780. import { Analyser } from "babylonjs/Audio/analyser";
  31781. import { Nullable } from "babylonjs/types";
  31782. import { Observable } from "babylonjs/Misc/observable";
  31783. /**
  31784. * This represents an audio engine and it is responsible
  31785. * to play, synchronize and analyse sounds throughout the application.
  31786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31787. */
  31788. export interface IAudioEngine extends IDisposable {
  31789. /**
  31790. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31791. */
  31792. readonly canUseWebAudio: boolean;
  31793. /**
  31794. * Gets the current AudioContext if available.
  31795. */
  31796. readonly audioContext: Nullable<AudioContext>;
  31797. /**
  31798. * The master gain node defines the global audio volume of your audio engine.
  31799. */
  31800. readonly masterGain: GainNode;
  31801. /**
  31802. * Gets whether or not mp3 are supported by your browser.
  31803. */
  31804. readonly isMP3supported: boolean;
  31805. /**
  31806. * Gets whether or not ogg are supported by your browser.
  31807. */
  31808. readonly isOGGsupported: boolean;
  31809. /**
  31810. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31811. * @ignoreNaming
  31812. */
  31813. WarnedWebAudioUnsupported: boolean;
  31814. /**
  31815. * Defines if the audio engine relies on a custom unlocked button.
  31816. * In this case, the embedded button will not be displayed.
  31817. */
  31818. useCustomUnlockedButton: boolean;
  31819. /**
  31820. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31821. */
  31822. readonly unlocked: boolean;
  31823. /**
  31824. * Event raised when audio has been unlocked on the browser.
  31825. */
  31826. onAudioUnlockedObservable: Observable<AudioEngine>;
  31827. /**
  31828. * Event raised when audio has been locked on the browser.
  31829. */
  31830. onAudioLockedObservable: Observable<AudioEngine>;
  31831. /**
  31832. * Flags the audio engine in Locked state.
  31833. * This happens due to new browser policies preventing audio to autoplay.
  31834. */
  31835. lock(): void;
  31836. /**
  31837. * Unlocks the audio engine once a user action has been done on the dom.
  31838. * This is helpful to resume play once browser policies have been satisfied.
  31839. */
  31840. unlock(): void;
  31841. }
  31842. /**
  31843. * This represents the default audio engine used in babylon.
  31844. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31846. */
  31847. export class AudioEngine implements IAudioEngine {
  31848. private _audioContext;
  31849. private _audioContextInitialized;
  31850. private _muteButton;
  31851. private _hostElement;
  31852. /**
  31853. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31854. */
  31855. canUseWebAudio: boolean;
  31856. /**
  31857. * The master gain node defines the global audio volume of your audio engine.
  31858. */
  31859. masterGain: GainNode;
  31860. /**
  31861. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31862. * @ignoreNaming
  31863. */
  31864. WarnedWebAudioUnsupported: boolean;
  31865. /**
  31866. * Gets whether or not mp3 are supported by your browser.
  31867. */
  31868. isMP3supported: boolean;
  31869. /**
  31870. * Gets whether or not ogg are supported by your browser.
  31871. */
  31872. isOGGsupported: boolean;
  31873. /**
  31874. * Gets whether audio has been unlocked on the device.
  31875. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31876. * a user interaction has happened.
  31877. */
  31878. unlocked: boolean;
  31879. /**
  31880. * Defines if the audio engine relies on a custom unlocked button.
  31881. * In this case, the embedded button will not be displayed.
  31882. */
  31883. useCustomUnlockedButton: boolean;
  31884. /**
  31885. * Event raised when audio has been unlocked on the browser.
  31886. */
  31887. onAudioUnlockedObservable: Observable<AudioEngine>;
  31888. /**
  31889. * Event raised when audio has been locked on the browser.
  31890. */
  31891. onAudioLockedObservable: Observable<AudioEngine>;
  31892. /**
  31893. * Gets the current AudioContext if available.
  31894. */
  31895. readonly audioContext: Nullable<AudioContext>;
  31896. private _connectedAnalyser;
  31897. /**
  31898. * Instantiates a new audio engine.
  31899. *
  31900. * There should be only one per page as some browsers restrict the number
  31901. * of audio contexts you can create.
  31902. * @param hostElement defines the host element where to display the mute icon if necessary
  31903. */
  31904. constructor(hostElement?: Nullable<HTMLElement>);
  31905. /**
  31906. * Flags the audio engine in Locked state.
  31907. * This happens due to new browser policies preventing audio to autoplay.
  31908. */
  31909. lock(): void;
  31910. /**
  31911. * Unlocks the audio engine once a user action has been done on the dom.
  31912. * This is helpful to resume play once browser policies have been satisfied.
  31913. */
  31914. unlock(): void;
  31915. private _resumeAudioContext;
  31916. private _initializeAudioContext;
  31917. private _tryToRun;
  31918. private _triggerRunningState;
  31919. private _triggerSuspendedState;
  31920. private _displayMuteButton;
  31921. private _moveButtonToTopLeft;
  31922. private _onResize;
  31923. private _hideMuteButton;
  31924. /**
  31925. * Destroy and release the resources associated with the audio ccontext.
  31926. */
  31927. dispose(): void;
  31928. /**
  31929. * Gets the global volume sets on the master gain.
  31930. * @returns the global volume if set or -1 otherwise
  31931. */
  31932. getGlobalVolume(): number;
  31933. /**
  31934. * Sets the global volume of your experience (sets on the master gain).
  31935. * @param newVolume Defines the new global volume of the application
  31936. */
  31937. setGlobalVolume(newVolume: number): void;
  31938. /**
  31939. * Connect the audio engine to an audio analyser allowing some amazing
  31940. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31942. * @param analyser The analyser to connect to the engine
  31943. */
  31944. connectToAnalyser(analyser: Analyser): void;
  31945. }
  31946. }
  31947. declare module "babylonjs/Loading/loadingScreen" {
  31948. /**
  31949. * Interface used to present a loading screen while loading a scene
  31950. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31951. */
  31952. export interface ILoadingScreen {
  31953. /**
  31954. * Function called to display the loading screen
  31955. */
  31956. displayLoadingUI: () => void;
  31957. /**
  31958. * Function called to hide the loading screen
  31959. */
  31960. hideLoadingUI: () => void;
  31961. /**
  31962. * Gets or sets the color to use for the background
  31963. */
  31964. loadingUIBackgroundColor: string;
  31965. /**
  31966. * Gets or sets the text to display while loading
  31967. */
  31968. loadingUIText: string;
  31969. }
  31970. /**
  31971. * Class used for the default loading screen
  31972. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31973. */
  31974. export class DefaultLoadingScreen implements ILoadingScreen {
  31975. private _renderingCanvas;
  31976. private _loadingText;
  31977. private _loadingDivBackgroundColor;
  31978. private _loadingDiv;
  31979. private _loadingTextDiv;
  31980. /** Gets or sets the logo url to use for the default loading screen */
  31981. static DefaultLogoUrl: string;
  31982. /** Gets or sets the spinner url to use for the default loading screen */
  31983. static DefaultSpinnerUrl: string;
  31984. /**
  31985. * Creates a new default loading screen
  31986. * @param _renderingCanvas defines the canvas used to render the scene
  31987. * @param _loadingText defines the default text to display
  31988. * @param _loadingDivBackgroundColor defines the default background color
  31989. */
  31990. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31991. /**
  31992. * Function called to display the loading screen
  31993. */
  31994. displayLoadingUI(): void;
  31995. /**
  31996. * Function called to hide the loading screen
  31997. */
  31998. hideLoadingUI(): void;
  31999. /**
  32000. * Gets or sets the text to display while loading
  32001. */
  32002. loadingUIText: string;
  32003. /**
  32004. * Gets or sets the color to use for the background
  32005. */
  32006. loadingUIBackgroundColor: string;
  32007. private _resizeLoadingUI;
  32008. }
  32009. }
  32010. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  32011. /**
  32012. * Interface for any object that can request an animation frame
  32013. */
  32014. export interface ICustomAnimationFrameRequester {
  32015. /**
  32016. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32017. */
  32018. renderFunction?: Function;
  32019. /**
  32020. * Called to request the next frame to render to
  32021. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32022. */
  32023. requestAnimationFrame: Function;
  32024. /**
  32025. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32026. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32027. */
  32028. requestID?: number;
  32029. }
  32030. }
  32031. declare module "babylonjs/Misc/IPerformanceMonitor" {
  32032. /**
  32033. * Interface for performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32034. */
  32035. export interface IPerformanceMonitor {
  32036. /**
  32037. * Enables contributions to the sliding window sample set
  32038. */
  32039. enable(): void;
  32040. /**
  32041. * Disables contributions to the sliding window sample set
  32042. * Samples will not be interpolated over the disabled period
  32043. */
  32044. disable(): void;
  32045. /**
  32046. * Samples current frame
  32047. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32048. */
  32049. sampleFrame(timeMs?: number): void;
  32050. /**
  32051. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32052. */
  32053. averageFrameTime: number;
  32054. /**
  32055. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32056. */
  32057. averageFrameTimeVariance: number;
  32058. /**
  32059. * Returns the frame time of the most recent frame
  32060. */
  32061. instantaneousFrameTime: number;
  32062. /**
  32063. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32064. */
  32065. averageFPS: number;
  32066. /**
  32067. * Returns the average framerate in frames per second using the most recent frame time
  32068. */
  32069. instantaneousFPS: number;
  32070. }
  32071. }
  32072. declare module "babylonjs/Engines/engine" {
  32073. import { Observable } from "babylonjs/Misc/observable";
  32074. import { Nullable } from "babylonjs/types";
  32075. import { Scene } from "babylonjs/scene";
  32076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32077. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32078. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32079. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32080. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32081. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32082. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32083. import { IPerformanceMonitor } from "babylonjs/Misc/IPerformanceMonitor";
  32084. import { BaseEngine, EngineOptions } from "babylonjs/Engines/baseEngine";
  32085. import { Material } from "babylonjs/Materials/material";
  32086. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32087. /**
  32088. * Defines the interface used by display changed events
  32089. */
  32090. export interface IDisplayChangedEventArgs {
  32091. /** Gets the vrDisplay object (if any) */
  32092. vrDisplay: Nullable<any>;
  32093. /** Gets a boolean indicating if webVR is supported */
  32094. vrSupported: boolean;
  32095. }
  32096. /**
  32097. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32098. */
  32099. export class Engine extends BaseEngine {
  32100. /**
  32101. * Returns the current npm package of the sdk
  32102. */
  32103. static readonly NpmPackage: string;
  32104. /**
  32105. * Returns the current version of the framework
  32106. */
  32107. static readonly Version: string;
  32108. /** Gets the list of created engines */
  32109. static readonly Instances: Engine[];
  32110. /**
  32111. * Gets the latest created engine
  32112. */
  32113. static readonly LastCreatedEngine: Nullable<Engine>;
  32114. /**
  32115. * Gets the latest created scene
  32116. */
  32117. static readonly LastCreatedScene: Nullable<Scene>;
  32118. /**
  32119. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32120. * @param flag defines which part of the materials must be marked as dirty
  32121. * @param predicate defines a predicate used to filter which materials should be affected
  32122. */
  32123. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32124. /**
  32125. * Factory used to create the performance monitor
  32126. * @returns a new PerformanceMonitor
  32127. */
  32128. static DefaultPerformanceMonitorFactory(): IPerformanceMonitor;
  32129. /**
  32130. * Method called to create the default loading screen.
  32131. * This can be overriden in your own app.
  32132. * @param canvas The rendering canvas element
  32133. * @returns The loading screen
  32134. */
  32135. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32136. /**
  32137. * Method called to create the default rescale post process on each engine.
  32138. */
  32139. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32140. /**
  32141. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32142. **/
  32143. enableOfflineSupport: boolean;
  32144. /**
  32145. * 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)
  32146. **/
  32147. disableManifestCheck: boolean;
  32148. /**
  32149. * Gets the list of created scenes
  32150. */
  32151. scenes: Scene[];
  32152. /**
  32153. * Event raised when a new scene is created
  32154. */
  32155. onNewSceneAddedObservable: Observable<Scene>;
  32156. /**
  32157. * Gets the list of created postprocesses
  32158. */
  32159. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32160. /**
  32161. * Observable event triggered each time the rendering canvas is resized
  32162. */
  32163. onResizeObservable: Observable<Engine>;
  32164. /**
  32165. * Observable event triggered each time the canvas loses focus
  32166. */
  32167. onCanvasBlurObservable: Observable<Engine>;
  32168. /**
  32169. * Observable event triggered each time the canvas gains focus
  32170. */
  32171. onCanvasFocusObservable: Observable<Engine>;
  32172. /**
  32173. * Observable event triggered each time the canvas receives pointerout event
  32174. */
  32175. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32176. /**
  32177. * Observable event triggered before each texture is initialized
  32178. */
  32179. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32180. /**
  32181. * Observable raised when the engine begins a new frame
  32182. */
  32183. onBeginFrameObservable: Observable<Engine>;
  32184. /**
  32185. * If set, will be used to request the next animation frame for the render loop
  32186. */
  32187. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32188. /**
  32189. * Observable raised when the engine ends the current frame
  32190. */
  32191. onEndFrameObservable: Observable<Engine>;
  32192. /**
  32193. * Observable raised when the engine is about to compile a shader
  32194. */
  32195. onBeforeShaderCompilationObservable: Observable<Engine>;
  32196. /**
  32197. * Observable raised when the engine has jsut compiled a shader
  32198. */
  32199. onAfterShaderCompilationObservable: Observable<Engine>;
  32200. /**
  32201. * Gets the audio engine
  32202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32203. * @ignorenaming
  32204. */
  32205. static audioEngine: IAudioEngine;
  32206. /**
  32207. * Default AudioEngine factory responsible of creating the Audio Engine.
  32208. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32209. */
  32210. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32211. /**
  32212. * Default offline support factory responsible of creating a tool used to store data locally.
  32213. * By default, this will create a Database object if the workload has been embedded.
  32214. */
  32215. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32216. private _loadingScreen;
  32217. private _pointerLockRequested;
  32218. private _dummyFramebuffer;
  32219. private _rescalePostProcess;
  32220. protected readonly _supportsHardwareTextureRescaling: boolean;
  32221. private _fps;
  32222. private _deltaTime;
  32223. /**
  32224. * Turn this value on if you want to pause FPS computation when in background
  32225. */
  32226. disablePerformanceMonitorInBackground: boolean;
  32227. private _performanceMonitor;
  32228. /**
  32229. * Gets the performance monitor attached to this engine
  32230. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32231. */
  32232. readonly performanceMonitor: IPerformanceMonitor;
  32233. private _onFocus;
  32234. private _onBlur;
  32235. private _onCanvasPointerOut;
  32236. private _onCanvasBlur;
  32237. private _onCanvasFocus;
  32238. private _onFullscreenChange;
  32239. private _onPointerLockChange;
  32240. /**
  32241. * Creates a new engine
  32242. * @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
  32243. * @param antialias defines enable antialiasing (default: false)
  32244. * @param options defines further options to be sent to the getContext() function
  32245. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32246. */
  32247. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32248. /**
  32249. * Initializes a webVR display and starts listening to display change events
  32250. * The onVRDisplayChangedObservable will be notified upon these changes
  32251. * @returns The onVRDisplayChangedObservable
  32252. */
  32253. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32254. /** @hidden */
  32255. _prepareVRComponent(): void;
  32256. /** @hidden */
  32257. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32258. /** @hidden */
  32259. _submitVRFrame(): void;
  32260. /**
  32261. * Call this function to leave webVR mode
  32262. * Will do nothing if webVR is not supported or if there is no webVR device
  32263. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32264. */
  32265. disableVR(): void;
  32266. /**
  32267. * Gets a boolean indicating that the system is in VR mode and is presenting
  32268. * @returns true if VR mode is engaged
  32269. */
  32270. isVRPresenting(): boolean;
  32271. /** @hidden */
  32272. _requestVRFrame(): void;
  32273. protected _rebuildBuffers(): void;
  32274. _renderLoop(): void;
  32275. /**
  32276. * Toggle full screen mode
  32277. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32278. */
  32279. switchFullscreen(requestPointerLock: boolean): void;
  32280. /**
  32281. * Enters full screen mode
  32282. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32283. */
  32284. enterFullscreen(requestPointerLock: boolean): void;
  32285. /**
  32286. * Exits full screen mode
  32287. */
  32288. exitFullscreen(): void;
  32289. /**
  32290. * Enters Pointerlock mode
  32291. */
  32292. enterPointerlock(): void;
  32293. /**
  32294. * Exits Pointerlock mode
  32295. */
  32296. exitPointerlock(): void;
  32297. /**
  32298. * Begin a new frame
  32299. */
  32300. beginFrame(): void;
  32301. /**
  32302. * Enf the current frame
  32303. */
  32304. endFrame(): void;
  32305. resize(): void;
  32306. /**
  32307. * Force a specific size of the canvas
  32308. * @param width defines the new canvas' width
  32309. * @param height defines the new canvas' height
  32310. */
  32311. setSize(width: number, height: number): void;
  32312. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32313. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32314. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32315. _releaseTexture(texture: InternalTexture): void;
  32316. /**
  32317. * @hidden
  32318. * Rescales a texture
  32319. * @param source input texutre
  32320. * @param destination destination texture
  32321. * @param scene scene to use to render the resize
  32322. * @param internalFormat format to use when resizing
  32323. * @param onComplete callback to be called when resize has completed
  32324. */
  32325. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32326. /**
  32327. * Gets the current framerate
  32328. * @returns a number representing the framerate
  32329. */
  32330. getFps(): number;
  32331. /**
  32332. * Gets the time spent between current and previous frame
  32333. * @returns a number representing the delta time in ms
  32334. */
  32335. getDeltaTime(): number;
  32336. private _measureFps;
  32337. /** @hidden */
  32338. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32339. dispose(): void;
  32340. /**
  32341. * Display the loading screen
  32342. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32343. */
  32344. displayLoadingUI(): void;
  32345. /**
  32346. * Hide the loading screen
  32347. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32348. */
  32349. hideLoadingUI(): void;
  32350. /**
  32351. * Gets the current loading screen object
  32352. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32353. */
  32354. /**
  32355. * Sets the current loading screen object
  32356. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32357. */
  32358. loadingScreen: ILoadingScreen;
  32359. /**
  32360. * Sets the current loading screen text
  32361. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32362. */
  32363. loadingUIText: string;
  32364. /**
  32365. * Sets the current loading screen background color
  32366. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32367. */
  32368. loadingUIBackgroundColor: string;
  32369. }
  32370. }
  32371. declare module "babylonjs/Engines/engineStore" {
  32372. import { Nullable } from "babylonjs/types";
  32373. import { Engine } from "babylonjs/Engines/engine";
  32374. import { Scene } from "babylonjs/scene";
  32375. /**
  32376. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32377. * during the life time of the application.
  32378. */
  32379. export class EngineStore {
  32380. /** Gets the list of created engines */
  32381. static Instances: import("babylonjs/Engines/engine").Engine[];
  32382. /** @hidden */
  32383. static _LastCreatedScene: Nullable<Scene>;
  32384. /**
  32385. * Gets the latest created engine
  32386. */
  32387. static readonly LastCreatedEngine: Nullable<Engine>;
  32388. /**
  32389. * Gets the latest created scene
  32390. */
  32391. static readonly LastCreatedScene: Nullable<Scene>;
  32392. /**
  32393. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32394. * @ignorenaming
  32395. */
  32396. static UseFallbackTexture: boolean;
  32397. /**
  32398. * Texture content used if a texture cannot loaded
  32399. * @ignorenaming
  32400. */
  32401. static FallbackTexture: string;
  32402. }
  32403. }
  32404. declare module "babylonjs/Misc/promise" {
  32405. /**
  32406. * Helper class that provides a small promise polyfill
  32407. */
  32408. export class PromisePolyfill {
  32409. /**
  32410. * Static function used to check if the polyfill is required
  32411. * If this is the case then the function will inject the polyfill to window.Promise
  32412. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32413. */
  32414. static Apply(force?: boolean): void;
  32415. }
  32416. }
  32417. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32418. /**
  32419. * Interface for screenshot methods with describe argument called `size` as object with options
  32420. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32421. */
  32422. export interface IScreenshotSize {
  32423. /**
  32424. * number in pixels for canvas height
  32425. */
  32426. height?: number;
  32427. /**
  32428. * multiplier allowing render at a higher or lower resolution
  32429. * If value is defined then height and width will be ignored and taken from camera
  32430. */
  32431. precision?: number;
  32432. /**
  32433. * number in pixels for canvas width
  32434. */
  32435. width?: number;
  32436. }
  32437. }
  32438. declare module "babylonjs/Misc/tools" {
  32439. import { Nullable, float } from "babylonjs/types";
  32440. import { DomManagement } from "babylonjs/Misc/domManagement";
  32441. import { WebRequest } from "babylonjs/Misc/webRequest";
  32442. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32443. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32444. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32445. import { Camera } from "babylonjs/Cameras/camera";
  32446. import { Engine } from "babylonjs/Engines/engine";
  32447. interface IColor4Like {
  32448. r: float;
  32449. g: float;
  32450. b: float;
  32451. a: float;
  32452. }
  32453. /**
  32454. * Class containing a set of static utilities functions
  32455. */
  32456. export class Tools {
  32457. /**
  32458. * Gets or sets the base URL to use to load assets
  32459. */
  32460. static BaseUrl: string;
  32461. /**
  32462. * Enable/Disable Custom HTTP Request Headers globally.
  32463. * default = false
  32464. * @see CustomRequestHeaders
  32465. */
  32466. static UseCustomRequestHeaders: boolean;
  32467. /**
  32468. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32469. * i.e. when loading files, where the server/service expects an Authorization header
  32470. */
  32471. static CustomRequestHeaders: {
  32472. [key: string]: string;
  32473. };
  32474. /**
  32475. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32476. */
  32477. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32478. /**
  32479. * Default behaviour for cors in the application.
  32480. * It can be a string if the expected behavior is identical in the entire app.
  32481. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32482. */
  32483. static CorsBehavior: string | ((url: string | string[]) => string);
  32484. /**
  32485. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32486. * @ignorenaming
  32487. */
  32488. static UseFallbackTexture: boolean;
  32489. /**
  32490. * Use this object to register external classes like custom textures or material
  32491. * to allow the laoders to instantiate them
  32492. */
  32493. static RegisteredExternalClasses: {
  32494. [key: string]: Object;
  32495. };
  32496. /**
  32497. * Texture content used if a texture cannot loaded
  32498. * @ignorenaming
  32499. */
  32500. static fallbackTexture: string;
  32501. /**
  32502. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32503. * @param u defines the coordinate on X axis
  32504. * @param v defines the coordinate on Y axis
  32505. * @param width defines the width of the source data
  32506. * @param height defines the height of the source data
  32507. * @param pixels defines the source byte array
  32508. * @param color defines the output color
  32509. */
  32510. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32511. /**
  32512. * Interpolates between a and b via alpha
  32513. * @param a The lower value (returned when alpha = 0)
  32514. * @param b The upper value (returned when alpha = 1)
  32515. * @param alpha The interpolation-factor
  32516. * @return The mixed value
  32517. */
  32518. static Mix(a: number, b: number, alpha: number): number;
  32519. /**
  32520. * Tries to instantiate a new object from a given class name
  32521. * @param className defines the class name to instantiate
  32522. * @returns the new object or null if the system was not able to do the instantiation
  32523. */
  32524. static Instantiate(className: string): any;
  32525. /**
  32526. * Provides a slice function that will work even on IE
  32527. * @param data defines the array to slice
  32528. * @param start defines the start of the data (optional)
  32529. * @param end defines the end of the data (optional)
  32530. * @returns the new sliced array
  32531. */
  32532. static Slice<T>(data: T, start?: number, end?: number): T;
  32533. /**
  32534. * Polyfill for setImmediate
  32535. * @param action defines the action to execute after the current execution block
  32536. */
  32537. static SetImmediate(action: () => void): void;
  32538. /**
  32539. * Function indicating if a number is an exponent of 2
  32540. * @param value defines the value to test
  32541. * @returns true if the value is an exponent of 2
  32542. */
  32543. static IsExponentOfTwo(value: number): boolean;
  32544. private static _tmpFloatArray;
  32545. /**
  32546. * Returns the nearest 32-bit single precision float representation of a Number
  32547. * @param value A Number. If the parameter is of a different type, it will get converted
  32548. * to a number or to NaN if it cannot be converted
  32549. * @returns number
  32550. */
  32551. static FloatRound(value: number): number;
  32552. /**
  32553. * Extracts the filename from a path
  32554. * @param path defines the path to use
  32555. * @returns the filename
  32556. */
  32557. static GetFilename(path: string): string;
  32558. /**
  32559. * Extracts the "folder" part of a path (everything before the filename).
  32560. * @param uri The URI to extract the info from
  32561. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32562. * @returns The "folder" part of the path
  32563. */
  32564. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32565. /**
  32566. * Extracts text content from a DOM element hierarchy
  32567. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32568. */
  32569. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32570. /**
  32571. * Convert an angle in radians to degrees
  32572. * @param angle defines the angle to convert
  32573. * @returns the angle in degrees
  32574. */
  32575. static ToDegrees(angle: number): number;
  32576. /**
  32577. * Convert an angle in degrees to radians
  32578. * @param angle defines the angle to convert
  32579. * @returns the angle in radians
  32580. */
  32581. static ToRadians(angle: number): number;
  32582. /**
  32583. * Encode a buffer to a base64 string
  32584. * @param buffer defines the buffer to encode
  32585. * @returns the encoded string
  32586. */
  32587. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32588. /**
  32589. * Returns an array if obj is not an array
  32590. * @param obj defines the object to evaluate as an array
  32591. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32592. * @returns either obj directly if obj is an array or a new array containing obj
  32593. */
  32594. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32595. /**
  32596. * Gets the pointer prefix to use
  32597. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32598. */
  32599. static GetPointerPrefix(): string;
  32600. /**
  32601. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32602. * @param url define the url we are trying
  32603. * @param element define the dom element where to configure the cors policy
  32604. */
  32605. static SetCorsBehavior(url: string | string[], element: {
  32606. crossOrigin: string | null;
  32607. }): void;
  32608. /**
  32609. * Removes unwanted characters from an url
  32610. * @param url defines the url to clean
  32611. * @returns the cleaned url
  32612. */
  32613. static CleanUrl(url: string): string;
  32614. /**
  32615. * Gets or sets a function used to pre-process url before using them to load assets
  32616. */
  32617. static PreprocessUrl: (url: string) => string;
  32618. /**
  32619. * Loads an image as an HTMLImageElement.
  32620. * @param input url string, ArrayBuffer, or Blob to load
  32621. * @param onLoad callback called when the image successfully loads
  32622. * @param onError callback called when the image fails to load
  32623. * @param offlineProvider offline provider for caching
  32624. * @returns the HTMLImageElement of the loaded image
  32625. */
  32626. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32627. /**
  32628. * Loads a file
  32629. * @param url url string, ArrayBuffer, or Blob to load
  32630. * @param onSuccess callback called when the file successfully loads
  32631. * @param onProgress callback called while file is loading (if the server supports this mode)
  32632. * @param offlineProvider defines the offline provider for caching
  32633. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32634. * @param onError callback called when the file fails to load
  32635. * @returns a file request object
  32636. */
  32637. 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;
  32638. /**
  32639. * Loads a file from a url
  32640. * @param url the file url to load
  32641. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32642. */
  32643. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32644. /**
  32645. * Load a script (identified by an url). When the url returns, the
  32646. * content of this file is added into a new script element, attached to the DOM (body element)
  32647. * @param scriptUrl defines the url of the script to laod
  32648. * @param onSuccess defines the callback called when the script is loaded
  32649. * @param onError defines the callback to call if an error occurs
  32650. * @param scriptId defines the id of the script element
  32651. */
  32652. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32653. /**
  32654. * Load an asynchronous script (identified by an url). When the url returns, the
  32655. * content of this file is added into a new script element, attached to the DOM (body element)
  32656. * @param scriptUrl defines the url of the script to laod
  32657. * @param scriptId defines the id of the script element
  32658. * @returns a promise request object
  32659. */
  32660. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32661. /**
  32662. * Loads a file from a blob
  32663. * @param fileToLoad defines the blob to use
  32664. * @param callback defines the callback to call when data is loaded
  32665. * @param progressCallback defines the callback to call during loading process
  32666. * @returns a file request object
  32667. */
  32668. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32669. /**
  32670. * Loads a file
  32671. * @param fileToLoad defines the file to load
  32672. * @param callback defines the callback to call when data is loaded
  32673. * @param progressCallBack defines the callback to call during loading process
  32674. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32675. * @returns a file request object
  32676. */
  32677. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32678. /**
  32679. * Creates a data url from a given string content
  32680. * @param content defines the content to convert
  32681. * @returns the new data url link
  32682. */
  32683. static FileAsURL(content: string): string;
  32684. /**
  32685. * Format the given number to a specific decimal format
  32686. * @param value defines the number to format
  32687. * @param decimals defines the number of decimals to use
  32688. * @returns the formatted string
  32689. */
  32690. static Format(value: number, decimals?: number): string;
  32691. /**
  32692. * Tries to copy an object by duplicating every property
  32693. * @param source defines the source object
  32694. * @param destination defines the target object
  32695. * @param doNotCopyList defines a list of properties to avoid
  32696. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32697. */
  32698. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32699. /**
  32700. * Gets a boolean indicating if the given object has no own property
  32701. * @param obj defines the object to test
  32702. * @returns true if object has no own property
  32703. */
  32704. static IsEmpty(obj: any): boolean;
  32705. /**
  32706. * Function used to register events at window level
  32707. * @param windowElement defines the Window object to use
  32708. * @param events defines the events to register
  32709. */
  32710. static RegisterTopRootEvents(windowElement: Window, events: {
  32711. name: string;
  32712. handler: Nullable<(e: FocusEvent) => any>;
  32713. }[]): void;
  32714. /**
  32715. * Function used to unregister events from window level
  32716. * @param windowElement defines the Window object to use
  32717. * @param events defines the events to unregister
  32718. */
  32719. static UnregisterTopRootEvents(windowElement: Window, events: {
  32720. name: string;
  32721. handler: Nullable<(e: FocusEvent) => any>;
  32722. }[]): void;
  32723. /**
  32724. * @ignore
  32725. */
  32726. static _ScreenshotCanvas: HTMLCanvasElement;
  32727. /**
  32728. * Dumps the current bound framebuffer
  32729. * @param width defines the rendering width
  32730. * @param height defines the rendering height
  32731. * @param engine defines the hosting engine
  32732. * @param successCallback defines the callback triggered once the data are available
  32733. * @param mimeType defines the mime type of the result
  32734. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32735. */
  32736. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32737. /**
  32738. * Converts the canvas data to blob.
  32739. * This acts as a polyfill for browsers not supporting the to blob function.
  32740. * @param canvas Defines the canvas to extract the data from
  32741. * @param successCallback Defines the callback triggered once the data are available
  32742. * @param mimeType Defines the mime type of the result
  32743. */
  32744. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32745. /**
  32746. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32747. * @param successCallback defines the callback triggered once the data are available
  32748. * @param mimeType defines the mime type of the result
  32749. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32750. */
  32751. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32752. /**
  32753. * Downloads a blob in the browser
  32754. * @param blob defines the blob to download
  32755. * @param fileName defines the name of the downloaded file
  32756. */
  32757. static Download(blob: Blob, fileName: string): void;
  32758. /**
  32759. * Captures a screenshot of the current rendering
  32760. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32761. * @param engine defines the rendering engine
  32762. * @param camera defines the source camera
  32763. * @param size This parameter can be set to a single number or to an object with the
  32764. * following (optional) properties: precision, width, height. If a single number is passed,
  32765. * it will be used for both width and height. If an object is passed, the screenshot size
  32766. * will be derived from the parameters. The precision property is a multiplier allowing
  32767. * rendering at a higher or lower resolution
  32768. * @param successCallback defines the callback receives a single parameter which contains the
  32769. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32770. * src parameter of an <img> to display it
  32771. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32772. * Check your browser for supported MIME types
  32773. */
  32774. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32775. /**
  32776. * Captures a screenshot of the current rendering
  32777. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32778. * @param engine defines the rendering engine
  32779. * @param camera defines the source camera
  32780. * @param size This parameter can be set to a single number or to an object with the
  32781. * following (optional) properties: precision, width, height. If a single number is passed,
  32782. * it will be used for both width and height. If an object is passed, the screenshot size
  32783. * will be derived from the parameters. The precision property is a multiplier allowing
  32784. * rendering at a higher or lower resolution
  32785. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32786. * Check your browser for supported MIME types
  32787. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32788. * to the src parameter of an <img> to display it
  32789. */
  32790. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32791. /**
  32792. * Generates an image screenshot from the specified camera.
  32793. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32794. * @param engine The engine to use for rendering
  32795. * @param camera The camera to use for rendering
  32796. * @param size This parameter can be set to a single number or to an object with the
  32797. * following (optional) properties: precision, width, height. If a single number is passed,
  32798. * it will be used for both width and height. If an object is passed, the screenshot size
  32799. * will be derived from the parameters. The precision property is a multiplier allowing
  32800. * rendering at a higher or lower resolution
  32801. * @param successCallback The callback receives a single parameter which contains the
  32802. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32803. * src parameter of an <img> to display it
  32804. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32805. * Check your browser for supported MIME types
  32806. * @param samples Texture samples (default: 1)
  32807. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32808. * @param fileName A name for for the downloaded file.
  32809. */
  32810. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32811. /**
  32812. * Generates an image screenshot from the specified camera.
  32813. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32814. * @param engine The engine to use for rendering
  32815. * @param camera The camera to use for rendering
  32816. * @param size This parameter can be set to a single number or to an object with the
  32817. * following (optional) properties: precision, width, height. If a single number is passed,
  32818. * it will be used for both width and height. If an object is passed, the screenshot size
  32819. * will be derived from the parameters. The precision property is a multiplier allowing
  32820. * rendering at a higher or lower resolution
  32821. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32822. * Check your browser for supported MIME types
  32823. * @param samples Texture samples (default: 1)
  32824. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32825. * @param fileName A name for for the downloaded file.
  32826. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32827. * to the src parameter of an <img> to display it
  32828. */
  32829. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32830. /**
  32831. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32832. * Be aware Math.random() could cause collisions, but:
  32833. * "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"
  32834. * @returns a pseudo random id
  32835. */
  32836. static RandomId(): string;
  32837. /**
  32838. * Test if the given uri is a base64 string
  32839. * @param uri The uri to test
  32840. * @return True if the uri is a base64 string or false otherwise
  32841. */
  32842. static IsBase64(uri: string): boolean;
  32843. /**
  32844. * Decode the given base64 uri.
  32845. * @param uri The uri to decode
  32846. * @return The decoded base64 data.
  32847. */
  32848. static DecodeBase64(uri: string): ArrayBuffer;
  32849. /**
  32850. * Gets the absolute url.
  32851. * @param url the input url
  32852. * @return the absolute url
  32853. */
  32854. static GetAbsoluteUrl(url: string): string;
  32855. /**
  32856. * No log
  32857. */
  32858. static readonly NoneLogLevel: number;
  32859. /**
  32860. * Only message logs
  32861. */
  32862. static readonly MessageLogLevel: number;
  32863. /**
  32864. * Only warning logs
  32865. */
  32866. static readonly WarningLogLevel: number;
  32867. /**
  32868. * Only error logs
  32869. */
  32870. static readonly ErrorLogLevel: number;
  32871. /**
  32872. * All logs
  32873. */
  32874. static readonly AllLogLevel: number;
  32875. /**
  32876. * Gets a value indicating the number of loading errors
  32877. * @ignorenaming
  32878. */
  32879. static readonly errorsCount: number;
  32880. /**
  32881. * Callback called when a new log is added
  32882. */
  32883. static OnNewCacheEntry: (entry: string) => void;
  32884. /**
  32885. * Log a message to the console
  32886. * @param message defines the message to log
  32887. */
  32888. static Log(message: string): void;
  32889. /**
  32890. * Write a warning message to the console
  32891. * @param message defines the message to log
  32892. */
  32893. static Warn(message: string): void;
  32894. /**
  32895. * Write an error message to the console
  32896. * @param message defines the message to log
  32897. */
  32898. static Error(message: string): void;
  32899. /**
  32900. * Gets current log cache (list of logs)
  32901. */
  32902. static readonly LogCache: string;
  32903. /**
  32904. * Clears the log cache
  32905. */
  32906. static ClearLogCache(): void;
  32907. /**
  32908. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32909. */
  32910. static LogLevels: number;
  32911. /**
  32912. * Checks if the window object exists
  32913. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32914. */
  32915. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32916. /**
  32917. * No performance log
  32918. */
  32919. static readonly PerformanceNoneLogLevel: number;
  32920. /**
  32921. * Use user marks to log performance
  32922. */
  32923. static readonly PerformanceUserMarkLogLevel: number;
  32924. /**
  32925. * Log performance to the console
  32926. */
  32927. static readonly PerformanceConsoleLogLevel: number;
  32928. private static _performance;
  32929. /**
  32930. * Sets the current performance log level
  32931. */
  32932. static PerformanceLogLevel: number;
  32933. private static _StartPerformanceCounterDisabled;
  32934. private static _EndPerformanceCounterDisabled;
  32935. private static _StartUserMark;
  32936. private static _EndUserMark;
  32937. private static _StartPerformanceConsole;
  32938. private static _EndPerformanceConsole;
  32939. /**
  32940. * Starts a performance counter
  32941. */
  32942. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32943. /**
  32944. * Ends a specific performance coutner
  32945. */
  32946. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32947. /**
  32948. * Gets either window.performance.now() if supported or Date.now() else
  32949. */
  32950. static readonly Now: number;
  32951. /**
  32952. * This method will return the name of the class used to create the instance of the given object.
  32953. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32954. * @param object the object to get the class name from
  32955. * @param isType defines if the object is actually a type
  32956. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32957. */
  32958. static GetClassName(object: any, isType?: boolean): string;
  32959. /**
  32960. * Gets the first element of an array satisfying a given predicate
  32961. * @param array defines the array to browse
  32962. * @param predicate defines the predicate to use
  32963. * @returns null if not found or the element
  32964. */
  32965. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32966. /**
  32967. * This method will return the name of the full name of the class, including its owning module (if any).
  32968. * 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).
  32969. * @param object the object to get the class name from
  32970. * @param isType defines if the object is actually a type
  32971. * @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.
  32972. * @ignorenaming
  32973. */
  32974. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32975. /**
  32976. * Returns a promise that resolves after the given amount of time.
  32977. * @param delay Number of milliseconds to delay
  32978. * @returns Promise that resolves after the given amount of time
  32979. */
  32980. static DelayAsync(delay: number): Promise<void>;
  32981. }
  32982. /**
  32983. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32984. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32985. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32986. * @param name The name of the class, case should be preserved
  32987. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32988. */
  32989. export function className(name: string, module?: string): (target: Object) => void;
  32990. /**
  32991. * An implementation of a loop for asynchronous functions.
  32992. */
  32993. export class AsyncLoop {
  32994. /**
  32995. * Defines the number of iterations for the loop
  32996. */
  32997. iterations: number;
  32998. /**
  32999. * Defines the current index of the loop.
  33000. */
  33001. index: number;
  33002. private _done;
  33003. private _fn;
  33004. private _successCallback;
  33005. /**
  33006. * Constructor.
  33007. * @param iterations the number of iterations.
  33008. * @param func the function to run each iteration
  33009. * @param successCallback the callback that will be called upon succesful execution
  33010. * @param offset starting offset.
  33011. */
  33012. constructor(
  33013. /**
  33014. * Defines the number of iterations for the loop
  33015. */
  33016. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33017. /**
  33018. * Execute the next iteration. Must be called after the last iteration was finished.
  33019. */
  33020. executeNext(): void;
  33021. /**
  33022. * Break the loop and run the success callback.
  33023. */
  33024. breakLoop(): void;
  33025. /**
  33026. * Create and run an async loop.
  33027. * @param iterations the number of iterations.
  33028. * @param fn the function to run each iteration
  33029. * @param successCallback the callback that will be called upon succesful execution
  33030. * @param offset starting offset.
  33031. * @returns the created async loop object
  33032. */
  33033. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33034. /**
  33035. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33036. * @param iterations total number of iterations
  33037. * @param syncedIterations number of synchronous iterations in each async iteration.
  33038. * @param fn the function to call each iteration.
  33039. * @param callback a success call back that will be called when iterating stops.
  33040. * @param breakFunction a break condition (optional)
  33041. * @param timeout timeout settings for the setTimeout function. default - 0.
  33042. * @returns the created async loop object
  33043. */
  33044. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33045. }
  33046. }
  33047. declare module "babylonjs/Misc/stringDictionary" {
  33048. import { Nullable } from "babylonjs/types";
  33049. /**
  33050. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33051. * The underlying implementation relies on an associative array to ensure the best performances.
  33052. * The value can be anything including 'null' but except 'undefined'
  33053. */
  33054. export class StringDictionary<T> {
  33055. /**
  33056. * This will clear this dictionary and copy the content from the 'source' one.
  33057. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33058. * @param source the dictionary to take the content from and copy to this dictionary
  33059. */
  33060. copyFrom(source: StringDictionary<T>): void;
  33061. /**
  33062. * Get a value based from its key
  33063. * @param key the given key to get the matching value from
  33064. * @return the value if found, otherwise undefined is returned
  33065. */
  33066. get(key: string): T | undefined;
  33067. /**
  33068. * Get a value from its key or add it if it doesn't exist.
  33069. * This method will ensure you that a given key/data will be present in the dictionary.
  33070. * @param key the given key to get the matching value from
  33071. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33072. * The factory will only be invoked if there's no data for the given key.
  33073. * @return the value corresponding to the key.
  33074. */
  33075. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33076. /**
  33077. * Get a value from its key if present in the dictionary otherwise add it
  33078. * @param key the key to get the value from
  33079. * @param val if there's no such key/value pair in the dictionary add it with this value
  33080. * @return the value corresponding to the key
  33081. */
  33082. getOrAdd(key: string, val: T): T;
  33083. /**
  33084. * Check if there's a given key in the dictionary
  33085. * @param key the key to check for
  33086. * @return true if the key is present, false otherwise
  33087. */
  33088. contains(key: string): boolean;
  33089. /**
  33090. * Add a new key and its corresponding value
  33091. * @param key the key to add
  33092. * @param value the value corresponding to the key
  33093. * @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
  33094. */
  33095. add(key: string, value: T): boolean;
  33096. /**
  33097. * Update a specific value associated to a key
  33098. * @param key defines the key to use
  33099. * @param value defines the value to store
  33100. * @returns true if the value was updated (or false if the key was not found)
  33101. */
  33102. set(key: string, value: T): boolean;
  33103. /**
  33104. * Get the element of the given key and remove it from the dictionary
  33105. * @param key defines the key to search
  33106. * @returns the value associated with the key or null if not found
  33107. */
  33108. getAndRemove(key: string): Nullable<T>;
  33109. /**
  33110. * Remove a key/value from the dictionary.
  33111. * @param key the key to remove
  33112. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33113. */
  33114. remove(key: string): boolean;
  33115. /**
  33116. * Clear the whole content of the dictionary
  33117. */
  33118. clear(): void;
  33119. /**
  33120. * Gets the current count
  33121. */
  33122. readonly count: number;
  33123. /**
  33124. * Execute a callback on each key/val of the dictionary.
  33125. * Note that you can remove any element in this dictionary in the callback implementation
  33126. * @param callback the callback to execute on a given key/value pair
  33127. */
  33128. forEach(callback: (key: string, val: T) => void): void;
  33129. /**
  33130. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33131. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33132. * Note that you can remove any element in this dictionary in the callback implementation
  33133. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33134. * @returns the first item
  33135. */
  33136. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33137. private _count;
  33138. private _data;
  33139. }
  33140. }
  33141. declare module "babylonjs/Collisions/collisionCoordinator" {
  33142. import { Nullable } from "babylonjs/types";
  33143. import { Scene } from "babylonjs/scene";
  33144. import { Vector3 } from "babylonjs/Maths/math.vector";
  33145. import { Collider } from "babylonjs/Collisions/collider";
  33146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33147. /** @hidden */
  33148. export interface ICollisionCoordinator {
  33149. createCollider(): Collider;
  33150. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33151. init(scene: Scene): void;
  33152. }
  33153. /** @hidden */
  33154. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33155. private _scene;
  33156. private _scaledPosition;
  33157. private _scaledVelocity;
  33158. private _finalPosition;
  33159. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33160. createCollider(): Collider;
  33161. init(scene: Scene): void;
  33162. private _collideWithWorld;
  33163. }
  33164. }
  33165. declare module "babylonjs/Inputs/scene.inputManager" {
  33166. import { Nullable } from "babylonjs/types";
  33167. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33168. import { Vector2 } from "babylonjs/Maths/math.vector";
  33169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33170. import { Scene } from "babylonjs/scene";
  33171. /**
  33172. * Class used to manage all inputs for the scene.
  33173. */
  33174. export class InputManager {
  33175. /** The distance in pixel that you have to move to prevent some events */
  33176. static DragMovementThreshold: number;
  33177. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33178. static LongPressDelay: number;
  33179. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33180. static DoubleClickDelay: number;
  33181. /** If you need to check double click without raising a single click at first click, enable this flag */
  33182. static ExclusiveDoubleClickMode: boolean;
  33183. private _wheelEventName;
  33184. private _onPointerMove;
  33185. private _onPointerDown;
  33186. private _onPointerUp;
  33187. private _initClickEvent;
  33188. private _initActionManager;
  33189. private _delayedSimpleClick;
  33190. private _delayedSimpleClickTimeout;
  33191. private _previousDelayedSimpleClickTimeout;
  33192. private _meshPickProceed;
  33193. private _previousButtonPressed;
  33194. private _currentPickResult;
  33195. private _previousPickResult;
  33196. private _totalPointersPressed;
  33197. private _doubleClickOccured;
  33198. private _pointerOverMesh;
  33199. private _pickedDownMesh;
  33200. private _pickedUpMesh;
  33201. private _pointerX;
  33202. private _pointerY;
  33203. private _unTranslatedPointerX;
  33204. private _unTranslatedPointerY;
  33205. private _startingPointerPosition;
  33206. private _previousStartingPointerPosition;
  33207. private _startingPointerTime;
  33208. private _previousStartingPointerTime;
  33209. private _pointerCaptures;
  33210. private _onKeyDown;
  33211. private _onKeyUp;
  33212. private _onCanvasFocusObserver;
  33213. private _onCanvasBlurObserver;
  33214. private _scene;
  33215. /**
  33216. * Creates a new InputManager
  33217. * @param scene defines the hosting scene
  33218. */
  33219. constructor(scene: Scene);
  33220. /**
  33221. * Gets the mesh that is currently under the pointer
  33222. */
  33223. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33224. /**
  33225. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33226. */
  33227. readonly unTranslatedPointer: Vector2;
  33228. /**
  33229. * Gets or sets the current on-screen X position of the pointer
  33230. */
  33231. pointerX: number;
  33232. /**
  33233. * Gets or sets the current on-screen Y position of the pointer
  33234. */
  33235. pointerY: number;
  33236. private _updatePointerPosition;
  33237. private _processPointerMove;
  33238. private _setRayOnPointerInfo;
  33239. private _checkPrePointerObservable;
  33240. /**
  33241. * Use this method to simulate a pointer move on a mesh
  33242. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33243. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33244. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33245. */
  33246. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33247. /**
  33248. * Use this method to simulate a pointer down on a mesh
  33249. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33250. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33251. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33252. */
  33253. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33254. private _processPointerDown;
  33255. /** @hidden */
  33256. _isPointerSwiping(): boolean;
  33257. /**
  33258. * Use this method to simulate a pointer up on a mesh
  33259. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33260. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33261. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33262. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33263. */
  33264. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33265. private _processPointerUp;
  33266. /**
  33267. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33268. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33269. * @returns true if the pointer was captured
  33270. */
  33271. isPointerCaptured(pointerId?: number): boolean;
  33272. /**
  33273. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33274. * @param attachUp defines if you want to attach events to pointerup
  33275. * @param attachDown defines if you want to attach events to pointerdown
  33276. * @param attachMove defines if you want to attach events to pointermove
  33277. */
  33278. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33279. /**
  33280. * Detaches all event handlers
  33281. */
  33282. detachControl(): void;
  33283. /**
  33284. * Force the value of meshUnderPointer
  33285. * @param mesh defines the mesh to use
  33286. */
  33287. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33288. /**
  33289. * Gets the mesh under the pointer
  33290. * @returns a Mesh or null if no mesh is under the pointer
  33291. */
  33292. getPointerOverMesh(): Nullable<AbstractMesh>;
  33293. }
  33294. }
  33295. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33296. /**
  33297. * Helper class used to generate session unique ID
  33298. */
  33299. export class UniqueIdGenerator {
  33300. private static _UniqueIdCounter;
  33301. /**
  33302. * Gets an unique (relatively to the current scene) Id
  33303. */
  33304. static readonly UniqueId: number;
  33305. }
  33306. }
  33307. declare module "babylonjs/Animations/animationGroup" {
  33308. import { Animatable } from "babylonjs/Animations/animatable";
  33309. import { Animation } from "babylonjs/Animations/animation";
  33310. import { Scene, IDisposable } from "babylonjs/scene";
  33311. import { Observable } from "babylonjs/Misc/observable";
  33312. import { Nullable } from "babylonjs/types";
  33313. import "babylonjs/Animations/animatable";
  33314. /**
  33315. * This class defines the direct association between an animation and a target
  33316. */
  33317. export class TargetedAnimation {
  33318. /**
  33319. * Animation to perform
  33320. */
  33321. animation: Animation;
  33322. /**
  33323. * Target to animate
  33324. */
  33325. target: any;
  33326. /**
  33327. * Serialize the object
  33328. * @returns the JSON object representing the current entity
  33329. */
  33330. serialize(): any;
  33331. }
  33332. /**
  33333. * Use this class to create coordinated animations on multiple targets
  33334. */
  33335. export class AnimationGroup implements IDisposable {
  33336. /** The name of the animation group */
  33337. name: string;
  33338. private _scene;
  33339. private _targetedAnimations;
  33340. private _animatables;
  33341. private _from;
  33342. private _to;
  33343. private _isStarted;
  33344. private _isPaused;
  33345. private _speedRatio;
  33346. private _loopAnimation;
  33347. /**
  33348. * Gets or sets the unique id of the node
  33349. */
  33350. uniqueId: number;
  33351. /**
  33352. * This observable will notify when one animation have ended
  33353. */
  33354. onAnimationEndObservable: Observable<TargetedAnimation>;
  33355. /**
  33356. * Observer raised when one animation loops
  33357. */
  33358. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33359. /**
  33360. * This observable will notify when all animations have ended.
  33361. */
  33362. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33363. /**
  33364. * This observable will notify when all animations have paused.
  33365. */
  33366. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33367. /**
  33368. * This observable will notify when all animations are playing.
  33369. */
  33370. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33371. /**
  33372. * Gets the first frame
  33373. */
  33374. readonly from: number;
  33375. /**
  33376. * Gets the last frame
  33377. */
  33378. readonly to: number;
  33379. /**
  33380. * Define if the animations are started
  33381. */
  33382. readonly isStarted: boolean;
  33383. /**
  33384. * Gets a value indicating that the current group is playing
  33385. */
  33386. readonly isPlaying: boolean;
  33387. /**
  33388. * Gets or sets the speed ratio to use for all animations
  33389. */
  33390. /**
  33391. * Gets or sets the speed ratio to use for all animations
  33392. */
  33393. speedRatio: number;
  33394. /**
  33395. * Gets or sets if all animations should loop or not
  33396. */
  33397. loopAnimation: boolean;
  33398. /**
  33399. * Gets the targeted animations for this animation group
  33400. */
  33401. readonly targetedAnimations: Array<TargetedAnimation>;
  33402. /**
  33403. * returning the list of animatables controlled by this animation group.
  33404. */
  33405. readonly animatables: Array<Animatable>;
  33406. /**
  33407. * Instantiates a new Animation Group.
  33408. * This helps managing several animations at once.
  33409. * @see http://doc.babylonjs.com/how_to/group
  33410. * @param name Defines the name of the group
  33411. * @param scene Defines the scene the group belongs to
  33412. */
  33413. constructor(
  33414. /** The name of the animation group */
  33415. name: string, scene?: Nullable<Scene>);
  33416. /**
  33417. * Add an animation (with its target) in the group
  33418. * @param animation defines the animation we want to add
  33419. * @param target defines the target of the animation
  33420. * @returns the TargetedAnimation object
  33421. */
  33422. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33423. /**
  33424. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33425. * It can add constant keys at begin or end
  33426. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33427. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33428. * @returns the animation group
  33429. */
  33430. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33431. /**
  33432. * Start all animations on given targets
  33433. * @param loop defines if animations must loop
  33434. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33435. * @param from defines the from key (optional)
  33436. * @param to defines the to key (optional)
  33437. * @returns the current animation group
  33438. */
  33439. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33440. /**
  33441. * Pause all animations
  33442. * @returns the animation group
  33443. */
  33444. pause(): AnimationGroup;
  33445. /**
  33446. * Play all animations to initial state
  33447. * This function will start() the animations if they were not started or will restart() them if they were paused
  33448. * @param loop defines if animations must loop
  33449. * @returns the animation group
  33450. */
  33451. play(loop?: boolean): AnimationGroup;
  33452. /**
  33453. * Reset all animations to initial state
  33454. * @returns the animation group
  33455. */
  33456. reset(): AnimationGroup;
  33457. /**
  33458. * Restart animations from key 0
  33459. * @returns the animation group
  33460. */
  33461. restart(): AnimationGroup;
  33462. /**
  33463. * Stop all animations
  33464. * @returns the animation group
  33465. */
  33466. stop(): AnimationGroup;
  33467. /**
  33468. * Set animation weight for all animatables
  33469. * @param weight defines the weight to use
  33470. * @return the animationGroup
  33471. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33472. */
  33473. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33474. /**
  33475. * Synchronize and normalize all animatables with a source animatable
  33476. * @param root defines the root animatable to synchronize with
  33477. * @return the animationGroup
  33478. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33479. */
  33480. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33481. /**
  33482. * Goes to a specific frame in this animation group
  33483. * @param frame the frame number to go to
  33484. * @return the animationGroup
  33485. */
  33486. goToFrame(frame: number): AnimationGroup;
  33487. /**
  33488. * Dispose all associated resources
  33489. */
  33490. dispose(): void;
  33491. private _checkAnimationGroupEnded;
  33492. /**
  33493. * Clone the current animation group and returns a copy
  33494. * @param newName defines the name of the new group
  33495. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33496. * @returns the new aniamtion group
  33497. */
  33498. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33499. /**
  33500. * Serializes the animationGroup to an object
  33501. * @returns Serialized object
  33502. */
  33503. serialize(): any;
  33504. /**
  33505. * Returns a new AnimationGroup object parsed from the source provided.
  33506. * @param parsedAnimationGroup defines the source
  33507. * @param scene defines the scene that will receive the animationGroup
  33508. * @returns a new AnimationGroup
  33509. */
  33510. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33511. /**
  33512. * Returns the string "AnimationGroup"
  33513. * @returns "AnimationGroup"
  33514. */
  33515. getClassName(): string;
  33516. /**
  33517. * Creates a detailled string about the object
  33518. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33519. * @returns a string representing the object
  33520. */
  33521. toString(fullDetails?: boolean): string;
  33522. }
  33523. }
  33524. declare module "babylonjs/scene" {
  33525. import { Nullable } from "babylonjs/types";
  33526. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33527. import { Observable } from "babylonjs/Misc/observable";
  33528. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33529. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33530. import { Geometry } from "babylonjs/Meshes/geometry";
  33531. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33534. import { Mesh } from "babylonjs/Meshes/mesh";
  33535. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33536. import { Bone } from "babylonjs/Bones/bone";
  33537. import { Skeleton } from "babylonjs/Bones/skeleton";
  33538. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33539. import { Camera } from "babylonjs/Cameras/camera";
  33540. import { AbstractScene } from "babylonjs/abstractScene";
  33541. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33542. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33543. import { Material } from "babylonjs/Materials/material";
  33544. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33545. import { Effect } from "babylonjs/Materials/effect";
  33546. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33547. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33548. import { Light } from "babylonjs/Lights/light";
  33549. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33550. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33551. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33552. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33553. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33554. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33555. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33556. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33557. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33558. import { Engine } from "babylonjs/Engines/engine";
  33559. import { Node } from "babylonjs/node";
  33560. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33561. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33562. import { WebRequest } from "babylonjs/Misc/webRequest";
  33563. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33564. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33565. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33566. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33567. import { Plane } from "babylonjs/Maths/math.plane";
  33568. import { Ray } from "babylonjs/Culling/ray";
  33569. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33570. import { Animation } from "babylonjs/Animations/animation";
  33571. import { Animatable } from "babylonjs/Animations/animatable";
  33572. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33573. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33574. import { Collider } from "babylonjs/Collisions/collider";
  33575. /**
  33576. * Define an interface for all classes that will hold resources
  33577. */
  33578. export interface IDisposable {
  33579. /**
  33580. * Releases all held resources
  33581. */
  33582. dispose(): void;
  33583. }
  33584. /** Interface defining initialization parameters for Scene class */
  33585. export interface SceneOptions {
  33586. /**
  33587. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33588. * It will improve performance when the number of geometries becomes important.
  33589. */
  33590. useGeometryUniqueIdsMap?: boolean;
  33591. /**
  33592. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33593. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33594. */
  33595. useMaterialMeshMap?: boolean;
  33596. /**
  33597. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33598. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33599. */
  33600. useClonedMeshhMap?: boolean;
  33601. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33602. virtual?: boolean;
  33603. }
  33604. /**
  33605. * Represents a scene to be rendered by the engine.
  33606. * @see http://doc.babylonjs.com/features/scene
  33607. */
  33608. export class Scene extends AbstractScene implements IAnimatable {
  33609. /** The fog is deactivated */
  33610. static readonly FOGMODE_NONE: number;
  33611. /** The fog density is following an exponential function */
  33612. static readonly FOGMODE_EXP: number;
  33613. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33614. static readonly FOGMODE_EXP2: number;
  33615. /** The fog density is following a linear function. */
  33616. static readonly FOGMODE_LINEAR: number;
  33617. /**
  33618. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33619. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33620. */
  33621. static MinDeltaTime: number;
  33622. /**
  33623. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33624. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33625. */
  33626. static MaxDeltaTime: number;
  33627. /**
  33628. * Factory used to create the default material.
  33629. * @param name The name of the material to create
  33630. * @param scene The scene to create the material for
  33631. * @returns The default material
  33632. */
  33633. static DefaultMaterialFactory(scene: Scene): Material;
  33634. /**
  33635. * Factory used to create the a collision coordinator.
  33636. * @returns The collision coordinator
  33637. */
  33638. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33639. /** @hidden */
  33640. _inputManager: InputManager;
  33641. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33642. cameraToUseForPointers: Nullable<Camera>;
  33643. /** @hidden */
  33644. readonly _isScene: boolean;
  33645. /**
  33646. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33647. */
  33648. autoClear: boolean;
  33649. /**
  33650. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33651. */
  33652. autoClearDepthAndStencil: boolean;
  33653. /**
  33654. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33655. */
  33656. clearColor: Color4;
  33657. /**
  33658. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33659. */
  33660. ambientColor: Color3;
  33661. /**
  33662. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33663. * It should only be one of the following (if not the default embedded one):
  33664. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33665. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33666. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33667. * The material properties need to be setup according to the type of texture in use.
  33668. */
  33669. environmentBRDFTexture: BaseTexture;
  33670. /** @hidden */
  33671. protected _environmentTexture: Nullable<BaseTexture>;
  33672. /**
  33673. * Texture used in all pbr material as the reflection texture.
  33674. * As in the majority of the scene they are the same (exception for multi room and so on),
  33675. * this is easier to reference from here than from all the materials.
  33676. */
  33677. /**
  33678. * Texture used in all pbr material as the reflection texture.
  33679. * As in the majority of the scene they are the same (exception for multi room and so on),
  33680. * this is easier to set here than in all the materials.
  33681. */
  33682. environmentTexture: Nullable<BaseTexture>;
  33683. /** @hidden */
  33684. protected _environmentIntensity: number;
  33685. /**
  33686. * Intensity of the environment in all pbr material.
  33687. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33688. * As in the majority of the scene they are the same (exception for multi room and so on),
  33689. * this is easier to reference from here than from all the materials.
  33690. */
  33691. /**
  33692. * Intensity of the environment in all pbr material.
  33693. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33694. * As in the majority of the scene they are the same (exception for multi room and so on),
  33695. * this is easier to set here than in all the materials.
  33696. */
  33697. environmentIntensity: number;
  33698. /** @hidden */
  33699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33700. /**
  33701. * Default image processing configuration used either in the rendering
  33702. * Forward main pass or through the imageProcessingPostProcess if present.
  33703. * As in the majority of the scene they are the same (exception for multi camera),
  33704. * this is easier to reference from here than from all the materials and post process.
  33705. *
  33706. * No setter as we it is a shared configuration, you can set the values instead.
  33707. */
  33708. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33709. private _forceWireframe;
  33710. /**
  33711. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33712. */
  33713. forceWireframe: boolean;
  33714. private _forcePointsCloud;
  33715. /**
  33716. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33717. */
  33718. forcePointsCloud: boolean;
  33719. /**
  33720. * Gets or sets the active clipplane 1
  33721. */
  33722. clipPlane: Nullable<Plane>;
  33723. /**
  33724. * Gets or sets the active clipplane 2
  33725. */
  33726. clipPlane2: Nullable<Plane>;
  33727. /**
  33728. * Gets or sets the active clipplane 3
  33729. */
  33730. clipPlane3: Nullable<Plane>;
  33731. /**
  33732. * Gets or sets the active clipplane 4
  33733. */
  33734. clipPlane4: Nullable<Plane>;
  33735. /**
  33736. * Gets or sets a boolean indicating if animations are enabled
  33737. */
  33738. animationsEnabled: boolean;
  33739. private _animationPropertiesOverride;
  33740. /**
  33741. * Gets or sets the animation properties override
  33742. */
  33743. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33744. /**
  33745. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33746. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33747. */
  33748. useConstantAnimationDeltaTime: boolean;
  33749. /**
  33750. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33751. * Please note that it requires to run a ray cast through the scene on every frame
  33752. */
  33753. constantlyUpdateMeshUnderPointer: boolean;
  33754. /**
  33755. * Defines the HTML cursor to use when hovering over interactive elements
  33756. */
  33757. hoverCursor: string;
  33758. /**
  33759. * Defines the HTML default cursor to use (empty by default)
  33760. */
  33761. defaultCursor: string;
  33762. /**
  33763. * This is used to call preventDefault() on pointer down
  33764. * in order to block unwanted artifacts like system double clicks
  33765. */
  33766. preventDefaultOnPointerDown: boolean;
  33767. /**
  33768. * This is used to call preventDefault() on pointer up
  33769. * in order to block unwanted artifacts like system double clicks
  33770. */
  33771. preventDefaultOnPointerUp: boolean;
  33772. /**
  33773. * Gets or sets user defined metadata
  33774. */
  33775. metadata: any;
  33776. /**
  33777. * For internal use only. Please do not use.
  33778. */
  33779. reservedDataStore: any;
  33780. /**
  33781. * Gets the name of the plugin used to load this scene (null by default)
  33782. */
  33783. loadingPluginName: string;
  33784. /**
  33785. * Use this array to add regular expressions used to disable offline support for specific urls
  33786. */
  33787. disableOfflineSupportExceptionRules: RegExp[];
  33788. /**
  33789. * An event triggered when the scene is disposed.
  33790. */
  33791. onDisposeObservable: Observable<Scene>;
  33792. private _onDisposeObserver;
  33793. /** Sets a function to be executed when this scene is disposed. */
  33794. onDispose: () => void;
  33795. /**
  33796. * An event triggered before rendering the scene (right after animations and physics)
  33797. */
  33798. onBeforeRenderObservable: Observable<Scene>;
  33799. private _onBeforeRenderObserver;
  33800. /** Sets a function to be executed before rendering this scene */
  33801. beforeRender: Nullable<() => void>;
  33802. /**
  33803. * An event triggered after rendering the scene
  33804. */
  33805. onAfterRenderObservable: Observable<Scene>;
  33806. /**
  33807. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33808. */
  33809. onAfterRenderCameraObservable: Observable<Camera>;
  33810. private _onAfterRenderObserver;
  33811. /** Sets a function to be executed after rendering this scene */
  33812. afterRender: Nullable<() => void>;
  33813. /**
  33814. * An event triggered before animating the scene
  33815. */
  33816. onBeforeAnimationsObservable: Observable<Scene>;
  33817. /**
  33818. * An event triggered after animations processing
  33819. */
  33820. onAfterAnimationsObservable: Observable<Scene>;
  33821. /**
  33822. * An event triggered before draw calls are ready to be sent
  33823. */
  33824. onBeforeDrawPhaseObservable: Observable<Scene>;
  33825. /**
  33826. * An event triggered after draw calls have been sent
  33827. */
  33828. onAfterDrawPhaseObservable: Observable<Scene>;
  33829. /**
  33830. * An event triggered when the scene is ready
  33831. */
  33832. onReadyObservable: Observable<Scene>;
  33833. /**
  33834. * An event triggered before rendering a camera
  33835. */
  33836. onBeforeCameraRenderObservable: Observable<Camera>;
  33837. private _onBeforeCameraRenderObserver;
  33838. /** Sets a function to be executed before rendering a camera*/
  33839. beforeCameraRender: () => void;
  33840. /**
  33841. * An event triggered after rendering a camera
  33842. */
  33843. onAfterCameraRenderObservable: Observable<Camera>;
  33844. private _onAfterCameraRenderObserver;
  33845. /** Sets a function to be executed after rendering a camera*/
  33846. afterCameraRender: () => void;
  33847. /**
  33848. * An event triggered when active meshes evaluation is about to start
  33849. */
  33850. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33851. /**
  33852. * An event triggered when active meshes evaluation is done
  33853. */
  33854. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33855. /**
  33856. * An event triggered when particles rendering is about to start
  33857. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33858. */
  33859. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33860. /**
  33861. * An event triggered when particles rendering is done
  33862. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33863. */
  33864. onAfterParticlesRenderingObservable: Observable<Scene>;
  33865. /**
  33866. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33867. */
  33868. onDataLoadedObservable: Observable<Scene>;
  33869. /**
  33870. * An event triggered when a camera is created
  33871. */
  33872. onNewCameraAddedObservable: Observable<Camera>;
  33873. /**
  33874. * An event triggered when a camera is removed
  33875. */
  33876. onCameraRemovedObservable: Observable<Camera>;
  33877. /**
  33878. * An event triggered when a light is created
  33879. */
  33880. onNewLightAddedObservable: Observable<Light>;
  33881. /**
  33882. * An event triggered when a light is removed
  33883. */
  33884. onLightRemovedObservable: Observable<Light>;
  33885. /**
  33886. * An event triggered when a geometry is created
  33887. */
  33888. onNewGeometryAddedObservable: Observable<Geometry>;
  33889. /**
  33890. * An event triggered when a geometry is removed
  33891. */
  33892. onGeometryRemovedObservable: Observable<Geometry>;
  33893. /**
  33894. * An event triggered when a transform node is created
  33895. */
  33896. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33897. /**
  33898. * An event triggered when a transform node is removed
  33899. */
  33900. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33901. /**
  33902. * An event triggered when a mesh is created
  33903. */
  33904. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33905. /**
  33906. * An event triggered when a mesh is removed
  33907. */
  33908. onMeshRemovedObservable: Observable<AbstractMesh>;
  33909. /**
  33910. * An event triggered when a skeleton is created
  33911. */
  33912. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33913. /**
  33914. * An event triggered when a skeleton is removed
  33915. */
  33916. onSkeletonRemovedObservable: Observable<Skeleton>;
  33917. /**
  33918. * An event triggered when a material is created
  33919. */
  33920. onNewMaterialAddedObservable: Observable<Material>;
  33921. /**
  33922. * An event triggered when a material is removed
  33923. */
  33924. onMaterialRemovedObservable: Observable<Material>;
  33925. /**
  33926. * An event triggered when a texture is created
  33927. */
  33928. onNewTextureAddedObservable: Observable<BaseTexture>;
  33929. /**
  33930. * An event triggered when a texture is removed
  33931. */
  33932. onTextureRemovedObservable: Observable<BaseTexture>;
  33933. /**
  33934. * An event triggered when render targets are about to be rendered
  33935. * Can happen multiple times per frame.
  33936. */
  33937. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33938. /**
  33939. * An event triggered when render targets were rendered.
  33940. * Can happen multiple times per frame.
  33941. */
  33942. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33943. /**
  33944. * An event triggered before calculating deterministic simulation step
  33945. */
  33946. onBeforeStepObservable: Observable<Scene>;
  33947. /**
  33948. * An event triggered after calculating deterministic simulation step
  33949. */
  33950. onAfterStepObservable: Observable<Scene>;
  33951. /**
  33952. * An event triggered when the activeCamera property is updated
  33953. */
  33954. onActiveCameraChanged: Observable<Scene>;
  33955. /**
  33956. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33957. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33958. * 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)
  33959. */
  33960. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33961. /**
  33962. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33963. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33964. * 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)
  33965. */
  33966. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33967. /**
  33968. * This Observable will when a mesh has been imported into the scene.
  33969. */
  33970. onMeshImportedObservable: Observable<AbstractMesh>;
  33971. /**
  33972. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33973. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33974. */
  33975. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33976. /** @hidden */
  33977. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33978. /**
  33979. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33980. */
  33981. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33982. /**
  33983. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33984. */
  33985. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33986. /**
  33987. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33988. */
  33989. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33990. /** Callback called when a pointer move is detected */
  33991. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33992. /** Callback called when a pointer down is detected */
  33993. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33994. /** Callback called when a pointer up is detected */
  33995. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33996. /** Callback called when a pointer pick is detected */
  33997. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33998. /**
  33999. * 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).
  34000. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34001. */
  34002. onPrePointerObservable: Observable<PointerInfoPre>;
  34003. /**
  34004. * Observable event triggered each time an input event is received from the rendering canvas
  34005. */
  34006. onPointerObservable: Observable<PointerInfo>;
  34007. /**
  34008. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34009. */
  34010. readonly unTranslatedPointer: Vector2;
  34011. /**
  34012. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34013. */
  34014. static DragMovementThreshold: number;
  34015. /**
  34016. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34017. */
  34018. static LongPressDelay: number;
  34019. /**
  34020. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34021. */
  34022. static DoubleClickDelay: number;
  34023. /** If you need to check double click without raising a single click at first click, enable this flag */
  34024. static ExclusiveDoubleClickMode: boolean;
  34025. /** @hidden */
  34026. _mirroredCameraPosition: Nullable<Vector3>;
  34027. /**
  34028. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34029. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34030. */
  34031. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34032. /**
  34033. * Observable event triggered each time an keyboard event is received from the hosting window
  34034. */
  34035. onKeyboardObservable: Observable<KeyboardInfo>;
  34036. private _useRightHandedSystem;
  34037. /**
  34038. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34039. */
  34040. useRightHandedSystem: boolean;
  34041. private _timeAccumulator;
  34042. private _currentStepId;
  34043. private _currentInternalStep;
  34044. /**
  34045. * Sets the step Id used by deterministic lock step
  34046. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34047. * @param newStepId defines the step Id
  34048. */
  34049. setStepId(newStepId: number): void;
  34050. /**
  34051. * Gets the step Id used by deterministic lock step
  34052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34053. * @returns the step Id
  34054. */
  34055. getStepId(): number;
  34056. /**
  34057. * Gets the internal step used by deterministic lock step
  34058. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34059. * @returns the internal step
  34060. */
  34061. getInternalStep(): number;
  34062. private _fogEnabled;
  34063. /**
  34064. * Gets or sets a boolean indicating if fog is enabled on this scene
  34065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34066. * (Default is true)
  34067. */
  34068. fogEnabled: boolean;
  34069. private _fogMode;
  34070. /**
  34071. * Gets or sets the fog mode to use
  34072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34073. * | mode | value |
  34074. * | --- | --- |
  34075. * | FOGMODE_NONE | 0 |
  34076. * | FOGMODE_EXP | 1 |
  34077. * | FOGMODE_EXP2 | 2 |
  34078. * | FOGMODE_LINEAR | 3 |
  34079. */
  34080. fogMode: number;
  34081. /**
  34082. * Gets or sets the fog color to use
  34083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34084. * (Default is Color3(0.2, 0.2, 0.3))
  34085. */
  34086. fogColor: Color3;
  34087. /**
  34088. * Gets or sets the fog density to use
  34089. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34090. * (Default is 0.1)
  34091. */
  34092. fogDensity: number;
  34093. /**
  34094. * Gets or sets the fog start distance to use
  34095. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34096. * (Default is 0)
  34097. */
  34098. fogStart: number;
  34099. /**
  34100. * Gets or sets the fog end distance to use
  34101. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34102. * (Default is 1000)
  34103. */
  34104. fogEnd: number;
  34105. private _shadowsEnabled;
  34106. /**
  34107. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34108. */
  34109. shadowsEnabled: boolean;
  34110. private _lightsEnabled;
  34111. /**
  34112. * Gets or sets a boolean indicating if lights are enabled on this scene
  34113. */
  34114. lightsEnabled: boolean;
  34115. /** All of the active cameras added to this scene. */
  34116. activeCameras: Camera[];
  34117. /** @hidden */
  34118. _activeCamera: Nullable<Camera>;
  34119. /** Gets or sets the current active camera */
  34120. activeCamera: Nullable<Camera>;
  34121. private _defaultMaterial;
  34122. /** The default material used on meshes when no material is affected */
  34123. /** The default material used on meshes when no material is affected */
  34124. defaultMaterial: Material;
  34125. private _texturesEnabled;
  34126. /**
  34127. * Gets or sets a boolean indicating if textures are enabled on this scene
  34128. */
  34129. texturesEnabled: boolean;
  34130. /**
  34131. * Gets or sets a boolean indicating if particles are enabled on this scene
  34132. */
  34133. particlesEnabled: boolean;
  34134. /**
  34135. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34136. */
  34137. spritesEnabled: boolean;
  34138. private _skeletonsEnabled;
  34139. /**
  34140. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34141. */
  34142. skeletonsEnabled: boolean;
  34143. /**
  34144. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34145. */
  34146. lensFlaresEnabled: boolean;
  34147. /**
  34148. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34150. */
  34151. collisionsEnabled: boolean;
  34152. private _collisionCoordinator;
  34153. /** @hidden */
  34154. readonly collisionCoordinator: ICollisionCoordinator;
  34155. /**
  34156. * Defines the gravity applied to this scene (used only for collisions)
  34157. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34158. */
  34159. gravity: Vector3;
  34160. /**
  34161. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34162. */
  34163. postProcessesEnabled: boolean;
  34164. /**
  34165. * The list of postprocesses added to the scene
  34166. */
  34167. postProcesses: PostProcess[];
  34168. /**
  34169. * Gets the current postprocess manager
  34170. */
  34171. postProcessManager: PostProcessManager;
  34172. /**
  34173. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34174. */
  34175. renderTargetsEnabled: boolean;
  34176. /**
  34177. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34178. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34179. */
  34180. dumpNextRenderTargets: boolean;
  34181. /**
  34182. * The list of user defined render targets added to the scene
  34183. */
  34184. customRenderTargets: RenderTargetTexture[];
  34185. /**
  34186. * Defines if texture loading must be delayed
  34187. * If true, textures will only be loaded when they need to be rendered
  34188. */
  34189. useDelayedTextureLoading: boolean;
  34190. /**
  34191. * Gets the list of meshes imported to the scene through SceneLoader
  34192. */
  34193. importedMeshesFiles: String[];
  34194. /**
  34195. * Gets or sets a boolean indicating if probes are enabled on this scene
  34196. */
  34197. probesEnabled: boolean;
  34198. /**
  34199. * Gets or sets the current offline provider to use to store scene data
  34200. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34201. */
  34202. offlineProvider: IOfflineProvider;
  34203. /**
  34204. * Gets or sets the action manager associated with the scene
  34205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34206. */
  34207. actionManager: AbstractActionManager;
  34208. private _meshesForIntersections;
  34209. /**
  34210. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34211. */
  34212. proceduralTexturesEnabled: boolean;
  34213. private _engine;
  34214. private _totalVertices;
  34215. /** @hidden */
  34216. _activeIndices: PerfCounter;
  34217. /** @hidden */
  34218. _activeParticles: PerfCounter;
  34219. /** @hidden */
  34220. _activeBones: PerfCounter;
  34221. private _animationRatio;
  34222. /** @hidden */
  34223. _animationTimeLast: number;
  34224. /** @hidden */
  34225. _animationTime: number;
  34226. /**
  34227. * Gets or sets a general scale for animation speed
  34228. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34229. */
  34230. animationTimeScale: number;
  34231. /** @hidden */
  34232. _cachedMaterial: Nullable<Material>;
  34233. /** @hidden */
  34234. _cachedEffect: Nullable<Effect>;
  34235. /** @hidden */
  34236. _cachedVisibility: Nullable<number>;
  34237. private _renderId;
  34238. private _frameId;
  34239. private _executeWhenReadyTimeoutId;
  34240. private _intermediateRendering;
  34241. private _viewUpdateFlag;
  34242. private _projectionUpdateFlag;
  34243. /** @hidden */
  34244. _toBeDisposed: Nullable<IDisposable>[];
  34245. private _activeRequests;
  34246. /** @hidden */
  34247. _pendingData: any[];
  34248. private _isDisposed;
  34249. /**
  34250. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34251. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34252. */
  34253. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34254. private _activeMeshes;
  34255. private _processedMaterials;
  34256. private _renderTargets;
  34257. /** @hidden */
  34258. _activeParticleSystems: SmartArray<IParticleSystem>;
  34259. private _activeSkeletons;
  34260. private _softwareSkinnedMeshes;
  34261. private _renderingManager;
  34262. /** @hidden */
  34263. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34264. private _transformMatrix;
  34265. private _sceneUbo;
  34266. /** @hidden */
  34267. _viewMatrix: Matrix;
  34268. private _projectionMatrix;
  34269. /** @hidden */
  34270. _forcedViewPosition: Nullable<Vector3>;
  34271. /** @hidden */
  34272. _frustumPlanes: Plane[];
  34273. /**
  34274. * Gets the list of frustum planes (built from the active camera)
  34275. */
  34276. readonly frustumPlanes: Plane[];
  34277. /**
  34278. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34279. * This is useful if there are more lights that the maximum simulteanous authorized
  34280. */
  34281. requireLightSorting: boolean;
  34282. /** @hidden */
  34283. readonly useMaterialMeshMap: boolean;
  34284. /** @hidden */
  34285. readonly useClonedMeshhMap: boolean;
  34286. private _externalData;
  34287. private _uid;
  34288. /**
  34289. * @hidden
  34290. * Backing store of defined scene components.
  34291. */
  34292. _components: ISceneComponent[];
  34293. /**
  34294. * @hidden
  34295. * Backing store of defined scene components.
  34296. */
  34297. _serializableComponents: ISceneSerializableComponent[];
  34298. /**
  34299. * List of components to register on the next registration step.
  34300. */
  34301. private _transientComponents;
  34302. /**
  34303. * Registers the transient components if needed.
  34304. */
  34305. private _registerTransientComponents;
  34306. /**
  34307. * @hidden
  34308. * Add a component to the scene.
  34309. * Note that the ccomponent could be registered on th next frame if this is called after
  34310. * the register component stage.
  34311. * @param component Defines the component to add to the scene
  34312. */
  34313. _addComponent(component: ISceneComponent): void;
  34314. /**
  34315. * @hidden
  34316. * Gets a component from the scene.
  34317. * @param name defines the name of the component to retrieve
  34318. * @returns the component or null if not present
  34319. */
  34320. _getComponent(name: string): Nullable<ISceneComponent>;
  34321. /**
  34322. * @hidden
  34323. * Defines the actions happening before camera updates.
  34324. */
  34325. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34326. /**
  34327. * @hidden
  34328. * Defines the actions happening before clear the canvas.
  34329. */
  34330. _beforeClearStage: Stage<SimpleStageAction>;
  34331. /**
  34332. * @hidden
  34333. * Defines the actions when collecting render targets for the frame.
  34334. */
  34335. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34336. /**
  34337. * @hidden
  34338. * Defines the actions happening for one camera in the frame.
  34339. */
  34340. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34341. /**
  34342. * @hidden
  34343. * Defines the actions happening during the per mesh ready checks.
  34344. */
  34345. _isReadyForMeshStage: Stage<MeshStageAction>;
  34346. /**
  34347. * @hidden
  34348. * Defines the actions happening before evaluate active mesh checks.
  34349. */
  34350. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34351. /**
  34352. * @hidden
  34353. * Defines the actions happening during the evaluate sub mesh checks.
  34354. */
  34355. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34356. /**
  34357. * @hidden
  34358. * Defines the actions happening during the active mesh stage.
  34359. */
  34360. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34361. /**
  34362. * @hidden
  34363. * Defines the actions happening during the per camera render target step.
  34364. */
  34365. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34366. /**
  34367. * @hidden
  34368. * Defines the actions happening just before the active camera is drawing.
  34369. */
  34370. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34371. /**
  34372. * @hidden
  34373. * Defines the actions happening just before a render target is drawing.
  34374. */
  34375. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34376. /**
  34377. * @hidden
  34378. * Defines the actions happening just before a rendering group is drawing.
  34379. */
  34380. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34381. /**
  34382. * @hidden
  34383. * Defines the actions happening just before a mesh is drawing.
  34384. */
  34385. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34386. /**
  34387. * @hidden
  34388. * Defines the actions happening just after a mesh has been drawn.
  34389. */
  34390. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34391. /**
  34392. * @hidden
  34393. * Defines the actions happening just after a rendering group has been drawn.
  34394. */
  34395. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34396. /**
  34397. * @hidden
  34398. * Defines the actions happening just after the active camera has been drawn.
  34399. */
  34400. _afterCameraDrawStage: Stage<CameraStageAction>;
  34401. /**
  34402. * @hidden
  34403. * Defines the actions happening just after a render target has been drawn.
  34404. */
  34405. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34406. /**
  34407. * @hidden
  34408. * Defines the actions happening just after rendering all cameras and computing intersections.
  34409. */
  34410. _afterRenderStage: Stage<SimpleStageAction>;
  34411. /**
  34412. * @hidden
  34413. * Defines the actions happening when a pointer move event happens.
  34414. */
  34415. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34416. /**
  34417. * @hidden
  34418. * Defines the actions happening when a pointer down event happens.
  34419. */
  34420. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34421. /**
  34422. * @hidden
  34423. * Defines the actions happening when a pointer up event happens.
  34424. */
  34425. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34426. /**
  34427. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34428. */
  34429. private geometriesByUniqueId;
  34430. /**
  34431. * Creates a new Scene
  34432. * @param engine defines the engine to use to render this scene
  34433. * @param options defines the scene options
  34434. */
  34435. constructor(engine: Engine, options?: SceneOptions);
  34436. /**
  34437. * Gets a string idenfifying the name of the class
  34438. * @returns "Scene" string
  34439. */
  34440. getClassName(): string;
  34441. private _defaultMeshCandidates;
  34442. /**
  34443. * @hidden
  34444. */
  34445. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34446. private _defaultSubMeshCandidates;
  34447. /**
  34448. * @hidden
  34449. */
  34450. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34451. /**
  34452. * Sets the default candidate providers for the scene.
  34453. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34454. * and getCollidingSubMeshCandidates to their default function
  34455. */
  34456. setDefaultCandidateProviders(): void;
  34457. /**
  34458. * Gets the mesh that is currently under the pointer
  34459. */
  34460. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34461. /**
  34462. * Gets or sets the current on-screen X position of the pointer
  34463. */
  34464. pointerX: number;
  34465. /**
  34466. * Gets or sets the current on-screen Y position of the pointer
  34467. */
  34468. pointerY: number;
  34469. /**
  34470. * Gets the cached material (ie. the latest rendered one)
  34471. * @returns the cached material
  34472. */
  34473. getCachedMaterial(): Nullable<Material>;
  34474. /**
  34475. * Gets the cached effect (ie. the latest rendered one)
  34476. * @returns the cached effect
  34477. */
  34478. getCachedEffect(): Nullable<Effect>;
  34479. /**
  34480. * Gets the cached visibility state (ie. the latest rendered one)
  34481. * @returns the cached visibility state
  34482. */
  34483. getCachedVisibility(): Nullable<number>;
  34484. /**
  34485. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34486. * @param material defines the current material
  34487. * @param effect defines the current effect
  34488. * @param visibility defines the current visibility state
  34489. * @returns true if one parameter is not cached
  34490. */
  34491. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34492. /**
  34493. * Gets the engine associated with the scene
  34494. * @returns an Engine
  34495. */
  34496. getEngine(): Engine;
  34497. /**
  34498. * Gets the total number of vertices rendered per frame
  34499. * @returns the total number of vertices rendered per frame
  34500. */
  34501. getTotalVertices(): number;
  34502. /**
  34503. * Gets the performance counter for total vertices
  34504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34505. */
  34506. readonly totalVerticesPerfCounter: PerfCounter;
  34507. /**
  34508. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34509. * @returns the total number of active indices rendered per frame
  34510. */
  34511. getActiveIndices(): number;
  34512. /**
  34513. * Gets the performance counter for active indices
  34514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34515. */
  34516. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34517. /**
  34518. * Gets the total number of active particles rendered per frame
  34519. * @returns the total number of active particles rendered per frame
  34520. */
  34521. getActiveParticles(): number;
  34522. /**
  34523. * Gets the performance counter for active particles
  34524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34525. */
  34526. readonly activeParticlesPerfCounter: PerfCounter;
  34527. /**
  34528. * Gets the total number of active bones rendered per frame
  34529. * @returns the total number of active bones rendered per frame
  34530. */
  34531. getActiveBones(): number;
  34532. /**
  34533. * Gets the performance counter for active bones
  34534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34535. */
  34536. readonly activeBonesPerfCounter: PerfCounter;
  34537. /**
  34538. * Gets the array of active meshes
  34539. * @returns an array of AbstractMesh
  34540. */
  34541. getActiveMeshes(): SmartArray<AbstractMesh>;
  34542. /**
  34543. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34544. * @returns a number
  34545. */
  34546. getAnimationRatio(): number;
  34547. /**
  34548. * Gets an unique Id for the current render phase
  34549. * @returns a number
  34550. */
  34551. getRenderId(): number;
  34552. /**
  34553. * Gets an unique Id for the current frame
  34554. * @returns a number
  34555. */
  34556. getFrameId(): number;
  34557. /** Call this function if you want to manually increment the render Id*/
  34558. incrementRenderId(): void;
  34559. private _createUbo;
  34560. /**
  34561. * Use this method to simulate a pointer move on a mesh
  34562. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34563. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34564. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34565. * @returns the current scene
  34566. */
  34567. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34568. /**
  34569. * Use this method to simulate a pointer down on a mesh
  34570. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34571. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34572. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34573. * @returns the current scene
  34574. */
  34575. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34576. /**
  34577. * Use this method to simulate a pointer up on a mesh
  34578. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34579. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34580. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34581. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34582. * @returns the current scene
  34583. */
  34584. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34585. /**
  34586. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34587. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34588. * @returns true if the pointer was captured
  34589. */
  34590. isPointerCaptured(pointerId?: number): boolean;
  34591. /**
  34592. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34593. * @param attachUp defines if you want to attach events to pointerup
  34594. * @param attachDown defines if you want to attach events to pointerdown
  34595. * @param attachMove defines if you want to attach events to pointermove
  34596. */
  34597. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34598. /** Detaches all event handlers*/
  34599. detachControl(): void;
  34600. /**
  34601. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34602. * Delay loaded resources are not taking in account
  34603. * @return true if all required resources are ready
  34604. */
  34605. isReady(): boolean;
  34606. /** Resets all cached information relative to material (including effect and visibility) */
  34607. resetCachedMaterial(): void;
  34608. /**
  34609. * Registers a function to be called before every frame render
  34610. * @param func defines the function to register
  34611. */
  34612. registerBeforeRender(func: () => void): void;
  34613. /**
  34614. * Unregisters a function called before every frame render
  34615. * @param func defines the function to unregister
  34616. */
  34617. unregisterBeforeRender(func: () => void): void;
  34618. /**
  34619. * Registers a function to be called after every frame render
  34620. * @param func defines the function to register
  34621. */
  34622. registerAfterRender(func: () => void): void;
  34623. /**
  34624. * Unregisters a function called after every frame render
  34625. * @param func defines the function to unregister
  34626. */
  34627. unregisterAfterRender(func: () => void): void;
  34628. private _executeOnceBeforeRender;
  34629. /**
  34630. * The provided function will run before render once and will be disposed afterwards.
  34631. * A timeout delay can be provided so that the function will be executed in N ms.
  34632. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34633. * @param func The function to be executed.
  34634. * @param timeout optional delay in ms
  34635. */
  34636. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34637. /** @hidden */
  34638. _addPendingData(data: any): void;
  34639. /** @hidden */
  34640. _removePendingData(data: any): void;
  34641. /**
  34642. * Returns the number of items waiting to be loaded
  34643. * @returns the number of items waiting to be loaded
  34644. */
  34645. getWaitingItemsCount(): number;
  34646. /**
  34647. * Returns a boolean indicating if the scene is still loading data
  34648. */
  34649. readonly isLoading: boolean;
  34650. /**
  34651. * Registers a function to be executed when the scene is ready
  34652. * @param {Function} func - the function to be executed
  34653. */
  34654. executeWhenReady(func: () => void): void;
  34655. /**
  34656. * Returns a promise that resolves when the scene is ready
  34657. * @returns A promise that resolves when the scene is ready
  34658. */
  34659. whenReadyAsync(): Promise<void>;
  34660. /** @hidden */
  34661. _checkIsReady(): void;
  34662. /**
  34663. * Gets all animatable attached to the scene
  34664. */
  34665. readonly animatables: Animatable[];
  34666. /**
  34667. * Resets the last animation time frame.
  34668. * Useful to override when animations start running when loading a scene for the first time.
  34669. */
  34670. resetLastAnimationTimeFrame(): void;
  34671. /**
  34672. * Gets the current view matrix
  34673. * @returns a Matrix
  34674. */
  34675. getViewMatrix(): Matrix;
  34676. /**
  34677. * Gets the current projection matrix
  34678. * @returns a Matrix
  34679. */
  34680. getProjectionMatrix(): Matrix;
  34681. /**
  34682. * Gets the current transform matrix
  34683. * @returns a Matrix made of View * Projection
  34684. */
  34685. getTransformMatrix(): Matrix;
  34686. /**
  34687. * Sets the current transform matrix
  34688. * @param viewL defines the View matrix to use
  34689. * @param projectionL defines the Projection matrix to use
  34690. * @param viewR defines the right View matrix to use (if provided)
  34691. * @param projectionR defines the right Projection matrix to use (if provided)
  34692. */
  34693. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34694. /**
  34695. * Gets the uniform buffer used to store scene data
  34696. * @returns a UniformBuffer
  34697. */
  34698. getSceneUniformBuffer(): UniformBuffer;
  34699. /**
  34700. * Gets an unique (relatively to the current scene) Id
  34701. * @returns an unique number for the scene
  34702. */
  34703. getUniqueId(): number;
  34704. /**
  34705. * Add a mesh to the list of scene's meshes
  34706. * @param newMesh defines the mesh to add
  34707. * @param recursive if all child meshes should also be added to the scene
  34708. */
  34709. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34710. /**
  34711. * Remove a mesh for the list of scene's meshes
  34712. * @param toRemove defines the mesh to remove
  34713. * @param recursive if all child meshes should also be removed from the scene
  34714. * @returns the index where the mesh was in the mesh list
  34715. */
  34716. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34717. /**
  34718. * Add a transform node to the list of scene's transform nodes
  34719. * @param newTransformNode defines the transform node to add
  34720. */
  34721. addTransformNode(newTransformNode: TransformNode): void;
  34722. /**
  34723. * Remove a transform node for the list of scene's transform nodes
  34724. * @param toRemove defines the transform node to remove
  34725. * @returns the index where the transform node was in the transform node list
  34726. */
  34727. removeTransformNode(toRemove: TransformNode): number;
  34728. /**
  34729. * Remove a skeleton for the list of scene's skeletons
  34730. * @param toRemove defines the skeleton to remove
  34731. * @returns the index where the skeleton was in the skeleton list
  34732. */
  34733. removeSkeleton(toRemove: Skeleton): number;
  34734. /**
  34735. * Remove a morph target for the list of scene's morph targets
  34736. * @param toRemove defines the morph target to remove
  34737. * @returns the index where the morph target was in the morph target list
  34738. */
  34739. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34740. /**
  34741. * Remove a light for the list of scene's lights
  34742. * @param toRemove defines the light to remove
  34743. * @returns the index where the light was in the light list
  34744. */
  34745. removeLight(toRemove: Light): number;
  34746. /**
  34747. * Remove a camera for the list of scene's cameras
  34748. * @param toRemove defines the camera to remove
  34749. * @returns the index where the camera was in the camera list
  34750. */
  34751. removeCamera(toRemove: Camera): number;
  34752. /**
  34753. * Remove a particle system for the list of scene's particle systems
  34754. * @param toRemove defines the particle system to remove
  34755. * @returns the index where the particle system was in the particle system list
  34756. */
  34757. removeParticleSystem(toRemove: IParticleSystem): number;
  34758. /**
  34759. * Remove a animation for the list of scene's animations
  34760. * @param toRemove defines the animation to remove
  34761. * @returns the index where the animation was in the animation list
  34762. */
  34763. removeAnimation(toRemove: Animation): number;
  34764. /**
  34765. * Will stop the animation of the given target
  34766. * @param target - the target
  34767. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34768. * @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)
  34769. */
  34770. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34771. /**
  34772. * Removes the given animation group from this scene.
  34773. * @param toRemove The animation group to remove
  34774. * @returns The index of the removed animation group
  34775. */
  34776. removeAnimationGroup(toRemove: AnimationGroup): number;
  34777. /**
  34778. * Removes the given multi-material from this scene.
  34779. * @param toRemove The multi-material to remove
  34780. * @returns The index of the removed multi-material
  34781. */
  34782. removeMultiMaterial(toRemove: MultiMaterial): number;
  34783. /**
  34784. * Removes the given material from this scene.
  34785. * @param toRemove The material to remove
  34786. * @returns The index of the removed material
  34787. */
  34788. removeMaterial(toRemove: Material): number;
  34789. /**
  34790. * Removes the given action manager from this scene.
  34791. * @param toRemove The action manager to remove
  34792. * @returns The index of the removed action manager
  34793. */
  34794. removeActionManager(toRemove: AbstractActionManager): number;
  34795. /**
  34796. * Removes the given texture from this scene.
  34797. * @param toRemove The texture to remove
  34798. * @returns The index of the removed texture
  34799. */
  34800. removeTexture(toRemove: BaseTexture): number;
  34801. /**
  34802. * Adds the given light to this scene
  34803. * @param newLight The light to add
  34804. */
  34805. addLight(newLight: Light): void;
  34806. /**
  34807. * Sorts the list list based on light priorities
  34808. */
  34809. sortLightsByPriority(): void;
  34810. /**
  34811. * Adds the given camera to this scene
  34812. * @param newCamera The camera to add
  34813. */
  34814. addCamera(newCamera: Camera): void;
  34815. /**
  34816. * Adds the given skeleton to this scene
  34817. * @param newSkeleton The skeleton to add
  34818. */
  34819. addSkeleton(newSkeleton: Skeleton): void;
  34820. /**
  34821. * Adds the given particle system to this scene
  34822. * @param newParticleSystem The particle system to add
  34823. */
  34824. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34825. /**
  34826. * Adds the given animation to this scene
  34827. * @param newAnimation The animation to add
  34828. */
  34829. addAnimation(newAnimation: Animation): void;
  34830. /**
  34831. * Adds the given animation group to this scene.
  34832. * @param newAnimationGroup The animation group to add
  34833. */
  34834. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34835. /**
  34836. * Adds the given multi-material to this scene
  34837. * @param newMultiMaterial The multi-material to add
  34838. */
  34839. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34840. /**
  34841. * Adds the given material to this scene
  34842. * @param newMaterial The material to add
  34843. */
  34844. addMaterial(newMaterial: Material): void;
  34845. /**
  34846. * Adds the given morph target to this scene
  34847. * @param newMorphTargetManager The morph target to add
  34848. */
  34849. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34850. /**
  34851. * Adds the given geometry to this scene
  34852. * @param newGeometry The geometry to add
  34853. */
  34854. addGeometry(newGeometry: Geometry): void;
  34855. /**
  34856. * Adds the given action manager to this scene
  34857. * @param newActionManager The action manager to add
  34858. */
  34859. addActionManager(newActionManager: AbstractActionManager): void;
  34860. /**
  34861. * Adds the given texture to this scene.
  34862. * @param newTexture The texture to add
  34863. */
  34864. addTexture(newTexture: BaseTexture): void;
  34865. /**
  34866. * Switch active camera
  34867. * @param newCamera defines the new active camera
  34868. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34869. */
  34870. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34871. /**
  34872. * sets the active camera of the scene using its ID
  34873. * @param id defines the camera's ID
  34874. * @return the new active camera or null if none found.
  34875. */
  34876. setActiveCameraByID(id: string): Nullable<Camera>;
  34877. /**
  34878. * sets the active camera of the scene using its name
  34879. * @param name defines the camera's name
  34880. * @returns the new active camera or null if none found.
  34881. */
  34882. setActiveCameraByName(name: string): Nullable<Camera>;
  34883. /**
  34884. * get an animation group using its name
  34885. * @param name defines the material's name
  34886. * @return the animation group or null if none found.
  34887. */
  34888. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34889. /**
  34890. * Get a material using its unique id
  34891. * @param uniqueId defines the material's unique id
  34892. * @return the material or null if none found.
  34893. */
  34894. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34895. /**
  34896. * get a material using its id
  34897. * @param id defines the material's ID
  34898. * @return the material or null if none found.
  34899. */
  34900. getMaterialByID(id: string): Nullable<Material>;
  34901. /**
  34902. * Gets a the last added material using a given id
  34903. * @param id defines the material's ID
  34904. * @return the last material with the given id or null if none found.
  34905. */
  34906. getLastMaterialByID(id: string): Nullable<Material>;
  34907. /**
  34908. * Gets a material using its name
  34909. * @param name defines the material's name
  34910. * @return the material or null if none found.
  34911. */
  34912. getMaterialByName(name: string): Nullable<Material>;
  34913. /**
  34914. * Get a texture using its unique id
  34915. * @param uniqueId defines the texture's unique id
  34916. * @return the texture or null if none found.
  34917. */
  34918. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34919. /**
  34920. * Gets a camera using its id
  34921. * @param id defines the id to look for
  34922. * @returns the camera or null if not found
  34923. */
  34924. getCameraByID(id: string): Nullable<Camera>;
  34925. /**
  34926. * Gets a camera using its unique id
  34927. * @param uniqueId defines the unique id to look for
  34928. * @returns the camera or null if not found
  34929. */
  34930. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34931. /**
  34932. * Gets a camera using its name
  34933. * @param name defines the camera's name
  34934. * @return the camera or null if none found.
  34935. */
  34936. getCameraByName(name: string): Nullable<Camera>;
  34937. /**
  34938. * Gets a bone using its id
  34939. * @param id defines the bone's id
  34940. * @return the bone or null if not found
  34941. */
  34942. getBoneByID(id: string): Nullable<Bone>;
  34943. /**
  34944. * Gets a bone using its id
  34945. * @param name defines the bone's name
  34946. * @return the bone or null if not found
  34947. */
  34948. getBoneByName(name: string): Nullable<Bone>;
  34949. /**
  34950. * Gets a light node using its name
  34951. * @param name defines the the light's name
  34952. * @return the light or null if none found.
  34953. */
  34954. getLightByName(name: string): Nullable<Light>;
  34955. /**
  34956. * Gets a light node using its id
  34957. * @param id defines the light's id
  34958. * @return the light or null if none found.
  34959. */
  34960. getLightByID(id: string): Nullable<Light>;
  34961. /**
  34962. * Gets a light node using its scene-generated unique ID
  34963. * @param uniqueId defines the light's unique id
  34964. * @return the light or null if none found.
  34965. */
  34966. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34967. /**
  34968. * Gets a particle system by id
  34969. * @param id defines the particle system id
  34970. * @return the corresponding system or null if none found
  34971. */
  34972. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34973. /**
  34974. * Gets a geometry using its ID
  34975. * @param id defines the geometry's id
  34976. * @return the geometry or null if none found.
  34977. */
  34978. getGeometryByID(id: string): Nullable<Geometry>;
  34979. private _getGeometryByUniqueID;
  34980. /**
  34981. * Add a new geometry to this scene
  34982. * @param geometry defines the geometry to be added to the scene.
  34983. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34984. * @return a boolean defining if the geometry was added or not
  34985. */
  34986. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34987. /**
  34988. * Removes an existing geometry
  34989. * @param geometry defines the geometry to be removed from the scene
  34990. * @return a boolean defining if the geometry was removed or not
  34991. */
  34992. removeGeometry(geometry: Geometry): boolean;
  34993. /**
  34994. * Gets the list of geometries attached to the scene
  34995. * @returns an array of Geometry
  34996. */
  34997. getGeometries(): Geometry[];
  34998. /**
  34999. * Gets the first added mesh found of a given ID
  35000. * @param id defines the id to search for
  35001. * @return the mesh found or null if not found at all
  35002. */
  35003. getMeshByID(id: string): Nullable<AbstractMesh>;
  35004. /**
  35005. * Gets a list of meshes using their id
  35006. * @param id defines the id to search for
  35007. * @returns a list of meshes
  35008. */
  35009. getMeshesByID(id: string): Array<AbstractMesh>;
  35010. /**
  35011. * Gets the first added transform node found of a given ID
  35012. * @param id defines the id to search for
  35013. * @return the found transform node or null if not found at all.
  35014. */
  35015. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35016. /**
  35017. * Gets a transform node with its auto-generated unique id
  35018. * @param uniqueId efines the unique id to search for
  35019. * @return the found transform node or null if not found at all.
  35020. */
  35021. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35022. /**
  35023. * Gets a list of transform nodes using their id
  35024. * @param id defines the id to search for
  35025. * @returns a list of transform nodes
  35026. */
  35027. getTransformNodesByID(id: string): Array<TransformNode>;
  35028. /**
  35029. * Gets a mesh with its auto-generated unique id
  35030. * @param uniqueId defines the unique id to search for
  35031. * @return the found mesh or null if not found at all.
  35032. */
  35033. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35034. /**
  35035. * Gets a the last added mesh using a given id
  35036. * @param id defines the id to search for
  35037. * @return the found mesh or null if not found at all.
  35038. */
  35039. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35040. /**
  35041. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35042. * @param id defines the id to search for
  35043. * @return the found node or null if not found at all
  35044. */
  35045. getLastEntryByID(id: string): Nullable<Node>;
  35046. /**
  35047. * Gets a node (Mesh, Camera, Light) using a given id
  35048. * @param id defines the id to search for
  35049. * @return the found node or null if not found at all
  35050. */
  35051. getNodeByID(id: string): Nullable<Node>;
  35052. /**
  35053. * Gets a node (Mesh, Camera, Light) using a given name
  35054. * @param name defines the name to search for
  35055. * @return the found node or null if not found at all.
  35056. */
  35057. getNodeByName(name: string): Nullable<Node>;
  35058. /**
  35059. * Gets a mesh using a given name
  35060. * @param name defines the name to search for
  35061. * @return the found mesh or null if not found at all.
  35062. */
  35063. getMeshByName(name: string): Nullable<AbstractMesh>;
  35064. /**
  35065. * Gets a transform node using a given name
  35066. * @param name defines the name to search for
  35067. * @return the found transform node or null if not found at all.
  35068. */
  35069. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35070. /**
  35071. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35072. * @param id defines the id to search for
  35073. * @return the found skeleton or null if not found at all.
  35074. */
  35075. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35076. /**
  35077. * Gets a skeleton using a given auto generated unique id
  35078. * @param uniqueId defines the unique id to search for
  35079. * @return the found skeleton or null if not found at all.
  35080. */
  35081. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35082. /**
  35083. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35084. * @param id defines the id to search for
  35085. * @return the found skeleton or null if not found at all.
  35086. */
  35087. getSkeletonById(id: string): Nullable<Skeleton>;
  35088. /**
  35089. * Gets a skeleton using a given name
  35090. * @param name defines the name to search for
  35091. * @return the found skeleton or null if not found at all.
  35092. */
  35093. getSkeletonByName(name: string): Nullable<Skeleton>;
  35094. /**
  35095. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35096. * @param id defines the id to search for
  35097. * @return the found morph target manager or null if not found at all.
  35098. */
  35099. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35100. /**
  35101. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35102. * @param id defines the id to search for
  35103. * @return the found morph target or null if not found at all.
  35104. */
  35105. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35106. /**
  35107. * Gets a boolean indicating if the given mesh is active
  35108. * @param mesh defines the mesh to look for
  35109. * @returns true if the mesh is in the active list
  35110. */
  35111. isActiveMesh(mesh: AbstractMesh): boolean;
  35112. /**
  35113. * Return a unique id as a string which can serve as an identifier for the scene
  35114. */
  35115. readonly uid: string;
  35116. /**
  35117. * Add an externaly attached data from its key.
  35118. * This method call will fail and return false, if such key already exists.
  35119. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35120. * @param key the unique key that identifies the data
  35121. * @param data the data object to associate to the key for this Engine instance
  35122. * @return true if no such key were already present and the data was added successfully, false otherwise
  35123. */
  35124. addExternalData<T>(key: string, data: T): boolean;
  35125. /**
  35126. * Get an externaly attached data from its key
  35127. * @param key the unique key that identifies the data
  35128. * @return the associated data, if present (can be null), or undefined if not present
  35129. */
  35130. getExternalData<T>(key: string): Nullable<T>;
  35131. /**
  35132. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35133. * @param key the unique key that identifies the data
  35134. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35135. * @return the associated data, can be null if the factory returned null.
  35136. */
  35137. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35138. /**
  35139. * Remove an externaly attached data from the Engine instance
  35140. * @param key the unique key that identifies the data
  35141. * @return true if the data was successfully removed, false if it doesn't exist
  35142. */
  35143. removeExternalData(key: string): boolean;
  35144. private _evaluateSubMesh;
  35145. /**
  35146. * Clear the processed materials smart array preventing retention point in material dispose.
  35147. */
  35148. freeProcessedMaterials(): void;
  35149. private _preventFreeActiveMeshesAndRenderingGroups;
  35150. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35151. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35152. * when disposing several meshes in a row or a hierarchy of meshes.
  35153. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35154. */
  35155. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35156. /**
  35157. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35158. */
  35159. freeActiveMeshes(): void;
  35160. /**
  35161. * Clear the info related to rendering groups preventing retention points during dispose.
  35162. */
  35163. freeRenderingGroups(): void;
  35164. /** @hidden */
  35165. _isInIntermediateRendering(): boolean;
  35166. /**
  35167. * Lambda returning the list of potentially active meshes.
  35168. */
  35169. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35170. /**
  35171. * Lambda returning the list of potentially active sub meshes.
  35172. */
  35173. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35174. /**
  35175. * Lambda returning the list of potentially intersecting sub meshes.
  35176. */
  35177. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35178. /**
  35179. * Lambda returning the list of potentially colliding sub meshes.
  35180. */
  35181. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35182. private _activeMeshesFrozen;
  35183. /**
  35184. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35185. * @returns the current scene
  35186. */
  35187. freezeActiveMeshes(): Scene;
  35188. /**
  35189. * Use this function to restart evaluating active meshes on every frame
  35190. * @returns the current scene
  35191. */
  35192. unfreezeActiveMeshes(): Scene;
  35193. private _evaluateActiveMeshes;
  35194. private _activeMesh;
  35195. /**
  35196. * Update the transform matrix to update from the current active camera
  35197. * @param force defines a boolean used to force the update even if cache is up to date
  35198. */
  35199. updateTransformMatrix(force?: boolean): void;
  35200. private _bindFrameBuffer;
  35201. /** @hidden */
  35202. _allowPostProcessClearColor: boolean;
  35203. /** @hidden */
  35204. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35205. private _processSubCameras;
  35206. private _checkIntersections;
  35207. /** @hidden */
  35208. _advancePhysicsEngineStep(step: number): void;
  35209. /**
  35210. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35211. */
  35212. getDeterministicFrameTime: () => number;
  35213. /** @hidden */
  35214. _animate(): void;
  35215. /** Execute all animations (for a frame) */
  35216. animate(): void;
  35217. /**
  35218. * Render the scene
  35219. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35220. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35221. */
  35222. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35223. /**
  35224. * Freeze all materials
  35225. * A frozen material will not be updatable but should be faster to render
  35226. */
  35227. freezeMaterials(): void;
  35228. /**
  35229. * Unfreeze all materials
  35230. * A frozen material will not be updatable but should be faster to render
  35231. */
  35232. unfreezeMaterials(): void;
  35233. /**
  35234. * Releases all held ressources
  35235. */
  35236. dispose(): void;
  35237. /**
  35238. * Gets if the scene is already disposed
  35239. */
  35240. readonly isDisposed: boolean;
  35241. /**
  35242. * Call this function to reduce memory footprint of the scene.
  35243. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35244. */
  35245. clearCachedVertexData(): void;
  35246. /**
  35247. * This function will remove the local cached buffer data from texture.
  35248. * It will save memory but will prevent the texture from being rebuilt
  35249. */
  35250. cleanCachedTextureBuffer(): void;
  35251. /**
  35252. * Get the world extend vectors with an optional filter
  35253. *
  35254. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35255. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35256. */
  35257. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35258. min: Vector3;
  35259. max: Vector3;
  35260. };
  35261. /**
  35262. * Creates a ray that can be used to pick in the scene
  35263. * @param x defines the x coordinate of the origin (on-screen)
  35264. * @param y defines the y coordinate of the origin (on-screen)
  35265. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35266. * @param camera defines the camera to use for the picking
  35267. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35268. * @returns a Ray
  35269. */
  35270. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35271. /**
  35272. * Creates a ray that can be used to pick in the scene
  35273. * @param x defines the x coordinate of the origin (on-screen)
  35274. * @param y defines the y coordinate of the origin (on-screen)
  35275. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35276. * @param result defines the ray where to store the picking ray
  35277. * @param camera defines the camera to use for the picking
  35278. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35279. * @returns the current scene
  35280. */
  35281. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35282. /**
  35283. * Creates a ray that can be used to pick in the scene
  35284. * @param x defines the x coordinate of the origin (on-screen)
  35285. * @param y defines the y coordinate of the origin (on-screen)
  35286. * @param camera defines the camera to use for the picking
  35287. * @returns a Ray
  35288. */
  35289. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35290. /**
  35291. * Creates a ray that can be used to pick in the scene
  35292. * @param x defines the x coordinate of the origin (on-screen)
  35293. * @param y defines the y coordinate of the origin (on-screen)
  35294. * @param result defines the ray where to store the picking ray
  35295. * @param camera defines the camera to use for the picking
  35296. * @returns the current scene
  35297. */
  35298. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35299. /** Launch a ray to try to pick a mesh in the scene
  35300. * @param x position on screen
  35301. * @param y position on screen
  35302. * @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
  35303. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35304. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35305. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35306. * @returns a PickingInfo
  35307. */
  35308. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35309. /** Use the given ray to pick a mesh in the scene
  35310. * @param ray The ray to use to pick meshes
  35311. * @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
  35312. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35313. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35314. * @returns a PickingInfo
  35315. */
  35316. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35317. /**
  35318. * Launch a ray to try to pick a mesh in the scene
  35319. * @param x X position on screen
  35320. * @param y Y position on screen
  35321. * @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
  35322. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35323. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35324. * @returns an array of PickingInfo
  35325. */
  35326. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35327. /**
  35328. * Launch a ray to try to pick a mesh in the scene
  35329. * @param ray Ray to use
  35330. * @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
  35331. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35332. * @returns an array of PickingInfo
  35333. */
  35334. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35335. /**
  35336. * Force the value of meshUnderPointer
  35337. * @param mesh defines the mesh to use
  35338. */
  35339. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35340. /**
  35341. * Gets the mesh under the pointer
  35342. * @returns a Mesh or null if no mesh is under the pointer
  35343. */
  35344. getPointerOverMesh(): Nullable<AbstractMesh>;
  35345. /** @hidden */
  35346. _rebuildGeometries(): void;
  35347. /** @hidden */
  35348. _rebuildTextures(): void;
  35349. private _getByTags;
  35350. /**
  35351. * Get a list of meshes by tags
  35352. * @param tagsQuery defines the tags query to use
  35353. * @param forEach defines a predicate used to filter results
  35354. * @returns an array of Mesh
  35355. */
  35356. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35357. /**
  35358. * Get a list of cameras by tags
  35359. * @param tagsQuery defines the tags query to use
  35360. * @param forEach defines a predicate used to filter results
  35361. * @returns an array of Camera
  35362. */
  35363. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35364. /**
  35365. * Get a list of lights by tags
  35366. * @param tagsQuery defines the tags query to use
  35367. * @param forEach defines a predicate used to filter results
  35368. * @returns an array of Light
  35369. */
  35370. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35371. /**
  35372. * Get a list of materials by tags
  35373. * @param tagsQuery defines the tags query to use
  35374. * @param forEach defines a predicate used to filter results
  35375. * @returns an array of Material
  35376. */
  35377. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35378. /**
  35379. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35380. * This allowed control for front to back rendering or reversly depending of the special needs.
  35381. *
  35382. * @param renderingGroupId The rendering group id corresponding to its index
  35383. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35384. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35385. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35386. */
  35387. 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;
  35388. /**
  35389. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35390. *
  35391. * @param renderingGroupId The rendering group id corresponding to its index
  35392. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35393. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35394. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35395. */
  35396. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35397. /**
  35398. * Gets the current auto clear configuration for one rendering group of the rendering
  35399. * manager.
  35400. * @param index the rendering group index to get the information for
  35401. * @returns The auto clear setup for the requested rendering group
  35402. */
  35403. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35404. private _blockMaterialDirtyMechanism;
  35405. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35406. blockMaterialDirtyMechanism: boolean;
  35407. /**
  35408. * Will flag all materials as dirty to trigger new shader compilation
  35409. * @param flag defines the flag used to specify which material part must be marked as dirty
  35410. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35411. */
  35412. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35413. /** @hidden */
  35414. _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;
  35415. /** @hidden */
  35416. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35417. }
  35418. }
  35419. declare module "babylonjs/assetContainer" {
  35420. import { AbstractScene } from "babylonjs/abstractScene";
  35421. import { Scene } from "babylonjs/scene";
  35422. import { Mesh } from "babylonjs/Meshes/mesh";
  35423. /**
  35424. * Set of assets to keep when moving a scene into an asset container.
  35425. */
  35426. export class KeepAssets extends AbstractScene {
  35427. }
  35428. /**
  35429. * Container with a set of assets that can be added or removed from a scene.
  35430. */
  35431. export class AssetContainer extends AbstractScene {
  35432. /**
  35433. * The scene the AssetContainer belongs to.
  35434. */
  35435. scene: Scene;
  35436. /**
  35437. * Instantiates an AssetContainer.
  35438. * @param scene The scene the AssetContainer belongs to.
  35439. */
  35440. constructor(scene: Scene);
  35441. /**
  35442. * Adds all the assets from the container to the scene.
  35443. */
  35444. addAllToScene(): void;
  35445. /**
  35446. * Removes all the assets in the container from the scene
  35447. */
  35448. removeAllFromScene(): void;
  35449. /**
  35450. * Disposes all the assets in the container
  35451. */
  35452. dispose(): void;
  35453. private _moveAssets;
  35454. /**
  35455. * Removes all the assets contained in the scene and adds them to the container.
  35456. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35457. */
  35458. moveAllFromScene(keepAssets?: KeepAssets): void;
  35459. /**
  35460. * 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.
  35461. * @returns the root mesh
  35462. */
  35463. createRootMesh(): Mesh;
  35464. }
  35465. }
  35466. declare module "babylonjs/abstractScene" {
  35467. import { Scene } from "babylonjs/scene";
  35468. import { Nullable } from "babylonjs/types";
  35469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35470. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35471. import { Geometry } from "babylonjs/Meshes/geometry";
  35472. import { Skeleton } from "babylonjs/Bones/skeleton";
  35473. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35474. import { AssetContainer } from "babylonjs/assetContainer";
  35475. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35476. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35477. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35478. import { Material } from "babylonjs/Materials/material";
  35479. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35480. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35481. import { Camera } from "babylonjs/Cameras/camera";
  35482. import { Light } from "babylonjs/Lights/light";
  35483. import { Node } from "babylonjs/node";
  35484. import { Animation } from "babylonjs/Animations/animation";
  35485. /**
  35486. * Defines how the parser contract is defined.
  35487. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35488. */
  35489. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35490. /**
  35491. * Defines how the individual parser contract is defined.
  35492. * These parser can parse an individual asset
  35493. */
  35494. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35495. /**
  35496. * Base class of the scene acting as a container for the different elements composing a scene.
  35497. * This class is dynamically extended by the different components of the scene increasing
  35498. * flexibility and reducing coupling
  35499. */
  35500. export abstract class AbstractScene {
  35501. /**
  35502. * Stores the list of available parsers in the application.
  35503. */
  35504. private static _BabylonFileParsers;
  35505. /**
  35506. * Stores the list of available individual parsers in the application.
  35507. */
  35508. private static _IndividualBabylonFileParsers;
  35509. /**
  35510. * Adds a parser in the list of available ones
  35511. * @param name Defines the name of the parser
  35512. * @param parser Defines the parser to add
  35513. */
  35514. static AddParser(name: string, parser: BabylonFileParser): void;
  35515. /**
  35516. * Gets a general parser from the list of avaialble ones
  35517. * @param name Defines the name of the parser
  35518. * @returns the requested parser or null
  35519. */
  35520. static GetParser(name: string): Nullable<BabylonFileParser>;
  35521. /**
  35522. * Adds n individual parser in the list of available ones
  35523. * @param name Defines the name of the parser
  35524. * @param parser Defines the parser to add
  35525. */
  35526. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35527. /**
  35528. * Gets an individual parser from the list of avaialble ones
  35529. * @param name Defines the name of the parser
  35530. * @returns the requested parser or null
  35531. */
  35532. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35533. /**
  35534. * Parser json data and populate both a scene and its associated container object
  35535. * @param jsonData Defines the data to parse
  35536. * @param scene Defines the scene to parse the data for
  35537. * @param container Defines the container attached to the parsing sequence
  35538. * @param rootUrl Defines the root url of the data
  35539. */
  35540. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35541. /**
  35542. * Gets the list of root nodes (ie. nodes with no parent)
  35543. */
  35544. rootNodes: Node[];
  35545. /** All of the cameras added to this scene
  35546. * @see http://doc.babylonjs.com/babylon101/cameras
  35547. */
  35548. cameras: Camera[];
  35549. /**
  35550. * All of the lights added to this scene
  35551. * @see http://doc.babylonjs.com/babylon101/lights
  35552. */
  35553. lights: Light[];
  35554. /**
  35555. * All of the (abstract) meshes added to this scene
  35556. */
  35557. meshes: AbstractMesh[];
  35558. /**
  35559. * The list of skeletons added to the scene
  35560. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35561. */
  35562. skeletons: Skeleton[];
  35563. /**
  35564. * All of the particle systems added to this scene
  35565. * @see http://doc.babylonjs.com/babylon101/particles
  35566. */
  35567. particleSystems: IParticleSystem[];
  35568. /**
  35569. * Gets a list of Animations associated with the scene
  35570. */
  35571. animations: Animation[];
  35572. /**
  35573. * All of the animation groups added to this scene
  35574. * @see http://doc.babylonjs.com/how_to/group
  35575. */
  35576. animationGroups: AnimationGroup[];
  35577. /**
  35578. * All of the multi-materials added to this scene
  35579. * @see http://doc.babylonjs.com/how_to/multi_materials
  35580. */
  35581. multiMaterials: MultiMaterial[];
  35582. /**
  35583. * All of the materials added to this scene
  35584. * In the context of a Scene, it is not supposed to be modified manually.
  35585. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35586. * Note also that the order of the Material wihin the array is not significant and might change.
  35587. * @see http://doc.babylonjs.com/babylon101/materials
  35588. */
  35589. materials: Material[];
  35590. /**
  35591. * The list of morph target managers added to the scene
  35592. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35593. */
  35594. morphTargetManagers: MorphTargetManager[];
  35595. /**
  35596. * The list of geometries used in the scene.
  35597. */
  35598. geometries: Geometry[];
  35599. /**
  35600. * All of the tranform nodes added to this scene
  35601. * In the context of a Scene, it is not supposed to be modified manually.
  35602. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35603. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35604. * @see http://doc.babylonjs.com/how_to/transformnode
  35605. */
  35606. transformNodes: TransformNode[];
  35607. /**
  35608. * ActionManagers available on the scene.
  35609. */
  35610. actionManagers: AbstractActionManager[];
  35611. /**
  35612. * Textures to keep.
  35613. */
  35614. textures: BaseTexture[];
  35615. /**
  35616. * Environment texture for the scene
  35617. */
  35618. environmentTexture: Nullable<BaseTexture>;
  35619. }
  35620. }
  35621. declare module "babylonjs/Audio/sound" {
  35622. import { Observable } from "babylonjs/Misc/observable";
  35623. import { Vector3 } from "babylonjs/Maths/math.vector";
  35624. import { Nullable } from "babylonjs/types";
  35625. import { Scene } from "babylonjs/scene";
  35626. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35627. /**
  35628. * Interface used to define options for Sound class
  35629. */
  35630. export interface ISoundOptions {
  35631. /**
  35632. * Does the sound autoplay once loaded.
  35633. */
  35634. autoplay?: boolean;
  35635. /**
  35636. * Does the sound loop after it finishes playing once.
  35637. */
  35638. loop?: boolean;
  35639. /**
  35640. * Sound's volume
  35641. */
  35642. volume?: number;
  35643. /**
  35644. * Is it a spatial sound?
  35645. */
  35646. spatialSound?: boolean;
  35647. /**
  35648. * Maximum distance to hear that sound
  35649. */
  35650. maxDistance?: number;
  35651. /**
  35652. * Uses user defined attenuation function
  35653. */
  35654. useCustomAttenuation?: boolean;
  35655. /**
  35656. * Define the roll off factor of spatial sounds.
  35657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35658. */
  35659. rolloffFactor?: number;
  35660. /**
  35661. * Define the reference distance the sound should be heard perfectly.
  35662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35663. */
  35664. refDistance?: number;
  35665. /**
  35666. * Define the distance attenuation model the sound will follow.
  35667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35668. */
  35669. distanceModel?: string;
  35670. /**
  35671. * Defines the playback speed (1 by default)
  35672. */
  35673. playbackRate?: number;
  35674. /**
  35675. * Defines if the sound is from a streaming source
  35676. */
  35677. streaming?: boolean;
  35678. /**
  35679. * Defines an optional length (in seconds) inside the sound file
  35680. */
  35681. length?: number;
  35682. /**
  35683. * Defines an optional offset (in seconds) inside the sound file
  35684. */
  35685. offset?: number;
  35686. /**
  35687. * If true, URLs will not be required to state the audio file codec to use.
  35688. */
  35689. skipCodecCheck?: boolean;
  35690. }
  35691. /**
  35692. * Defines a sound that can be played in the application.
  35693. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35695. */
  35696. export class Sound {
  35697. /**
  35698. * The name of the sound in the scene.
  35699. */
  35700. name: string;
  35701. /**
  35702. * Does the sound autoplay once loaded.
  35703. */
  35704. autoplay: boolean;
  35705. /**
  35706. * Does the sound loop after it finishes playing once.
  35707. */
  35708. loop: boolean;
  35709. /**
  35710. * Does the sound use a custom attenuation curve to simulate the falloff
  35711. * happening when the source gets further away from the camera.
  35712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35713. */
  35714. useCustomAttenuation: boolean;
  35715. /**
  35716. * The sound track id this sound belongs to.
  35717. */
  35718. soundTrackId: number;
  35719. /**
  35720. * Is this sound currently played.
  35721. */
  35722. isPlaying: boolean;
  35723. /**
  35724. * Is this sound currently paused.
  35725. */
  35726. isPaused: boolean;
  35727. /**
  35728. * Does this sound enables spatial sound.
  35729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35730. */
  35731. spatialSound: boolean;
  35732. /**
  35733. * Define the reference distance the sound should be heard perfectly.
  35734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35735. */
  35736. refDistance: number;
  35737. /**
  35738. * Define the roll off factor of spatial sounds.
  35739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35740. */
  35741. rolloffFactor: number;
  35742. /**
  35743. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35745. */
  35746. maxDistance: number;
  35747. /**
  35748. * Define the distance attenuation model the sound will follow.
  35749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35750. */
  35751. distanceModel: string;
  35752. /**
  35753. * @hidden
  35754. * Back Compat
  35755. **/
  35756. onended: () => any;
  35757. /**
  35758. * Observable event when the current playing sound finishes.
  35759. */
  35760. onEndedObservable: Observable<Sound>;
  35761. private _panningModel;
  35762. private _playbackRate;
  35763. private _streaming;
  35764. private _startTime;
  35765. private _startOffset;
  35766. private _position;
  35767. /** @hidden */
  35768. _positionInEmitterSpace: boolean;
  35769. private _localDirection;
  35770. private _volume;
  35771. private _isReadyToPlay;
  35772. private _isDirectional;
  35773. private _readyToPlayCallback;
  35774. private _audioBuffer;
  35775. private _soundSource;
  35776. private _streamingSource;
  35777. private _soundPanner;
  35778. private _soundGain;
  35779. private _inputAudioNode;
  35780. private _outputAudioNode;
  35781. private _coneInnerAngle;
  35782. private _coneOuterAngle;
  35783. private _coneOuterGain;
  35784. private _scene;
  35785. private _connectedTransformNode;
  35786. private _customAttenuationFunction;
  35787. private _registerFunc;
  35788. private _isOutputConnected;
  35789. private _htmlAudioElement;
  35790. private _urlType;
  35791. private _length?;
  35792. private _offset?;
  35793. /** @hidden */
  35794. static _SceneComponentInitialization: (scene: Scene) => void;
  35795. /**
  35796. * Create a sound and attach it to a scene
  35797. * @param name Name of your sound
  35798. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35799. * @param scene defines the scene the sound belongs to
  35800. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35801. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35802. */
  35803. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35804. /**
  35805. * Release the sound and its associated resources
  35806. */
  35807. dispose(): void;
  35808. /**
  35809. * Gets if the sounds is ready to be played or not.
  35810. * @returns true if ready, otherwise false
  35811. */
  35812. isReady(): boolean;
  35813. private _soundLoaded;
  35814. /**
  35815. * Sets the data of the sound from an audiobuffer
  35816. * @param audioBuffer The audioBuffer containing the data
  35817. */
  35818. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35819. /**
  35820. * Updates the current sounds options such as maxdistance, loop...
  35821. * @param options A JSON object containing values named as the object properties
  35822. */
  35823. updateOptions(options: ISoundOptions): void;
  35824. private _createSpatialParameters;
  35825. private _updateSpatialParameters;
  35826. /**
  35827. * Switch the panning model to HRTF:
  35828. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35830. */
  35831. switchPanningModelToHRTF(): void;
  35832. /**
  35833. * Switch the panning model to Equal Power:
  35834. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35836. */
  35837. switchPanningModelToEqualPower(): void;
  35838. private _switchPanningModel;
  35839. /**
  35840. * Connect this sound to a sound track audio node like gain...
  35841. * @param soundTrackAudioNode the sound track audio node to connect to
  35842. */
  35843. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35844. /**
  35845. * Transform this sound into a directional source
  35846. * @param coneInnerAngle Size of the inner cone in degree
  35847. * @param coneOuterAngle Size of the outer cone in degree
  35848. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35849. */
  35850. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35851. /**
  35852. * Gets or sets the inner angle for the directional cone.
  35853. */
  35854. /**
  35855. * Gets or sets the inner angle for the directional cone.
  35856. */
  35857. directionalConeInnerAngle: number;
  35858. /**
  35859. * Gets or sets the outer angle for the directional cone.
  35860. */
  35861. /**
  35862. * Gets or sets the outer angle for the directional cone.
  35863. */
  35864. directionalConeOuterAngle: number;
  35865. /**
  35866. * Sets the position of the emitter if spatial sound is enabled
  35867. * @param newPosition Defines the new posisiton
  35868. */
  35869. setPosition(newPosition: Vector3): void;
  35870. /**
  35871. * Sets the local direction of the emitter if spatial sound is enabled
  35872. * @param newLocalDirection Defines the new local direction
  35873. */
  35874. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35875. private _updateDirection;
  35876. /** @hidden */
  35877. updateDistanceFromListener(): void;
  35878. /**
  35879. * Sets a new custom attenuation function for the sound.
  35880. * @param callback Defines the function used for the attenuation
  35881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35882. */
  35883. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35884. /**
  35885. * Play the sound
  35886. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35887. * @param offset (optional) Start the sound at a specific time in seconds
  35888. * @param length (optional) Sound duration (in seconds)
  35889. */
  35890. play(time?: number, offset?: number, length?: number): void;
  35891. private _onended;
  35892. /**
  35893. * Stop the sound
  35894. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35895. */
  35896. stop(time?: number): void;
  35897. /**
  35898. * Put the sound in pause
  35899. */
  35900. pause(): void;
  35901. /**
  35902. * Sets a dedicated volume for this sounds
  35903. * @param newVolume Define the new volume of the sound
  35904. * @param time Define time for gradual change to new volume
  35905. */
  35906. setVolume(newVolume: number, time?: number): void;
  35907. /**
  35908. * Set the sound play back rate
  35909. * @param newPlaybackRate Define the playback rate the sound should be played at
  35910. */
  35911. setPlaybackRate(newPlaybackRate: number): void;
  35912. /**
  35913. * Gets the volume of the sound.
  35914. * @returns the volume of the sound
  35915. */
  35916. getVolume(): number;
  35917. /**
  35918. * Attach the sound to a dedicated mesh
  35919. * @param transformNode The transform node to connect the sound with
  35920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35921. */
  35922. attachToMesh(transformNode: TransformNode): void;
  35923. /**
  35924. * Detach the sound from the previously attached mesh
  35925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35926. */
  35927. detachFromMesh(): void;
  35928. private _onRegisterAfterWorldMatrixUpdate;
  35929. /**
  35930. * Clone the current sound in the scene.
  35931. * @returns the new sound clone
  35932. */
  35933. clone(): Nullable<Sound>;
  35934. /**
  35935. * Gets the current underlying audio buffer containing the data
  35936. * @returns the audio buffer
  35937. */
  35938. getAudioBuffer(): Nullable<AudioBuffer>;
  35939. /**
  35940. * Serializes the Sound in a JSON representation
  35941. * @returns the JSON representation of the sound
  35942. */
  35943. serialize(): any;
  35944. /**
  35945. * Parse a JSON representation of a sound to innstantiate in a given scene
  35946. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35947. * @param scene Define the scene the new parsed sound should be created in
  35948. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35949. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35950. * @returns the newly parsed sound
  35951. */
  35952. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35953. }
  35954. }
  35955. declare module "babylonjs/Actions/directAudioActions" {
  35956. import { Action } from "babylonjs/Actions/action";
  35957. import { Condition } from "babylonjs/Actions/condition";
  35958. import { Sound } from "babylonjs/Audio/sound";
  35959. /**
  35960. * This defines an action helpful to play a defined sound on a triggered action.
  35961. */
  35962. export class PlaySoundAction extends Action {
  35963. private _sound;
  35964. /**
  35965. * Instantiate the action
  35966. * @param triggerOptions defines the trigger options
  35967. * @param sound defines the sound to play
  35968. * @param condition defines the trigger related conditions
  35969. */
  35970. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35971. /** @hidden */
  35972. _prepare(): void;
  35973. /**
  35974. * Execute the action and play the sound.
  35975. */
  35976. execute(): void;
  35977. /**
  35978. * Serializes the actions and its related information.
  35979. * @param parent defines the object to serialize in
  35980. * @returns the serialized object
  35981. */
  35982. serialize(parent: any): any;
  35983. }
  35984. /**
  35985. * This defines an action helpful to stop a defined sound on a triggered action.
  35986. */
  35987. export class StopSoundAction extends Action {
  35988. private _sound;
  35989. /**
  35990. * Instantiate the action
  35991. * @param triggerOptions defines the trigger options
  35992. * @param sound defines the sound to stop
  35993. * @param condition defines the trigger related conditions
  35994. */
  35995. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35996. /** @hidden */
  35997. _prepare(): void;
  35998. /**
  35999. * Execute the action and stop the sound.
  36000. */
  36001. execute(): void;
  36002. /**
  36003. * Serializes the actions and its related information.
  36004. * @param parent defines the object to serialize in
  36005. * @returns the serialized object
  36006. */
  36007. serialize(parent: any): any;
  36008. }
  36009. }
  36010. declare module "babylonjs/Actions/interpolateValueAction" {
  36011. import { Action } from "babylonjs/Actions/action";
  36012. import { Condition } from "babylonjs/Actions/condition";
  36013. import { Observable } from "babylonjs/Misc/observable";
  36014. /**
  36015. * This defines an action responsible to change the value of a property
  36016. * by interpolating between its current value and the newly set one once triggered.
  36017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36018. */
  36019. export class InterpolateValueAction extends Action {
  36020. /**
  36021. * Defines the path of the property where the value should be interpolated
  36022. */
  36023. propertyPath: string;
  36024. /**
  36025. * Defines the target value at the end of the interpolation.
  36026. */
  36027. value: any;
  36028. /**
  36029. * Defines the time it will take for the property to interpolate to the value.
  36030. */
  36031. duration: number;
  36032. /**
  36033. * Defines if the other scene animations should be stopped when the action has been triggered
  36034. */
  36035. stopOtherAnimations?: boolean;
  36036. /**
  36037. * Defines a callback raised once the interpolation animation has been done.
  36038. */
  36039. onInterpolationDone?: () => void;
  36040. /**
  36041. * Observable triggered once the interpolation animation has been done.
  36042. */
  36043. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36044. private _target;
  36045. private _effectiveTarget;
  36046. private _property;
  36047. /**
  36048. * Instantiate the action
  36049. * @param triggerOptions defines the trigger options
  36050. * @param target defines the object containing the value to interpolate
  36051. * @param propertyPath defines the path to the property in the target object
  36052. * @param value defines the target value at the end of the interpolation
  36053. * @param duration deines the time it will take for the property to interpolate to the value.
  36054. * @param condition defines the trigger related conditions
  36055. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36056. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36057. */
  36058. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36059. /** @hidden */
  36060. _prepare(): void;
  36061. /**
  36062. * Execute the action starts the value interpolation.
  36063. */
  36064. execute(): void;
  36065. /**
  36066. * Serializes the actions and its related information.
  36067. * @param parent defines the object to serialize in
  36068. * @returns the serialized object
  36069. */
  36070. serialize(parent: any): any;
  36071. }
  36072. }
  36073. declare module "babylonjs/Actions/index" {
  36074. export * from "babylonjs/Actions/abstractActionManager";
  36075. export * from "babylonjs/Actions/action";
  36076. export * from "babylonjs/Actions/actionEvent";
  36077. export * from "babylonjs/Actions/actionManager";
  36078. export * from "babylonjs/Actions/condition";
  36079. export * from "babylonjs/Actions/directActions";
  36080. export * from "babylonjs/Actions/directAudioActions";
  36081. export * from "babylonjs/Actions/interpolateValueAction";
  36082. }
  36083. declare module "babylonjs/Animations/index" {
  36084. export * from "babylonjs/Animations/animatable";
  36085. export * from "babylonjs/Animations/animation";
  36086. export * from "babylonjs/Animations/animationGroup";
  36087. export * from "babylonjs/Animations/animationPropertiesOverride";
  36088. export * from "babylonjs/Animations/easing";
  36089. export * from "babylonjs/Animations/runtimeAnimation";
  36090. export * from "babylonjs/Animations/animationEvent";
  36091. export * from "babylonjs/Animations/animationGroup";
  36092. export * from "babylonjs/Animations/animationKey";
  36093. export * from "babylonjs/Animations/animationRange";
  36094. export * from "babylonjs/Animations/animatable.interface";
  36095. }
  36096. declare module "babylonjs/Audio/soundTrack" {
  36097. import { Sound } from "babylonjs/Audio/sound";
  36098. import { Analyser } from "babylonjs/Audio/analyser";
  36099. import { Scene } from "babylonjs/scene";
  36100. /**
  36101. * Options allowed during the creation of a sound track.
  36102. */
  36103. export interface ISoundTrackOptions {
  36104. /**
  36105. * The volume the sound track should take during creation
  36106. */
  36107. volume?: number;
  36108. /**
  36109. * Define if the sound track is the main sound track of the scene
  36110. */
  36111. mainTrack?: boolean;
  36112. }
  36113. /**
  36114. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36115. * It will be also used in a future release to apply effects on a specific track.
  36116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36117. */
  36118. export class SoundTrack {
  36119. /**
  36120. * The unique identifier of the sound track in the scene.
  36121. */
  36122. id: number;
  36123. /**
  36124. * The list of sounds included in the sound track.
  36125. */
  36126. soundCollection: Array<Sound>;
  36127. private _outputAudioNode;
  36128. private _scene;
  36129. private _isMainTrack;
  36130. private _connectedAnalyser;
  36131. private _options;
  36132. private _isInitialized;
  36133. /**
  36134. * Creates a new sound track.
  36135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36136. * @param scene Define the scene the sound track belongs to
  36137. * @param options
  36138. */
  36139. constructor(scene: Scene, options?: ISoundTrackOptions);
  36140. private _initializeSoundTrackAudioGraph;
  36141. /**
  36142. * Release the sound track and its associated resources
  36143. */
  36144. dispose(): void;
  36145. /**
  36146. * Adds a sound to this sound track
  36147. * @param sound define the cound to add
  36148. * @ignoreNaming
  36149. */
  36150. AddSound(sound: Sound): void;
  36151. /**
  36152. * Removes a sound to this sound track
  36153. * @param sound define the cound to remove
  36154. * @ignoreNaming
  36155. */
  36156. RemoveSound(sound: Sound): void;
  36157. /**
  36158. * Set a global volume for the full sound track.
  36159. * @param newVolume Define the new volume of the sound track
  36160. */
  36161. setVolume(newVolume: number): void;
  36162. /**
  36163. * Switch the panning model to HRTF:
  36164. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36166. */
  36167. switchPanningModelToHRTF(): void;
  36168. /**
  36169. * Switch the panning model to Equal Power:
  36170. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36172. */
  36173. switchPanningModelToEqualPower(): void;
  36174. /**
  36175. * Connect the sound track to an audio analyser allowing some amazing
  36176. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36178. * @param analyser The analyser to connect to the engine
  36179. */
  36180. connectToAnalyser(analyser: Analyser): void;
  36181. }
  36182. }
  36183. declare module "babylonjs/Audio/audioSceneComponent" {
  36184. import { Sound } from "babylonjs/Audio/sound";
  36185. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36186. import { Nullable } from "babylonjs/types";
  36187. import { Vector3 } from "babylonjs/Maths/math.vector";
  36188. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36189. import { Scene } from "babylonjs/scene";
  36190. import { AbstractScene } from "babylonjs/abstractScene";
  36191. import "babylonjs/Audio/audioEngine";
  36192. module "babylonjs/abstractScene" {
  36193. interface AbstractScene {
  36194. /**
  36195. * The list of sounds used in the scene.
  36196. */
  36197. sounds: Nullable<Array<Sound>>;
  36198. }
  36199. }
  36200. module "babylonjs/scene" {
  36201. interface Scene {
  36202. /**
  36203. * @hidden
  36204. * Backing field
  36205. */
  36206. _mainSoundTrack: SoundTrack;
  36207. /**
  36208. * The main sound track played by the scene.
  36209. * It cotains your primary collection of sounds.
  36210. */
  36211. mainSoundTrack: SoundTrack;
  36212. /**
  36213. * The list of sound tracks added to the scene
  36214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36215. */
  36216. soundTracks: Nullable<Array<SoundTrack>>;
  36217. /**
  36218. * Gets a sound using a given name
  36219. * @param name defines the name to search for
  36220. * @return the found sound or null if not found at all.
  36221. */
  36222. getSoundByName(name: string): Nullable<Sound>;
  36223. /**
  36224. * Gets or sets if audio support is enabled
  36225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36226. */
  36227. audioEnabled: boolean;
  36228. /**
  36229. * Gets or sets if audio will be output to headphones
  36230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36231. */
  36232. headphone: boolean;
  36233. /**
  36234. * Gets or sets custom audio listener position provider
  36235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36236. */
  36237. audioListenerPositionProvider: Nullable<() => Vector3>;
  36238. }
  36239. }
  36240. /**
  36241. * Defines the sound scene component responsible to manage any sounds
  36242. * in a given scene.
  36243. */
  36244. export class AudioSceneComponent implements ISceneSerializableComponent {
  36245. /**
  36246. * The component name helpfull to identify the component in the list of scene components.
  36247. */
  36248. readonly name: string;
  36249. /**
  36250. * The scene the component belongs to.
  36251. */
  36252. scene: Scene;
  36253. private _audioEnabled;
  36254. /**
  36255. * Gets whether audio is enabled or not.
  36256. * Please use related enable/disable method to switch state.
  36257. */
  36258. readonly audioEnabled: boolean;
  36259. private _headphone;
  36260. /**
  36261. * Gets whether audio is outputing to headphone or not.
  36262. * Please use the according Switch methods to change output.
  36263. */
  36264. readonly headphone: boolean;
  36265. private _audioListenerPositionProvider;
  36266. /**
  36267. * Gets the current audio listener position provider
  36268. */
  36269. /**
  36270. * Sets a custom listener position for all sounds in the scene
  36271. * By default, this is the position of the first active camera
  36272. */
  36273. audioListenerPositionProvider: Nullable<() => Vector3>;
  36274. /**
  36275. * Creates a new instance of the component for the given scene
  36276. * @param scene Defines the scene to register the component in
  36277. */
  36278. constructor(scene: Scene);
  36279. /**
  36280. * Registers the component in a given scene
  36281. */
  36282. register(): void;
  36283. /**
  36284. * Rebuilds the elements related to this component in case of
  36285. * context lost for instance.
  36286. */
  36287. rebuild(): void;
  36288. /**
  36289. * Serializes the component data to the specified json object
  36290. * @param serializationObject The object to serialize to
  36291. */
  36292. serialize(serializationObject: any): void;
  36293. /**
  36294. * Adds all the elements from the container to the scene
  36295. * @param container the container holding the elements
  36296. */
  36297. addFromContainer(container: AbstractScene): void;
  36298. /**
  36299. * Removes all the elements in the container from the scene
  36300. * @param container contains the elements to remove
  36301. * @param dispose if the removed element should be disposed (default: false)
  36302. */
  36303. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36304. /**
  36305. * Disposes the component and the associated ressources.
  36306. */
  36307. dispose(): void;
  36308. /**
  36309. * Disables audio in the associated scene.
  36310. */
  36311. disableAudio(): void;
  36312. /**
  36313. * Enables audio in the associated scene.
  36314. */
  36315. enableAudio(): void;
  36316. /**
  36317. * Switch audio to headphone output.
  36318. */
  36319. switchAudioModeForHeadphones(): void;
  36320. /**
  36321. * Switch audio to normal speakers.
  36322. */
  36323. switchAudioModeForNormalSpeakers(): void;
  36324. private _afterRender;
  36325. }
  36326. }
  36327. declare module "babylonjs/Audio/weightedsound" {
  36328. import { Sound } from "babylonjs/Audio/sound";
  36329. /**
  36330. * Wraps one or more Sound objects and selects one with random weight for playback.
  36331. */
  36332. export class WeightedSound {
  36333. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36334. loop: boolean;
  36335. private _coneInnerAngle;
  36336. private _coneOuterAngle;
  36337. private _volume;
  36338. /** A Sound is currently playing. */
  36339. isPlaying: boolean;
  36340. /** A Sound is currently paused. */
  36341. isPaused: boolean;
  36342. private _sounds;
  36343. private _weights;
  36344. private _currentIndex?;
  36345. /**
  36346. * Creates a new WeightedSound from the list of sounds given.
  36347. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36348. * @param sounds Array of Sounds that will be selected from.
  36349. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36350. */
  36351. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36352. /**
  36353. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36354. */
  36355. /**
  36356. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36357. */
  36358. directionalConeInnerAngle: number;
  36359. /**
  36360. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36361. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36362. */
  36363. /**
  36364. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36365. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36366. */
  36367. directionalConeOuterAngle: number;
  36368. /**
  36369. * Playback volume.
  36370. */
  36371. /**
  36372. * Playback volume.
  36373. */
  36374. volume: number;
  36375. private _onended;
  36376. /**
  36377. * Suspend playback
  36378. */
  36379. pause(): void;
  36380. /**
  36381. * Stop playback
  36382. */
  36383. stop(): void;
  36384. /**
  36385. * Start playback.
  36386. * @param startOffset Position the clip head at a specific time in seconds.
  36387. */
  36388. play(startOffset?: number): void;
  36389. }
  36390. }
  36391. declare module "babylonjs/Audio/index" {
  36392. export * from "babylonjs/Audio/analyser";
  36393. export * from "babylonjs/Audio/audioEngine";
  36394. export * from "babylonjs/Audio/audioSceneComponent";
  36395. export * from "babylonjs/Audio/sound";
  36396. export * from "babylonjs/Audio/soundTrack";
  36397. export * from "babylonjs/Audio/weightedsound";
  36398. }
  36399. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36400. import { Behavior } from "babylonjs/Behaviors/behavior";
  36401. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36402. import { BackEase } from "babylonjs/Animations/easing";
  36403. /**
  36404. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36405. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36406. */
  36407. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36408. /**
  36409. * Gets the name of the behavior.
  36410. */
  36411. readonly name: string;
  36412. /**
  36413. * The easing function used by animations
  36414. */
  36415. static EasingFunction: BackEase;
  36416. /**
  36417. * The easing mode used by animations
  36418. */
  36419. static EasingMode: number;
  36420. /**
  36421. * The duration of the animation, in milliseconds
  36422. */
  36423. transitionDuration: number;
  36424. /**
  36425. * Length of the distance animated by the transition when lower radius is reached
  36426. */
  36427. lowerRadiusTransitionRange: number;
  36428. /**
  36429. * Length of the distance animated by the transition when upper radius is reached
  36430. */
  36431. upperRadiusTransitionRange: number;
  36432. private _autoTransitionRange;
  36433. /**
  36434. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36435. */
  36436. /**
  36437. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36438. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36439. */
  36440. autoTransitionRange: boolean;
  36441. private _attachedCamera;
  36442. private _onAfterCheckInputsObserver;
  36443. private _onMeshTargetChangedObserver;
  36444. /**
  36445. * Initializes the behavior.
  36446. */
  36447. init(): void;
  36448. /**
  36449. * Attaches the behavior to its arc rotate camera.
  36450. * @param camera Defines the camera to attach the behavior to
  36451. */
  36452. attach(camera: ArcRotateCamera): void;
  36453. /**
  36454. * Detaches the behavior from its current arc rotate camera.
  36455. */
  36456. detach(): void;
  36457. private _radiusIsAnimating;
  36458. private _radiusBounceTransition;
  36459. private _animatables;
  36460. private _cachedWheelPrecision;
  36461. /**
  36462. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36463. * @param radiusLimit The limit to check against.
  36464. * @return Bool to indicate if at limit.
  36465. */
  36466. private _isRadiusAtLimit;
  36467. /**
  36468. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36469. * @param radiusDelta The delta by which to animate to. Can be negative.
  36470. */
  36471. private _applyBoundRadiusAnimation;
  36472. /**
  36473. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36474. */
  36475. protected _clearAnimationLocks(): void;
  36476. /**
  36477. * Stops and removes all animations that have been applied to the camera
  36478. */
  36479. stopAllAnimations(): void;
  36480. }
  36481. }
  36482. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36483. import { Behavior } from "babylonjs/Behaviors/behavior";
  36484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36485. import { ExponentialEase } from "babylonjs/Animations/easing";
  36486. import { Nullable } from "babylonjs/types";
  36487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36488. import { Vector3 } from "babylonjs/Maths/math.vector";
  36489. /**
  36490. * 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.
  36491. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36492. */
  36493. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36494. /**
  36495. * Gets the name of the behavior.
  36496. */
  36497. readonly name: string;
  36498. private _mode;
  36499. private _radiusScale;
  36500. private _positionScale;
  36501. private _defaultElevation;
  36502. private _elevationReturnTime;
  36503. private _elevationReturnWaitTime;
  36504. private _zoomStopsAnimation;
  36505. private _framingTime;
  36506. /**
  36507. * The easing function used by animations
  36508. */
  36509. static EasingFunction: ExponentialEase;
  36510. /**
  36511. * The easing mode used by animations
  36512. */
  36513. static EasingMode: number;
  36514. /**
  36515. * Sets the current mode used by the behavior
  36516. */
  36517. /**
  36518. * Gets current mode used by the behavior.
  36519. */
  36520. mode: number;
  36521. /**
  36522. * Sets the scale applied to the radius (1 by default)
  36523. */
  36524. /**
  36525. * Gets the scale applied to the radius
  36526. */
  36527. radiusScale: number;
  36528. /**
  36529. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36530. */
  36531. /**
  36532. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36533. */
  36534. positionScale: number;
  36535. /**
  36536. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36537. * behaviour is triggered, in radians.
  36538. */
  36539. /**
  36540. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36541. * behaviour is triggered, in radians.
  36542. */
  36543. defaultElevation: number;
  36544. /**
  36545. * Sets the time (in milliseconds) taken to return to the default beta position.
  36546. * Negative value indicates camera should not return to default.
  36547. */
  36548. /**
  36549. * Gets the time (in milliseconds) taken to return to the default beta position.
  36550. * Negative value indicates camera should not return to default.
  36551. */
  36552. elevationReturnTime: number;
  36553. /**
  36554. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36555. */
  36556. /**
  36557. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36558. */
  36559. elevationReturnWaitTime: number;
  36560. /**
  36561. * Sets the flag that indicates if user zooming should stop animation.
  36562. */
  36563. /**
  36564. * Gets the flag that indicates if user zooming should stop animation.
  36565. */
  36566. zoomStopsAnimation: boolean;
  36567. /**
  36568. * Sets the transition time when framing the mesh, in milliseconds
  36569. */
  36570. /**
  36571. * Gets the transition time when framing the mesh, in milliseconds
  36572. */
  36573. framingTime: number;
  36574. /**
  36575. * Define if the behavior should automatically change the configured
  36576. * camera limits and sensibilities.
  36577. */
  36578. autoCorrectCameraLimitsAndSensibility: boolean;
  36579. private _onPrePointerObservableObserver;
  36580. private _onAfterCheckInputsObserver;
  36581. private _onMeshTargetChangedObserver;
  36582. private _attachedCamera;
  36583. private _isPointerDown;
  36584. private _lastInteractionTime;
  36585. /**
  36586. * Initializes the behavior.
  36587. */
  36588. init(): void;
  36589. /**
  36590. * Attaches the behavior to its arc rotate camera.
  36591. * @param camera Defines the camera to attach the behavior to
  36592. */
  36593. attach(camera: ArcRotateCamera): void;
  36594. /**
  36595. * Detaches the behavior from its current arc rotate camera.
  36596. */
  36597. detach(): void;
  36598. private _animatables;
  36599. private _betaIsAnimating;
  36600. private _betaTransition;
  36601. private _radiusTransition;
  36602. private _vectorTransition;
  36603. /**
  36604. * Targets the given mesh and updates zoom level accordingly.
  36605. * @param mesh The mesh to target.
  36606. * @param radius Optional. If a cached radius position already exists, overrides default.
  36607. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36608. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36609. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36610. */
  36611. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36612. /**
  36613. * Targets the given mesh with its children and updates zoom level accordingly.
  36614. * @param mesh The mesh to target.
  36615. * @param radius Optional. If a cached radius position already exists, overrides default.
  36616. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36617. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36618. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36619. */
  36620. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36621. /**
  36622. * Targets the given meshes with their children and updates zoom level accordingly.
  36623. * @param meshes The mesh to target.
  36624. * @param radius Optional. If a cached radius position already exists, overrides default.
  36625. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36626. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36627. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36628. */
  36629. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36630. /**
  36631. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36632. * @param minimumWorld Determines the smaller position of the bounding box extend
  36633. * @param maximumWorld Determines the bigger position of the bounding box extend
  36634. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36635. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36636. */
  36637. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36638. /**
  36639. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36640. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36641. * frustum width.
  36642. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36643. * to fully enclose the mesh in the viewing frustum.
  36644. */
  36645. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36646. /**
  36647. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36648. * is automatically returned to its default position (expected to be above ground plane).
  36649. */
  36650. private _maintainCameraAboveGround;
  36651. /**
  36652. * Returns the frustum slope based on the canvas ratio and camera FOV
  36653. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36654. */
  36655. private _getFrustumSlope;
  36656. /**
  36657. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36658. */
  36659. private _clearAnimationLocks;
  36660. /**
  36661. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36662. */
  36663. private _applyUserInteraction;
  36664. /**
  36665. * Stops and removes all animations that have been applied to the camera
  36666. */
  36667. stopAllAnimations(): void;
  36668. /**
  36669. * Gets a value indicating if the user is moving the camera
  36670. */
  36671. readonly isUserIsMoving: boolean;
  36672. /**
  36673. * The camera can move all the way towards the mesh.
  36674. */
  36675. static IgnoreBoundsSizeMode: number;
  36676. /**
  36677. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36678. */
  36679. static FitFrustumSidesMode: number;
  36680. }
  36681. }
  36682. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36683. import { Nullable } from "babylonjs/types";
  36684. import { Camera } from "babylonjs/Cameras/camera";
  36685. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36686. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36687. /**
  36688. * Base class for Camera Pointer Inputs.
  36689. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36690. * for example usage.
  36691. */
  36692. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36693. /**
  36694. * Defines the camera the input is attached to.
  36695. */
  36696. abstract camera: Camera;
  36697. /**
  36698. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36699. */
  36700. protected _altKey: boolean;
  36701. protected _ctrlKey: boolean;
  36702. protected _metaKey: boolean;
  36703. protected _shiftKey: boolean;
  36704. /**
  36705. * Which mouse buttons were pressed at time of last mouse event.
  36706. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36707. */
  36708. protected _buttonsPressed: number;
  36709. /**
  36710. * Defines the buttons associated with the input to handle camera move.
  36711. */
  36712. buttons: number[];
  36713. /**
  36714. * Attach the input controls to a specific dom element to get the input from.
  36715. * @param element Defines the element the controls should be listened from
  36716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36717. */
  36718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36719. /**
  36720. * Detach the current controls from the specified dom element.
  36721. * @param element Defines the element to stop listening the inputs from
  36722. */
  36723. detachControl(element: Nullable<HTMLElement>): void;
  36724. /**
  36725. * Gets the class name of the current input.
  36726. * @returns the class name
  36727. */
  36728. getClassName(): string;
  36729. /**
  36730. * Get the friendly name associated with the input class.
  36731. * @returns the input friendly name
  36732. */
  36733. getSimpleName(): string;
  36734. /**
  36735. * Called on pointer POINTERDOUBLETAP event.
  36736. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36737. */
  36738. protected onDoubleTap(type: string): void;
  36739. /**
  36740. * Called on pointer POINTERMOVE event if only a single touch is active.
  36741. * Override this method to provide functionality.
  36742. */
  36743. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36744. /**
  36745. * Called on pointer POINTERMOVE event if multiple touches are active.
  36746. * Override this method to provide functionality.
  36747. */
  36748. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36749. /**
  36750. * Called on JS contextmenu event.
  36751. * Override this method to provide functionality.
  36752. */
  36753. protected onContextMenu(evt: PointerEvent): void;
  36754. /**
  36755. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36756. * press.
  36757. * Override this method to provide functionality.
  36758. */
  36759. protected onButtonDown(evt: PointerEvent): void;
  36760. /**
  36761. * Called each time a new POINTERUP event occurs. Ie, for each button
  36762. * release.
  36763. * Override this method to provide functionality.
  36764. */
  36765. protected onButtonUp(evt: PointerEvent): void;
  36766. /**
  36767. * Called when window becomes inactive.
  36768. * Override this method to provide functionality.
  36769. */
  36770. protected onLostFocus(): void;
  36771. private _pointerInput;
  36772. private _observer;
  36773. private _onLostFocus;
  36774. private pointA;
  36775. private pointB;
  36776. }
  36777. }
  36778. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36779. import { Nullable } from "babylonjs/types";
  36780. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36781. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36782. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36783. /**
  36784. * Manage the pointers inputs to control an arc rotate camera.
  36785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36786. */
  36787. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36788. /**
  36789. * Defines the camera the input is attached to.
  36790. */
  36791. camera: ArcRotateCamera;
  36792. /**
  36793. * Gets the class name of the current input.
  36794. * @returns the class name
  36795. */
  36796. getClassName(): string;
  36797. /**
  36798. * Defines the buttons associated with the input to handle camera move.
  36799. */
  36800. buttons: number[];
  36801. /**
  36802. * Defines the pointer angular sensibility along the X axis or how fast is
  36803. * the camera rotating.
  36804. */
  36805. angularSensibilityX: number;
  36806. /**
  36807. * Defines the pointer angular sensibility along the Y axis or how fast is
  36808. * the camera rotating.
  36809. */
  36810. angularSensibilityY: number;
  36811. /**
  36812. * Defines the pointer pinch precision or how fast is the camera zooming.
  36813. */
  36814. pinchPrecision: number;
  36815. /**
  36816. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36817. * from 0.
  36818. * It defines the percentage of current camera.radius to use as delta when
  36819. * pinch zoom is used.
  36820. */
  36821. pinchDeltaPercentage: number;
  36822. /**
  36823. * Defines the pointer panning sensibility or how fast is the camera moving.
  36824. */
  36825. panningSensibility: number;
  36826. /**
  36827. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36828. */
  36829. multiTouchPanning: boolean;
  36830. /**
  36831. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36832. * zoom (pinch) through multitouch.
  36833. */
  36834. multiTouchPanAndZoom: boolean;
  36835. /**
  36836. * Revers pinch action direction.
  36837. */
  36838. pinchInwards: boolean;
  36839. private _isPanClick;
  36840. private _twoFingerActivityCount;
  36841. private _isPinching;
  36842. /**
  36843. * Called on pointer POINTERMOVE event if only a single touch is active.
  36844. */
  36845. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36846. /**
  36847. * Called on pointer POINTERDOUBLETAP event.
  36848. */
  36849. protected onDoubleTap(type: string): void;
  36850. /**
  36851. * Called on pointer POINTERMOVE event if multiple touches are active.
  36852. */
  36853. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36854. /**
  36855. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36856. * press.
  36857. */
  36858. protected onButtonDown(evt: PointerEvent): void;
  36859. /**
  36860. * Called each time a new POINTERUP event occurs. Ie, for each button
  36861. * release.
  36862. */
  36863. protected onButtonUp(evt: PointerEvent): void;
  36864. /**
  36865. * Called when window becomes inactive.
  36866. */
  36867. protected onLostFocus(): void;
  36868. }
  36869. }
  36870. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36871. import { Nullable } from "babylonjs/types";
  36872. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36873. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36874. /**
  36875. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36877. */
  36878. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36879. /**
  36880. * Defines the camera the input is attached to.
  36881. */
  36882. camera: ArcRotateCamera;
  36883. /**
  36884. * Defines the list of key codes associated with the up action (increase alpha)
  36885. */
  36886. keysUp: number[];
  36887. /**
  36888. * Defines the list of key codes associated with the down action (decrease alpha)
  36889. */
  36890. keysDown: number[];
  36891. /**
  36892. * Defines the list of key codes associated with the left action (increase beta)
  36893. */
  36894. keysLeft: number[];
  36895. /**
  36896. * Defines the list of key codes associated with the right action (decrease beta)
  36897. */
  36898. keysRight: number[];
  36899. /**
  36900. * Defines the list of key codes associated with the reset action.
  36901. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36902. */
  36903. keysReset: number[];
  36904. /**
  36905. * Defines the panning sensibility of the inputs.
  36906. * (How fast is the camera paning)
  36907. */
  36908. panningSensibility: number;
  36909. /**
  36910. * Defines the zooming sensibility of the inputs.
  36911. * (How fast is the camera zooming)
  36912. */
  36913. zoomingSensibility: number;
  36914. /**
  36915. * Defines wether maintaining the alt key down switch the movement mode from
  36916. * orientation to zoom.
  36917. */
  36918. useAltToZoom: boolean;
  36919. /**
  36920. * Rotation speed of the camera
  36921. */
  36922. angularSpeed: number;
  36923. private _keys;
  36924. private _ctrlPressed;
  36925. private _altPressed;
  36926. private _onCanvasBlurObserver;
  36927. private _onKeyboardObserver;
  36928. private _engine;
  36929. private _scene;
  36930. /**
  36931. * Attach the input controls to a specific dom element to get the input from.
  36932. * @param element Defines the element the controls should be listened from
  36933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36934. */
  36935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36936. /**
  36937. * Detach the current controls from the specified dom element.
  36938. * @param element Defines the element to stop listening the inputs from
  36939. */
  36940. detachControl(element: Nullable<HTMLElement>): void;
  36941. /**
  36942. * Update the current camera state depending on the inputs that have been used this frame.
  36943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36944. */
  36945. checkInputs(): void;
  36946. /**
  36947. * Gets the class name of the current intput.
  36948. * @returns the class name
  36949. */
  36950. getClassName(): string;
  36951. /**
  36952. * Get the friendly name associated with the input class.
  36953. * @returns the input friendly name
  36954. */
  36955. getSimpleName(): string;
  36956. }
  36957. }
  36958. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36959. import { Nullable } from "babylonjs/types";
  36960. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36961. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36962. /**
  36963. * Manage the mouse wheel inputs to control an arc rotate camera.
  36964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36965. */
  36966. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36967. /**
  36968. * Defines the camera the input is attached to.
  36969. */
  36970. camera: ArcRotateCamera;
  36971. /**
  36972. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36973. */
  36974. wheelPrecision: number;
  36975. /**
  36976. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36977. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36978. */
  36979. wheelDeltaPercentage: number;
  36980. private _wheel;
  36981. private _observer;
  36982. private computeDeltaFromMouseWheelLegacyEvent;
  36983. /**
  36984. * Attach the input controls to a specific dom element to get the input from.
  36985. * @param element Defines the element the controls should be listened from
  36986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36987. */
  36988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36989. /**
  36990. * Detach the current controls from the specified dom element.
  36991. * @param element Defines the element to stop listening the inputs from
  36992. */
  36993. detachControl(element: Nullable<HTMLElement>): void;
  36994. /**
  36995. * Gets the class name of the current intput.
  36996. * @returns the class name
  36997. */
  36998. getClassName(): string;
  36999. /**
  37000. * Get the friendly name associated with the input class.
  37001. * @returns the input friendly name
  37002. */
  37003. getSimpleName(): string;
  37004. }
  37005. }
  37006. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37007. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37008. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37009. /**
  37010. * Default Inputs manager for the ArcRotateCamera.
  37011. * It groups all the default supported inputs for ease of use.
  37012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37013. */
  37014. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37015. /**
  37016. * Instantiates a new ArcRotateCameraInputsManager.
  37017. * @param camera Defines the camera the inputs belong to
  37018. */
  37019. constructor(camera: ArcRotateCamera);
  37020. /**
  37021. * Add mouse wheel input support to the input manager.
  37022. * @returns the current input manager
  37023. */
  37024. addMouseWheel(): ArcRotateCameraInputsManager;
  37025. /**
  37026. * Add pointers input support to the input manager.
  37027. * @returns the current input manager
  37028. */
  37029. addPointers(): ArcRotateCameraInputsManager;
  37030. /**
  37031. * Add keyboard input support to the input manager.
  37032. * @returns the current input manager
  37033. */
  37034. addKeyboard(): ArcRotateCameraInputsManager;
  37035. }
  37036. }
  37037. declare module "babylonjs/Cameras/arcRotateCamera" {
  37038. import { Observable } from "babylonjs/Misc/observable";
  37039. import { Nullable } from "babylonjs/types";
  37040. import { Scene } from "babylonjs/scene";
  37041. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37043. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37044. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37045. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37046. import { Camera } from "babylonjs/Cameras/camera";
  37047. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37048. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37049. import { Collider } from "babylonjs/Collisions/collider";
  37050. /**
  37051. * This represents an orbital type of camera.
  37052. *
  37053. * 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.
  37054. * 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.
  37055. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37056. */
  37057. export class ArcRotateCamera extends TargetCamera {
  37058. /**
  37059. * Defines the rotation angle of the camera along the longitudinal axis.
  37060. */
  37061. alpha: number;
  37062. /**
  37063. * Defines the rotation angle of the camera along the latitudinal axis.
  37064. */
  37065. beta: number;
  37066. /**
  37067. * Defines the radius of the camera from it s target point.
  37068. */
  37069. radius: number;
  37070. protected _target: Vector3;
  37071. protected _targetHost: Nullable<AbstractMesh>;
  37072. /**
  37073. * Defines the target point of the camera.
  37074. * The camera looks towards it form the radius distance.
  37075. */
  37076. target: Vector3;
  37077. /**
  37078. * Define the current local position of the camera in the scene
  37079. */
  37080. position: Vector3;
  37081. protected _upVector: Vector3;
  37082. protected _upToYMatrix: Matrix;
  37083. protected _YToUpMatrix: Matrix;
  37084. /**
  37085. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37086. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37087. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37088. */
  37089. upVector: Vector3;
  37090. /**
  37091. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37092. */
  37093. setMatUp(): void;
  37094. /**
  37095. * Current inertia value on the longitudinal axis.
  37096. * The bigger this number the longer it will take for the camera to stop.
  37097. */
  37098. inertialAlphaOffset: number;
  37099. /**
  37100. * Current inertia value on the latitudinal axis.
  37101. * The bigger this number the longer it will take for the camera to stop.
  37102. */
  37103. inertialBetaOffset: number;
  37104. /**
  37105. * Current inertia value on the radius axis.
  37106. * The bigger this number the longer it will take for the camera to stop.
  37107. */
  37108. inertialRadiusOffset: number;
  37109. /**
  37110. * Minimum allowed angle on the longitudinal axis.
  37111. * This can help limiting how the Camera is able to move in the scene.
  37112. */
  37113. lowerAlphaLimit: Nullable<number>;
  37114. /**
  37115. * Maximum allowed angle on the longitudinal axis.
  37116. * This can help limiting how the Camera is able to move in the scene.
  37117. */
  37118. upperAlphaLimit: Nullable<number>;
  37119. /**
  37120. * Minimum allowed angle on the latitudinal axis.
  37121. * This can help limiting how the Camera is able to move in the scene.
  37122. */
  37123. lowerBetaLimit: number;
  37124. /**
  37125. * Maximum allowed angle on the latitudinal axis.
  37126. * This can help limiting how the Camera is able to move in the scene.
  37127. */
  37128. upperBetaLimit: number;
  37129. /**
  37130. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37131. * This can help limiting how the Camera is able to move in the scene.
  37132. */
  37133. lowerRadiusLimit: Nullable<number>;
  37134. /**
  37135. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37136. * This can help limiting how the Camera is able to move in the scene.
  37137. */
  37138. upperRadiusLimit: Nullable<number>;
  37139. /**
  37140. * Defines the current inertia value used during panning of the camera along the X axis.
  37141. */
  37142. inertialPanningX: number;
  37143. /**
  37144. * Defines the current inertia value used during panning of the camera along the Y axis.
  37145. */
  37146. inertialPanningY: number;
  37147. /**
  37148. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37149. * Basically if your fingers moves away from more than this distance you will be considered
  37150. * in pinch mode.
  37151. */
  37152. pinchToPanMaxDistance: number;
  37153. /**
  37154. * Defines the maximum distance the camera can pan.
  37155. * This could help keeping the cammera always in your scene.
  37156. */
  37157. panningDistanceLimit: Nullable<number>;
  37158. /**
  37159. * Defines the target of the camera before paning.
  37160. */
  37161. panningOriginTarget: Vector3;
  37162. /**
  37163. * Defines the value of the inertia used during panning.
  37164. * 0 would mean stop inertia and one would mean no decelleration at all.
  37165. */
  37166. panningInertia: number;
  37167. /**
  37168. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37169. */
  37170. angularSensibilityX: number;
  37171. /**
  37172. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37173. */
  37174. angularSensibilityY: number;
  37175. /**
  37176. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37177. */
  37178. pinchPrecision: number;
  37179. /**
  37180. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37181. * It will be used instead of pinchDeltaPrecision if different from 0.
  37182. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37183. */
  37184. pinchDeltaPercentage: number;
  37185. /**
  37186. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37187. */
  37188. panningSensibility: number;
  37189. /**
  37190. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37191. */
  37192. keysUp: number[];
  37193. /**
  37194. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37195. */
  37196. keysDown: number[];
  37197. /**
  37198. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37199. */
  37200. keysLeft: number[];
  37201. /**
  37202. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37203. */
  37204. keysRight: number[];
  37205. /**
  37206. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37207. */
  37208. wheelPrecision: number;
  37209. /**
  37210. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37211. * It will be used instead of pinchDeltaPrecision if different from 0.
  37212. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37213. */
  37214. wheelDeltaPercentage: number;
  37215. /**
  37216. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37217. */
  37218. zoomOnFactor: number;
  37219. /**
  37220. * Defines a screen offset for the camera position.
  37221. */
  37222. targetScreenOffset: Vector2;
  37223. /**
  37224. * Allows the camera to be completely reversed.
  37225. * If false the camera can not arrive upside down.
  37226. */
  37227. allowUpsideDown: boolean;
  37228. /**
  37229. * Define if double tap/click is used to restore the previously saved state of the camera.
  37230. */
  37231. useInputToRestoreState: boolean;
  37232. /** @hidden */
  37233. _viewMatrix: Matrix;
  37234. /** @hidden */
  37235. _useCtrlForPanning: boolean;
  37236. /** @hidden */
  37237. _panningMouseButton: number;
  37238. /**
  37239. * Defines the input associated to the camera.
  37240. */
  37241. inputs: ArcRotateCameraInputsManager;
  37242. /** @hidden */
  37243. _reset: () => void;
  37244. /**
  37245. * Defines the allowed panning axis.
  37246. */
  37247. panningAxis: Vector3;
  37248. protected _localDirection: Vector3;
  37249. protected _transformedDirection: Vector3;
  37250. private _bouncingBehavior;
  37251. /**
  37252. * Gets the bouncing behavior of the camera if it has been enabled.
  37253. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37254. */
  37255. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37256. /**
  37257. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37258. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37259. */
  37260. useBouncingBehavior: boolean;
  37261. private _framingBehavior;
  37262. /**
  37263. * Gets the framing behavior of the camera if it has been enabled.
  37264. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37265. */
  37266. readonly framingBehavior: Nullable<FramingBehavior>;
  37267. /**
  37268. * Defines if the framing behavior of the camera is enabled on the camera.
  37269. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37270. */
  37271. useFramingBehavior: boolean;
  37272. private _autoRotationBehavior;
  37273. /**
  37274. * Gets the auto rotation behavior of the camera if it has been enabled.
  37275. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37276. */
  37277. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37278. /**
  37279. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37280. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37281. */
  37282. useAutoRotationBehavior: boolean;
  37283. /**
  37284. * Observable triggered when the mesh target has been changed on the camera.
  37285. */
  37286. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37287. /**
  37288. * Event raised when the camera is colliding with a mesh.
  37289. */
  37290. onCollide: (collidedMesh: AbstractMesh) => void;
  37291. /**
  37292. * Defines whether the camera should check collision with the objects oh the scene.
  37293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37294. */
  37295. checkCollisions: boolean;
  37296. /**
  37297. * Defines the collision radius of the camera.
  37298. * This simulates a sphere around the camera.
  37299. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37300. */
  37301. collisionRadius: Vector3;
  37302. protected _collider: Collider;
  37303. protected _previousPosition: Vector3;
  37304. protected _collisionVelocity: Vector3;
  37305. protected _newPosition: Vector3;
  37306. protected _previousAlpha: number;
  37307. protected _previousBeta: number;
  37308. protected _previousRadius: number;
  37309. protected _collisionTriggered: boolean;
  37310. protected _targetBoundingCenter: Nullable<Vector3>;
  37311. private _computationVector;
  37312. /**
  37313. * Instantiates a new ArcRotateCamera in a given scene
  37314. * @param name Defines the name of the camera
  37315. * @param alpha Defines the camera rotation along the logitudinal axis
  37316. * @param beta Defines the camera rotation along the latitudinal axis
  37317. * @param radius Defines the camera distance from its target
  37318. * @param target Defines the camera target
  37319. * @param scene Defines the scene the camera belongs to
  37320. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37321. */
  37322. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37323. /** @hidden */
  37324. _initCache(): void;
  37325. /** @hidden */
  37326. _updateCache(ignoreParentClass?: boolean): void;
  37327. protected _getTargetPosition(): Vector3;
  37328. private _storedAlpha;
  37329. private _storedBeta;
  37330. private _storedRadius;
  37331. private _storedTarget;
  37332. private _storedTargetScreenOffset;
  37333. /**
  37334. * Stores the current state of the camera (alpha, beta, radius and target)
  37335. * @returns the camera itself
  37336. */
  37337. storeState(): Camera;
  37338. /**
  37339. * @hidden
  37340. * Restored camera state. You must call storeState() first
  37341. */
  37342. _restoreStateValues(): boolean;
  37343. /** @hidden */
  37344. _isSynchronizedViewMatrix(): boolean;
  37345. /**
  37346. * Attached controls to the current camera.
  37347. * @param element Defines the element the controls should be listened from
  37348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37349. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37350. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37351. */
  37352. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37353. /**
  37354. * Detach the current controls from the camera.
  37355. * The camera will stop reacting to inputs.
  37356. * @param element Defines the element to stop listening the inputs from
  37357. */
  37358. detachControl(element: HTMLElement): void;
  37359. /** @hidden */
  37360. _checkInputs(): void;
  37361. protected _checkLimits(): void;
  37362. /**
  37363. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37364. */
  37365. rebuildAnglesAndRadius(): void;
  37366. /**
  37367. * Use a position to define the current camera related information like aplha, beta and radius
  37368. * @param position Defines the position to set the camera at
  37369. */
  37370. setPosition(position: Vector3): void;
  37371. /**
  37372. * Defines the target the camera should look at.
  37373. * This will automatically adapt alpha beta and radius to fit within the new target.
  37374. * @param target Defines the new target as a Vector or a mesh
  37375. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37376. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37377. */
  37378. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37379. /** @hidden */
  37380. _getViewMatrix(): Matrix;
  37381. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37382. /**
  37383. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37384. * @param meshes Defines the mesh to zoom on
  37385. * @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)
  37386. */
  37387. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37388. /**
  37389. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37390. * The target will be changed but the radius
  37391. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37392. * @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)
  37393. */
  37394. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37395. min: Vector3;
  37396. max: Vector3;
  37397. distance: number;
  37398. }, doNotUpdateMaxZ?: boolean): void;
  37399. /**
  37400. * @override
  37401. * Override Camera.createRigCamera
  37402. */
  37403. createRigCamera(name: string, cameraIndex: number): Camera;
  37404. /**
  37405. * @hidden
  37406. * @override
  37407. * Override Camera._updateRigCameras
  37408. */
  37409. _updateRigCameras(): void;
  37410. /**
  37411. * Destroy the camera and release the current resources hold by it.
  37412. */
  37413. dispose(): void;
  37414. /**
  37415. * Gets the current object class name.
  37416. * @return the class name
  37417. */
  37418. getClassName(): string;
  37419. }
  37420. }
  37421. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37422. import { Behavior } from "babylonjs/Behaviors/behavior";
  37423. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37424. /**
  37425. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37427. */
  37428. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37429. /**
  37430. * Gets the name of the behavior.
  37431. */
  37432. readonly name: string;
  37433. private _zoomStopsAnimation;
  37434. private _idleRotationSpeed;
  37435. private _idleRotationWaitTime;
  37436. private _idleRotationSpinupTime;
  37437. /**
  37438. * Sets the flag that indicates if user zooming should stop animation.
  37439. */
  37440. /**
  37441. * Gets the flag that indicates if user zooming should stop animation.
  37442. */
  37443. zoomStopsAnimation: boolean;
  37444. /**
  37445. * Sets the default speed at which the camera rotates around the model.
  37446. */
  37447. /**
  37448. * Gets the default speed at which the camera rotates around the model.
  37449. */
  37450. idleRotationSpeed: number;
  37451. /**
  37452. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37453. */
  37454. /**
  37455. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37456. */
  37457. idleRotationWaitTime: number;
  37458. /**
  37459. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37460. */
  37461. /**
  37462. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37463. */
  37464. idleRotationSpinupTime: number;
  37465. /**
  37466. * Gets a value indicating if the camera is currently rotating because of this behavior
  37467. */
  37468. readonly rotationInProgress: boolean;
  37469. private _onPrePointerObservableObserver;
  37470. private _onAfterCheckInputsObserver;
  37471. private _attachedCamera;
  37472. private _isPointerDown;
  37473. private _lastFrameTime;
  37474. private _lastInteractionTime;
  37475. private _cameraRotationSpeed;
  37476. /**
  37477. * Initializes the behavior.
  37478. */
  37479. init(): void;
  37480. /**
  37481. * Attaches the behavior to its arc rotate camera.
  37482. * @param camera Defines the camera to attach the behavior to
  37483. */
  37484. attach(camera: ArcRotateCamera): void;
  37485. /**
  37486. * Detaches the behavior from its current arc rotate camera.
  37487. */
  37488. detach(): void;
  37489. /**
  37490. * Returns true if user is scrolling.
  37491. * @return true if user is scrolling.
  37492. */
  37493. private _userIsZooming;
  37494. private _lastFrameRadius;
  37495. private _shouldAnimationStopForInteraction;
  37496. /**
  37497. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37498. */
  37499. private _applyUserInteraction;
  37500. private _userIsMoving;
  37501. }
  37502. }
  37503. declare module "babylonjs/Behaviors/Cameras/index" {
  37504. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37505. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37506. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37507. }
  37508. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37509. import { Mesh } from "babylonjs/Meshes/mesh";
  37510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37511. import { Behavior } from "babylonjs/Behaviors/behavior";
  37512. /**
  37513. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37514. */
  37515. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37516. private ui;
  37517. /**
  37518. * The name of the behavior
  37519. */
  37520. name: string;
  37521. /**
  37522. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37523. */
  37524. distanceAwayFromFace: number;
  37525. /**
  37526. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37527. */
  37528. distanceAwayFromBottomOfFace: number;
  37529. private _faceVectors;
  37530. private _target;
  37531. private _scene;
  37532. private _onRenderObserver;
  37533. private _tmpMatrix;
  37534. private _tmpVector;
  37535. /**
  37536. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37537. * @param ui The transform node that should be attched to the mesh
  37538. */
  37539. constructor(ui: TransformNode);
  37540. /**
  37541. * Initializes the behavior
  37542. */
  37543. init(): void;
  37544. private _closestFace;
  37545. private _zeroVector;
  37546. private _lookAtTmpMatrix;
  37547. private _lookAtToRef;
  37548. /**
  37549. * Attaches the AttachToBoxBehavior to the passed in mesh
  37550. * @param target The mesh that the specified node will be attached to
  37551. */
  37552. attach(target: Mesh): void;
  37553. /**
  37554. * Detaches the behavior from the mesh
  37555. */
  37556. detach(): void;
  37557. }
  37558. }
  37559. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37560. import { Behavior } from "babylonjs/Behaviors/behavior";
  37561. import { Mesh } from "babylonjs/Meshes/mesh";
  37562. /**
  37563. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37564. */
  37565. export class FadeInOutBehavior implements Behavior<Mesh> {
  37566. /**
  37567. * Time in milliseconds to delay before fading in (Default: 0)
  37568. */
  37569. delay: number;
  37570. /**
  37571. * Time in milliseconds for the mesh to fade in (Default: 300)
  37572. */
  37573. fadeInTime: number;
  37574. private _millisecondsPerFrame;
  37575. private _hovered;
  37576. private _hoverValue;
  37577. private _ownerNode;
  37578. /**
  37579. * Instatiates the FadeInOutBehavior
  37580. */
  37581. constructor();
  37582. /**
  37583. * The name of the behavior
  37584. */
  37585. readonly name: string;
  37586. /**
  37587. * Initializes the behavior
  37588. */
  37589. init(): void;
  37590. /**
  37591. * Attaches the fade behavior on the passed in mesh
  37592. * @param ownerNode The mesh that will be faded in/out once attached
  37593. */
  37594. attach(ownerNode: Mesh): void;
  37595. /**
  37596. * Detaches the behavior from the mesh
  37597. */
  37598. detach(): void;
  37599. /**
  37600. * Triggers the mesh to begin fading in or out
  37601. * @param value if the object should fade in or out (true to fade in)
  37602. */
  37603. fadeIn(value: boolean): void;
  37604. private _update;
  37605. private _setAllVisibility;
  37606. }
  37607. }
  37608. declare module "babylonjs/Misc/pivotTools" {
  37609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37610. /**
  37611. * Class containing a set of static utilities functions for managing Pivots
  37612. * @hidden
  37613. */
  37614. export class PivotTools {
  37615. private static _PivotCached;
  37616. private static _OldPivotPoint;
  37617. private static _PivotTranslation;
  37618. private static _PivotTmpVector;
  37619. /** @hidden */
  37620. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37621. /** @hidden */
  37622. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37623. }
  37624. }
  37625. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37626. import { Scene } from "babylonjs/scene";
  37627. import { Vector4 } from "babylonjs/Maths/math.vector";
  37628. import { Mesh } from "babylonjs/Meshes/mesh";
  37629. import { Nullable } from "babylonjs/types";
  37630. import { Plane } from "babylonjs/Maths/math.plane";
  37631. /**
  37632. * Class containing static functions to help procedurally build meshes
  37633. */
  37634. export class PlaneBuilder {
  37635. /**
  37636. * Creates a plane mesh
  37637. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37638. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37639. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37643. * @param name defines the name of the mesh
  37644. * @param options defines the options used to create the mesh
  37645. * @param scene defines the hosting scene
  37646. * @returns the plane mesh
  37647. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37648. */
  37649. static CreatePlane(name: string, options: {
  37650. size?: number;
  37651. width?: number;
  37652. height?: number;
  37653. sideOrientation?: number;
  37654. frontUVs?: Vector4;
  37655. backUVs?: Vector4;
  37656. updatable?: boolean;
  37657. sourcePlane?: Plane;
  37658. }, scene?: Nullable<Scene>): Mesh;
  37659. }
  37660. }
  37661. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37662. import { Behavior } from "babylonjs/Behaviors/behavior";
  37663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37664. import { Observable } from "babylonjs/Misc/observable";
  37665. import { Vector3 } from "babylonjs/Maths/math.vector";
  37666. import { Ray } from "babylonjs/Culling/ray";
  37667. import "babylonjs/Meshes/Builders/planeBuilder";
  37668. /**
  37669. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37670. */
  37671. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37672. private static _AnyMouseID;
  37673. /**
  37674. * Abstract mesh the behavior is set on
  37675. */
  37676. attachedNode: AbstractMesh;
  37677. private _dragPlane;
  37678. private _scene;
  37679. private _pointerObserver;
  37680. private _beforeRenderObserver;
  37681. private static _planeScene;
  37682. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37683. /**
  37684. * 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)
  37685. */
  37686. maxDragAngle: number;
  37687. /**
  37688. * @hidden
  37689. */
  37690. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37691. /**
  37692. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37693. */
  37694. currentDraggingPointerID: number;
  37695. /**
  37696. * The last position where the pointer hit the drag plane in world space
  37697. */
  37698. lastDragPosition: Vector3;
  37699. /**
  37700. * If the behavior is currently in a dragging state
  37701. */
  37702. dragging: boolean;
  37703. /**
  37704. * 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)
  37705. */
  37706. dragDeltaRatio: number;
  37707. /**
  37708. * If the drag plane orientation should be updated during the dragging (Default: true)
  37709. */
  37710. updateDragPlane: boolean;
  37711. private _debugMode;
  37712. private _moving;
  37713. /**
  37714. * Fires each time the attached mesh is dragged with the pointer
  37715. * * delta between last drag position and current drag position in world space
  37716. * * dragDistance along the drag axis
  37717. * * dragPlaneNormal normal of the current drag plane used during the drag
  37718. * * dragPlanePoint in world space where the drag intersects the drag plane
  37719. */
  37720. onDragObservable: Observable<{
  37721. delta: Vector3;
  37722. dragPlanePoint: Vector3;
  37723. dragPlaneNormal: Vector3;
  37724. dragDistance: number;
  37725. pointerId: number;
  37726. }>;
  37727. /**
  37728. * Fires each time a drag begins (eg. mouse down on mesh)
  37729. */
  37730. onDragStartObservable: Observable<{
  37731. dragPlanePoint: Vector3;
  37732. pointerId: number;
  37733. }>;
  37734. /**
  37735. * Fires each time a drag ends (eg. mouse release after drag)
  37736. */
  37737. onDragEndObservable: Observable<{
  37738. dragPlanePoint: Vector3;
  37739. pointerId: number;
  37740. }>;
  37741. /**
  37742. * If the attached mesh should be moved when dragged
  37743. */
  37744. moveAttached: boolean;
  37745. /**
  37746. * If the drag behavior will react to drag events (Default: true)
  37747. */
  37748. enabled: boolean;
  37749. /**
  37750. * If pointer events should start and release the drag (Default: true)
  37751. */
  37752. startAndReleaseDragOnPointerEvents: boolean;
  37753. /**
  37754. * If camera controls should be detached during the drag
  37755. */
  37756. detachCameraControls: boolean;
  37757. /**
  37758. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37759. */
  37760. useObjectOrienationForDragging: boolean;
  37761. private _options;
  37762. /**
  37763. * Creates a pointer drag behavior that can be attached to a mesh
  37764. * @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)
  37765. */
  37766. constructor(options?: {
  37767. dragAxis?: Vector3;
  37768. dragPlaneNormal?: Vector3;
  37769. });
  37770. /**
  37771. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37772. */
  37773. validateDrag: (targetPosition: Vector3) => boolean;
  37774. /**
  37775. * The name of the behavior
  37776. */
  37777. readonly name: string;
  37778. /**
  37779. * Initializes the behavior
  37780. */
  37781. init(): void;
  37782. private _tmpVector;
  37783. private _alternatePickedPoint;
  37784. private _worldDragAxis;
  37785. private _targetPosition;
  37786. private _attachedElement;
  37787. /**
  37788. * Attaches the drag behavior the passed in mesh
  37789. * @param ownerNode The mesh that will be dragged around once attached
  37790. * @param predicate Predicate to use for pick filtering
  37791. */
  37792. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37793. /**
  37794. * Force relase the drag action by code.
  37795. */
  37796. releaseDrag(): void;
  37797. private _startDragRay;
  37798. private _lastPointerRay;
  37799. /**
  37800. * Simulates the start of a pointer drag event on the behavior
  37801. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37802. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37803. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37804. */
  37805. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37806. private _startDrag;
  37807. private _dragDelta;
  37808. private _moveDrag;
  37809. private _pickWithRayOnDragPlane;
  37810. private _pointA;
  37811. private _pointB;
  37812. private _pointC;
  37813. private _lineA;
  37814. private _lineB;
  37815. private _localAxis;
  37816. private _lookAt;
  37817. private _updateDragPlanePosition;
  37818. /**
  37819. * Detaches the behavior from the mesh
  37820. */
  37821. detach(): void;
  37822. }
  37823. }
  37824. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37825. import { Mesh } from "babylonjs/Meshes/mesh";
  37826. import { Behavior } from "babylonjs/Behaviors/behavior";
  37827. /**
  37828. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37829. */
  37830. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37831. private _dragBehaviorA;
  37832. private _dragBehaviorB;
  37833. private _startDistance;
  37834. private _initialScale;
  37835. private _targetScale;
  37836. private _ownerNode;
  37837. private _sceneRenderObserver;
  37838. /**
  37839. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37840. */
  37841. constructor();
  37842. /**
  37843. * The name of the behavior
  37844. */
  37845. readonly name: string;
  37846. /**
  37847. * Initializes the behavior
  37848. */
  37849. init(): void;
  37850. private _getCurrentDistance;
  37851. /**
  37852. * Attaches the scale behavior the passed in mesh
  37853. * @param ownerNode The mesh that will be scaled around once attached
  37854. */
  37855. attach(ownerNode: Mesh): void;
  37856. /**
  37857. * Detaches the behavior from the mesh
  37858. */
  37859. detach(): void;
  37860. }
  37861. }
  37862. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37863. import { Behavior } from "babylonjs/Behaviors/behavior";
  37864. import { Mesh } from "babylonjs/Meshes/mesh";
  37865. import { Observable } from "babylonjs/Misc/observable";
  37866. /**
  37867. * 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
  37868. */
  37869. export class SixDofDragBehavior implements Behavior<Mesh> {
  37870. private static _virtualScene;
  37871. private _ownerNode;
  37872. private _sceneRenderObserver;
  37873. private _scene;
  37874. private _targetPosition;
  37875. private _virtualOriginMesh;
  37876. private _virtualDragMesh;
  37877. private _pointerObserver;
  37878. private _moving;
  37879. private _startingOrientation;
  37880. /**
  37881. * 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)
  37882. */
  37883. private zDragFactor;
  37884. /**
  37885. * If the object should rotate to face the drag origin
  37886. */
  37887. rotateDraggedObject: boolean;
  37888. /**
  37889. * If the behavior is currently in a dragging state
  37890. */
  37891. dragging: boolean;
  37892. /**
  37893. * 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)
  37894. */
  37895. dragDeltaRatio: number;
  37896. /**
  37897. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37898. */
  37899. currentDraggingPointerID: number;
  37900. /**
  37901. * If camera controls should be detached during the drag
  37902. */
  37903. detachCameraControls: boolean;
  37904. /**
  37905. * Fires each time a drag starts
  37906. */
  37907. onDragStartObservable: Observable<{}>;
  37908. /**
  37909. * Fires each time a drag ends (eg. mouse release after drag)
  37910. */
  37911. onDragEndObservable: Observable<{}>;
  37912. /**
  37913. * 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
  37914. */
  37915. constructor();
  37916. /**
  37917. * The name of the behavior
  37918. */
  37919. readonly name: string;
  37920. /**
  37921. * Initializes the behavior
  37922. */
  37923. init(): void;
  37924. /**
  37925. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37926. */
  37927. private readonly _pointerCamera;
  37928. /**
  37929. * Attaches the scale behavior the passed in mesh
  37930. * @param ownerNode The mesh that will be scaled around once attached
  37931. */
  37932. attach(ownerNode: Mesh): void;
  37933. /**
  37934. * Detaches the behavior from the mesh
  37935. */
  37936. detach(): void;
  37937. }
  37938. }
  37939. declare module "babylonjs/Behaviors/Meshes/index" {
  37940. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37941. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37942. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37943. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37944. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37945. }
  37946. declare module "babylonjs/Behaviors/index" {
  37947. export * from "babylonjs/Behaviors/behavior";
  37948. export * from "babylonjs/Behaviors/Cameras/index";
  37949. export * from "babylonjs/Behaviors/Meshes/index";
  37950. }
  37951. declare module "babylonjs/Bones/boneIKController" {
  37952. import { Bone } from "babylonjs/Bones/bone";
  37953. import { Vector3 } from "babylonjs/Maths/math.vector";
  37954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37955. import { Nullable } from "babylonjs/types";
  37956. /**
  37957. * Class used to apply inverse kinematics to bones
  37958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37959. */
  37960. export class BoneIKController {
  37961. private static _tmpVecs;
  37962. private static _tmpQuat;
  37963. private static _tmpMats;
  37964. /**
  37965. * Gets or sets the target mesh
  37966. */
  37967. targetMesh: AbstractMesh;
  37968. /** Gets or sets the mesh used as pole */
  37969. poleTargetMesh: AbstractMesh;
  37970. /**
  37971. * Gets or sets the bone used as pole
  37972. */
  37973. poleTargetBone: Nullable<Bone>;
  37974. /**
  37975. * Gets or sets the target position
  37976. */
  37977. targetPosition: Vector3;
  37978. /**
  37979. * Gets or sets the pole target position
  37980. */
  37981. poleTargetPosition: Vector3;
  37982. /**
  37983. * Gets or sets the pole target local offset
  37984. */
  37985. poleTargetLocalOffset: Vector3;
  37986. /**
  37987. * Gets or sets the pole angle
  37988. */
  37989. poleAngle: number;
  37990. /**
  37991. * Gets or sets the mesh associated with the controller
  37992. */
  37993. mesh: AbstractMesh;
  37994. /**
  37995. * 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)
  37996. */
  37997. slerpAmount: number;
  37998. private _bone1Quat;
  37999. private _bone1Mat;
  38000. private _bone2Ang;
  38001. private _bone1;
  38002. private _bone2;
  38003. private _bone1Length;
  38004. private _bone2Length;
  38005. private _maxAngle;
  38006. private _maxReach;
  38007. private _rightHandedSystem;
  38008. private _bendAxis;
  38009. private _slerping;
  38010. private _adjustRoll;
  38011. /**
  38012. * Gets or sets maximum allowed angle
  38013. */
  38014. maxAngle: number;
  38015. /**
  38016. * Creates a new BoneIKController
  38017. * @param mesh defines the mesh to control
  38018. * @param bone defines the bone to control
  38019. * @param options defines options to set up the controller
  38020. */
  38021. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38022. targetMesh?: AbstractMesh;
  38023. poleTargetMesh?: AbstractMesh;
  38024. poleTargetBone?: Bone;
  38025. poleTargetLocalOffset?: Vector3;
  38026. poleAngle?: number;
  38027. bendAxis?: Vector3;
  38028. maxAngle?: number;
  38029. slerpAmount?: number;
  38030. });
  38031. private _setMaxAngle;
  38032. /**
  38033. * Force the controller to update the bones
  38034. */
  38035. update(): void;
  38036. }
  38037. }
  38038. declare module "babylonjs/Bones/boneLookController" {
  38039. import { Vector3 } from "babylonjs/Maths/math.vector";
  38040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38041. import { Bone } from "babylonjs/Bones/bone";
  38042. import { Space } from "babylonjs/Maths/math.axis";
  38043. /**
  38044. * Class used to make a bone look toward a point in space
  38045. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38046. */
  38047. export class BoneLookController {
  38048. private static _tmpVecs;
  38049. private static _tmpQuat;
  38050. private static _tmpMats;
  38051. /**
  38052. * The target Vector3 that the bone will look at
  38053. */
  38054. target: Vector3;
  38055. /**
  38056. * The mesh that the bone is attached to
  38057. */
  38058. mesh: AbstractMesh;
  38059. /**
  38060. * The bone that will be looking to the target
  38061. */
  38062. bone: Bone;
  38063. /**
  38064. * The up axis of the coordinate system that is used when the bone is rotated
  38065. */
  38066. upAxis: Vector3;
  38067. /**
  38068. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38069. */
  38070. upAxisSpace: Space;
  38071. /**
  38072. * Used to make an adjustment to the yaw of the bone
  38073. */
  38074. adjustYaw: number;
  38075. /**
  38076. * Used to make an adjustment to the pitch of the bone
  38077. */
  38078. adjustPitch: number;
  38079. /**
  38080. * Used to make an adjustment to the roll of the bone
  38081. */
  38082. adjustRoll: number;
  38083. /**
  38084. * 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)
  38085. */
  38086. slerpAmount: number;
  38087. private _minYaw;
  38088. private _maxYaw;
  38089. private _minPitch;
  38090. private _maxPitch;
  38091. private _minYawSin;
  38092. private _minYawCos;
  38093. private _maxYawSin;
  38094. private _maxYawCos;
  38095. private _midYawConstraint;
  38096. private _minPitchTan;
  38097. private _maxPitchTan;
  38098. private _boneQuat;
  38099. private _slerping;
  38100. private _transformYawPitch;
  38101. private _transformYawPitchInv;
  38102. private _firstFrameSkipped;
  38103. private _yawRange;
  38104. private _fowardAxis;
  38105. /**
  38106. * Gets or sets the minimum yaw angle that the bone can look to
  38107. */
  38108. minYaw: number;
  38109. /**
  38110. * Gets or sets the maximum yaw angle that the bone can look to
  38111. */
  38112. maxYaw: number;
  38113. /**
  38114. * Gets or sets the minimum pitch angle that the bone can look to
  38115. */
  38116. minPitch: number;
  38117. /**
  38118. * Gets or sets the maximum pitch angle that the bone can look to
  38119. */
  38120. maxPitch: number;
  38121. /**
  38122. * Create a BoneLookController
  38123. * @param mesh the mesh that the bone belongs to
  38124. * @param bone the bone that will be looking to the target
  38125. * @param target the target Vector3 to look at
  38126. * @param options optional settings:
  38127. * * maxYaw: the maximum angle the bone will yaw to
  38128. * * minYaw: the minimum angle the bone will yaw to
  38129. * * maxPitch: the maximum angle the bone will pitch to
  38130. * * minPitch: the minimum angle the bone will yaw to
  38131. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38132. * * upAxis: the up axis of the coordinate system
  38133. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38134. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38135. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38136. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38137. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38138. * * adjustRoll: used to make an adjustment to the roll of the bone
  38139. **/
  38140. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38141. maxYaw?: number;
  38142. minYaw?: number;
  38143. maxPitch?: number;
  38144. minPitch?: number;
  38145. slerpAmount?: number;
  38146. upAxis?: Vector3;
  38147. upAxisSpace?: Space;
  38148. yawAxis?: Vector3;
  38149. pitchAxis?: Vector3;
  38150. adjustYaw?: number;
  38151. adjustPitch?: number;
  38152. adjustRoll?: number;
  38153. });
  38154. /**
  38155. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38156. */
  38157. update(): void;
  38158. private _getAngleDiff;
  38159. private _getAngleBetween;
  38160. private _isAngleBetween;
  38161. }
  38162. }
  38163. declare module "babylonjs/Bones/index" {
  38164. export * from "babylonjs/Bones/bone";
  38165. export * from "babylonjs/Bones/boneIKController";
  38166. export * from "babylonjs/Bones/boneLookController";
  38167. export * from "babylonjs/Bones/skeleton";
  38168. }
  38169. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38170. import { Nullable } from "babylonjs/types";
  38171. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38172. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38173. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38174. /**
  38175. * Manage the gamepad inputs to control an arc rotate camera.
  38176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38177. */
  38178. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38179. /**
  38180. * Defines the camera the input is attached to.
  38181. */
  38182. camera: ArcRotateCamera;
  38183. /**
  38184. * Defines the gamepad the input is gathering event from.
  38185. */
  38186. gamepad: Nullable<Gamepad>;
  38187. /**
  38188. * Defines the gamepad rotation sensiblity.
  38189. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38190. */
  38191. gamepadRotationSensibility: number;
  38192. /**
  38193. * Defines the gamepad move sensiblity.
  38194. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38195. */
  38196. gamepadMoveSensibility: number;
  38197. private _onGamepadConnectedObserver;
  38198. private _onGamepadDisconnectedObserver;
  38199. /**
  38200. * Attach the input controls to a specific dom element to get the input from.
  38201. * @param element Defines the element the controls should be listened from
  38202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38203. */
  38204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38205. /**
  38206. * Detach the current controls from the specified dom element.
  38207. * @param element Defines the element to stop listening the inputs from
  38208. */
  38209. detachControl(element: Nullable<HTMLElement>): void;
  38210. /**
  38211. * Update the current camera state depending on the inputs that have been used this frame.
  38212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38213. */
  38214. checkInputs(): void;
  38215. /**
  38216. * Gets the class name of the current intput.
  38217. * @returns the class name
  38218. */
  38219. getClassName(): string;
  38220. /**
  38221. * Get the friendly name associated with the input class.
  38222. * @returns the input friendly name
  38223. */
  38224. getSimpleName(): string;
  38225. }
  38226. }
  38227. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38228. import { Nullable } from "babylonjs/types";
  38229. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38230. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38231. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38232. interface ArcRotateCameraInputsManager {
  38233. /**
  38234. * Add orientation input support to the input manager.
  38235. * @returns the current input manager
  38236. */
  38237. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38238. }
  38239. }
  38240. /**
  38241. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38243. */
  38244. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38245. /**
  38246. * Defines the camera the input is attached to.
  38247. */
  38248. camera: ArcRotateCamera;
  38249. /**
  38250. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38251. */
  38252. alphaCorrection: number;
  38253. /**
  38254. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38255. */
  38256. gammaCorrection: number;
  38257. private _alpha;
  38258. private _gamma;
  38259. private _dirty;
  38260. private _deviceOrientationHandler;
  38261. /**
  38262. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38263. */
  38264. constructor();
  38265. /**
  38266. * Attach the input controls to a specific dom element to get the input from.
  38267. * @param element Defines the element the controls should be listened from
  38268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38269. */
  38270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38271. /** @hidden */
  38272. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38273. /**
  38274. * Update the current camera state depending on the inputs that have been used this frame.
  38275. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38276. */
  38277. checkInputs(): void;
  38278. /**
  38279. * Detach the current controls from the specified dom element.
  38280. * @param element Defines the element to stop listening the inputs from
  38281. */
  38282. detachControl(element: Nullable<HTMLElement>): void;
  38283. /**
  38284. * Gets the class name of the current intput.
  38285. * @returns the class name
  38286. */
  38287. getClassName(): string;
  38288. /**
  38289. * Get the friendly name associated with the input class.
  38290. * @returns the input friendly name
  38291. */
  38292. getSimpleName(): string;
  38293. }
  38294. }
  38295. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38296. import { Nullable } from "babylonjs/types";
  38297. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38298. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38299. /**
  38300. * Listen to mouse events to control the camera.
  38301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38302. */
  38303. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38304. /**
  38305. * Defines the camera the input is attached to.
  38306. */
  38307. camera: FlyCamera;
  38308. /**
  38309. * Defines if touch is enabled. (Default is true.)
  38310. */
  38311. touchEnabled: boolean;
  38312. /**
  38313. * Defines the buttons associated with the input to handle camera rotation.
  38314. */
  38315. buttons: number[];
  38316. /**
  38317. * Assign buttons for Yaw control.
  38318. */
  38319. buttonsYaw: number[];
  38320. /**
  38321. * Assign buttons for Pitch control.
  38322. */
  38323. buttonsPitch: number[];
  38324. /**
  38325. * Assign buttons for Roll control.
  38326. */
  38327. buttonsRoll: number[];
  38328. /**
  38329. * Detect if any button is being pressed while mouse is moved.
  38330. * -1 = Mouse locked.
  38331. * 0 = Left button.
  38332. * 1 = Middle Button.
  38333. * 2 = Right Button.
  38334. */
  38335. activeButton: number;
  38336. /**
  38337. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38338. * Higher values reduce its sensitivity.
  38339. */
  38340. angularSensibility: number;
  38341. private _mousemoveCallback;
  38342. private _observer;
  38343. private _rollObserver;
  38344. private previousPosition;
  38345. private noPreventDefault;
  38346. private element;
  38347. /**
  38348. * Listen to mouse events to control the camera.
  38349. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38351. */
  38352. constructor(touchEnabled?: boolean);
  38353. /**
  38354. * Attach the mouse control to the HTML DOM element.
  38355. * @param element Defines the element that listens to the input events.
  38356. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38357. */
  38358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38359. /**
  38360. * Detach the current controls from the specified dom element.
  38361. * @param element Defines the element to stop listening the inputs from
  38362. */
  38363. detachControl(element: Nullable<HTMLElement>): void;
  38364. /**
  38365. * Gets the class name of the current input.
  38366. * @returns the class name.
  38367. */
  38368. getClassName(): string;
  38369. /**
  38370. * Get the friendly name associated with the input class.
  38371. * @returns the input's friendly name.
  38372. */
  38373. getSimpleName(): string;
  38374. private _pointerInput;
  38375. private _onMouseMove;
  38376. /**
  38377. * Rotate camera by mouse offset.
  38378. */
  38379. private rotateCamera;
  38380. }
  38381. }
  38382. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38383. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38384. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38385. /**
  38386. * Default Inputs manager for the FlyCamera.
  38387. * It groups all the default supported inputs for ease of use.
  38388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38389. */
  38390. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38391. /**
  38392. * Instantiates a new FlyCameraInputsManager.
  38393. * @param camera Defines the camera the inputs belong to.
  38394. */
  38395. constructor(camera: FlyCamera);
  38396. /**
  38397. * Add keyboard input support to the input manager.
  38398. * @returns the new FlyCameraKeyboardMoveInput().
  38399. */
  38400. addKeyboard(): FlyCameraInputsManager;
  38401. /**
  38402. * Add mouse input support to the input manager.
  38403. * @param touchEnabled Enable touch screen support.
  38404. * @returns the new FlyCameraMouseInput().
  38405. */
  38406. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38407. }
  38408. }
  38409. declare module "babylonjs/Cameras/flyCamera" {
  38410. import { Scene } from "babylonjs/scene";
  38411. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38413. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38414. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38415. /**
  38416. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38417. * such as in a 3D Space Shooter or a Flight Simulator.
  38418. */
  38419. export class FlyCamera extends TargetCamera {
  38420. /**
  38421. * Define the collision ellipsoid of the camera.
  38422. * This is helpful for simulating a camera body, like a player's body.
  38423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38424. */
  38425. ellipsoid: Vector3;
  38426. /**
  38427. * Define an offset for the position of the ellipsoid around the camera.
  38428. * This can be helpful if the camera is attached away from the player's body center,
  38429. * such as at its head.
  38430. */
  38431. ellipsoidOffset: Vector3;
  38432. /**
  38433. * Enable or disable collisions of the camera with the rest of the scene objects.
  38434. */
  38435. checkCollisions: boolean;
  38436. /**
  38437. * Enable or disable gravity on the camera.
  38438. */
  38439. applyGravity: boolean;
  38440. /**
  38441. * Define the current direction the camera is moving to.
  38442. */
  38443. cameraDirection: Vector3;
  38444. /**
  38445. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38446. * This overrides and empties cameraRotation.
  38447. */
  38448. rotationQuaternion: Quaternion;
  38449. /**
  38450. * Track Roll to maintain the wanted Rolling when looking around.
  38451. */
  38452. _trackRoll: number;
  38453. /**
  38454. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38455. */
  38456. rollCorrect: number;
  38457. /**
  38458. * Mimic a banked turn, Rolling the camera when Yawing.
  38459. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38460. */
  38461. bankedTurn: boolean;
  38462. /**
  38463. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38464. */
  38465. bankedTurnLimit: number;
  38466. /**
  38467. * Value of 0 disables the banked Roll.
  38468. * Value of 1 is equal to the Yaw angle in radians.
  38469. */
  38470. bankedTurnMultiplier: number;
  38471. /**
  38472. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38473. */
  38474. inputs: FlyCameraInputsManager;
  38475. /**
  38476. * Gets the input sensibility for mouse input.
  38477. * Higher values reduce sensitivity.
  38478. */
  38479. /**
  38480. * Sets the input sensibility for a mouse input.
  38481. * Higher values reduce sensitivity.
  38482. */
  38483. angularSensibility: number;
  38484. /**
  38485. * Get the keys for camera movement forward.
  38486. */
  38487. /**
  38488. * Set the keys for camera movement forward.
  38489. */
  38490. keysForward: number[];
  38491. /**
  38492. * Get the keys for camera movement backward.
  38493. */
  38494. keysBackward: number[];
  38495. /**
  38496. * Get the keys for camera movement up.
  38497. */
  38498. /**
  38499. * Set the keys for camera movement up.
  38500. */
  38501. keysUp: number[];
  38502. /**
  38503. * Get the keys for camera movement down.
  38504. */
  38505. /**
  38506. * Set the keys for camera movement down.
  38507. */
  38508. keysDown: number[];
  38509. /**
  38510. * Get the keys for camera movement left.
  38511. */
  38512. /**
  38513. * Set the keys for camera movement left.
  38514. */
  38515. keysLeft: number[];
  38516. /**
  38517. * Set the keys for camera movement right.
  38518. */
  38519. /**
  38520. * Set the keys for camera movement right.
  38521. */
  38522. keysRight: number[];
  38523. /**
  38524. * Event raised when the camera collides with a mesh in the scene.
  38525. */
  38526. onCollide: (collidedMesh: AbstractMesh) => void;
  38527. private _collider;
  38528. private _needMoveForGravity;
  38529. private _oldPosition;
  38530. private _diffPosition;
  38531. private _newPosition;
  38532. /** @hidden */
  38533. _localDirection: Vector3;
  38534. /** @hidden */
  38535. _transformedDirection: Vector3;
  38536. /**
  38537. * Instantiates a FlyCamera.
  38538. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38539. * such as in a 3D Space Shooter or a Flight Simulator.
  38540. * @param name Define the name of the camera in the scene.
  38541. * @param position Define the starting position of the camera in the scene.
  38542. * @param scene Define the scene the camera belongs to.
  38543. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38544. */
  38545. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38546. /**
  38547. * Attach a control to the HTML DOM element.
  38548. * @param element Defines the element that listens to the input events.
  38549. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38550. */
  38551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38552. /**
  38553. * Detach a control from the HTML DOM element.
  38554. * The camera will stop reacting to that input.
  38555. * @param element Defines the element that listens to the input events.
  38556. */
  38557. detachControl(element: HTMLElement): void;
  38558. private _collisionMask;
  38559. /**
  38560. * Get the mask that the camera ignores in collision events.
  38561. */
  38562. /**
  38563. * Set the mask that the camera ignores in collision events.
  38564. */
  38565. collisionMask: number;
  38566. /** @hidden */
  38567. _collideWithWorld(displacement: Vector3): void;
  38568. /** @hidden */
  38569. private _onCollisionPositionChange;
  38570. /** @hidden */
  38571. _checkInputs(): void;
  38572. /** @hidden */
  38573. _decideIfNeedsToMove(): boolean;
  38574. /** @hidden */
  38575. _updatePosition(): void;
  38576. /**
  38577. * Restore the Roll to its target value at the rate specified.
  38578. * @param rate - Higher means slower restoring.
  38579. * @hidden
  38580. */
  38581. restoreRoll(rate: number): void;
  38582. /**
  38583. * Destroy the camera and release the current resources held by it.
  38584. */
  38585. dispose(): void;
  38586. /**
  38587. * Get the current object class name.
  38588. * @returns the class name.
  38589. */
  38590. getClassName(): string;
  38591. }
  38592. }
  38593. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38594. import { Nullable } from "babylonjs/types";
  38595. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38596. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38597. /**
  38598. * Listen to keyboard events to control the camera.
  38599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38600. */
  38601. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38602. /**
  38603. * Defines the camera the input is attached to.
  38604. */
  38605. camera: FlyCamera;
  38606. /**
  38607. * The list of keyboard keys used to control the forward move of the camera.
  38608. */
  38609. keysForward: number[];
  38610. /**
  38611. * The list of keyboard keys used to control the backward move of the camera.
  38612. */
  38613. keysBackward: number[];
  38614. /**
  38615. * The list of keyboard keys used to control the forward move of the camera.
  38616. */
  38617. keysUp: number[];
  38618. /**
  38619. * The list of keyboard keys used to control the backward move of the camera.
  38620. */
  38621. keysDown: number[];
  38622. /**
  38623. * The list of keyboard keys used to control the right strafe move of the camera.
  38624. */
  38625. keysRight: number[];
  38626. /**
  38627. * The list of keyboard keys used to control the left strafe move of the camera.
  38628. */
  38629. keysLeft: number[];
  38630. private _keys;
  38631. private _onCanvasBlurObserver;
  38632. private _onKeyboardObserver;
  38633. private _engine;
  38634. private _scene;
  38635. /**
  38636. * Attach the input controls to a specific dom element to get the input from.
  38637. * @param element Defines the element the controls should be listened from
  38638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38639. */
  38640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38641. /**
  38642. * Detach the current controls from the specified dom element.
  38643. * @param element Defines the element to stop listening the inputs from
  38644. */
  38645. detachControl(element: Nullable<HTMLElement>): void;
  38646. /**
  38647. * Gets the class name of the current intput.
  38648. * @returns the class name
  38649. */
  38650. getClassName(): string;
  38651. /** @hidden */
  38652. _onLostFocus(e: FocusEvent): void;
  38653. /**
  38654. * Get the friendly name associated with the input class.
  38655. * @returns the input friendly name
  38656. */
  38657. getSimpleName(): string;
  38658. /**
  38659. * Update the current camera state depending on the inputs that have been used this frame.
  38660. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38661. */
  38662. checkInputs(): void;
  38663. }
  38664. }
  38665. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38666. import { Nullable } from "babylonjs/types";
  38667. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38668. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38669. /**
  38670. * Manage the mouse wheel inputs to control a follow camera.
  38671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38672. */
  38673. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38674. /**
  38675. * Defines the camera the input is attached to.
  38676. */
  38677. camera: FollowCamera;
  38678. /**
  38679. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38680. */
  38681. axisControlRadius: boolean;
  38682. /**
  38683. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38684. */
  38685. axisControlHeight: boolean;
  38686. /**
  38687. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38688. */
  38689. axisControlRotation: boolean;
  38690. /**
  38691. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38692. * relation to mouseWheel events.
  38693. */
  38694. wheelPrecision: number;
  38695. /**
  38696. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38697. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38698. */
  38699. wheelDeltaPercentage: number;
  38700. private _wheel;
  38701. private _observer;
  38702. /**
  38703. * Attach the input controls to a specific dom element to get the input from.
  38704. * @param element Defines the element the controls should be listened from
  38705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38706. */
  38707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38708. /**
  38709. * Detach the current controls from the specified dom element.
  38710. * @param element Defines the element to stop listening the inputs from
  38711. */
  38712. detachControl(element: Nullable<HTMLElement>): void;
  38713. /**
  38714. * Gets the class name of the current intput.
  38715. * @returns the class name
  38716. */
  38717. getClassName(): string;
  38718. /**
  38719. * Get the friendly name associated with the input class.
  38720. * @returns the input friendly name
  38721. */
  38722. getSimpleName(): string;
  38723. }
  38724. }
  38725. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38726. import { Nullable } from "babylonjs/types";
  38727. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38728. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38729. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38730. /**
  38731. * Manage the pointers inputs to control an follow camera.
  38732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38733. */
  38734. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38735. /**
  38736. * Defines the camera the input is attached to.
  38737. */
  38738. camera: FollowCamera;
  38739. /**
  38740. * Gets the class name of the current input.
  38741. * @returns the class name
  38742. */
  38743. getClassName(): string;
  38744. /**
  38745. * Defines the pointer angular sensibility along the X axis or how fast is
  38746. * the camera rotating.
  38747. * A negative number will reverse the axis direction.
  38748. */
  38749. angularSensibilityX: number;
  38750. /**
  38751. * Defines the pointer angular sensibility along the Y axis or how fast is
  38752. * the camera rotating.
  38753. * A negative number will reverse the axis direction.
  38754. */
  38755. angularSensibilityY: number;
  38756. /**
  38757. * Defines the pointer pinch precision or how fast is the camera zooming.
  38758. * A negative number will reverse the axis direction.
  38759. */
  38760. pinchPrecision: number;
  38761. /**
  38762. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38763. * from 0.
  38764. * It defines the percentage of current camera.radius to use as delta when
  38765. * pinch zoom is used.
  38766. */
  38767. pinchDeltaPercentage: number;
  38768. /**
  38769. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38770. */
  38771. axisXControlRadius: boolean;
  38772. /**
  38773. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38774. */
  38775. axisXControlHeight: boolean;
  38776. /**
  38777. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38778. */
  38779. axisXControlRotation: boolean;
  38780. /**
  38781. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38782. */
  38783. axisYControlRadius: boolean;
  38784. /**
  38785. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38786. */
  38787. axisYControlHeight: boolean;
  38788. /**
  38789. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38790. */
  38791. axisYControlRotation: boolean;
  38792. /**
  38793. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38794. */
  38795. axisPinchControlRadius: boolean;
  38796. /**
  38797. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38798. */
  38799. axisPinchControlHeight: boolean;
  38800. /**
  38801. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38802. */
  38803. axisPinchControlRotation: boolean;
  38804. /**
  38805. * Log error messages if basic misconfiguration has occurred.
  38806. */
  38807. warningEnable: boolean;
  38808. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38809. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38810. private _warningCounter;
  38811. private _warning;
  38812. }
  38813. }
  38814. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38815. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38816. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38817. /**
  38818. * Default Inputs manager for the FollowCamera.
  38819. * It groups all the default supported inputs for ease of use.
  38820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38821. */
  38822. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38823. /**
  38824. * Instantiates a new FollowCameraInputsManager.
  38825. * @param camera Defines the camera the inputs belong to
  38826. */
  38827. constructor(camera: FollowCamera);
  38828. /**
  38829. * Add keyboard input support to the input manager.
  38830. * @returns the current input manager
  38831. */
  38832. addKeyboard(): FollowCameraInputsManager;
  38833. /**
  38834. * Add mouse wheel input support to the input manager.
  38835. * @returns the current input manager
  38836. */
  38837. addMouseWheel(): FollowCameraInputsManager;
  38838. /**
  38839. * Add pointers input support to the input manager.
  38840. * @returns the current input manager
  38841. */
  38842. addPointers(): FollowCameraInputsManager;
  38843. /**
  38844. * Add orientation input support to the input manager.
  38845. * @returns the current input manager
  38846. */
  38847. addVRDeviceOrientation(): FollowCameraInputsManager;
  38848. }
  38849. }
  38850. declare module "babylonjs/Cameras/followCamera" {
  38851. import { Nullable } from "babylonjs/types";
  38852. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38853. import { Scene } from "babylonjs/scene";
  38854. import { Vector3 } from "babylonjs/Maths/math.vector";
  38855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38856. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38857. /**
  38858. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38859. * an arc rotate version arcFollowCamera are available.
  38860. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38861. */
  38862. export class FollowCamera extends TargetCamera {
  38863. /**
  38864. * Distance the follow camera should follow an object at
  38865. */
  38866. radius: number;
  38867. /**
  38868. * Minimum allowed distance of the camera to the axis of rotation
  38869. * (The camera can not get closer).
  38870. * This can help limiting how the Camera is able to move in the scene.
  38871. */
  38872. lowerRadiusLimit: Nullable<number>;
  38873. /**
  38874. * Maximum allowed distance of the camera to the axis of rotation
  38875. * (The camera can not get further).
  38876. * This can help limiting how the Camera is able to move in the scene.
  38877. */
  38878. upperRadiusLimit: Nullable<number>;
  38879. /**
  38880. * Define a rotation offset between the camera and the object it follows
  38881. */
  38882. rotationOffset: number;
  38883. /**
  38884. * Minimum allowed angle to camera position relative to target object.
  38885. * This can help limiting how the Camera is able to move in the scene.
  38886. */
  38887. lowerRotationOffsetLimit: Nullable<number>;
  38888. /**
  38889. * Maximum allowed angle to camera position relative to target object.
  38890. * This can help limiting how the Camera is able to move in the scene.
  38891. */
  38892. upperRotationOffsetLimit: Nullable<number>;
  38893. /**
  38894. * Define a height offset between the camera and the object it follows.
  38895. * It can help following an object from the top (like a car chaing a plane)
  38896. */
  38897. heightOffset: number;
  38898. /**
  38899. * Minimum allowed height of camera position relative to target object.
  38900. * This can help limiting how the Camera is able to move in the scene.
  38901. */
  38902. lowerHeightOffsetLimit: Nullable<number>;
  38903. /**
  38904. * Maximum allowed height of camera position relative to target object.
  38905. * This can help limiting how the Camera is able to move in the scene.
  38906. */
  38907. upperHeightOffsetLimit: Nullable<number>;
  38908. /**
  38909. * Define how fast the camera can accelerate to follow it s target.
  38910. */
  38911. cameraAcceleration: number;
  38912. /**
  38913. * Define the speed limit of the camera following an object.
  38914. */
  38915. maxCameraSpeed: number;
  38916. /**
  38917. * Define the target of the camera.
  38918. */
  38919. lockedTarget: Nullable<AbstractMesh>;
  38920. /**
  38921. * Defines the input associated with the camera.
  38922. */
  38923. inputs: FollowCameraInputsManager;
  38924. /**
  38925. * Instantiates the follow camera.
  38926. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38927. * @param name Define the name of the camera in the scene
  38928. * @param position Define the position of the camera
  38929. * @param scene Define the scene the camera belong to
  38930. * @param lockedTarget Define the target of the camera
  38931. */
  38932. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38933. private _follow;
  38934. /**
  38935. * Attached controls to the current camera.
  38936. * @param element Defines the element the controls should be listened from
  38937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38938. */
  38939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38940. /**
  38941. * Detach the current controls from the camera.
  38942. * The camera will stop reacting to inputs.
  38943. * @param element Defines the element to stop listening the inputs from
  38944. */
  38945. detachControl(element: HTMLElement): void;
  38946. /** @hidden */
  38947. _checkInputs(): void;
  38948. private _checkLimits;
  38949. /**
  38950. * Gets the camera class name.
  38951. * @returns the class name
  38952. */
  38953. getClassName(): string;
  38954. }
  38955. /**
  38956. * Arc Rotate version of the follow camera.
  38957. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38958. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38959. */
  38960. export class ArcFollowCamera extends TargetCamera {
  38961. /** The longitudinal angle of the camera */
  38962. alpha: number;
  38963. /** The latitudinal angle of the camera */
  38964. beta: number;
  38965. /** The radius of the camera from its target */
  38966. radius: number;
  38967. /** Define the camera target (the messh it should follow) */
  38968. target: Nullable<AbstractMesh>;
  38969. private _cartesianCoordinates;
  38970. /**
  38971. * Instantiates a new ArcFollowCamera
  38972. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38973. * @param name Define the name of the camera
  38974. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38975. * @param beta Define the rotation angle of the camera around the elevation axis
  38976. * @param radius Define the radius of the camera from its target point
  38977. * @param target Define the target of the camera
  38978. * @param scene Define the scene the camera belongs to
  38979. */
  38980. constructor(name: string,
  38981. /** The longitudinal angle of the camera */
  38982. alpha: number,
  38983. /** The latitudinal angle of the camera */
  38984. beta: number,
  38985. /** The radius of the camera from its target */
  38986. radius: number,
  38987. /** Define the camera target (the messh it should follow) */
  38988. target: Nullable<AbstractMesh>, scene: Scene);
  38989. private _follow;
  38990. /** @hidden */
  38991. _checkInputs(): void;
  38992. /**
  38993. * Returns the class name of the object.
  38994. * It is mostly used internally for serialization purposes.
  38995. */
  38996. getClassName(): string;
  38997. }
  38998. }
  38999. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39000. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39001. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39002. import { Nullable } from "babylonjs/types";
  39003. /**
  39004. * Manage the keyboard inputs to control the movement of a follow camera.
  39005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39006. */
  39007. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39008. /**
  39009. * Defines the camera the input is attached to.
  39010. */
  39011. camera: FollowCamera;
  39012. /**
  39013. * Defines the list of key codes associated with the up action (increase heightOffset)
  39014. */
  39015. keysHeightOffsetIncr: number[];
  39016. /**
  39017. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39018. */
  39019. keysHeightOffsetDecr: number[];
  39020. /**
  39021. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39022. */
  39023. keysHeightOffsetModifierAlt: boolean;
  39024. /**
  39025. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39026. */
  39027. keysHeightOffsetModifierCtrl: boolean;
  39028. /**
  39029. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39030. */
  39031. keysHeightOffsetModifierShift: boolean;
  39032. /**
  39033. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39034. */
  39035. keysRotationOffsetIncr: number[];
  39036. /**
  39037. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39038. */
  39039. keysRotationOffsetDecr: number[];
  39040. /**
  39041. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39042. */
  39043. keysRotationOffsetModifierAlt: boolean;
  39044. /**
  39045. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39046. */
  39047. keysRotationOffsetModifierCtrl: boolean;
  39048. /**
  39049. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39050. */
  39051. keysRotationOffsetModifierShift: boolean;
  39052. /**
  39053. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39054. */
  39055. keysRadiusIncr: number[];
  39056. /**
  39057. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39058. */
  39059. keysRadiusDecr: number[];
  39060. /**
  39061. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39062. */
  39063. keysRadiusModifierAlt: boolean;
  39064. /**
  39065. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39066. */
  39067. keysRadiusModifierCtrl: boolean;
  39068. /**
  39069. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39070. */
  39071. keysRadiusModifierShift: boolean;
  39072. /**
  39073. * Defines the rate of change of heightOffset.
  39074. */
  39075. heightSensibility: number;
  39076. /**
  39077. * Defines the rate of change of rotationOffset.
  39078. */
  39079. rotationSensibility: number;
  39080. /**
  39081. * Defines the rate of change of radius.
  39082. */
  39083. radiusSensibility: number;
  39084. private _keys;
  39085. private _ctrlPressed;
  39086. private _altPressed;
  39087. private _shiftPressed;
  39088. private _onCanvasBlurObserver;
  39089. private _onKeyboardObserver;
  39090. private _engine;
  39091. private _scene;
  39092. /**
  39093. * Attach the input controls to a specific dom element to get the input from.
  39094. * @param element Defines the element the controls should be listened from
  39095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39096. */
  39097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39098. /**
  39099. * Detach the current controls from the specified dom element.
  39100. * @param element Defines the element to stop listening the inputs from
  39101. */
  39102. detachControl(element: Nullable<HTMLElement>): void;
  39103. /**
  39104. * Update the current camera state depending on the inputs that have been used this frame.
  39105. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39106. */
  39107. checkInputs(): void;
  39108. /**
  39109. * Gets the class name of the current input.
  39110. * @returns the class name
  39111. */
  39112. getClassName(): string;
  39113. /**
  39114. * Get the friendly name associated with the input class.
  39115. * @returns the input friendly name
  39116. */
  39117. getSimpleName(): string;
  39118. /**
  39119. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39120. * allow modification of the heightOffset value.
  39121. */
  39122. private _modifierHeightOffset;
  39123. /**
  39124. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39125. * allow modification of the rotationOffset value.
  39126. */
  39127. private _modifierRotationOffset;
  39128. /**
  39129. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39130. * allow modification of the radius value.
  39131. */
  39132. private _modifierRadius;
  39133. }
  39134. }
  39135. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39136. import { Nullable } from "babylonjs/types";
  39137. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39138. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39139. import { Observable } from "babylonjs/Misc/observable";
  39140. module "babylonjs/Cameras/freeCameraInputsManager" {
  39141. interface FreeCameraInputsManager {
  39142. /**
  39143. * @hidden
  39144. */
  39145. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39146. /**
  39147. * Add orientation input support to the input manager.
  39148. * @returns the current input manager
  39149. */
  39150. addDeviceOrientation(): FreeCameraInputsManager;
  39151. }
  39152. }
  39153. /**
  39154. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39155. * Screen rotation is taken into account.
  39156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39157. */
  39158. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39159. private _camera;
  39160. private _screenOrientationAngle;
  39161. private _constantTranform;
  39162. private _screenQuaternion;
  39163. private _alpha;
  39164. private _beta;
  39165. private _gamma;
  39166. /**
  39167. * Can be used to detect if a device orientation sensor is availible on a device
  39168. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39169. * @returns a promise that will resolve on orientation change
  39170. */
  39171. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39172. /**
  39173. * @hidden
  39174. */
  39175. _onDeviceOrientationChangedObservable: Observable<void>;
  39176. /**
  39177. * Instantiates a new input
  39178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39179. */
  39180. constructor();
  39181. /**
  39182. * Define the camera controlled by the input.
  39183. */
  39184. camera: FreeCamera;
  39185. /**
  39186. * Attach the input controls to a specific dom element to get the input from.
  39187. * @param element Defines the element the controls should be listened from
  39188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39189. */
  39190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39191. private _orientationChanged;
  39192. private _deviceOrientation;
  39193. /**
  39194. * Detach the current controls from the specified dom element.
  39195. * @param element Defines the element to stop listening the inputs from
  39196. */
  39197. detachControl(element: Nullable<HTMLElement>): void;
  39198. /**
  39199. * Update the current camera state depending on the inputs that have been used this frame.
  39200. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39201. */
  39202. checkInputs(): void;
  39203. /**
  39204. * Gets the class name of the current intput.
  39205. * @returns the class name
  39206. */
  39207. getClassName(): string;
  39208. /**
  39209. * Get the friendly name associated with the input class.
  39210. * @returns the input friendly name
  39211. */
  39212. getSimpleName(): string;
  39213. }
  39214. }
  39215. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39216. import { Nullable } from "babylonjs/types";
  39217. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39218. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39219. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39220. /**
  39221. * Manage the gamepad inputs to control a free camera.
  39222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39223. */
  39224. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39225. /**
  39226. * Define the camera the input is attached to.
  39227. */
  39228. camera: FreeCamera;
  39229. /**
  39230. * Define the Gamepad controlling the input
  39231. */
  39232. gamepad: Nullable<Gamepad>;
  39233. /**
  39234. * Defines the gamepad rotation sensiblity.
  39235. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39236. */
  39237. gamepadAngularSensibility: number;
  39238. /**
  39239. * Defines the gamepad move sensiblity.
  39240. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39241. */
  39242. gamepadMoveSensibility: number;
  39243. private _onGamepadConnectedObserver;
  39244. private _onGamepadDisconnectedObserver;
  39245. private _cameraTransform;
  39246. private _deltaTransform;
  39247. private _vector3;
  39248. private _vector2;
  39249. /**
  39250. * Attach the input controls to a specific dom element to get the input from.
  39251. * @param element Defines the element the controls should be listened from
  39252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39253. */
  39254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39255. /**
  39256. * Detach the current controls from the specified dom element.
  39257. * @param element Defines the element to stop listening the inputs from
  39258. */
  39259. detachControl(element: Nullable<HTMLElement>): void;
  39260. /**
  39261. * Update the current camera state depending on the inputs that have been used this frame.
  39262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39263. */
  39264. checkInputs(): void;
  39265. /**
  39266. * Gets the class name of the current intput.
  39267. * @returns the class name
  39268. */
  39269. getClassName(): string;
  39270. /**
  39271. * Get the friendly name associated with the input class.
  39272. * @returns the input friendly name
  39273. */
  39274. getSimpleName(): string;
  39275. }
  39276. }
  39277. declare module "babylonjs/Misc/virtualJoystick" {
  39278. import { Nullable } from "babylonjs/types";
  39279. import { Vector3 } from "babylonjs/Maths/math.vector";
  39280. /**
  39281. * Defines the potential axis of a Joystick
  39282. */
  39283. export enum JoystickAxis {
  39284. /** X axis */
  39285. X = 0,
  39286. /** Y axis */
  39287. Y = 1,
  39288. /** Z axis */
  39289. Z = 2
  39290. }
  39291. /**
  39292. * Class used to define virtual joystick (used in touch mode)
  39293. */
  39294. export class VirtualJoystick {
  39295. /**
  39296. * Gets or sets a boolean indicating that left and right values must be inverted
  39297. */
  39298. reverseLeftRight: boolean;
  39299. /**
  39300. * Gets or sets a boolean indicating that up and down values must be inverted
  39301. */
  39302. reverseUpDown: boolean;
  39303. /**
  39304. * Gets the offset value for the position (ie. the change of the position value)
  39305. */
  39306. deltaPosition: Vector3;
  39307. /**
  39308. * Gets a boolean indicating if the virtual joystick was pressed
  39309. */
  39310. pressed: boolean;
  39311. /**
  39312. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39313. */
  39314. static Canvas: Nullable<HTMLCanvasElement>;
  39315. private static _globalJoystickIndex;
  39316. private static vjCanvasContext;
  39317. private static vjCanvasWidth;
  39318. private static vjCanvasHeight;
  39319. private static halfWidth;
  39320. private _action;
  39321. private _axisTargetedByLeftAndRight;
  39322. private _axisTargetedByUpAndDown;
  39323. private _joystickSensibility;
  39324. private _inversedSensibility;
  39325. private _joystickPointerID;
  39326. private _joystickColor;
  39327. private _joystickPointerPos;
  39328. private _joystickPreviousPointerPos;
  39329. private _joystickPointerStartPos;
  39330. private _deltaJoystickVector;
  39331. private _leftJoystick;
  39332. private _touches;
  39333. private _onPointerDownHandlerRef;
  39334. private _onPointerMoveHandlerRef;
  39335. private _onPointerUpHandlerRef;
  39336. private _onResize;
  39337. /**
  39338. * Creates a new virtual joystick
  39339. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39340. */
  39341. constructor(leftJoystick?: boolean);
  39342. /**
  39343. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39344. * @param newJoystickSensibility defines the new sensibility
  39345. */
  39346. setJoystickSensibility(newJoystickSensibility: number): void;
  39347. private _onPointerDown;
  39348. private _onPointerMove;
  39349. private _onPointerUp;
  39350. /**
  39351. * Change the color of the virtual joystick
  39352. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39353. */
  39354. setJoystickColor(newColor: string): void;
  39355. /**
  39356. * Defines a callback to call when the joystick is touched
  39357. * @param action defines the callback
  39358. */
  39359. setActionOnTouch(action: () => any): void;
  39360. /**
  39361. * Defines which axis you'd like to control for left & right
  39362. * @param axis defines the axis to use
  39363. */
  39364. setAxisForLeftRight(axis: JoystickAxis): void;
  39365. /**
  39366. * Defines which axis you'd like to control for up & down
  39367. * @param axis defines the axis to use
  39368. */
  39369. setAxisForUpDown(axis: JoystickAxis): void;
  39370. private _drawVirtualJoystick;
  39371. /**
  39372. * Release internal HTML canvas
  39373. */
  39374. releaseCanvas(): void;
  39375. }
  39376. }
  39377. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39378. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39379. import { Nullable } from "babylonjs/types";
  39380. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39381. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39382. module "babylonjs/Cameras/freeCameraInputsManager" {
  39383. interface FreeCameraInputsManager {
  39384. /**
  39385. * Add virtual joystick input support to the input manager.
  39386. * @returns the current input manager
  39387. */
  39388. addVirtualJoystick(): FreeCameraInputsManager;
  39389. }
  39390. }
  39391. /**
  39392. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39394. */
  39395. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39396. /**
  39397. * Defines the camera the input is attached to.
  39398. */
  39399. camera: FreeCamera;
  39400. private _leftjoystick;
  39401. private _rightjoystick;
  39402. /**
  39403. * Gets the left stick of the virtual joystick.
  39404. * @returns The virtual Joystick
  39405. */
  39406. getLeftJoystick(): VirtualJoystick;
  39407. /**
  39408. * Gets the right stick of the virtual joystick.
  39409. * @returns The virtual Joystick
  39410. */
  39411. getRightJoystick(): VirtualJoystick;
  39412. /**
  39413. * Update the current camera state depending on the inputs that have been used this frame.
  39414. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39415. */
  39416. checkInputs(): void;
  39417. /**
  39418. * Attach the input controls to a specific dom element to get the input from.
  39419. * @param element Defines the element the controls should be listened from
  39420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39421. */
  39422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39423. /**
  39424. * Detach the current controls from the specified dom element.
  39425. * @param element Defines the element to stop listening the inputs from
  39426. */
  39427. detachControl(element: Nullable<HTMLElement>): void;
  39428. /**
  39429. * Gets the class name of the current intput.
  39430. * @returns the class name
  39431. */
  39432. getClassName(): string;
  39433. /**
  39434. * Get the friendly name associated with the input class.
  39435. * @returns the input friendly name
  39436. */
  39437. getSimpleName(): string;
  39438. }
  39439. }
  39440. declare module "babylonjs/Cameras/Inputs/index" {
  39441. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39442. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39443. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39444. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39445. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39446. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39447. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39448. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39449. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39450. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39451. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39452. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39453. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39454. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39455. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39456. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39457. }
  39458. declare module "babylonjs/Cameras/touchCamera" {
  39459. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39460. import { Scene } from "babylonjs/scene";
  39461. import { Vector3 } from "babylonjs/Maths/math.vector";
  39462. /**
  39463. * This represents a FPS type of camera controlled by touch.
  39464. * This is like a universal camera minus the Gamepad controls.
  39465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39466. */
  39467. export class TouchCamera extends FreeCamera {
  39468. /**
  39469. * Defines the touch sensibility for rotation.
  39470. * The higher the faster.
  39471. */
  39472. touchAngularSensibility: number;
  39473. /**
  39474. * Defines the touch sensibility for move.
  39475. * The higher the faster.
  39476. */
  39477. touchMoveSensibility: number;
  39478. /**
  39479. * Instantiates a new touch camera.
  39480. * This represents a FPS type of camera controlled by touch.
  39481. * This is like a universal camera minus the Gamepad controls.
  39482. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39483. * @param name Define the name of the camera in the scene
  39484. * @param position Define the start position of the camera in the scene
  39485. * @param scene Define the scene the camera belongs to
  39486. */
  39487. constructor(name: string, position: Vector3, scene: Scene);
  39488. /**
  39489. * Gets the current object class name.
  39490. * @return the class name
  39491. */
  39492. getClassName(): string;
  39493. /** @hidden */
  39494. _setupInputs(): void;
  39495. }
  39496. }
  39497. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39498. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39499. import { Scene } from "babylonjs/scene";
  39500. import { Vector3 } from "babylonjs/Maths/math.vector";
  39501. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39502. import { Axis } from "babylonjs/Maths/math.axis";
  39503. /**
  39504. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39505. * being tilted forward or back and left or right.
  39506. */
  39507. export class DeviceOrientationCamera extends FreeCamera {
  39508. private _initialQuaternion;
  39509. private _quaternionCache;
  39510. private _tmpDragQuaternion;
  39511. private _disablePointerInputWhenUsingDeviceOrientation;
  39512. /**
  39513. * Creates a new device orientation camera
  39514. * @param name The name of the camera
  39515. * @param position The start position camera
  39516. * @param scene The scene the camera belongs to
  39517. */
  39518. constructor(name: string, position: Vector3, scene: Scene);
  39519. /**
  39520. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39521. */
  39522. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39523. private _dragFactor;
  39524. /**
  39525. * Enabled turning on the y axis when the orientation sensor is active
  39526. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39527. */
  39528. enableHorizontalDragging(dragFactor?: number): void;
  39529. /**
  39530. * Gets the current instance class name ("DeviceOrientationCamera").
  39531. * This helps avoiding instanceof at run time.
  39532. * @returns the class name
  39533. */
  39534. getClassName(): string;
  39535. /**
  39536. * @hidden
  39537. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39538. */
  39539. _checkInputs(): void;
  39540. /**
  39541. * Reset the camera to its default orientation on the specified axis only.
  39542. * @param axis The axis to reset
  39543. */
  39544. resetToCurrentRotation(axis?: Axis): void;
  39545. }
  39546. }
  39547. declare module "babylonjs/Gamepads/xboxGamepad" {
  39548. import { Observable } from "babylonjs/Misc/observable";
  39549. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39550. /**
  39551. * Defines supported buttons for XBox360 compatible gamepads
  39552. */
  39553. export enum Xbox360Button {
  39554. /** A */
  39555. A = 0,
  39556. /** B */
  39557. B = 1,
  39558. /** X */
  39559. X = 2,
  39560. /** Y */
  39561. Y = 3,
  39562. /** Start */
  39563. Start = 4,
  39564. /** Back */
  39565. Back = 5,
  39566. /** Left button */
  39567. LB = 6,
  39568. /** Right button */
  39569. RB = 7,
  39570. /** Left stick */
  39571. LeftStick = 8,
  39572. /** Right stick */
  39573. RightStick = 9
  39574. }
  39575. /** Defines values for XBox360 DPad */
  39576. export enum Xbox360Dpad {
  39577. /** Up */
  39578. Up = 0,
  39579. /** Down */
  39580. Down = 1,
  39581. /** Left */
  39582. Left = 2,
  39583. /** Right */
  39584. Right = 3
  39585. }
  39586. /**
  39587. * Defines a XBox360 gamepad
  39588. */
  39589. export class Xbox360Pad extends Gamepad {
  39590. private _leftTrigger;
  39591. private _rightTrigger;
  39592. private _onlefttriggerchanged;
  39593. private _onrighttriggerchanged;
  39594. private _onbuttondown;
  39595. private _onbuttonup;
  39596. private _ondpaddown;
  39597. private _ondpadup;
  39598. /** Observable raised when a button is pressed */
  39599. onButtonDownObservable: Observable<Xbox360Button>;
  39600. /** Observable raised when a button is released */
  39601. onButtonUpObservable: Observable<Xbox360Button>;
  39602. /** Observable raised when a pad is pressed */
  39603. onPadDownObservable: Observable<Xbox360Dpad>;
  39604. /** Observable raised when a pad is released */
  39605. onPadUpObservable: Observable<Xbox360Dpad>;
  39606. private _buttonA;
  39607. private _buttonB;
  39608. private _buttonX;
  39609. private _buttonY;
  39610. private _buttonBack;
  39611. private _buttonStart;
  39612. private _buttonLB;
  39613. private _buttonRB;
  39614. private _buttonLeftStick;
  39615. private _buttonRightStick;
  39616. private _dPadUp;
  39617. private _dPadDown;
  39618. private _dPadLeft;
  39619. private _dPadRight;
  39620. private _isXboxOnePad;
  39621. /**
  39622. * Creates a new XBox360 gamepad object
  39623. * @param id defines the id of this gamepad
  39624. * @param index defines its index
  39625. * @param gamepad defines the internal HTML gamepad object
  39626. * @param xboxOne defines if it is a XBox One gamepad
  39627. */
  39628. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39629. /**
  39630. * Defines the callback to call when left trigger is pressed
  39631. * @param callback defines the callback to use
  39632. */
  39633. onlefttriggerchanged(callback: (value: number) => void): void;
  39634. /**
  39635. * Defines the callback to call when right trigger is pressed
  39636. * @param callback defines the callback to use
  39637. */
  39638. onrighttriggerchanged(callback: (value: number) => void): void;
  39639. /**
  39640. * Gets the left trigger value
  39641. */
  39642. /**
  39643. * Sets the left trigger value
  39644. */
  39645. leftTrigger: number;
  39646. /**
  39647. * Gets the right trigger value
  39648. */
  39649. /**
  39650. * Sets the right trigger value
  39651. */
  39652. rightTrigger: number;
  39653. /**
  39654. * Defines the callback to call when a button is pressed
  39655. * @param callback defines the callback to use
  39656. */
  39657. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39658. /**
  39659. * Defines the callback to call when a button is released
  39660. * @param callback defines the callback to use
  39661. */
  39662. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39663. /**
  39664. * Defines the callback to call when a pad is pressed
  39665. * @param callback defines the callback to use
  39666. */
  39667. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39668. /**
  39669. * Defines the callback to call when a pad is released
  39670. * @param callback defines the callback to use
  39671. */
  39672. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39673. private _setButtonValue;
  39674. private _setDPadValue;
  39675. /**
  39676. * Gets the value of the `A` button
  39677. */
  39678. /**
  39679. * Sets the value of the `A` button
  39680. */
  39681. buttonA: number;
  39682. /**
  39683. * Gets the value of the `B` button
  39684. */
  39685. /**
  39686. * Sets the value of the `B` button
  39687. */
  39688. buttonB: number;
  39689. /**
  39690. * Gets the value of the `X` button
  39691. */
  39692. /**
  39693. * Sets the value of the `X` button
  39694. */
  39695. buttonX: number;
  39696. /**
  39697. * Gets the value of the `Y` button
  39698. */
  39699. /**
  39700. * Sets the value of the `Y` button
  39701. */
  39702. buttonY: number;
  39703. /**
  39704. * Gets the value of the `Start` button
  39705. */
  39706. /**
  39707. * Sets the value of the `Start` button
  39708. */
  39709. buttonStart: number;
  39710. /**
  39711. * Gets the value of the `Back` button
  39712. */
  39713. /**
  39714. * Sets the value of the `Back` button
  39715. */
  39716. buttonBack: number;
  39717. /**
  39718. * Gets the value of the `Left` button
  39719. */
  39720. /**
  39721. * Sets the value of the `Left` button
  39722. */
  39723. buttonLB: number;
  39724. /**
  39725. * Gets the value of the `Right` button
  39726. */
  39727. /**
  39728. * Sets the value of the `Right` button
  39729. */
  39730. buttonRB: number;
  39731. /**
  39732. * Gets the value of the Left joystick
  39733. */
  39734. /**
  39735. * Sets the value of the Left joystick
  39736. */
  39737. buttonLeftStick: number;
  39738. /**
  39739. * Gets the value of the Right joystick
  39740. */
  39741. /**
  39742. * Sets the value of the Right joystick
  39743. */
  39744. buttonRightStick: number;
  39745. /**
  39746. * Gets the value of D-pad up
  39747. */
  39748. /**
  39749. * Sets the value of D-pad up
  39750. */
  39751. dPadUp: number;
  39752. /**
  39753. * Gets the value of D-pad down
  39754. */
  39755. /**
  39756. * Sets the value of D-pad down
  39757. */
  39758. dPadDown: number;
  39759. /**
  39760. * Gets the value of D-pad left
  39761. */
  39762. /**
  39763. * Sets the value of D-pad left
  39764. */
  39765. dPadLeft: number;
  39766. /**
  39767. * Gets the value of D-pad right
  39768. */
  39769. /**
  39770. * Sets the value of D-pad right
  39771. */
  39772. dPadRight: number;
  39773. /**
  39774. * Force the gamepad to synchronize with device values
  39775. */
  39776. update(): void;
  39777. /**
  39778. * Disposes the gamepad
  39779. */
  39780. dispose(): void;
  39781. }
  39782. }
  39783. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39784. import { Observable } from "babylonjs/Misc/observable";
  39785. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39786. /**
  39787. * Defines supported buttons for DualShock compatible gamepads
  39788. */
  39789. export enum DualShockButton {
  39790. /** Cross */
  39791. Cross = 0,
  39792. /** Circle */
  39793. Circle = 1,
  39794. /** Square */
  39795. Square = 2,
  39796. /** Triangle */
  39797. Triangle = 3,
  39798. /** Options */
  39799. Options = 4,
  39800. /** Share */
  39801. Share = 5,
  39802. /** L1 */
  39803. L1 = 6,
  39804. /** R1 */
  39805. R1 = 7,
  39806. /** Left stick */
  39807. LeftStick = 8,
  39808. /** Right stick */
  39809. RightStick = 9
  39810. }
  39811. /** Defines values for DualShock DPad */
  39812. export enum DualShockDpad {
  39813. /** Up */
  39814. Up = 0,
  39815. /** Down */
  39816. Down = 1,
  39817. /** Left */
  39818. Left = 2,
  39819. /** Right */
  39820. Right = 3
  39821. }
  39822. /**
  39823. * Defines a DualShock gamepad
  39824. */
  39825. export class DualShockPad extends Gamepad {
  39826. private _leftTrigger;
  39827. private _rightTrigger;
  39828. private _onlefttriggerchanged;
  39829. private _onrighttriggerchanged;
  39830. private _onbuttondown;
  39831. private _onbuttonup;
  39832. private _ondpaddown;
  39833. private _ondpadup;
  39834. /** Observable raised when a button is pressed */
  39835. onButtonDownObservable: Observable<DualShockButton>;
  39836. /** Observable raised when a button is released */
  39837. onButtonUpObservable: Observable<DualShockButton>;
  39838. /** Observable raised when a pad is pressed */
  39839. onPadDownObservable: Observable<DualShockDpad>;
  39840. /** Observable raised when a pad is released */
  39841. onPadUpObservable: Observable<DualShockDpad>;
  39842. private _buttonCross;
  39843. private _buttonCircle;
  39844. private _buttonSquare;
  39845. private _buttonTriangle;
  39846. private _buttonShare;
  39847. private _buttonOptions;
  39848. private _buttonL1;
  39849. private _buttonR1;
  39850. private _buttonLeftStick;
  39851. private _buttonRightStick;
  39852. private _dPadUp;
  39853. private _dPadDown;
  39854. private _dPadLeft;
  39855. private _dPadRight;
  39856. /**
  39857. * Creates a new DualShock gamepad object
  39858. * @param id defines the id of this gamepad
  39859. * @param index defines its index
  39860. * @param gamepad defines the internal HTML gamepad object
  39861. */
  39862. constructor(id: string, index: number, gamepad: any);
  39863. /**
  39864. * Defines the callback to call when left trigger is pressed
  39865. * @param callback defines the callback to use
  39866. */
  39867. onlefttriggerchanged(callback: (value: number) => void): void;
  39868. /**
  39869. * Defines the callback to call when right trigger is pressed
  39870. * @param callback defines the callback to use
  39871. */
  39872. onrighttriggerchanged(callback: (value: number) => void): void;
  39873. /**
  39874. * Gets the left trigger value
  39875. */
  39876. /**
  39877. * Sets the left trigger value
  39878. */
  39879. leftTrigger: number;
  39880. /**
  39881. * Gets the right trigger value
  39882. */
  39883. /**
  39884. * Sets the right trigger value
  39885. */
  39886. rightTrigger: number;
  39887. /**
  39888. * Defines the callback to call when a button is pressed
  39889. * @param callback defines the callback to use
  39890. */
  39891. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39892. /**
  39893. * Defines the callback to call when a button is released
  39894. * @param callback defines the callback to use
  39895. */
  39896. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39897. /**
  39898. * Defines the callback to call when a pad is pressed
  39899. * @param callback defines the callback to use
  39900. */
  39901. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39902. /**
  39903. * Defines the callback to call when a pad is released
  39904. * @param callback defines the callback to use
  39905. */
  39906. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39907. private _setButtonValue;
  39908. private _setDPadValue;
  39909. /**
  39910. * Gets the value of the `Cross` button
  39911. */
  39912. /**
  39913. * Sets the value of the `Cross` button
  39914. */
  39915. buttonCross: number;
  39916. /**
  39917. * Gets the value of the `Circle` button
  39918. */
  39919. /**
  39920. * Sets the value of the `Circle` button
  39921. */
  39922. buttonCircle: number;
  39923. /**
  39924. * Gets the value of the `Square` button
  39925. */
  39926. /**
  39927. * Sets the value of the `Square` button
  39928. */
  39929. buttonSquare: number;
  39930. /**
  39931. * Gets the value of the `Triangle` button
  39932. */
  39933. /**
  39934. * Sets the value of the `Triangle` button
  39935. */
  39936. buttonTriangle: number;
  39937. /**
  39938. * Gets the value of the `Options` button
  39939. */
  39940. /**
  39941. * Sets the value of the `Options` button
  39942. */
  39943. buttonOptions: number;
  39944. /**
  39945. * Gets the value of the `Share` button
  39946. */
  39947. /**
  39948. * Sets the value of the `Share` button
  39949. */
  39950. buttonShare: number;
  39951. /**
  39952. * Gets the value of the `L1` button
  39953. */
  39954. /**
  39955. * Sets the value of the `L1` button
  39956. */
  39957. buttonL1: number;
  39958. /**
  39959. * Gets the value of the `R1` button
  39960. */
  39961. /**
  39962. * Sets the value of the `R1` button
  39963. */
  39964. buttonR1: number;
  39965. /**
  39966. * Gets the value of the Left joystick
  39967. */
  39968. /**
  39969. * Sets the value of the Left joystick
  39970. */
  39971. buttonLeftStick: number;
  39972. /**
  39973. * Gets the value of the Right joystick
  39974. */
  39975. /**
  39976. * Sets the value of the Right joystick
  39977. */
  39978. buttonRightStick: number;
  39979. /**
  39980. * Gets the value of D-pad up
  39981. */
  39982. /**
  39983. * Sets the value of D-pad up
  39984. */
  39985. dPadUp: number;
  39986. /**
  39987. * Gets the value of D-pad down
  39988. */
  39989. /**
  39990. * Sets the value of D-pad down
  39991. */
  39992. dPadDown: number;
  39993. /**
  39994. * Gets the value of D-pad left
  39995. */
  39996. /**
  39997. * Sets the value of D-pad left
  39998. */
  39999. dPadLeft: number;
  40000. /**
  40001. * Gets the value of D-pad right
  40002. */
  40003. /**
  40004. * Sets the value of D-pad right
  40005. */
  40006. dPadRight: number;
  40007. /**
  40008. * Force the gamepad to synchronize with device values
  40009. */
  40010. update(): void;
  40011. /**
  40012. * Disposes the gamepad
  40013. */
  40014. dispose(): void;
  40015. }
  40016. }
  40017. declare module "babylonjs/Gamepads/gamepadManager" {
  40018. import { Observable } from "babylonjs/Misc/observable";
  40019. import { Nullable } from "babylonjs/types";
  40020. import { Scene } from "babylonjs/scene";
  40021. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40022. /**
  40023. * Manager for handling gamepads
  40024. */
  40025. export class GamepadManager {
  40026. private _scene?;
  40027. private _babylonGamepads;
  40028. private _oneGamepadConnected;
  40029. /** @hidden */
  40030. _isMonitoring: boolean;
  40031. private _gamepadEventSupported;
  40032. private _gamepadSupport;
  40033. /**
  40034. * observable to be triggered when the gamepad controller has been connected
  40035. */
  40036. onGamepadConnectedObservable: Observable<Gamepad>;
  40037. /**
  40038. * observable to be triggered when the gamepad controller has been disconnected
  40039. */
  40040. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40041. private _onGamepadConnectedEvent;
  40042. private _onGamepadDisconnectedEvent;
  40043. /**
  40044. * Initializes the gamepad manager
  40045. * @param _scene BabylonJS scene
  40046. */
  40047. constructor(_scene?: Scene | undefined);
  40048. /**
  40049. * The gamepads in the game pad manager
  40050. */
  40051. readonly gamepads: Gamepad[];
  40052. /**
  40053. * Get the gamepad controllers based on type
  40054. * @param type The type of gamepad controller
  40055. * @returns Nullable gamepad
  40056. */
  40057. getGamepadByType(type?: number): Nullable<Gamepad>;
  40058. /**
  40059. * Disposes the gamepad manager
  40060. */
  40061. dispose(): void;
  40062. private _addNewGamepad;
  40063. private _startMonitoringGamepads;
  40064. private _stopMonitoringGamepads;
  40065. /** @hidden */
  40066. _checkGamepadsStatus(): void;
  40067. private _updateGamepadObjects;
  40068. }
  40069. }
  40070. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40071. import { Nullable } from "babylonjs/types";
  40072. import { Scene } from "babylonjs/scene";
  40073. import { ISceneComponent } from "babylonjs/sceneComponent";
  40074. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40075. module "babylonjs/scene" {
  40076. interface Scene {
  40077. /** @hidden */
  40078. _gamepadManager: Nullable<GamepadManager>;
  40079. /**
  40080. * Gets the gamepad manager associated with the scene
  40081. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40082. */
  40083. gamepadManager: GamepadManager;
  40084. }
  40085. }
  40086. module "babylonjs/Cameras/freeCameraInputsManager" {
  40087. /**
  40088. * Interface representing a free camera inputs manager
  40089. */
  40090. interface FreeCameraInputsManager {
  40091. /**
  40092. * Adds gamepad input support to the FreeCameraInputsManager.
  40093. * @returns the FreeCameraInputsManager
  40094. */
  40095. addGamepad(): FreeCameraInputsManager;
  40096. }
  40097. }
  40098. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40099. /**
  40100. * Interface representing an arc rotate camera inputs manager
  40101. */
  40102. interface ArcRotateCameraInputsManager {
  40103. /**
  40104. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40105. * @returns the camera inputs manager
  40106. */
  40107. addGamepad(): ArcRotateCameraInputsManager;
  40108. }
  40109. }
  40110. /**
  40111. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40112. */
  40113. export class GamepadSystemSceneComponent implements ISceneComponent {
  40114. /**
  40115. * The component name helpfull to identify the component in the list of scene components.
  40116. */
  40117. readonly name: string;
  40118. /**
  40119. * The scene the component belongs to.
  40120. */
  40121. scene: Scene;
  40122. /**
  40123. * Creates a new instance of the component for the given scene
  40124. * @param scene Defines the scene to register the component in
  40125. */
  40126. constructor(scene: Scene);
  40127. /**
  40128. * Registers the component in a given scene
  40129. */
  40130. register(): void;
  40131. /**
  40132. * Rebuilds the elements related to this component in case of
  40133. * context lost for instance.
  40134. */
  40135. rebuild(): void;
  40136. /**
  40137. * Disposes the component and the associated ressources
  40138. */
  40139. dispose(): void;
  40140. private _beforeCameraUpdate;
  40141. }
  40142. }
  40143. declare module "babylonjs/Cameras/universalCamera" {
  40144. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40145. import { Scene } from "babylonjs/scene";
  40146. import { Vector3 } from "babylonjs/Maths/math.vector";
  40147. import "babylonjs/Gamepads/gamepadSceneComponent";
  40148. /**
  40149. * 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,
  40150. * which still works and will still be found in many Playgrounds.
  40151. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40152. */
  40153. export class UniversalCamera extends TouchCamera {
  40154. /**
  40155. * Defines the gamepad rotation sensiblity.
  40156. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40157. */
  40158. gamepadAngularSensibility: number;
  40159. /**
  40160. * Defines the gamepad move sensiblity.
  40161. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40162. */
  40163. gamepadMoveSensibility: number;
  40164. /**
  40165. * 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,
  40166. * which still works and will still be found in many Playgrounds.
  40167. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40168. * @param name Define the name of the camera in the scene
  40169. * @param position Define the start position of the camera in the scene
  40170. * @param scene Define the scene the camera belongs to
  40171. */
  40172. constructor(name: string, position: Vector3, scene: Scene);
  40173. /**
  40174. * Gets the current object class name.
  40175. * @return the class name
  40176. */
  40177. getClassName(): string;
  40178. }
  40179. }
  40180. declare module "babylonjs/Cameras/gamepadCamera" {
  40181. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40182. import { Scene } from "babylonjs/scene";
  40183. import { Vector3 } from "babylonjs/Maths/math.vector";
  40184. /**
  40185. * This represents a FPS type of camera. This is only here for back compat purpose.
  40186. * Please use the UniversalCamera instead as both are identical.
  40187. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40188. */
  40189. export class GamepadCamera extends UniversalCamera {
  40190. /**
  40191. * Instantiates a new Gamepad Camera
  40192. * This represents a FPS type of camera. This is only here for back compat purpose.
  40193. * Please use the UniversalCamera instead as both are identical.
  40194. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40195. * @param name Define the name of the camera in the scene
  40196. * @param position Define the start position of the camera in the scene
  40197. * @param scene Define the scene the camera belongs to
  40198. */
  40199. constructor(name: string, position: Vector3, scene: Scene);
  40200. /**
  40201. * Gets the current object class name.
  40202. * @return the class name
  40203. */
  40204. getClassName(): string;
  40205. }
  40206. }
  40207. declare module "babylonjs/Shaders/pass.fragment" {
  40208. /** @hidden */
  40209. export var passPixelShader: {
  40210. name: string;
  40211. shader: string;
  40212. };
  40213. }
  40214. declare module "babylonjs/Shaders/passCube.fragment" {
  40215. /** @hidden */
  40216. export var passCubePixelShader: {
  40217. name: string;
  40218. shader: string;
  40219. };
  40220. }
  40221. declare module "babylonjs/PostProcesses/passPostProcess" {
  40222. import { Nullable } from "babylonjs/types";
  40223. import { Camera } from "babylonjs/Cameras/camera";
  40224. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40225. import { Engine } from "babylonjs/Engines/engine";
  40226. import "babylonjs/Shaders/pass.fragment";
  40227. import "babylonjs/Shaders/passCube.fragment";
  40228. /**
  40229. * PassPostProcess which produces an output the same as it's input
  40230. */
  40231. export class PassPostProcess extends PostProcess {
  40232. /**
  40233. * Creates the PassPostProcess
  40234. * @param name The name of the effect.
  40235. * @param options The required width/height ratio to downsize to before computing the render pass.
  40236. * @param camera The camera to apply the render pass to.
  40237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40238. * @param engine The engine which the post process will be applied. (default: current engine)
  40239. * @param reusable If the post process can be reused on the same frame. (default: false)
  40240. * @param textureType The type of texture to be used when performing the post processing.
  40241. * @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)
  40242. */
  40243. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40244. }
  40245. /**
  40246. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40247. */
  40248. export class PassCubePostProcess extends PostProcess {
  40249. private _face;
  40250. /**
  40251. * Gets or sets the cube face to display.
  40252. * * 0 is +X
  40253. * * 1 is -X
  40254. * * 2 is +Y
  40255. * * 3 is -Y
  40256. * * 4 is +Z
  40257. * * 5 is -Z
  40258. */
  40259. face: number;
  40260. /**
  40261. * Creates the PassCubePostProcess
  40262. * @param name The name of the effect.
  40263. * @param options The required width/height ratio to downsize to before computing the render pass.
  40264. * @param camera The camera to apply the render pass to.
  40265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40266. * @param engine The engine which the post process will be applied. (default: current engine)
  40267. * @param reusable If the post process can be reused on the same frame. (default: false)
  40268. * @param textureType The type of texture to be used when performing the post processing.
  40269. * @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)
  40270. */
  40271. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40272. }
  40273. }
  40274. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40275. /** @hidden */
  40276. export var anaglyphPixelShader: {
  40277. name: string;
  40278. shader: string;
  40279. };
  40280. }
  40281. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40282. import { Engine } from "babylonjs/Engines/engine";
  40283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40284. import { Camera } from "babylonjs/Cameras/camera";
  40285. import "babylonjs/Shaders/anaglyph.fragment";
  40286. /**
  40287. * Postprocess used to generate anaglyphic rendering
  40288. */
  40289. export class AnaglyphPostProcess extends PostProcess {
  40290. private _passedProcess;
  40291. /**
  40292. * Creates a new AnaglyphPostProcess
  40293. * @param name defines postprocess name
  40294. * @param options defines creation options or target ratio scale
  40295. * @param rigCameras defines cameras using this postprocess
  40296. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40297. * @param engine defines hosting engine
  40298. * @param reusable defines if the postprocess will be reused multiple times per frame
  40299. */
  40300. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40301. }
  40302. }
  40303. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40304. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40305. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40306. import { Scene } from "babylonjs/scene";
  40307. import { Vector3 } from "babylonjs/Maths/math.vector";
  40308. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40309. /**
  40310. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40311. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40312. */
  40313. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40314. /**
  40315. * Creates a new AnaglyphArcRotateCamera
  40316. * @param name defines camera name
  40317. * @param alpha defines alpha angle (in radians)
  40318. * @param beta defines beta angle (in radians)
  40319. * @param radius defines radius
  40320. * @param target defines camera target
  40321. * @param interaxialDistance defines distance between each color axis
  40322. * @param scene defines the hosting scene
  40323. */
  40324. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40325. /**
  40326. * Gets camera class name
  40327. * @returns AnaglyphArcRotateCamera
  40328. */
  40329. getClassName(): string;
  40330. }
  40331. }
  40332. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40333. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40334. import { Scene } from "babylonjs/scene";
  40335. import { Vector3 } from "babylonjs/Maths/math.vector";
  40336. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40337. /**
  40338. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40340. */
  40341. export class AnaglyphFreeCamera extends FreeCamera {
  40342. /**
  40343. * Creates a new AnaglyphFreeCamera
  40344. * @param name defines camera name
  40345. * @param position defines initial position
  40346. * @param interaxialDistance defines distance between each color axis
  40347. * @param scene defines the hosting scene
  40348. */
  40349. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40350. /**
  40351. * Gets camera class name
  40352. * @returns AnaglyphFreeCamera
  40353. */
  40354. getClassName(): string;
  40355. }
  40356. }
  40357. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40358. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40359. import { Scene } from "babylonjs/scene";
  40360. import { Vector3 } from "babylonjs/Maths/math.vector";
  40361. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40362. /**
  40363. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40364. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40365. */
  40366. export class AnaglyphGamepadCamera extends GamepadCamera {
  40367. /**
  40368. * Creates a new AnaglyphGamepadCamera
  40369. * @param name defines camera name
  40370. * @param position defines initial position
  40371. * @param interaxialDistance defines distance between each color axis
  40372. * @param scene defines the hosting scene
  40373. */
  40374. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40375. /**
  40376. * Gets camera class name
  40377. * @returns AnaglyphGamepadCamera
  40378. */
  40379. getClassName(): string;
  40380. }
  40381. }
  40382. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40383. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40384. import { Scene } from "babylonjs/scene";
  40385. import { Vector3 } from "babylonjs/Maths/math.vector";
  40386. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40387. /**
  40388. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40389. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40390. */
  40391. export class AnaglyphUniversalCamera extends UniversalCamera {
  40392. /**
  40393. * Creates a new AnaglyphUniversalCamera
  40394. * @param name defines camera name
  40395. * @param position defines initial position
  40396. * @param interaxialDistance defines distance between each color axis
  40397. * @param scene defines the hosting scene
  40398. */
  40399. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40400. /**
  40401. * Gets camera class name
  40402. * @returns AnaglyphUniversalCamera
  40403. */
  40404. getClassName(): string;
  40405. }
  40406. }
  40407. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40408. /** @hidden */
  40409. export var stereoscopicInterlacePixelShader: {
  40410. name: string;
  40411. shader: string;
  40412. };
  40413. }
  40414. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40415. import { Camera } from "babylonjs/Cameras/camera";
  40416. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40417. import { Engine } from "babylonjs/Engines/engine";
  40418. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40419. /**
  40420. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40421. */
  40422. export class StereoscopicInterlacePostProcess extends PostProcess {
  40423. private _stepSize;
  40424. private _passedProcess;
  40425. /**
  40426. * Initializes a StereoscopicInterlacePostProcess
  40427. * @param name The name of the effect.
  40428. * @param rigCameras The rig cameras to be appled to the post process
  40429. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40431. * @param engine The engine which the post process will be applied. (default: current engine)
  40432. * @param reusable If the post process can be reused on the same frame. (default: false)
  40433. */
  40434. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40435. }
  40436. }
  40437. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40438. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40439. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40440. import { Scene } from "babylonjs/scene";
  40441. import { Vector3 } from "babylonjs/Maths/math.vector";
  40442. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40443. /**
  40444. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40445. * @see http://doc.babylonjs.com/features/cameras
  40446. */
  40447. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40448. /**
  40449. * Creates a new StereoscopicArcRotateCamera
  40450. * @param name defines camera name
  40451. * @param alpha defines alpha angle (in radians)
  40452. * @param beta defines beta angle (in radians)
  40453. * @param radius defines radius
  40454. * @param target defines camera target
  40455. * @param interaxialDistance defines distance between each color axis
  40456. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40457. * @param scene defines the hosting scene
  40458. */
  40459. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40460. /**
  40461. * Gets camera class name
  40462. * @returns StereoscopicArcRotateCamera
  40463. */
  40464. getClassName(): string;
  40465. }
  40466. }
  40467. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40468. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40469. import { Scene } from "babylonjs/scene";
  40470. import { Vector3 } from "babylonjs/Maths/math.vector";
  40471. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40472. /**
  40473. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40474. * @see http://doc.babylonjs.com/features/cameras
  40475. */
  40476. export class StereoscopicFreeCamera extends FreeCamera {
  40477. /**
  40478. * Creates a new StereoscopicFreeCamera
  40479. * @param name defines camera name
  40480. * @param position defines initial position
  40481. * @param interaxialDistance defines distance between each color axis
  40482. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40483. * @param scene defines the hosting scene
  40484. */
  40485. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40486. /**
  40487. * Gets camera class name
  40488. * @returns StereoscopicFreeCamera
  40489. */
  40490. getClassName(): string;
  40491. }
  40492. }
  40493. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40494. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40495. import { Scene } from "babylonjs/scene";
  40496. import { Vector3 } from "babylonjs/Maths/math.vector";
  40497. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40498. /**
  40499. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40500. * @see http://doc.babylonjs.com/features/cameras
  40501. */
  40502. export class StereoscopicGamepadCamera extends GamepadCamera {
  40503. /**
  40504. * Creates a new StereoscopicGamepadCamera
  40505. * @param name defines camera name
  40506. * @param position defines initial position
  40507. * @param interaxialDistance defines distance between each color axis
  40508. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40509. * @param scene defines the hosting scene
  40510. */
  40511. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40512. /**
  40513. * Gets camera class name
  40514. * @returns StereoscopicGamepadCamera
  40515. */
  40516. getClassName(): string;
  40517. }
  40518. }
  40519. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40520. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40521. import { Scene } from "babylonjs/scene";
  40522. import { Vector3 } from "babylonjs/Maths/math.vector";
  40523. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40524. /**
  40525. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40526. * @see http://doc.babylonjs.com/features/cameras
  40527. */
  40528. export class StereoscopicUniversalCamera extends UniversalCamera {
  40529. /**
  40530. * Creates a new StereoscopicUniversalCamera
  40531. * @param name defines camera name
  40532. * @param position defines initial position
  40533. * @param interaxialDistance defines distance between each color axis
  40534. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40535. * @param scene defines the hosting scene
  40536. */
  40537. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40538. /**
  40539. * Gets camera class name
  40540. * @returns StereoscopicUniversalCamera
  40541. */
  40542. getClassName(): string;
  40543. }
  40544. }
  40545. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40546. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40547. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40548. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40549. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40550. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40551. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40552. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40553. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40554. }
  40555. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40556. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40557. import { Scene } from "babylonjs/scene";
  40558. import { Vector3 } from "babylonjs/Maths/math.vector";
  40559. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40560. /**
  40561. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40562. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40563. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40564. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40565. */
  40566. export class VirtualJoysticksCamera extends FreeCamera {
  40567. /**
  40568. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40569. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40570. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40571. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40572. * @param name Define the name of the camera in the scene
  40573. * @param position Define the start position of the camera in the scene
  40574. * @param scene Define the scene the camera belongs to
  40575. */
  40576. constructor(name: string, position: Vector3, scene: Scene);
  40577. /**
  40578. * Gets the current object class name.
  40579. * @return the class name
  40580. */
  40581. getClassName(): string;
  40582. }
  40583. }
  40584. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40585. import { Matrix } from "babylonjs/Maths/math.vector";
  40586. /**
  40587. * This represents all the required metrics to create a VR camera.
  40588. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40589. */
  40590. export class VRCameraMetrics {
  40591. /**
  40592. * Define the horizontal resolution off the screen.
  40593. */
  40594. hResolution: number;
  40595. /**
  40596. * Define the vertical resolution off the screen.
  40597. */
  40598. vResolution: number;
  40599. /**
  40600. * Define the horizontal screen size.
  40601. */
  40602. hScreenSize: number;
  40603. /**
  40604. * Define the vertical screen size.
  40605. */
  40606. vScreenSize: number;
  40607. /**
  40608. * Define the vertical screen center position.
  40609. */
  40610. vScreenCenter: number;
  40611. /**
  40612. * Define the distance of the eyes to the screen.
  40613. */
  40614. eyeToScreenDistance: number;
  40615. /**
  40616. * Define the distance between both lenses
  40617. */
  40618. lensSeparationDistance: number;
  40619. /**
  40620. * Define the distance between both viewer's eyes.
  40621. */
  40622. interpupillaryDistance: number;
  40623. /**
  40624. * Define the distortion factor of the VR postprocess.
  40625. * Please, touch with care.
  40626. */
  40627. distortionK: number[];
  40628. /**
  40629. * Define the chromatic aberration correction factors for the VR post process.
  40630. */
  40631. chromaAbCorrection: number[];
  40632. /**
  40633. * Define the scale factor of the post process.
  40634. * The smaller the better but the slower.
  40635. */
  40636. postProcessScaleFactor: number;
  40637. /**
  40638. * Define an offset for the lens center.
  40639. */
  40640. lensCenterOffset: number;
  40641. /**
  40642. * Define if the current vr camera should compensate the distortion of the lense or not.
  40643. */
  40644. compensateDistortion: boolean;
  40645. /**
  40646. * Defines if multiview should be enabled when rendering (Default: false)
  40647. */
  40648. multiviewEnabled: boolean;
  40649. /**
  40650. * Gets the rendering aspect ratio based on the provided resolutions.
  40651. */
  40652. readonly aspectRatio: number;
  40653. /**
  40654. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40655. */
  40656. readonly aspectRatioFov: number;
  40657. /**
  40658. * @hidden
  40659. */
  40660. readonly leftHMatrix: Matrix;
  40661. /**
  40662. * @hidden
  40663. */
  40664. readonly rightHMatrix: Matrix;
  40665. /**
  40666. * @hidden
  40667. */
  40668. readonly leftPreViewMatrix: Matrix;
  40669. /**
  40670. * @hidden
  40671. */
  40672. readonly rightPreViewMatrix: Matrix;
  40673. /**
  40674. * Get the default VRMetrics based on the most generic setup.
  40675. * @returns the default vr metrics
  40676. */
  40677. static GetDefault(): VRCameraMetrics;
  40678. }
  40679. }
  40680. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40681. /** @hidden */
  40682. export var vrDistortionCorrectionPixelShader: {
  40683. name: string;
  40684. shader: string;
  40685. };
  40686. }
  40687. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40688. import { Camera } from "babylonjs/Cameras/camera";
  40689. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40690. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40691. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40692. /**
  40693. * VRDistortionCorrectionPostProcess used for mobile VR
  40694. */
  40695. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40696. private _isRightEye;
  40697. private _distortionFactors;
  40698. private _postProcessScaleFactor;
  40699. private _lensCenterOffset;
  40700. private _scaleIn;
  40701. private _scaleFactor;
  40702. private _lensCenter;
  40703. /**
  40704. * Initializes the VRDistortionCorrectionPostProcess
  40705. * @param name The name of the effect.
  40706. * @param camera The camera to apply the render pass to.
  40707. * @param isRightEye If this is for the right eye distortion
  40708. * @param vrMetrics All the required metrics for the VR camera
  40709. */
  40710. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40711. }
  40712. }
  40713. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40714. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40715. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40716. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40717. import { Scene } from "babylonjs/scene";
  40718. import { Vector3 } from "babylonjs/Maths/math.vector";
  40719. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40720. import "babylonjs/Cameras/RigModes/vrRigMode";
  40721. /**
  40722. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40723. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40724. */
  40725. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40726. /**
  40727. * Creates a new VRDeviceOrientationArcRotateCamera
  40728. * @param name defines camera name
  40729. * @param alpha defines the camera rotation along the logitudinal axis
  40730. * @param beta defines the camera rotation along the latitudinal axis
  40731. * @param radius defines the camera distance from its target
  40732. * @param target defines the camera target
  40733. * @param scene defines the scene the camera belongs to
  40734. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40735. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40736. */
  40737. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40738. /**
  40739. * Gets camera class name
  40740. * @returns VRDeviceOrientationArcRotateCamera
  40741. */
  40742. getClassName(): string;
  40743. }
  40744. }
  40745. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40746. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40747. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40748. import { Scene } from "babylonjs/scene";
  40749. import { Vector3 } from "babylonjs/Maths/math.vector";
  40750. import "babylonjs/Cameras/RigModes/vrRigMode";
  40751. /**
  40752. * Camera used to simulate VR rendering (based on FreeCamera)
  40753. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40754. */
  40755. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40756. /**
  40757. * Creates a new VRDeviceOrientationFreeCamera
  40758. * @param name defines camera name
  40759. * @param position defines the start position of the camera
  40760. * @param scene defines the scene the camera belongs to
  40761. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40762. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40763. */
  40764. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40765. /**
  40766. * Gets camera class name
  40767. * @returns VRDeviceOrientationFreeCamera
  40768. */
  40769. getClassName(): string;
  40770. }
  40771. }
  40772. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40773. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40774. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40775. import { Scene } from "babylonjs/scene";
  40776. import { Vector3 } from "babylonjs/Maths/math.vector";
  40777. import "babylonjs/Gamepads/gamepadSceneComponent";
  40778. /**
  40779. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40780. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40781. */
  40782. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40783. /**
  40784. * Creates a new VRDeviceOrientationGamepadCamera
  40785. * @param name defines camera name
  40786. * @param position defines the start position of the camera
  40787. * @param scene defines the scene the camera belongs to
  40788. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40789. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40790. */
  40791. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40792. /**
  40793. * Gets camera class name
  40794. * @returns VRDeviceOrientationGamepadCamera
  40795. */
  40796. getClassName(): string;
  40797. }
  40798. }
  40799. declare module "babylonjs/Materials/pushMaterial" {
  40800. import { Nullable } from "babylonjs/types";
  40801. import { Scene } from "babylonjs/scene";
  40802. import { Matrix } from "babylonjs/Maths/math.vector";
  40803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40804. import { Mesh } from "babylonjs/Meshes/mesh";
  40805. import { Material } from "babylonjs/Materials/material";
  40806. import { Effect } from "babylonjs/Materials/effect";
  40807. /**
  40808. * Base class of materials working in push mode in babylon JS
  40809. * @hidden
  40810. */
  40811. export class PushMaterial extends Material {
  40812. protected _activeEffect: Effect;
  40813. protected _normalMatrix: Matrix;
  40814. /**
  40815. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40816. * This means that the material can keep using a previous shader while a new one is being compiled.
  40817. * This is mostly used when shader parallel compilation is supported (true by default)
  40818. */
  40819. allowShaderHotSwapping: boolean;
  40820. constructor(name: string, scene: Scene);
  40821. getEffect(): Effect;
  40822. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40823. /**
  40824. * Binds the given world matrix to the active effect
  40825. *
  40826. * @param world the matrix to bind
  40827. */
  40828. bindOnlyWorldMatrix(world: Matrix): void;
  40829. /**
  40830. * Binds the given normal matrix to the active effect
  40831. *
  40832. * @param normalMatrix the matrix to bind
  40833. */
  40834. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40835. bind(world: Matrix, mesh?: Mesh): void;
  40836. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40837. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40838. }
  40839. }
  40840. declare module "babylonjs/Materials/materialFlags" {
  40841. /**
  40842. * This groups all the flags used to control the materials channel.
  40843. */
  40844. export class MaterialFlags {
  40845. private static _DiffuseTextureEnabled;
  40846. /**
  40847. * Are diffuse textures enabled in the application.
  40848. */
  40849. static DiffuseTextureEnabled: boolean;
  40850. private static _AmbientTextureEnabled;
  40851. /**
  40852. * Are ambient textures enabled in the application.
  40853. */
  40854. static AmbientTextureEnabled: boolean;
  40855. private static _OpacityTextureEnabled;
  40856. /**
  40857. * Are opacity textures enabled in the application.
  40858. */
  40859. static OpacityTextureEnabled: boolean;
  40860. private static _ReflectionTextureEnabled;
  40861. /**
  40862. * Are reflection textures enabled in the application.
  40863. */
  40864. static ReflectionTextureEnabled: boolean;
  40865. private static _EmissiveTextureEnabled;
  40866. /**
  40867. * Are emissive textures enabled in the application.
  40868. */
  40869. static EmissiveTextureEnabled: boolean;
  40870. private static _SpecularTextureEnabled;
  40871. /**
  40872. * Are specular textures enabled in the application.
  40873. */
  40874. static SpecularTextureEnabled: boolean;
  40875. private static _BumpTextureEnabled;
  40876. /**
  40877. * Are bump textures enabled in the application.
  40878. */
  40879. static BumpTextureEnabled: boolean;
  40880. private static _LightmapTextureEnabled;
  40881. /**
  40882. * Are lightmap textures enabled in the application.
  40883. */
  40884. static LightmapTextureEnabled: boolean;
  40885. private static _RefractionTextureEnabled;
  40886. /**
  40887. * Are refraction textures enabled in the application.
  40888. */
  40889. static RefractionTextureEnabled: boolean;
  40890. private static _ColorGradingTextureEnabled;
  40891. /**
  40892. * Are color grading textures enabled in the application.
  40893. */
  40894. static ColorGradingTextureEnabled: boolean;
  40895. private static _FresnelEnabled;
  40896. /**
  40897. * Are fresnels enabled in the application.
  40898. */
  40899. static FresnelEnabled: boolean;
  40900. private static _ClearCoatTextureEnabled;
  40901. /**
  40902. * Are clear coat textures enabled in the application.
  40903. */
  40904. static ClearCoatTextureEnabled: boolean;
  40905. private static _ClearCoatBumpTextureEnabled;
  40906. /**
  40907. * Are clear coat bump textures enabled in the application.
  40908. */
  40909. static ClearCoatBumpTextureEnabled: boolean;
  40910. private static _ClearCoatTintTextureEnabled;
  40911. /**
  40912. * Are clear coat tint textures enabled in the application.
  40913. */
  40914. static ClearCoatTintTextureEnabled: boolean;
  40915. private static _SheenTextureEnabled;
  40916. /**
  40917. * Are sheen textures enabled in the application.
  40918. */
  40919. static SheenTextureEnabled: boolean;
  40920. private static _AnisotropicTextureEnabled;
  40921. /**
  40922. * Are anisotropic textures enabled in the application.
  40923. */
  40924. static AnisotropicTextureEnabled: boolean;
  40925. private static _ThicknessTextureEnabled;
  40926. /**
  40927. * Are thickness textures enabled in the application.
  40928. */
  40929. static ThicknessTextureEnabled: boolean;
  40930. }
  40931. }
  40932. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40933. /** @hidden */
  40934. export var defaultFragmentDeclaration: {
  40935. name: string;
  40936. shader: string;
  40937. };
  40938. }
  40939. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40940. /** @hidden */
  40941. export var defaultUboDeclaration: {
  40942. name: string;
  40943. shader: string;
  40944. };
  40945. }
  40946. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40947. /** @hidden */
  40948. export var lightFragmentDeclaration: {
  40949. name: string;
  40950. shader: string;
  40951. };
  40952. }
  40953. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40954. /** @hidden */
  40955. export var lightUboDeclaration: {
  40956. name: string;
  40957. shader: string;
  40958. };
  40959. }
  40960. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40961. /** @hidden */
  40962. export var lightsFragmentFunctions: {
  40963. name: string;
  40964. shader: string;
  40965. };
  40966. }
  40967. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40968. /** @hidden */
  40969. export var shadowsFragmentFunctions: {
  40970. name: string;
  40971. shader: string;
  40972. };
  40973. }
  40974. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40975. /** @hidden */
  40976. export var fresnelFunction: {
  40977. name: string;
  40978. shader: string;
  40979. };
  40980. }
  40981. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40982. /** @hidden */
  40983. export var reflectionFunction: {
  40984. name: string;
  40985. shader: string;
  40986. };
  40987. }
  40988. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40989. /** @hidden */
  40990. export var bumpFragmentFunctions: {
  40991. name: string;
  40992. shader: string;
  40993. };
  40994. }
  40995. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40996. /** @hidden */
  40997. export var logDepthDeclaration: {
  40998. name: string;
  40999. shader: string;
  41000. };
  41001. }
  41002. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41003. /** @hidden */
  41004. export var bumpFragment: {
  41005. name: string;
  41006. shader: string;
  41007. };
  41008. }
  41009. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41010. /** @hidden */
  41011. export var depthPrePass: {
  41012. name: string;
  41013. shader: string;
  41014. };
  41015. }
  41016. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41017. /** @hidden */
  41018. export var lightFragment: {
  41019. name: string;
  41020. shader: string;
  41021. };
  41022. }
  41023. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41024. /** @hidden */
  41025. export var logDepthFragment: {
  41026. name: string;
  41027. shader: string;
  41028. };
  41029. }
  41030. declare module "babylonjs/Shaders/default.fragment" {
  41031. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41032. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41033. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41034. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41035. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41036. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41037. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41038. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41039. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41040. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41041. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41042. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41043. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41044. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41045. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41046. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41047. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41048. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41049. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41050. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41051. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41052. /** @hidden */
  41053. export var defaultPixelShader: {
  41054. name: string;
  41055. shader: string;
  41056. };
  41057. }
  41058. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41059. /** @hidden */
  41060. export var defaultVertexDeclaration: {
  41061. name: string;
  41062. shader: string;
  41063. };
  41064. }
  41065. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41066. /** @hidden */
  41067. export var bumpVertexDeclaration: {
  41068. name: string;
  41069. shader: string;
  41070. };
  41071. }
  41072. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41073. /** @hidden */
  41074. export var bumpVertex: {
  41075. name: string;
  41076. shader: string;
  41077. };
  41078. }
  41079. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41080. /** @hidden */
  41081. export var fogVertex: {
  41082. name: string;
  41083. shader: string;
  41084. };
  41085. }
  41086. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41087. /** @hidden */
  41088. export var shadowsVertex: {
  41089. name: string;
  41090. shader: string;
  41091. };
  41092. }
  41093. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41094. /** @hidden */
  41095. export var pointCloudVertex: {
  41096. name: string;
  41097. shader: string;
  41098. };
  41099. }
  41100. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41101. /** @hidden */
  41102. export var logDepthVertex: {
  41103. name: string;
  41104. shader: string;
  41105. };
  41106. }
  41107. declare module "babylonjs/Shaders/default.vertex" {
  41108. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41109. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41110. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41111. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41112. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41113. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41114. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41115. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41116. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41117. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41118. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41119. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41120. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41121. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41122. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41123. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41124. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41125. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41126. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41127. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41128. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41129. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41130. /** @hidden */
  41131. export var defaultVertexShader: {
  41132. name: string;
  41133. shader: string;
  41134. };
  41135. }
  41136. declare module "babylonjs/Materials/standardMaterial" {
  41137. import { SmartArray } from "babylonjs/Misc/smartArray";
  41138. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41139. import { Nullable } from "babylonjs/types";
  41140. import { Scene } from "babylonjs/scene";
  41141. import { Matrix } from "babylonjs/Maths/math.vector";
  41142. import { Color3 } from "babylonjs/Maths/math.color";
  41143. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41145. import { Mesh } from "babylonjs/Meshes/mesh";
  41146. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41147. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41148. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41149. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41150. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41151. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41153. import "babylonjs/Shaders/default.fragment";
  41154. import "babylonjs/Shaders/default.vertex";
  41155. /** @hidden */
  41156. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41157. MAINUV1: boolean;
  41158. MAINUV2: boolean;
  41159. DIFFUSE: boolean;
  41160. DIFFUSEDIRECTUV: number;
  41161. AMBIENT: boolean;
  41162. AMBIENTDIRECTUV: number;
  41163. OPACITY: boolean;
  41164. OPACITYDIRECTUV: number;
  41165. OPACITYRGB: boolean;
  41166. REFLECTION: boolean;
  41167. EMISSIVE: boolean;
  41168. EMISSIVEDIRECTUV: number;
  41169. SPECULAR: boolean;
  41170. SPECULARDIRECTUV: number;
  41171. BUMP: boolean;
  41172. BUMPDIRECTUV: number;
  41173. PARALLAX: boolean;
  41174. PARALLAXOCCLUSION: boolean;
  41175. SPECULAROVERALPHA: boolean;
  41176. CLIPPLANE: boolean;
  41177. CLIPPLANE2: boolean;
  41178. CLIPPLANE3: boolean;
  41179. CLIPPLANE4: boolean;
  41180. ALPHATEST: boolean;
  41181. DEPTHPREPASS: boolean;
  41182. ALPHAFROMDIFFUSE: boolean;
  41183. POINTSIZE: boolean;
  41184. FOG: boolean;
  41185. SPECULARTERM: boolean;
  41186. DIFFUSEFRESNEL: boolean;
  41187. OPACITYFRESNEL: boolean;
  41188. REFLECTIONFRESNEL: boolean;
  41189. REFRACTIONFRESNEL: boolean;
  41190. EMISSIVEFRESNEL: boolean;
  41191. FRESNEL: boolean;
  41192. NORMAL: boolean;
  41193. UV1: boolean;
  41194. UV2: boolean;
  41195. VERTEXCOLOR: boolean;
  41196. VERTEXALPHA: boolean;
  41197. NUM_BONE_INFLUENCERS: number;
  41198. BonesPerMesh: number;
  41199. BONETEXTURE: boolean;
  41200. INSTANCES: boolean;
  41201. GLOSSINESS: boolean;
  41202. ROUGHNESS: boolean;
  41203. EMISSIVEASILLUMINATION: boolean;
  41204. LINKEMISSIVEWITHDIFFUSE: boolean;
  41205. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41206. LIGHTMAP: boolean;
  41207. LIGHTMAPDIRECTUV: number;
  41208. OBJECTSPACE_NORMALMAP: boolean;
  41209. USELIGHTMAPASSHADOWMAP: boolean;
  41210. REFLECTIONMAP_3D: boolean;
  41211. REFLECTIONMAP_SPHERICAL: boolean;
  41212. REFLECTIONMAP_PLANAR: boolean;
  41213. REFLECTIONMAP_CUBIC: boolean;
  41214. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41215. REFLECTIONMAP_PROJECTION: boolean;
  41216. REFLECTIONMAP_SKYBOX: boolean;
  41217. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41218. REFLECTIONMAP_EXPLICIT: boolean;
  41219. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41220. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41221. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41222. INVERTCUBICMAP: boolean;
  41223. LOGARITHMICDEPTH: boolean;
  41224. REFRACTION: boolean;
  41225. REFRACTIONMAP_3D: boolean;
  41226. REFLECTIONOVERALPHA: boolean;
  41227. TWOSIDEDLIGHTING: boolean;
  41228. SHADOWFLOAT: boolean;
  41229. MORPHTARGETS: boolean;
  41230. MORPHTARGETS_NORMAL: boolean;
  41231. MORPHTARGETS_TANGENT: boolean;
  41232. MORPHTARGETS_UV: boolean;
  41233. NUM_MORPH_INFLUENCERS: number;
  41234. NONUNIFORMSCALING: boolean;
  41235. PREMULTIPLYALPHA: boolean;
  41236. IMAGEPROCESSING: boolean;
  41237. VIGNETTE: boolean;
  41238. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41239. VIGNETTEBLENDMODEOPAQUE: boolean;
  41240. TONEMAPPING: boolean;
  41241. TONEMAPPING_ACES: boolean;
  41242. CONTRAST: boolean;
  41243. COLORCURVES: boolean;
  41244. COLORGRADING: boolean;
  41245. COLORGRADING3D: boolean;
  41246. SAMPLER3DGREENDEPTH: boolean;
  41247. SAMPLER3DBGRMAP: boolean;
  41248. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41249. MULTIVIEW: boolean;
  41250. /**
  41251. * If the reflection texture on this material is in linear color space
  41252. * @hidden
  41253. */
  41254. IS_REFLECTION_LINEAR: boolean;
  41255. /**
  41256. * If the refraction texture on this material is in linear color space
  41257. * @hidden
  41258. */
  41259. IS_REFRACTION_LINEAR: boolean;
  41260. EXPOSURE: boolean;
  41261. constructor();
  41262. setReflectionMode(modeToEnable: string): void;
  41263. }
  41264. /**
  41265. * This is the default material used in Babylon. It is the best trade off between quality
  41266. * and performances.
  41267. * @see http://doc.babylonjs.com/babylon101/materials
  41268. */
  41269. export class StandardMaterial extends PushMaterial {
  41270. private _diffuseTexture;
  41271. /**
  41272. * The basic texture of the material as viewed under a light.
  41273. */
  41274. diffuseTexture: Nullable<BaseTexture>;
  41275. private _ambientTexture;
  41276. /**
  41277. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41278. */
  41279. ambientTexture: Nullable<BaseTexture>;
  41280. private _opacityTexture;
  41281. /**
  41282. * Define the transparency of the material from a texture.
  41283. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41284. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41285. */
  41286. opacityTexture: Nullable<BaseTexture>;
  41287. private _reflectionTexture;
  41288. /**
  41289. * Define the texture used to display the reflection.
  41290. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41291. */
  41292. reflectionTexture: Nullable<BaseTexture>;
  41293. private _emissiveTexture;
  41294. /**
  41295. * Define texture of the material as if self lit.
  41296. * This will be mixed in the final result even in the absence of light.
  41297. */
  41298. emissiveTexture: Nullable<BaseTexture>;
  41299. private _specularTexture;
  41300. /**
  41301. * Define how the color and intensity of the highlight given by the light in the material.
  41302. */
  41303. specularTexture: Nullable<BaseTexture>;
  41304. private _bumpTexture;
  41305. /**
  41306. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41307. * 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.
  41308. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41309. */
  41310. bumpTexture: Nullable<BaseTexture>;
  41311. private _lightmapTexture;
  41312. /**
  41313. * Complex lighting can be computationally expensive to compute at runtime.
  41314. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41315. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41316. */
  41317. lightmapTexture: Nullable<BaseTexture>;
  41318. private _refractionTexture;
  41319. /**
  41320. * Define the texture used to display the refraction.
  41321. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41322. */
  41323. refractionTexture: Nullable<BaseTexture>;
  41324. /**
  41325. * The color of the material lit by the environmental background lighting.
  41326. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41327. */
  41328. ambientColor: Color3;
  41329. /**
  41330. * The basic color of the material as viewed under a light.
  41331. */
  41332. diffuseColor: Color3;
  41333. /**
  41334. * Define how the color and intensity of the highlight given by the light in the material.
  41335. */
  41336. specularColor: Color3;
  41337. /**
  41338. * Define the color of the material as if self lit.
  41339. * This will be mixed in the final result even in the absence of light.
  41340. */
  41341. emissiveColor: Color3;
  41342. /**
  41343. * Defines how sharp are the highlights in the material.
  41344. * The bigger the value the sharper giving a more glossy feeling to the result.
  41345. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41346. */
  41347. specularPower: number;
  41348. private _useAlphaFromDiffuseTexture;
  41349. /**
  41350. * Does the transparency come from the diffuse texture alpha channel.
  41351. */
  41352. useAlphaFromDiffuseTexture: boolean;
  41353. private _useEmissiveAsIllumination;
  41354. /**
  41355. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41356. */
  41357. useEmissiveAsIllumination: boolean;
  41358. private _linkEmissiveWithDiffuse;
  41359. /**
  41360. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41361. * the emissive level when the final color is close to one.
  41362. */
  41363. linkEmissiveWithDiffuse: boolean;
  41364. private _useSpecularOverAlpha;
  41365. /**
  41366. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41367. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41368. */
  41369. useSpecularOverAlpha: boolean;
  41370. private _useReflectionOverAlpha;
  41371. /**
  41372. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41373. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41374. */
  41375. useReflectionOverAlpha: boolean;
  41376. private _disableLighting;
  41377. /**
  41378. * Does lights from the scene impacts this material.
  41379. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41380. */
  41381. disableLighting: boolean;
  41382. private _useObjectSpaceNormalMap;
  41383. /**
  41384. * Allows using an object space normal map (instead of tangent space).
  41385. */
  41386. useObjectSpaceNormalMap: boolean;
  41387. private _useParallax;
  41388. /**
  41389. * Is parallax enabled or not.
  41390. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41391. */
  41392. useParallax: boolean;
  41393. private _useParallaxOcclusion;
  41394. /**
  41395. * Is parallax occlusion enabled or not.
  41396. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41397. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41398. */
  41399. useParallaxOcclusion: boolean;
  41400. /**
  41401. * 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.
  41402. */
  41403. parallaxScaleBias: number;
  41404. private _roughness;
  41405. /**
  41406. * Helps to define how blurry the reflections should appears in the material.
  41407. */
  41408. roughness: number;
  41409. /**
  41410. * In case of refraction, define the value of the index of refraction.
  41411. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41412. */
  41413. indexOfRefraction: number;
  41414. /**
  41415. * Invert the refraction texture alongside the y axis.
  41416. * It can be useful with procedural textures or probe for instance.
  41417. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41418. */
  41419. invertRefractionY: boolean;
  41420. /**
  41421. * Defines the alpha limits in alpha test mode.
  41422. */
  41423. alphaCutOff: number;
  41424. private _useLightmapAsShadowmap;
  41425. /**
  41426. * In case of light mapping, define whether the map contains light or shadow informations.
  41427. */
  41428. useLightmapAsShadowmap: boolean;
  41429. private _diffuseFresnelParameters;
  41430. /**
  41431. * Define the diffuse fresnel parameters of the material.
  41432. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41433. */
  41434. diffuseFresnelParameters: FresnelParameters;
  41435. private _opacityFresnelParameters;
  41436. /**
  41437. * Define the opacity fresnel parameters of the material.
  41438. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41439. */
  41440. opacityFresnelParameters: FresnelParameters;
  41441. private _reflectionFresnelParameters;
  41442. /**
  41443. * Define the reflection fresnel parameters of the material.
  41444. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41445. */
  41446. reflectionFresnelParameters: FresnelParameters;
  41447. private _refractionFresnelParameters;
  41448. /**
  41449. * Define the refraction fresnel parameters of the material.
  41450. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41451. */
  41452. refractionFresnelParameters: FresnelParameters;
  41453. private _emissiveFresnelParameters;
  41454. /**
  41455. * Define the emissive fresnel parameters of the material.
  41456. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41457. */
  41458. emissiveFresnelParameters: FresnelParameters;
  41459. private _useReflectionFresnelFromSpecular;
  41460. /**
  41461. * If true automatically deducts the fresnels values from the material specularity.
  41462. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41463. */
  41464. useReflectionFresnelFromSpecular: boolean;
  41465. private _useGlossinessFromSpecularMapAlpha;
  41466. /**
  41467. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41468. */
  41469. useGlossinessFromSpecularMapAlpha: boolean;
  41470. private _maxSimultaneousLights;
  41471. /**
  41472. * Defines the maximum number of lights that can be used in the material
  41473. */
  41474. maxSimultaneousLights: number;
  41475. private _invertNormalMapX;
  41476. /**
  41477. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41478. */
  41479. invertNormalMapX: boolean;
  41480. private _invertNormalMapY;
  41481. /**
  41482. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41483. */
  41484. invertNormalMapY: boolean;
  41485. private _twoSidedLighting;
  41486. /**
  41487. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41488. */
  41489. twoSidedLighting: boolean;
  41490. /**
  41491. * Default configuration related to image processing available in the standard Material.
  41492. */
  41493. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41494. /**
  41495. * Gets the image processing configuration used either in this material.
  41496. */
  41497. /**
  41498. * Sets the Default image processing configuration used either in the this material.
  41499. *
  41500. * If sets to null, the scene one is in use.
  41501. */
  41502. imageProcessingConfiguration: ImageProcessingConfiguration;
  41503. /**
  41504. * Keep track of the image processing observer to allow dispose and replace.
  41505. */
  41506. private _imageProcessingObserver;
  41507. /**
  41508. * Attaches a new image processing configuration to the Standard Material.
  41509. * @param configuration
  41510. */
  41511. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41512. /**
  41513. * Gets wether the color curves effect is enabled.
  41514. */
  41515. /**
  41516. * Sets wether the color curves effect is enabled.
  41517. */
  41518. cameraColorCurvesEnabled: boolean;
  41519. /**
  41520. * Gets wether the color grading effect is enabled.
  41521. */
  41522. /**
  41523. * Gets wether the color grading effect is enabled.
  41524. */
  41525. cameraColorGradingEnabled: boolean;
  41526. /**
  41527. * Gets wether tonemapping is enabled or not.
  41528. */
  41529. /**
  41530. * Sets wether tonemapping is enabled or not
  41531. */
  41532. cameraToneMappingEnabled: boolean;
  41533. /**
  41534. * The camera exposure used on this material.
  41535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41536. * This corresponds to a photographic exposure.
  41537. */
  41538. /**
  41539. * The camera exposure used on this material.
  41540. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41541. * This corresponds to a photographic exposure.
  41542. */
  41543. cameraExposure: number;
  41544. /**
  41545. * Gets The camera contrast used on this material.
  41546. */
  41547. /**
  41548. * Sets The camera contrast used on this material.
  41549. */
  41550. cameraContrast: number;
  41551. /**
  41552. * Gets the Color Grading 2D Lookup Texture.
  41553. */
  41554. /**
  41555. * Sets the Color Grading 2D Lookup Texture.
  41556. */
  41557. cameraColorGradingTexture: Nullable<BaseTexture>;
  41558. /**
  41559. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41560. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41561. * 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;
  41562. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41563. */
  41564. /**
  41565. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41566. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41567. * 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;
  41568. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41569. */
  41570. cameraColorCurves: Nullable<ColorCurves>;
  41571. /**
  41572. * Custom callback helping to override the default shader used in the material.
  41573. */
  41574. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41575. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41576. protected _worldViewProjectionMatrix: Matrix;
  41577. protected _globalAmbientColor: Color3;
  41578. protected _useLogarithmicDepth: boolean;
  41579. protected _rebuildInParallel: boolean;
  41580. /**
  41581. * Instantiates a new standard material.
  41582. * This is the default material used in Babylon. It is the best trade off between quality
  41583. * and performances.
  41584. * @see http://doc.babylonjs.com/babylon101/materials
  41585. * @param name Define the name of the material in the scene
  41586. * @param scene Define the scene the material belong to
  41587. */
  41588. constructor(name: string, scene: Scene);
  41589. /**
  41590. * Gets a boolean indicating that current material needs to register RTT
  41591. */
  41592. readonly hasRenderTargetTextures: boolean;
  41593. /**
  41594. * Gets the current class name of the material e.g. "StandardMaterial"
  41595. * Mainly use in serialization.
  41596. * @returns the class name
  41597. */
  41598. getClassName(): string;
  41599. /**
  41600. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41601. * You can try switching to logarithmic depth.
  41602. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41603. */
  41604. useLogarithmicDepth: boolean;
  41605. /**
  41606. * Specifies if the material will require alpha blending
  41607. * @returns a boolean specifying if alpha blending is needed
  41608. */
  41609. needAlphaBlending(): boolean;
  41610. /**
  41611. * Specifies if this material should be rendered in alpha test mode
  41612. * @returns a boolean specifying if an alpha test is needed.
  41613. */
  41614. needAlphaTesting(): boolean;
  41615. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41616. /**
  41617. * Get the texture used for alpha test purpose.
  41618. * @returns the diffuse texture in case of the standard material.
  41619. */
  41620. getAlphaTestTexture(): Nullable<BaseTexture>;
  41621. /**
  41622. * Get if the submesh is ready to be used and all its information available.
  41623. * Child classes can use it to update shaders
  41624. * @param mesh defines the mesh to check
  41625. * @param subMesh defines which submesh to check
  41626. * @param useInstances specifies that instances should be used
  41627. * @returns a boolean indicating that the submesh is ready or not
  41628. */
  41629. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41630. /**
  41631. * Builds the material UBO layouts.
  41632. * Used internally during the effect preparation.
  41633. */
  41634. buildUniformLayout(): void;
  41635. /**
  41636. * Unbinds the material from the mesh
  41637. */
  41638. unbind(): void;
  41639. /**
  41640. * Binds the submesh to this material by preparing the effect and shader to draw
  41641. * @param world defines the world transformation matrix
  41642. * @param mesh defines the mesh containing the submesh
  41643. * @param subMesh defines the submesh to bind the material to
  41644. */
  41645. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41646. /**
  41647. * Get the list of animatables in the material.
  41648. * @returns the list of animatables object used in the material
  41649. */
  41650. getAnimatables(): IAnimatable[];
  41651. /**
  41652. * Gets the active textures from the material
  41653. * @returns an array of textures
  41654. */
  41655. getActiveTextures(): BaseTexture[];
  41656. /**
  41657. * Specifies if the material uses a texture
  41658. * @param texture defines the texture to check against the material
  41659. * @returns a boolean specifying if the material uses the texture
  41660. */
  41661. hasTexture(texture: BaseTexture): boolean;
  41662. /**
  41663. * Disposes the material
  41664. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41665. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41666. */
  41667. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41668. /**
  41669. * Makes a duplicate of the material, and gives it a new name
  41670. * @param name defines the new name for the duplicated material
  41671. * @returns the cloned material
  41672. */
  41673. clone(name: string): StandardMaterial;
  41674. /**
  41675. * Serializes this material in a JSON representation
  41676. * @returns the serialized material object
  41677. */
  41678. serialize(): any;
  41679. /**
  41680. * Creates a standard material from parsed material data
  41681. * @param source defines the JSON representation of the material
  41682. * @param scene defines the hosting scene
  41683. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41684. * @returns a new standard material
  41685. */
  41686. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41687. /**
  41688. * Are diffuse textures enabled in the application.
  41689. */
  41690. static DiffuseTextureEnabled: boolean;
  41691. /**
  41692. * Are ambient textures enabled in the application.
  41693. */
  41694. static AmbientTextureEnabled: boolean;
  41695. /**
  41696. * Are opacity textures enabled in the application.
  41697. */
  41698. static OpacityTextureEnabled: boolean;
  41699. /**
  41700. * Are reflection textures enabled in the application.
  41701. */
  41702. static ReflectionTextureEnabled: boolean;
  41703. /**
  41704. * Are emissive textures enabled in the application.
  41705. */
  41706. static EmissiveTextureEnabled: boolean;
  41707. /**
  41708. * Are specular textures enabled in the application.
  41709. */
  41710. static SpecularTextureEnabled: boolean;
  41711. /**
  41712. * Are bump textures enabled in the application.
  41713. */
  41714. static BumpTextureEnabled: boolean;
  41715. /**
  41716. * Are lightmap textures enabled in the application.
  41717. */
  41718. static LightmapTextureEnabled: boolean;
  41719. /**
  41720. * Are refraction textures enabled in the application.
  41721. */
  41722. static RefractionTextureEnabled: boolean;
  41723. /**
  41724. * Are color grading textures enabled in the application.
  41725. */
  41726. static ColorGradingTextureEnabled: boolean;
  41727. /**
  41728. * Are fresnels enabled in the application.
  41729. */
  41730. static FresnelEnabled: boolean;
  41731. }
  41732. }
  41733. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41734. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41735. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41736. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41737. /** @hidden */
  41738. export var imageProcessingPixelShader: {
  41739. name: string;
  41740. shader: string;
  41741. };
  41742. }
  41743. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41744. import { Nullable } from "babylonjs/types";
  41745. import { Color4 } from "babylonjs/Maths/math.color";
  41746. import { Camera } from "babylonjs/Cameras/camera";
  41747. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41748. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41749. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41750. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41751. import { Engine } from "babylonjs/Engines/engine";
  41752. import "babylonjs/Shaders/imageProcessing.fragment";
  41753. import "babylonjs/Shaders/postprocess.vertex";
  41754. /**
  41755. * ImageProcessingPostProcess
  41756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41757. */
  41758. export class ImageProcessingPostProcess extends PostProcess {
  41759. /**
  41760. * Default configuration related to image processing available in the PBR Material.
  41761. */
  41762. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41763. /**
  41764. * Gets the image processing configuration used either in this material.
  41765. */
  41766. /**
  41767. * Sets the Default image processing configuration used either in the this material.
  41768. *
  41769. * If sets to null, the scene one is in use.
  41770. */
  41771. imageProcessingConfiguration: ImageProcessingConfiguration;
  41772. /**
  41773. * Keep track of the image processing observer to allow dispose and replace.
  41774. */
  41775. private _imageProcessingObserver;
  41776. /**
  41777. * Attaches a new image processing configuration to the PBR Material.
  41778. * @param configuration
  41779. */
  41780. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41781. /**
  41782. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41783. */
  41784. /**
  41785. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41786. */
  41787. colorCurves: Nullable<ColorCurves>;
  41788. /**
  41789. * Gets wether the color curves effect is enabled.
  41790. */
  41791. /**
  41792. * Sets wether the color curves effect is enabled.
  41793. */
  41794. colorCurvesEnabled: boolean;
  41795. /**
  41796. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41797. */
  41798. /**
  41799. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41800. */
  41801. colorGradingTexture: Nullable<BaseTexture>;
  41802. /**
  41803. * Gets wether the color grading effect is enabled.
  41804. */
  41805. /**
  41806. * Gets wether the color grading effect is enabled.
  41807. */
  41808. colorGradingEnabled: boolean;
  41809. /**
  41810. * Gets exposure used in the effect.
  41811. */
  41812. /**
  41813. * Sets exposure used in the effect.
  41814. */
  41815. exposure: number;
  41816. /**
  41817. * Gets wether tonemapping is enabled or not.
  41818. */
  41819. /**
  41820. * Sets wether tonemapping is enabled or not
  41821. */
  41822. toneMappingEnabled: boolean;
  41823. /**
  41824. * Gets the type of tone mapping effect.
  41825. */
  41826. /**
  41827. * Sets the type of tone mapping effect.
  41828. */
  41829. toneMappingType: number;
  41830. /**
  41831. * Gets contrast used in the effect.
  41832. */
  41833. /**
  41834. * Sets contrast used in the effect.
  41835. */
  41836. contrast: number;
  41837. /**
  41838. * Gets Vignette stretch size.
  41839. */
  41840. /**
  41841. * Sets Vignette stretch size.
  41842. */
  41843. vignetteStretch: number;
  41844. /**
  41845. * Gets Vignette centre X Offset.
  41846. */
  41847. /**
  41848. * Sets Vignette centre X Offset.
  41849. */
  41850. vignetteCentreX: number;
  41851. /**
  41852. * Gets Vignette centre Y Offset.
  41853. */
  41854. /**
  41855. * Sets Vignette centre Y Offset.
  41856. */
  41857. vignetteCentreY: number;
  41858. /**
  41859. * Gets Vignette weight or intensity of the vignette effect.
  41860. */
  41861. /**
  41862. * Sets Vignette weight or intensity of the vignette effect.
  41863. */
  41864. vignetteWeight: number;
  41865. /**
  41866. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41867. * if vignetteEnabled is set to true.
  41868. */
  41869. /**
  41870. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41871. * if vignetteEnabled is set to true.
  41872. */
  41873. vignetteColor: Color4;
  41874. /**
  41875. * Gets Camera field of view used by the Vignette effect.
  41876. */
  41877. /**
  41878. * Sets Camera field of view used by the Vignette effect.
  41879. */
  41880. vignetteCameraFov: number;
  41881. /**
  41882. * Gets the vignette blend mode allowing different kind of effect.
  41883. */
  41884. /**
  41885. * Sets the vignette blend mode allowing different kind of effect.
  41886. */
  41887. vignetteBlendMode: number;
  41888. /**
  41889. * Gets wether the vignette effect is enabled.
  41890. */
  41891. /**
  41892. * Sets wether the vignette effect is enabled.
  41893. */
  41894. vignetteEnabled: boolean;
  41895. private _fromLinearSpace;
  41896. /**
  41897. * Gets wether the input of the processing is in Gamma or Linear Space.
  41898. */
  41899. /**
  41900. * Sets wether the input of the processing is in Gamma or Linear Space.
  41901. */
  41902. fromLinearSpace: boolean;
  41903. /**
  41904. * Defines cache preventing GC.
  41905. */
  41906. private _defines;
  41907. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41908. /**
  41909. * "ImageProcessingPostProcess"
  41910. * @returns "ImageProcessingPostProcess"
  41911. */
  41912. getClassName(): string;
  41913. protected _updateParameters(): void;
  41914. dispose(camera?: Camera): void;
  41915. }
  41916. }
  41917. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41918. import { Scene } from "babylonjs/scene";
  41919. import { Color3 } from "babylonjs/Maths/math.color";
  41920. import { Mesh } from "babylonjs/Meshes/mesh";
  41921. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41922. import { Nullable } from "babylonjs/types";
  41923. /**
  41924. * Class containing static functions to help procedurally build meshes
  41925. */
  41926. export class GroundBuilder {
  41927. /**
  41928. * Creates a ground mesh
  41929. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41930. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41932. * @param name defines the name of the mesh
  41933. * @param options defines the options used to create the mesh
  41934. * @param scene defines the hosting scene
  41935. * @returns the ground mesh
  41936. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41937. */
  41938. static CreateGround(name: string, options: {
  41939. width?: number;
  41940. height?: number;
  41941. subdivisions?: number;
  41942. subdivisionsX?: number;
  41943. subdivisionsY?: number;
  41944. updatable?: boolean;
  41945. }, scene: any): Mesh;
  41946. /**
  41947. * Creates a tiled ground mesh
  41948. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41949. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41950. * * 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
  41951. * * 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
  41952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41953. * @param name defines the name of the mesh
  41954. * @param options defines the options used to create the mesh
  41955. * @param scene defines the hosting scene
  41956. * @returns the tiled ground mesh
  41957. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41958. */
  41959. static CreateTiledGround(name: string, options: {
  41960. xmin: number;
  41961. zmin: number;
  41962. xmax: number;
  41963. zmax: number;
  41964. subdivisions?: {
  41965. w: number;
  41966. h: number;
  41967. };
  41968. precision?: {
  41969. w: number;
  41970. h: number;
  41971. };
  41972. updatable?: boolean;
  41973. }, scene?: Nullable<Scene>): Mesh;
  41974. /**
  41975. * Creates a ground mesh from a height map
  41976. * * The parameter `url` sets the URL of the height map image resource.
  41977. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41978. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41979. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41980. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41981. * * 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.
  41982. * * 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).
  41983. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41985. * @param name defines the name of the mesh
  41986. * @param url defines the url to the height map
  41987. * @param options defines the options used to create the mesh
  41988. * @param scene defines the hosting scene
  41989. * @returns the ground mesh
  41990. * @see https://doc.babylonjs.com/babylon101/height_map
  41991. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41992. */
  41993. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41994. width?: number;
  41995. height?: number;
  41996. subdivisions?: number;
  41997. minHeight?: number;
  41998. maxHeight?: number;
  41999. colorFilter?: Color3;
  42000. alphaFilter?: number;
  42001. updatable?: boolean;
  42002. onReady?: (mesh: GroundMesh) => void;
  42003. }, scene?: Nullable<Scene>): GroundMesh;
  42004. }
  42005. }
  42006. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42007. import { Vector4 } from "babylonjs/Maths/math.vector";
  42008. import { Mesh } from "babylonjs/Meshes/mesh";
  42009. /**
  42010. * Class containing static functions to help procedurally build meshes
  42011. */
  42012. export class TorusBuilder {
  42013. /**
  42014. * Creates a torus mesh
  42015. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42016. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42017. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42021. * @param name defines the name of the mesh
  42022. * @param options defines the options used to create the mesh
  42023. * @param scene defines the hosting scene
  42024. * @returns the torus mesh
  42025. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42026. */
  42027. static CreateTorus(name: string, options: {
  42028. diameter?: number;
  42029. thickness?: number;
  42030. tessellation?: number;
  42031. updatable?: boolean;
  42032. sideOrientation?: number;
  42033. frontUVs?: Vector4;
  42034. backUVs?: Vector4;
  42035. }, scene: any): Mesh;
  42036. }
  42037. }
  42038. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42039. import { Vector4 } from "babylonjs/Maths/math.vector";
  42040. import { Color4 } from "babylonjs/Maths/math.color";
  42041. import { Mesh } from "babylonjs/Meshes/mesh";
  42042. /**
  42043. * Class containing static functions to help procedurally build meshes
  42044. */
  42045. export class CylinderBuilder {
  42046. /**
  42047. * Creates a cylinder or a cone mesh
  42048. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42049. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42050. * * 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.
  42051. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42052. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42053. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42054. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42055. * * 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).
  42056. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42057. * * 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).
  42058. * * 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
  42059. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42060. * * 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
  42061. * * 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.
  42062. * * If `enclose` is false, a ring surface is one element.
  42063. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42064. * * 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
  42065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42068. * @param name defines the name of the mesh
  42069. * @param options defines the options used to create the mesh
  42070. * @param scene defines the hosting scene
  42071. * @returns the cylinder mesh
  42072. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42073. */
  42074. static CreateCylinder(name: string, options: {
  42075. height?: number;
  42076. diameterTop?: number;
  42077. diameterBottom?: number;
  42078. diameter?: number;
  42079. tessellation?: number;
  42080. subdivisions?: number;
  42081. arc?: number;
  42082. faceColors?: Color4[];
  42083. faceUV?: Vector4[];
  42084. updatable?: boolean;
  42085. hasRings?: boolean;
  42086. enclose?: boolean;
  42087. cap?: number;
  42088. sideOrientation?: number;
  42089. frontUVs?: Vector4;
  42090. backUVs?: Vector4;
  42091. }, scene: any): Mesh;
  42092. }
  42093. }
  42094. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42095. import { Observable } from "babylonjs/Misc/observable";
  42096. import { Nullable } from "babylonjs/types";
  42097. import { Camera } from "babylonjs/Cameras/camera";
  42098. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42099. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42100. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42101. import { Scene } from "babylonjs/scene";
  42102. import { Vector3 } from "babylonjs/Maths/math.vector";
  42103. import { Color3 } from "babylonjs/Maths/math.color";
  42104. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42106. import { Mesh } from "babylonjs/Meshes/mesh";
  42107. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42108. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42109. import "babylonjs/Meshes/Builders/groundBuilder";
  42110. import "babylonjs/Meshes/Builders/torusBuilder";
  42111. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42112. import "babylonjs/Gamepads/gamepadSceneComponent";
  42113. import "babylonjs/Animations/animatable";
  42114. /**
  42115. * Options to modify the vr teleportation behavior.
  42116. */
  42117. export interface VRTeleportationOptions {
  42118. /**
  42119. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42120. */
  42121. floorMeshName?: string;
  42122. /**
  42123. * A list of meshes to be used as the teleportation floor. (default: empty)
  42124. */
  42125. floorMeshes?: Mesh[];
  42126. }
  42127. /**
  42128. * Options to modify the vr experience helper's behavior.
  42129. */
  42130. export interface VRExperienceHelperOptions extends WebVROptions {
  42131. /**
  42132. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42133. */
  42134. createDeviceOrientationCamera?: boolean;
  42135. /**
  42136. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42137. */
  42138. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42139. /**
  42140. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42141. */
  42142. laserToggle?: boolean;
  42143. /**
  42144. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42145. */
  42146. floorMeshes?: Mesh[];
  42147. /**
  42148. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42149. */
  42150. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42151. }
  42152. /**
  42153. * Event containing information after VR has been entered
  42154. */
  42155. export class OnAfterEnteringVRObservableEvent {
  42156. /**
  42157. * If entering vr was successful
  42158. */
  42159. success: boolean;
  42160. }
  42161. /**
  42162. * Helps to quickly add VR support to an existing scene.
  42163. * See http://doc.babylonjs.com/how_to/webvr_helper
  42164. */
  42165. export class VRExperienceHelper {
  42166. /** Options to modify the vr experience helper's behavior. */
  42167. webVROptions: VRExperienceHelperOptions;
  42168. private _scene;
  42169. private _position;
  42170. private _btnVR;
  42171. private _btnVRDisplayed;
  42172. private _webVRsupported;
  42173. private _webVRready;
  42174. private _webVRrequesting;
  42175. private _webVRpresenting;
  42176. private _hasEnteredVR;
  42177. private _fullscreenVRpresenting;
  42178. private _canvas;
  42179. private _webVRCamera;
  42180. private _vrDeviceOrientationCamera;
  42181. private _deviceOrientationCamera;
  42182. private _existingCamera;
  42183. private _onKeyDown;
  42184. private _onVrDisplayPresentChange;
  42185. private _onVRDisplayChanged;
  42186. private _onVRRequestPresentStart;
  42187. private _onVRRequestPresentComplete;
  42188. /**
  42189. * 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)
  42190. */
  42191. enableGazeEvenWhenNoPointerLock: boolean;
  42192. /**
  42193. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42194. */
  42195. exitVROnDoubleTap: boolean;
  42196. /**
  42197. * Observable raised right before entering VR.
  42198. */
  42199. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42200. /**
  42201. * Observable raised when entering VR has completed.
  42202. */
  42203. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42204. /**
  42205. * Observable raised when exiting VR.
  42206. */
  42207. onExitingVRObservable: Observable<VRExperienceHelper>;
  42208. /**
  42209. * Observable raised when controller mesh is loaded.
  42210. */
  42211. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42212. /** Return this.onEnteringVRObservable
  42213. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42214. */
  42215. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42216. /** Return this.onExitingVRObservable
  42217. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42218. */
  42219. readonly onExitingVR: Observable<VRExperienceHelper>;
  42220. /** Return this.onControllerMeshLoadedObservable
  42221. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42222. */
  42223. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42224. private _rayLength;
  42225. private _useCustomVRButton;
  42226. private _teleportationRequested;
  42227. private _teleportActive;
  42228. private _floorMeshName;
  42229. private _floorMeshesCollection;
  42230. private _rotationAllowed;
  42231. private _teleportBackwardsVector;
  42232. private _teleportationTarget;
  42233. private _isDefaultTeleportationTarget;
  42234. private _postProcessMove;
  42235. private _teleportationFillColor;
  42236. private _teleportationBorderColor;
  42237. private _rotationAngle;
  42238. private _haloCenter;
  42239. private _cameraGazer;
  42240. private _padSensibilityUp;
  42241. private _padSensibilityDown;
  42242. private _leftController;
  42243. private _rightController;
  42244. /**
  42245. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42246. */
  42247. onNewMeshSelected: Observable<AbstractMesh>;
  42248. /**
  42249. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42250. * This observable will provide the mesh and the controller used to select the mesh
  42251. */
  42252. onMeshSelectedWithController: Observable<{
  42253. mesh: AbstractMesh;
  42254. controller: WebVRController;
  42255. }>;
  42256. /**
  42257. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42258. */
  42259. onNewMeshPicked: Observable<PickingInfo>;
  42260. private _circleEase;
  42261. /**
  42262. * Observable raised before camera teleportation
  42263. */
  42264. onBeforeCameraTeleport: Observable<Vector3>;
  42265. /**
  42266. * Observable raised after camera teleportation
  42267. */
  42268. onAfterCameraTeleport: Observable<Vector3>;
  42269. /**
  42270. * Observable raised when current selected mesh gets unselected
  42271. */
  42272. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42273. private _raySelectionPredicate;
  42274. /**
  42275. * To be optionaly changed by user to define custom ray selection
  42276. */
  42277. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42278. /**
  42279. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42280. */
  42281. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42282. /**
  42283. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42284. */
  42285. teleportationEnabled: boolean;
  42286. private _defaultHeight;
  42287. private _teleportationInitialized;
  42288. private _interactionsEnabled;
  42289. private _interactionsRequested;
  42290. private _displayGaze;
  42291. private _displayLaserPointer;
  42292. /**
  42293. * The mesh used to display where the user is going to teleport.
  42294. */
  42295. /**
  42296. * Sets the mesh to be used to display where the user is going to teleport.
  42297. */
  42298. teleportationTarget: Mesh;
  42299. /**
  42300. * 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
  42301. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42302. * See http://doc.babylonjs.com/resources/baking_transformations
  42303. */
  42304. gazeTrackerMesh: Mesh;
  42305. /**
  42306. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42307. */
  42308. updateGazeTrackerScale: boolean;
  42309. /**
  42310. * If the gaze trackers color should be updated when selecting meshes
  42311. */
  42312. updateGazeTrackerColor: boolean;
  42313. /**
  42314. * If the controller laser color should be updated when selecting meshes
  42315. */
  42316. updateControllerLaserColor: boolean;
  42317. /**
  42318. * The gaze tracking mesh corresponding to the left controller
  42319. */
  42320. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42321. /**
  42322. * The gaze tracking mesh corresponding to the right controller
  42323. */
  42324. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42325. /**
  42326. * If the ray of the gaze should be displayed.
  42327. */
  42328. /**
  42329. * Sets if the ray of the gaze should be displayed.
  42330. */
  42331. displayGaze: boolean;
  42332. /**
  42333. * If the ray of the LaserPointer should be displayed.
  42334. */
  42335. /**
  42336. * Sets if the ray of the LaserPointer should be displayed.
  42337. */
  42338. displayLaserPointer: boolean;
  42339. /**
  42340. * The deviceOrientationCamera used as the camera when not in VR.
  42341. */
  42342. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42343. /**
  42344. * Based on the current WebVR support, returns the current VR camera used.
  42345. */
  42346. readonly currentVRCamera: Nullable<Camera>;
  42347. /**
  42348. * The webVRCamera which is used when in VR.
  42349. */
  42350. readonly webVRCamera: WebVRFreeCamera;
  42351. /**
  42352. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42353. */
  42354. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42355. /**
  42356. * The html button that is used to trigger entering into VR.
  42357. */
  42358. readonly vrButton: Nullable<HTMLButtonElement>;
  42359. private readonly _teleportationRequestInitiated;
  42360. /**
  42361. * Defines wether or not Pointer lock should be requested when switching to
  42362. * full screen.
  42363. */
  42364. requestPointerLockOnFullScreen: boolean;
  42365. /**
  42366. * Instantiates a VRExperienceHelper.
  42367. * Helps to quickly add VR support to an existing scene.
  42368. * @param scene The scene the VRExperienceHelper belongs to.
  42369. * @param webVROptions Options to modify the vr experience helper's behavior.
  42370. */
  42371. constructor(scene: Scene,
  42372. /** Options to modify the vr experience helper's behavior. */
  42373. webVROptions?: VRExperienceHelperOptions);
  42374. private _onDefaultMeshLoaded;
  42375. private _onResize;
  42376. private _onFullscreenChange;
  42377. /**
  42378. * Gets a value indicating if we are currently in VR mode.
  42379. */
  42380. readonly isInVRMode: boolean;
  42381. private onVrDisplayPresentChange;
  42382. private onVRDisplayChanged;
  42383. private moveButtonToBottomRight;
  42384. private displayVRButton;
  42385. private updateButtonVisibility;
  42386. private _cachedAngularSensibility;
  42387. /**
  42388. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42389. * Otherwise, will use the fullscreen API.
  42390. */
  42391. enterVR(): void;
  42392. /**
  42393. * Attempt to exit VR, or fullscreen.
  42394. */
  42395. exitVR(): void;
  42396. /**
  42397. * The position of the vr experience helper.
  42398. */
  42399. /**
  42400. * Sets the position of the vr experience helper.
  42401. */
  42402. position: Vector3;
  42403. /**
  42404. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42405. */
  42406. enableInteractions(): void;
  42407. private readonly _noControllerIsActive;
  42408. private beforeRender;
  42409. private _isTeleportationFloor;
  42410. /**
  42411. * Adds a floor mesh to be used for teleportation.
  42412. * @param floorMesh the mesh to be used for teleportation.
  42413. */
  42414. addFloorMesh(floorMesh: Mesh): void;
  42415. /**
  42416. * Removes a floor mesh from being used for teleportation.
  42417. * @param floorMesh the mesh to be removed.
  42418. */
  42419. removeFloorMesh(floorMesh: Mesh): void;
  42420. /**
  42421. * Enables interactions and teleportation using the VR controllers and gaze.
  42422. * @param vrTeleportationOptions options to modify teleportation behavior.
  42423. */
  42424. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42425. private _onNewGamepadConnected;
  42426. private _tryEnableInteractionOnController;
  42427. private _onNewGamepadDisconnected;
  42428. private _enableInteractionOnController;
  42429. private _checkTeleportWithRay;
  42430. private _checkRotate;
  42431. private _checkTeleportBackwards;
  42432. private _enableTeleportationOnController;
  42433. private _createTeleportationCircles;
  42434. private _displayTeleportationTarget;
  42435. private _hideTeleportationTarget;
  42436. private _rotateCamera;
  42437. private _moveTeleportationSelectorTo;
  42438. private _workingVector;
  42439. private _workingQuaternion;
  42440. private _workingMatrix;
  42441. /**
  42442. * Teleports the users feet to the desired location
  42443. * @param location The location where the user's feet should be placed
  42444. */
  42445. teleportCamera(location: Vector3): void;
  42446. private _convertNormalToDirectionOfRay;
  42447. private _castRayAndSelectObject;
  42448. private _notifySelectedMeshUnselected;
  42449. /**
  42450. * Sets the color of the laser ray from the vr controllers.
  42451. * @param color new color for the ray.
  42452. */
  42453. changeLaserColor(color: Color3): void;
  42454. /**
  42455. * Sets the color of the ray from the vr headsets gaze.
  42456. * @param color new color for the ray.
  42457. */
  42458. changeGazeColor(color: Color3): void;
  42459. /**
  42460. * Exits VR and disposes of the vr experience helper
  42461. */
  42462. dispose(): void;
  42463. /**
  42464. * Gets the name of the VRExperienceHelper class
  42465. * @returns "VRExperienceHelper"
  42466. */
  42467. getClassName(): string;
  42468. }
  42469. }
  42470. declare module "babylonjs/Cameras/VR/index" {
  42471. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42472. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42473. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42474. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42475. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42476. export * from "babylonjs/Cameras/VR/webVRCamera";
  42477. }
  42478. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42479. import { Observable } from "babylonjs/Misc/observable";
  42480. import { Nullable } from "babylonjs/types";
  42481. import { IDisposable, Scene } from "babylonjs/scene";
  42482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42483. /**
  42484. * Manages an XRSession to work with Babylon's engine
  42485. * @see https://doc.babylonjs.com/how_to/webxr
  42486. */
  42487. export class WebXRSessionManager implements IDisposable {
  42488. private scene;
  42489. /**
  42490. * Fires every time a new xrFrame arrives which can be used to update the camera
  42491. */
  42492. onXRFrameObservable: Observable<any>;
  42493. /**
  42494. * Fires when the xr session is ended either by the device or manually done
  42495. */
  42496. onXRSessionEnded: Observable<any>;
  42497. /**
  42498. * Underlying xr session
  42499. */
  42500. session: XRSession;
  42501. /**
  42502. * Type of reference space used when creating the session
  42503. */
  42504. referenceSpace: XRReferenceSpace;
  42505. /** @hidden */
  42506. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42507. /**
  42508. * Current XR frame
  42509. */
  42510. currentFrame: Nullable<XRFrame>;
  42511. private _xrNavigator;
  42512. private baseLayer;
  42513. /**
  42514. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42515. * @param scene The scene which the session should be created for
  42516. */
  42517. constructor(scene: Scene);
  42518. /**
  42519. * Initializes the manager
  42520. * After initialization enterXR can be called to start an XR session
  42521. * @returns Promise which resolves after it is initialized
  42522. */
  42523. initializeAsync(): Promise<void>;
  42524. /**
  42525. * Initializes an xr session
  42526. * @param xrSessionMode mode to initialize
  42527. * @returns a promise which will resolve once the session has been initialized
  42528. */
  42529. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42530. /**
  42531. * Sets the reference space on the xr session
  42532. * @param referenceSpace space to set
  42533. * @returns a promise that will resolve once the reference space has been set
  42534. */
  42535. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42536. /**
  42537. * Updates the render state of the session
  42538. * @param state state to set
  42539. * @returns a promise that resolves once the render state has been updated
  42540. */
  42541. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42542. /**
  42543. * Starts rendering to the xr layer
  42544. * @returns a promise that will resolve once rendering has started
  42545. */
  42546. startRenderingToXRAsync(): Promise<void>;
  42547. /**
  42548. * Stops the xrSession and restores the renderloop
  42549. * @returns Promise which resolves after it exits XR
  42550. */
  42551. exitXRAsync(): Promise<unknown>;
  42552. /**
  42553. * Checks if a session would be supported for the creation options specified
  42554. * @param sessionMode session mode to check if supported eg. immersive-vr
  42555. * @returns true if supported
  42556. */
  42557. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42558. /**
  42559. * @hidden
  42560. * Converts the render layer of xrSession to a render target
  42561. * @param session session to create render target for
  42562. * @param scene scene the new render target should be created for
  42563. */
  42564. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42565. /**
  42566. * Disposes of the session manager
  42567. */
  42568. dispose(): void;
  42569. }
  42570. }
  42571. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42572. import { Scene } from "babylonjs/scene";
  42573. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42574. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42575. /**
  42576. * WebXR Camera which holds the views for the xrSession
  42577. * @see https://doc.babylonjs.com/how_to/webxr
  42578. */
  42579. export class WebXRCamera extends FreeCamera {
  42580. private static _TmpMatrix;
  42581. /**
  42582. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42583. * @param name the name of the camera
  42584. * @param scene the scene to add the camera to
  42585. */
  42586. constructor(name: string, scene: Scene);
  42587. private _updateNumberOfRigCameras;
  42588. /** @hidden */
  42589. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42590. /**
  42591. * Updates the cameras position from the current pose information of the XR session
  42592. * @param xrSessionManager the session containing pose information
  42593. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42594. */
  42595. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42596. }
  42597. }
  42598. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42599. import { Nullable } from "babylonjs/types";
  42600. import { IDisposable } from "babylonjs/scene";
  42601. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42602. /**
  42603. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42604. */
  42605. export class WebXRManagedOutputCanvas implements IDisposable {
  42606. private helper;
  42607. private _canvas;
  42608. /**
  42609. * xrpresent context of the canvas which can be used to display/mirror xr content
  42610. */
  42611. canvasContext: WebGLRenderingContext;
  42612. /**
  42613. * xr layer for the canvas
  42614. */
  42615. xrLayer: Nullable<XRWebGLLayer>;
  42616. /**
  42617. * Initializes the xr layer for the session
  42618. * @param xrSession xr session
  42619. * @returns a promise that will resolve once the XR Layer has been created
  42620. */
  42621. initializeXRLayerAsync(xrSession: any): any;
  42622. /**
  42623. * Initializes the canvas to be added/removed upon entering/exiting xr
  42624. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42625. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42626. */
  42627. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42628. /**
  42629. * Disposes of the object
  42630. */
  42631. dispose(): void;
  42632. private _setManagedOutputCanvas;
  42633. private _addCanvas;
  42634. private _removeCanvas;
  42635. }
  42636. }
  42637. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42638. import { Observable } from "babylonjs/Misc/observable";
  42639. import { IDisposable, Scene } from "babylonjs/scene";
  42640. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42642. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42643. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42644. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42645. /**
  42646. * States of the webXR experience
  42647. */
  42648. export enum WebXRState {
  42649. /**
  42650. * Transitioning to being in XR mode
  42651. */
  42652. ENTERING_XR = 0,
  42653. /**
  42654. * Transitioning to non XR mode
  42655. */
  42656. EXITING_XR = 1,
  42657. /**
  42658. * In XR mode and presenting
  42659. */
  42660. IN_XR = 2,
  42661. /**
  42662. * Not entered XR mode
  42663. */
  42664. NOT_IN_XR = 3
  42665. }
  42666. /**
  42667. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42668. * @see https://doc.babylonjs.com/how_to/webxr
  42669. */
  42670. export class WebXRExperienceHelper implements IDisposable {
  42671. private scene;
  42672. /**
  42673. * 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
  42674. */
  42675. container: AbstractMesh;
  42676. /**
  42677. * Camera used to render xr content
  42678. */
  42679. camera: WebXRCamera;
  42680. /**
  42681. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42682. */
  42683. state: WebXRState;
  42684. private _setState;
  42685. private static _TmpVector;
  42686. /**
  42687. * Fires when the state of the experience helper has changed
  42688. */
  42689. onStateChangedObservable: Observable<WebXRState>;
  42690. /** Session manager used to keep track of xr session */
  42691. sessionManager: WebXRSessionManager;
  42692. private _nonVRCamera;
  42693. private _originalSceneAutoClear;
  42694. private _supported;
  42695. /**
  42696. * Creates the experience helper
  42697. * @param scene the scene to attach the experience helper to
  42698. * @returns a promise for the experience helper
  42699. */
  42700. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42701. /**
  42702. * Creates a WebXRExperienceHelper
  42703. * @param scene The scene the helper should be created in
  42704. */
  42705. private constructor();
  42706. /**
  42707. * Exits XR mode and returns the scene to its original state
  42708. * @returns promise that resolves after xr mode has exited
  42709. */
  42710. exitXRAsync(): Promise<unknown>;
  42711. /**
  42712. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42713. * @param sessionCreationOptions options for the XR session
  42714. * @param referenceSpaceType frame of reference of the XR session
  42715. * @param outputCanvas the output canvas that will be used to enter XR mode
  42716. * @returns promise that resolves after xr mode has entered
  42717. */
  42718. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42719. /**
  42720. * Updates the global position of the camera by moving the camera's container
  42721. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42722. * @param position The desired global position of the camera
  42723. */
  42724. setPositionOfCameraUsingContainer(position: Vector3): void;
  42725. /**
  42726. * Rotates the xr camera by rotating the camera's container around the camera's position
  42727. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42728. * @param rotation the desired quaternion rotation to apply to the camera
  42729. */
  42730. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42731. /**
  42732. * Disposes of the experience helper
  42733. */
  42734. dispose(): void;
  42735. }
  42736. }
  42737. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42738. import { Nullable } from "babylonjs/types";
  42739. import { Observable } from "babylonjs/Misc/observable";
  42740. import { IDisposable, Scene } from "babylonjs/scene";
  42741. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42742. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42743. /**
  42744. * Button which can be used to enter a different mode of XR
  42745. */
  42746. export class WebXREnterExitUIButton {
  42747. /** button element */
  42748. element: HTMLElement;
  42749. /** XR initialization options for the button */
  42750. sessionMode: XRSessionMode;
  42751. /** Reference space type */
  42752. referenceSpaceType: XRReferenceSpaceType;
  42753. /**
  42754. * Creates a WebXREnterExitUIButton
  42755. * @param element button element
  42756. * @param sessionMode XR initialization session mode
  42757. * @param referenceSpaceType the type of reference space to be used
  42758. */
  42759. constructor(
  42760. /** button element */
  42761. element: HTMLElement,
  42762. /** XR initialization options for the button */
  42763. sessionMode: XRSessionMode,
  42764. /** Reference space type */
  42765. referenceSpaceType: XRReferenceSpaceType);
  42766. /**
  42767. * Overwritable function which can be used to update the button's visuals when the state changes
  42768. * @param activeButton the current active button in the UI
  42769. */
  42770. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42771. }
  42772. /**
  42773. * Options to create the webXR UI
  42774. */
  42775. export class WebXREnterExitUIOptions {
  42776. /**
  42777. * Context to enter xr with
  42778. */
  42779. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42780. /**
  42781. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42782. */
  42783. customButtons?: Array<WebXREnterExitUIButton>;
  42784. }
  42785. /**
  42786. * UI to allow the user to enter/exit XR mode
  42787. */
  42788. export class WebXREnterExitUI implements IDisposable {
  42789. private scene;
  42790. private _overlay;
  42791. private _buttons;
  42792. private _activeButton;
  42793. /**
  42794. * Fired every time the active button is changed.
  42795. *
  42796. * When xr is entered via a button that launches xr that button will be the callback parameter
  42797. *
  42798. * When exiting xr the callback parameter will be null)
  42799. */
  42800. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42801. /**
  42802. * Creates UI to allow the user to enter/exit XR mode
  42803. * @param scene the scene to add the ui to
  42804. * @param helper the xr experience helper to enter/exit xr with
  42805. * @param options options to configure the UI
  42806. * @returns the created ui
  42807. */
  42808. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42809. private constructor();
  42810. private _updateButtons;
  42811. /**
  42812. * Disposes of the object
  42813. */
  42814. dispose(): void;
  42815. }
  42816. }
  42817. declare module "babylonjs/Cameras/XR/webXRController" {
  42818. import { Nullable } from "babylonjs/types";
  42819. import { Observable } from "babylonjs/Misc/observable";
  42820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42821. import { Ray } from "babylonjs/Culling/ray";
  42822. import { Scene } from "babylonjs/scene";
  42823. /**
  42824. * Represents an XR input
  42825. */
  42826. export class WebXRController {
  42827. private scene;
  42828. /** The underlying input source for the controller */
  42829. inputSource: XRInputSource;
  42830. private parentContainer;
  42831. /**
  42832. * 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
  42833. */
  42834. grip?: AbstractMesh;
  42835. /**
  42836. * Pointer which can be used to select objects or attach a visible laser to
  42837. */
  42838. pointer: AbstractMesh;
  42839. /**
  42840. * Event that fires when the controller is removed/disposed
  42841. */
  42842. onDisposeObservable: Observable<{}>;
  42843. private _tmpMatrix;
  42844. private _tmpQuaternion;
  42845. private _tmpVector;
  42846. /**
  42847. * Creates the controller
  42848. * @see https://doc.babylonjs.com/how_to/webxr
  42849. * @param scene the scene which the controller should be associated to
  42850. * @param inputSource the underlying input source for the controller
  42851. * @param parentContainer parent that the controller meshes should be children of
  42852. */
  42853. constructor(scene: Scene,
  42854. /** The underlying input source for the controller */
  42855. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42856. /**
  42857. * Updates the controller pose based on the given XRFrame
  42858. * @param xrFrame xr frame to update the pose with
  42859. * @param referenceSpace reference space to use
  42860. */
  42861. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42862. /**
  42863. * Gets a world space ray coming from the controller
  42864. * @param result the resulting ray
  42865. */
  42866. getWorldPointerRayToRef(result: Ray): void;
  42867. /**
  42868. * Disposes of the object
  42869. */
  42870. dispose(): void;
  42871. }
  42872. }
  42873. declare module "babylonjs/Cameras/XR/webXRInput" {
  42874. import { Observable } from "babylonjs/Misc/observable";
  42875. import { IDisposable } from "babylonjs/scene";
  42876. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42877. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42878. /**
  42879. * XR input used to track XR inputs such as controllers/rays
  42880. */
  42881. export class WebXRInput implements IDisposable {
  42882. /**
  42883. * Base experience the input listens to
  42884. */
  42885. baseExperience: WebXRExperienceHelper;
  42886. /**
  42887. * XR controllers being tracked
  42888. */
  42889. controllers: Array<WebXRController>;
  42890. private _frameObserver;
  42891. private _stateObserver;
  42892. /**
  42893. * Event when a controller has been connected/added
  42894. */
  42895. onControllerAddedObservable: Observable<WebXRController>;
  42896. /**
  42897. * Event when a controller has been removed/disconnected
  42898. */
  42899. onControllerRemovedObservable: Observable<WebXRController>;
  42900. /**
  42901. * Initializes the WebXRInput
  42902. * @param baseExperience experience helper which the input should be created for
  42903. */
  42904. constructor(
  42905. /**
  42906. * Base experience the input listens to
  42907. */
  42908. baseExperience: WebXRExperienceHelper);
  42909. private _onInputSourcesChange;
  42910. private _addAndRemoveControllers;
  42911. /**
  42912. * Disposes of the object
  42913. */
  42914. dispose(): void;
  42915. }
  42916. }
  42917. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42919. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42920. /**
  42921. * Enables teleportation
  42922. */
  42923. export class WebXRControllerTeleportation {
  42924. private _teleportationFillColor;
  42925. private _teleportationBorderColor;
  42926. private _tmpRay;
  42927. private _tmpVector;
  42928. /**
  42929. * Creates a WebXRControllerTeleportation
  42930. * @param input input manager to add teleportation to
  42931. * @param floorMeshes floormeshes which can be teleported to
  42932. */
  42933. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42934. }
  42935. }
  42936. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42937. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42938. /**
  42939. * Handles pointer input automatically for the pointer of XR controllers
  42940. */
  42941. export class WebXRControllerPointerSelection {
  42942. private static _idCounter;
  42943. private _tmpRay;
  42944. /**
  42945. * Creates a WebXRControllerPointerSelection
  42946. * @param input input manager to setup pointer selection
  42947. */
  42948. constructor(input: WebXRInput);
  42949. private _convertNormalToDirectionOfRay;
  42950. private _updatePointerDistance;
  42951. }
  42952. }
  42953. declare module "babylonjs/Loading/sceneLoader" {
  42954. import { Observable } from "babylonjs/Misc/observable";
  42955. import { Nullable } from "babylonjs/types";
  42956. import { Scene } from "babylonjs/scene";
  42957. import { Engine } from "babylonjs/Engines/engine";
  42958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42959. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42960. import { AssetContainer } from "babylonjs/assetContainer";
  42961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42962. import { Skeleton } from "babylonjs/Bones/skeleton";
  42963. /**
  42964. * Class used to represent data loading progression
  42965. */
  42966. export class SceneLoaderProgressEvent {
  42967. /** defines if data length to load can be evaluated */
  42968. readonly lengthComputable: boolean;
  42969. /** defines the loaded data length */
  42970. readonly loaded: number;
  42971. /** defines the data length to load */
  42972. readonly total: number;
  42973. /**
  42974. * Create a new progress event
  42975. * @param lengthComputable defines if data length to load can be evaluated
  42976. * @param loaded defines the loaded data length
  42977. * @param total defines the data length to load
  42978. */
  42979. constructor(
  42980. /** defines if data length to load can be evaluated */
  42981. lengthComputable: boolean,
  42982. /** defines the loaded data length */
  42983. loaded: number,
  42984. /** defines the data length to load */
  42985. total: number);
  42986. /**
  42987. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42988. * @param event defines the source event
  42989. * @returns a new SceneLoaderProgressEvent
  42990. */
  42991. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42992. }
  42993. /**
  42994. * Interface used by SceneLoader plugins to define supported file extensions
  42995. */
  42996. export interface ISceneLoaderPluginExtensions {
  42997. /**
  42998. * Defines the list of supported extensions
  42999. */
  43000. [extension: string]: {
  43001. isBinary: boolean;
  43002. };
  43003. }
  43004. /**
  43005. * Interface used by SceneLoader plugin factory
  43006. */
  43007. export interface ISceneLoaderPluginFactory {
  43008. /**
  43009. * Defines the name of the factory
  43010. */
  43011. name: string;
  43012. /**
  43013. * Function called to create a new plugin
  43014. * @return the new plugin
  43015. */
  43016. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43017. /**
  43018. * Boolean indicating if the plugin can direct load specific data
  43019. */
  43020. canDirectLoad?: (data: string) => boolean;
  43021. }
  43022. /**
  43023. * Interface used to define a SceneLoader plugin
  43024. */
  43025. export interface ISceneLoaderPlugin {
  43026. /**
  43027. * The friendly name of this plugin.
  43028. */
  43029. name: string;
  43030. /**
  43031. * The file extensions supported by this plugin.
  43032. */
  43033. extensions: string | ISceneLoaderPluginExtensions;
  43034. /**
  43035. * Import meshes into a scene.
  43036. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43037. * @param scene The scene to import into
  43038. * @param data The data to import
  43039. * @param rootUrl The root url for scene and resources
  43040. * @param meshes The meshes array to import into
  43041. * @param particleSystems The particle systems array to import into
  43042. * @param skeletons The skeletons array to import into
  43043. * @param onError The callback when import fails
  43044. * @returns True if successful or false otherwise
  43045. */
  43046. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43047. /**
  43048. * Load into a scene.
  43049. * @param scene The scene to load into
  43050. * @param data The data to import
  43051. * @param rootUrl The root url for scene and resources
  43052. * @param onError The callback when import fails
  43053. * @returns true if successful or false otherwise
  43054. */
  43055. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43056. /**
  43057. * The callback that returns true if the data can be directly loaded.
  43058. */
  43059. canDirectLoad?: (data: string) => boolean;
  43060. /**
  43061. * The callback that allows custom handling of the root url based on the response url.
  43062. */
  43063. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43064. /**
  43065. * Load into an asset container.
  43066. * @param scene The scene to load into
  43067. * @param data The data to import
  43068. * @param rootUrl The root url for scene and resources
  43069. * @param onError The callback when import fails
  43070. * @returns The loaded asset container
  43071. */
  43072. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43073. }
  43074. /**
  43075. * Interface used to define an async SceneLoader plugin
  43076. */
  43077. export interface ISceneLoaderPluginAsync {
  43078. /**
  43079. * The friendly name of this plugin.
  43080. */
  43081. name: string;
  43082. /**
  43083. * The file extensions supported by this plugin.
  43084. */
  43085. extensions: string | ISceneLoaderPluginExtensions;
  43086. /**
  43087. * Import meshes into a scene.
  43088. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43089. * @param scene The scene to import into
  43090. * @param data The data to import
  43091. * @param rootUrl The root url for scene and resources
  43092. * @param onProgress The callback when the load progresses
  43093. * @param fileName Defines the name of the file to load
  43094. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43095. */
  43096. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43097. meshes: AbstractMesh[];
  43098. particleSystems: IParticleSystem[];
  43099. skeletons: Skeleton[];
  43100. animationGroups: AnimationGroup[];
  43101. }>;
  43102. /**
  43103. * Load into a scene.
  43104. * @param scene The scene to load into
  43105. * @param data The data to import
  43106. * @param rootUrl The root url for scene and resources
  43107. * @param onProgress The callback when the load progresses
  43108. * @param fileName Defines the name of the file to load
  43109. * @returns Nothing
  43110. */
  43111. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43112. /**
  43113. * The callback that returns true if the data can be directly loaded.
  43114. */
  43115. canDirectLoad?: (data: string) => boolean;
  43116. /**
  43117. * The callback that allows custom handling of the root url based on the response url.
  43118. */
  43119. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43120. /**
  43121. * Load into an asset container.
  43122. * @param scene The scene to load into
  43123. * @param data The data to import
  43124. * @param rootUrl The root url for scene and resources
  43125. * @param onProgress The callback when the load progresses
  43126. * @param fileName Defines the name of the file to load
  43127. * @returns The loaded asset container
  43128. */
  43129. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43130. }
  43131. /**
  43132. * Class used to load scene from various file formats using registered plugins
  43133. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43134. */
  43135. export class SceneLoader {
  43136. /**
  43137. * No logging while loading
  43138. */
  43139. static readonly NO_LOGGING: number;
  43140. /**
  43141. * Minimal logging while loading
  43142. */
  43143. static readonly MINIMAL_LOGGING: number;
  43144. /**
  43145. * Summary logging while loading
  43146. */
  43147. static readonly SUMMARY_LOGGING: number;
  43148. /**
  43149. * Detailled logging while loading
  43150. */
  43151. static readonly DETAILED_LOGGING: number;
  43152. /**
  43153. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43154. */
  43155. static ForceFullSceneLoadingForIncremental: boolean;
  43156. /**
  43157. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43158. */
  43159. static ShowLoadingScreen: boolean;
  43160. /**
  43161. * Defines the current logging level (while loading the scene)
  43162. * @ignorenaming
  43163. */
  43164. static loggingLevel: number;
  43165. /**
  43166. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43167. */
  43168. static CleanBoneMatrixWeights: boolean;
  43169. /**
  43170. * Event raised when a plugin is used to load a scene
  43171. */
  43172. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43173. private static _registeredPlugins;
  43174. private static _getDefaultPlugin;
  43175. private static _getPluginForExtension;
  43176. private static _getPluginForDirectLoad;
  43177. private static _getPluginForFilename;
  43178. private static _getDirectLoad;
  43179. private static _loadData;
  43180. private static _getFileInfo;
  43181. /**
  43182. * Gets a plugin that can load the given extension
  43183. * @param extension defines the extension to load
  43184. * @returns a plugin or null if none works
  43185. */
  43186. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43187. /**
  43188. * Gets a boolean indicating that the given extension can be loaded
  43189. * @param extension defines the extension to load
  43190. * @returns true if the extension is supported
  43191. */
  43192. static IsPluginForExtensionAvailable(extension: string): boolean;
  43193. /**
  43194. * Adds a new plugin to the list of registered plugins
  43195. * @param plugin defines the plugin to add
  43196. */
  43197. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43198. /**
  43199. * Import meshes into a scene
  43200. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43201. * @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)
  43202. * @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)
  43203. * @param scene the instance of BABYLON.Scene to append to
  43204. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43205. * @param onProgress a callback with a progress event for each file being loaded
  43206. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43207. * @param pluginExtension the extension used to determine the plugin
  43208. * @returns The loaded plugin
  43209. */
  43210. 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>;
  43211. /**
  43212. * Import meshes into a scene
  43213. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43214. * @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)
  43215. * @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)
  43216. * @param scene the instance of BABYLON.Scene to append to
  43217. * @param onProgress a callback with a progress event for each file being loaded
  43218. * @param pluginExtension the extension used to determine the plugin
  43219. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43220. */
  43221. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43222. meshes: AbstractMesh[];
  43223. particleSystems: IParticleSystem[];
  43224. skeletons: Skeleton[];
  43225. animationGroups: AnimationGroup[];
  43226. }>;
  43227. /**
  43228. * Load a scene
  43229. * @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)
  43230. * @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)
  43231. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43232. * @param onSuccess a callback with the scene when import succeeds
  43233. * @param onProgress a callback with a progress event for each file being loaded
  43234. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43235. * @param pluginExtension the extension used to determine the plugin
  43236. * @returns The loaded plugin
  43237. */
  43238. 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>;
  43239. /**
  43240. * Load a scene
  43241. * @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)
  43242. * @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)
  43243. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43244. * @param onProgress a callback with a progress event for each file being loaded
  43245. * @param pluginExtension the extension used to determine the plugin
  43246. * @returns The loaded scene
  43247. */
  43248. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43249. /**
  43250. * Append a scene
  43251. * @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)
  43252. * @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)
  43253. * @param scene is the instance of BABYLON.Scene to append to
  43254. * @param onSuccess a callback with the scene when import succeeds
  43255. * @param onProgress a callback with a progress event for each file being loaded
  43256. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43257. * @param pluginExtension the extension used to determine the plugin
  43258. * @returns The loaded plugin
  43259. */
  43260. 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>;
  43261. /**
  43262. * Append a scene
  43263. * @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)
  43264. * @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)
  43265. * @param scene is the instance of BABYLON.Scene to append to
  43266. * @param onProgress a callback with a progress event for each file being loaded
  43267. * @param pluginExtension the extension used to determine the plugin
  43268. * @returns The given scene
  43269. */
  43270. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43271. /**
  43272. * Load a scene into an asset container
  43273. * @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)
  43274. * @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)
  43275. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43276. * @param onSuccess a callback with the scene when import succeeds
  43277. * @param onProgress a callback with a progress event for each file being loaded
  43278. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43279. * @param pluginExtension the extension used to determine the plugin
  43280. * @returns The loaded plugin
  43281. */
  43282. 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>;
  43283. /**
  43284. * Load a scene into an asset container
  43285. * @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)
  43286. * @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)
  43287. * @param scene is the instance of Scene to append to
  43288. * @param onProgress a callback with a progress event for each file being loaded
  43289. * @param pluginExtension the extension used to determine the plugin
  43290. * @returns The loaded asset container
  43291. */
  43292. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43293. }
  43294. }
  43295. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43296. import { Scene } from "babylonjs/scene";
  43297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43298. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43299. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43300. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43301. /**
  43302. * Generic Controller
  43303. */
  43304. export class GenericController extends WebVRController {
  43305. /**
  43306. * Base Url for the controller model.
  43307. */
  43308. static readonly MODEL_BASE_URL: string;
  43309. /**
  43310. * File name for the controller model.
  43311. */
  43312. static readonly MODEL_FILENAME: string;
  43313. /**
  43314. * Creates a new GenericController from a gamepad
  43315. * @param vrGamepad the gamepad that the controller should be created from
  43316. */
  43317. constructor(vrGamepad: any);
  43318. /**
  43319. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43320. * @param scene scene in which to add meshes
  43321. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43322. */
  43323. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43324. /**
  43325. * Called once for each button that changed state since the last frame
  43326. * @param buttonIdx Which button index changed
  43327. * @param state New state of the button
  43328. * @param changes Which properties on the state changed since last frame
  43329. */
  43330. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43331. }
  43332. }
  43333. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43334. import { Observable } from "babylonjs/Misc/observable";
  43335. import { Scene } from "babylonjs/scene";
  43336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43337. import { Ray } from "babylonjs/Culling/ray";
  43338. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43339. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43340. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43341. /**
  43342. * Defines the WindowsMotionController object that the state of the windows motion controller
  43343. */
  43344. export class WindowsMotionController extends WebVRController {
  43345. /**
  43346. * The base url used to load the left and right controller models
  43347. */
  43348. static MODEL_BASE_URL: string;
  43349. /**
  43350. * The name of the left controller model file
  43351. */
  43352. static MODEL_LEFT_FILENAME: string;
  43353. /**
  43354. * The name of the right controller model file
  43355. */
  43356. static MODEL_RIGHT_FILENAME: string;
  43357. /**
  43358. * The controller name prefix for this controller type
  43359. */
  43360. static readonly GAMEPAD_ID_PREFIX: string;
  43361. /**
  43362. * The controller id pattern for this controller type
  43363. */
  43364. private static readonly GAMEPAD_ID_PATTERN;
  43365. private _loadedMeshInfo;
  43366. private readonly _mapping;
  43367. /**
  43368. * Fired when the trackpad on this controller is clicked
  43369. */
  43370. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43371. /**
  43372. * Fired when the trackpad on this controller is modified
  43373. */
  43374. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43375. /**
  43376. * The current x and y values of this controller's trackpad
  43377. */
  43378. trackpad: StickValues;
  43379. /**
  43380. * Creates a new WindowsMotionController from a gamepad
  43381. * @param vrGamepad the gamepad that the controller should be created from
  43382. */
  43383. constructor(vrGamepad: any);
  43384. /**
  43385. * Fired when the trigger on this controller is modified
  43386. */
  43387. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43388. /**
  43389. * Fired when the menu button on this controller is modified
  43390. */
  43391. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43392. /**
  43393. * Fired when the grip button on this controller is modified
  43394. */
  43395. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43396. /**
  43397. * Fired when the thumbstick button on this controller is modified
  43398. */
  43399. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43400. /**
  43401. * Fired when the touchpad button on this controller is modified
  43402. */
  43403. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43404. /**
  43405. * Fired when the touchpad values on this controller are modified
  43406. */
  43407. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43408. private _updateTrackpad;
  43409. /**
  43410. * Called once per frame by the engine.
  43411. */
  43412. update(): void;
  43413. /**
  43414. * Called once for each button that changed state since the last frame
  43415. * @param buttonIdx Which button index changed
  43416. * @param state New state of the button
  43417. * @param changes Which properties on the state changed since last frame
  43418. */
  43419. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43420. /**
  43421. * Moves the buttons on the controller mesh based on their current state
  43422. * @param buttonName the name of the button to move
  43423. * @param buttonValue the value of the button which determines the buttons new position
  43424. */
  43425. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43426. /**
  43427. * Moves the axis on the controller mesh based on its current state
  43428. * @param axis the index of the axis
  43429. * @param axisValue the value of the axis which determines the meshes new position
  43430. * @hidden
  43431. */
  43432. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43433. /**
  43434. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43435. * @param scene scene in which to add meshes
  43436. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43437. */
  43438. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43439. /**
  43440. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43441. * can be transformed by button presses and axes values, based on this._mapping.
  43442. *
  43443. * @param scene scene in which the meshes exist
  43444. * @param meshes list of meshes that make up the controller model to process
  43445. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43446. */
  43447. private processModel;
  43448. private createMeshInfo;
  43449. /**
  43450. * Gets the ray of the controller in the direction the controller is pointing
  43451. * @param length the length the resulting ray should be
  43452. * @returns a ray in the direction the controller is pointing
  43453. */
  43454. getForwardRay(length?: number): Ray;
  43455. /**
  43456. * Disposes of the controller
  43457. */
  43458. dispose(): void;
  43459. }
  43460. }
  43461. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43462. import { Observable } from "babylonjs/Misc/observable";
  43463. import { Scene } from "babylonjs/scene";
  43464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43465. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43466. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43467. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43468. /**
  43469. * Oculus Touch Controller
  43470. */
  43471. export class OculusTouchController extends WebVRController {
  43472. /**
  43473. * Base Url for the controller model.
  43474. */
  43475. static MODEL_BASE_URL: string;
  43476. /**
  43477. * File name for the left controller model.
  43478. */
  43479. static MODEL_LEFT_FILENAME: string;
  43480. /**
  43481. * File name for the right controller model.
  43482. */
  43483. static MODEL_RIGHT_FILENAME: string;
  43484. /**
  43485. * Base Url for the Quest controller model.
  43486. */
  43487. static QUEST_MODEL_BASE_URL: string;
  43488. /**
  43489. * @hidden
  43490. * If the controllers are running on a device that needs the updated Quest controller models
  43491. */
  43492. static _IsQuest: boolean;
  43493. /**
  43494. * Fired when the secondary trigger on this controller is modified
  43495. */
  43496. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43497. /**
  43498. * Fired when the thumb rest on this controller is modified
  43499. */
  43500. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43501. /**
  43502. * Creates a new OculusTouchController from a gamepad
  43503. * @param vrGamepad the gamepad that the controller should be created from
  43504. */
  43505. constructor(vrGamepad: any);
  43506. /**
  43507. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43508. * @param scene scene in which to add meshes
  43509. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43510. */
  43511. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43512. /**
  43513. * Fired when the A button on this controller is modified
  43514. */
  43515. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43516. /**
  43517. * Fired when the B button on this controller is modified
  43518. */
  43519. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43520. /**
  43521. * Fired when the X button on this controller is modified
  43522. */
  43523. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43524. /**
  43525. * Fired when the Y button on this controller is modified
  43526. */
  43527. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43528. /**
  43529. * Called once for each button that changed state since the last frame
  43530. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43531. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43532. * 2) secondary trigger (same)
  43533. * 3) A (right) X (left), touch, pressed = value
  43534. * 4) B / Y
  43535. * 5) thumb rest
  43536. * @param buttonIdx Which button index changed
  43537. * @param state New state of the button
  43538. * @param changes Which properties on the state changed since last frame
  43539. */
  43540. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43541. }
  43542. }
  43543. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43544. import { Scene } from "babylonjs/scene";
  43545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43546. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43547. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43548. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43549. import { Observable } from "babylonjs/Misc/observable";
  43550. /**
  43551. * Vive Controller
  43552. */
  43553. export class ViveController extends WebVRController {
  43554. /**
  43555. * Base Url for the controller model.
  43556. */
  43557. static MODEL_BASE_URL: string;
  43558. /**
  43559. * File name for the controller model.
  43560. */
  43561. static MODEL_FILENAME: string;
  43562. /**
  43563. * Creates a new ViveController from a gamepad
  43564. * @param vrGamepad the gamepad that the controller should be created from
  43565. */
  43566. constructor(vrGamepad: any);
  43567. /**
  43568. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43569. * @param scene scene in which to add meshes
  43570. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43571. */
  43572. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43573. /**
  43574. * Fired when the left button on this controller is modified
  43575. */
  43576. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43577. /**
  43578. * Fired when the right button on this controller is modified
  43579. */
  43580. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43581. /**
  43582. * Fired when the menu button on this controller is modified
  43583. */
  43584. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43585. /**
  43586. * Called once for each button that changed state since the last frame
  43587. * Vive mapping:
  43588. * 0: touchpad
  43589. * 1: trigger
  43590. * 2: left AND right buttons
  43591. * 3: menu button
  43592. * @param buttonIdx Which button index changed
  43593. * @param state New state of the button
  43594. * @param changes Which properties on the state changed since last frame
  43595. */
  43596. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43597. }
  43598. }
  43599. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43600. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43601. /**
  43602. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43603. */
  43604. export class WebXRControllerModelLoader {
  43605. /**
  43606. * Creates the WebXRControllerModelLoader
  43607. * @param input xr input that creates the controllers
  43608. */
  43609. constructor(input: WebXRInput);
  43610. }
  43611. }
  43612. declare module "babylonjs/Cameras/XR/index" {
  43613. export * from "babylonjs/Cameras/XR/webXRCamera";
  43614. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43615. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43616. export * from "babylonjs/Cameras/XR/webXRInput";
  43617. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43618. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43619. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43620. export * from "babylonjs/Cameras/XR/webXRController";
  43621. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43622. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43623. }
  43624. declare module "babylonjs/Cameras/RigModes/index" {
  43625. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43626. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43627. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43628. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43629. }
  43630. declare module "babylonjs/Cameras/index" {
  43631. export * from "babylonjs/Cameras/Inputs/index";
  43632. export * from "babylonjs/Cameras/cameraInputsManager";
  43633. export * from "babylonjs/Cameras/camera";
  43634. export * from "babylonjs/Cameras/targetCamera";
  43635. export * from "babylonjs/Cameras/freeCamera";
  43636. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43637. export * from "babylonjs/Cameras/touchCamera";
  43638. export * from "babylonjs/Cameras/arcRotateCamera";
  43639. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43640. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43641. export * from "babylonjs/Cameras/flyCamera";
  43642. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43643. export * from "babylonjs/Cameras/followCamera";
  43644. export * from "babylonjs/Cameras/followCameraInputsManager";
  43645. export * from "babylonjs/Cameras/gamepadCamera";
  43646. export * from "babylonjs/Cameras/Stereoscopic/index";
  43647. export * from "babylonjs/Cameras/universalCamera";
  43648. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43649. export * from "babylonjs/Cameras/VR/index";
  43650. export * from "babylonjs/Cameras/XR/index";
  43651. export * from "babylonjs/Cameras/RigModes/index";
  43652. }
  43653. declare module "babylonjs/Collisions/index" {
  43654. export * from "babylonjs/Collisions/collider";
  43655. export * from "babylonjs/Collisions/collisionCoordinator";
  43656. export * from "babylonjs/Collisions/pickingInfo";
  43657. export * from "babylonjs/Collisions/intersectionInfo";
  43658. export * from "babylonjs/Collisions/meshCollisionData";
  43659. }
  43660. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43661. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43662. import { Vector3 } from "babylonjs/Maths/math.vector";
  43663. import { Ray } from "babylonjs/Culling/ray";
  43664. import { Plane } from "babylonjs/Maths/math.plane";
  43665. /**
  43666. * Contains an array of blocks representing the octree
  43667. */
  43668. export interface IOctreeContainer<T> {
  43669. /**
  43670. * Blocks within the octree
  43671. */
  43672. blocks: Array<OctreeBlock<T>>;
  43673. }
  43674. /**
  43675. * Class used to store a cell in an octree
  43676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43677. */
  43678. export class OctreeBlock<T> {
  43679. /**
  43680. * Gets the content of the current block
  43681. */
  43682. entries: T[];
  43683. /**
  43684. * Gets the list of block children
  43685. */
  43686. blocks: Array<OctreeBlock<T>>;
  43687. private _depth;
  43688. private _maxDepth;
  43689. private _capacity;
  43690. private _minPoint;
  43691. private _maxPoint;
  43692. private _boundingVectors;
  43693. private _creationFunc;
  43694. /**
  43695. * Creates a new block
  43696. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43697. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43698. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43699. * @param depth defines the current depth of this block in the octree
  43700. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43701. * @param creationFunc defines a callback to call when an element is added to the block
  43702. */
  43703. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43704. /**
  43705. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43706. */
  43707. readonly capacity: number;
  43708. /**
  43709. * Gets the minimum vector (in world space) of the block's bounding box
  43710. */
  43711. readonly minPoint: Vector3;
  43712. /**
  43713. * Gets the maximum vector (in world space) of the block's bounding box
  43714. */
  43715. readonly maxPoint: Vector3;
  43716. /**
  43717. * Add a new element to this block
  43718. * @param entry defines the element to add
  43719. */
  43720. addEntry(entry: T): void;
  43721. /**
  43722. * Remove an element from this block
  43723. * @param entry defines the element to remove
  43724. */
  43725. removeEntry(entry: T): void;
  43726. /**
  43727. * Add an array of elements to this block
  43728. * @param entries defines the array of elements to add
  43729. */
  43730. addEntries(entries: T[]): void;
  43731. /**
  43732. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43733. * @param frustumPlanes defines the frustum planes to test
  43734. * @param selection defines the array to store current content if selection is positive
  43735. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43736. */
  43737. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43738. /**
  43739. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43740. * @param sphereCenter defines the bounding sphere center
  43741. * @param sphereRadius defines the bounding sphere radius
  43742. * @param selection defines the array to store current content if selection is positive
  43743. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43744. */
  43745. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43746. /**
  43747. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43748. * @param ray defines the ray to test with
  43749. * @param selection defines the array to store current content if selection is positive
  43750. */
  43751. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43752. /**
  43753. * Subdivide the content into child blocks (this block will then be empty)
  43754. */
  43755. createInnerBlocks(): void;
  43756. /**
  43757. * @hidden
  43758. */
  43759. 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;
  43760. }
  43761. }
  43762. declare module "babylonjs/Culling/Octrees/octree" {
  43763. import { SmartArray } from "babylonjs/Misc/smartArray";
  43764. import { Vector3 } from "babylonjs/Maths/math.vector";
  43765. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43767. import { Ray } from "babylonjs/Culling/ray";
  43768. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43769. import { Plane } from "babylonjs/Maths/math.plane";
  43770. /**
  43771. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43773. */
  43774. export class Octree<T> {
  43775. /** 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.) */
  43776. maxDepth: number;
  43777. /**
  43778. * Blocks within the octree containing objects
  43779. */
  43780. blocks: Array<OctreeBlock<T>>;
  43781. /**
  43782. * Content stored in the octree
  43783. */
  43784. dynamicContent: T[];
  43785. private _maxBlockCapacity;
  43786. private _selectionContent;
  43787. private _creationFunc;
  43788. /**
  43789. * Creates a octree
  43790. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43791. * @param creationFunc function to be used to instatiate the octree
  43792. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43793. * @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.)
  43794. */
  43795. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43796. /** 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.) */
  43797. maxDepth?: number);
  43798. /**
  43799. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43800. * @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);
  43801. * @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);
  43802. * @param entries meshes to be added to the octree blocks
  43803. */
  43804. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43805. /**
  43806. * Adds a mesh to the octree
  43807. * @param entry Mesh to add to the octree
  43808. */
  43809. addMesh(entry: T): void;
  43810. /**
  43811. * Remove an element from the octree
  43812. * @param entry defines the element to remove
  43813. */
  43814. removeMesh(entry: T): void;
  43815. /**
  43816. * Selects an array of meshes within the frustum
  43817. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43818. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43819. * @returns array of meshes within the frustum
  43820. */
  43821. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43822. /**
  43823. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43824. * @param sphereCenter defines the bounding sphere center
  43825. * @param sphereRadius defines the bounding sphere radius
  43826. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43827. * @returns an array of objects that intersect the sphere
  43828. */
  43829. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43830. /**
  43831. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43832. * @param ray defines the ray to test with
  43833. * @returns array of intersected objects
  43834. */
  43835. intersectsRay(ray: Ray): SmartArray<T>;
  43836. /**
  43837. * Adds a mesh into the octree block if it intersects the block
  43838. */
  43839. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43840. /**
  43841. * Adds a submesh into the octree block if it intersects the block
  43842. */
  43843. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43844. }
  43845. }
  43846. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43847. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43848. import { Scene } from "babylonjs/scene";
  43849. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43851. import { Ray } from "babylonjs/Culling/ray";
  43852. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43853. import { Collider } from "babylonjs/Collisions/collider";
  43854. module "babylonjs/scene" {
  43855. interface Scene {
  43856. /**
  43857. * @hidden
  43858. * Backing Filed
  43859. */
  43860. _selectionOctree: Octree<AbstractMesh>;
  43861. /**
  43862. * Gets the octree used to boost mesh selection (picking)
  43863. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43864. */
  43865. selectionOctree: Octree<AbstractMesh>;
  43866. /**
  43867. * Creates or updates the octree used to boost selection (picking)
  43868. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43869. * @param maxCapacity defines the maximum capacity per leaf
  43870. * @param maxDepth defines the maximum depth of the octree
  43871. * @returns an octree of AbstractMesh
  43872. */
  43873. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43874. }
  43875. }
  43876. module "babylonjs/Meshes/abstractMesh" {
  43877. interface AbstractMesh {
  43878. /**
  43879. * @hidden
  43880. * Backing Field
  43881. */
  43882. _submeshesOctree: Octree<SubMesh>;
  43883. /**
  43884. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43885. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43886. * @param maxCapacity defines the maximum size of each block (64 by default)
  43887. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43888. * @returns the new octree
  43889. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43891. */
  43892. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43893. }
  43894. }
  43895. /**
  43896. * Defines the octree scene component responsible to manage any octrees
  43897. * in a given scene.
  43898. */
  43899. export class OctreeSceneComponent {
  43900. /**
  43901. * The component name help to identify the component in the list of scene components.
  43902. */
  43903. readonly name: string;
  43904. /**
  43905. * The scene the component belongs to.
  43906. */
  43907. scene: Scene;
  43908. /**
  43909. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43910. */
  43911. readonly checksIsEnabled: boolean;
  43912. /**
  43913. * Creates a new instance of the component for the given scene
  43914. * @param scene Defines the scene to register the component in
  43915. */
  43916. constructor(scene: Scene);
  43917. /**
  43918. * Registers the component in a given scene
  43919. */
  43920. register(): void;
  43921. /**
  43922. * Return the list of active meshes
  43923. * @returns the list of active meshes
  43924. */
  43925. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43926. /**
  43927. * Return the list of active sub meshes
  43928. * @param mesh The mesh to get the candidates sub meshes from
  43929. * @returns the list of active sub meshes
  43930. */
  43931. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43932. private _tempRay;
  43933. /**
  43934. * Return the list of sub meshes intersecting with a given local ray
  43935. * @param mesh defines the mesh to find the submesh for
  43936. * @param localRay defines the ray in local space
  43937. * @returns the list of intersecting sub meshes
  43938. */
  43939. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43940. /**
  43941. * Return the list of sub meshes colliding with a collider
  43942. * @param mesh defines the mesh to find the submesh for
  43943. * @param collider defines the collider to evaluate the collision against
  43944. * @returns the list of colliding sub meshes
  43945. */
  43946. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43947. /**
  43948. * Rebuilds the elements related to this component in case of
  43949. * context lost for instance.
  43950. */
  43951. rebuild(): void;
  43952. /**
  43953. * Disposes the component and the associated ressources.
  43954. */
  43955. dispose(): void;
  43956. }
  43957. }
  43958. declare module "babylonjs/Culling/Octrees/index" {
  43959. export * from "babylonjs/Culling/Octrees/octree";
  43960. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43961. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43962. }
  43963. declare module "babylonjs/Culling/index" {
  43964. export * from "babylonjs/Culling/boundingBox";
  43965. export * from "babylonjs/Culling/boundingInfo";
  43966. export * from "babylonjs/Culling/boundingSphere";
  43967. export * from "babylonjs/Culling/Octrees/index";
  43968. export * from "babylonjs/Culling/ray";
  43969. }
  43970. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43971. import { IDisposable, Scene } from "babylonjs/scene";
  43972. import { Nullable } from "babylonjs/types";
  43973. import { Observable } from "babylonjs/Misc/observable";
  43974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43975. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43976. import { Camera } from "babylonjs/Cameras/camera";
  43977. /**
  43978. * Renders a layer on top of an existing scene
  43979. */
  43980. export class UtilityLayerRenderer implements IDisposable {
  43981. /** the original scene that will be rendered on top of */
  43982. originalScene: Scene;
  43983. private _pointerCaptures;
  43984. private _lastPointerEvents;
  43985. private static _DefaultUtilityLayer;
  43986. private static _DefaultKeepDepthUtilityLayer;
  43987. private _sharedGizmoLight;
  43988. private _renderCamera;
  43989. /**
  43990. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43991. * @returns the camera that is used when rendering the utility layer
  43992. */
  43993. getRenderCamera(): Nullable<Camera>;
  43994. /**
  43995. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43996. * @param cam the camera that should be used when rendering the utility layer
  43997. */
  43998. setRenderCamera(cam: Nullable<Camera>): void;
  43999. /**
  44000. * @hidden
  44001. * Light which used by gizmos to get light shading
  44002. */
  44003. _getSharedGizmoLight(): HemisphericLight;
  44004. /**
  44005. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44006. */
  44007. pickUtilitySceneFirst: boolean;
  44008. /**
  44009. * 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)
  44010. */
  44011. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44012. /**
  44013. * 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)
  44014. */
  44015. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44016. /**
  44017. * The scene that is rendered on top of the original scene
  44018. */
  44019. utilityLayerScene: Scene;
  44020. /**
  44021. * If the utility layer should automatically be rendered on top of existing scene
  44022. */
  44023. shouldRender: boolean;
  44024. /**
  44025. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44026. */
  44027. onlyCheckPointerDownEvents: boolean;
  44028. /**
  44029. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44030. */
  44031. processAllEvents: boolean;
  44032. /**
  44033. * Observable raised when the pointer move from the utility layer scene to the main scene
  44034. */
  44035. onPointerOutObservable: Observable<number>;
  44036. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44037. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44038. private _afterRenderObserver;
  44039. private _sceneDisposeObserver;
  44040. private _originalPointerObserver;
  44041. /**
  44042. * Instantiates a UtilityLayerRenderer
  44043. * @param originalScene the original scene that will be rendered on top of
  44044. * @param handleEvents boolean indicating if the utility layer should handle events
  44045. */
  44046. constructor(
  44047. /** the original scene that will be rendered on top of */
  44048. originalScene: Scene, handleEvents?: boolean);
  44049. private _notifyObservers;
  44050. /**
  44051. * Renders the utility layers scene on top of the original scene
  44052. */
  44053. render(): void;
  44054. /**
  44055. * Disposes of the renderer
  44056. */
  44057. dispose(): void;
  44058. private _updateCamera;
  44059. }
  44060. }
  44061. declare module "babylonjs/Gizmos/gizmo" {
  44062. import { Nullable } from "babylonjs/types";
  44063. import { IDisposable } from "babylonjs/scene";
  44064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44065. import { Mesh } from "babylonjs/Meshes/mesh";
  44066. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44067. /**
  44068. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44069. */
  44070. export class Gizmo implements IDisposable {
  44071. /** The utility layer the gizmo will be added to */
  44072. gizmoLayer: UtilityLayerRenderer;
  44073. /**
  44074. * The root mesh of the gizmo
  44075. */
  44076. _rootMesh: Mesh;
  44077. private _attachedMesh;
  44078. /**
  44079. * Ratio for the scale of the gizmo (Default: 1)
  44080. */
  44081. scaleRatio: number;
  44082. /**
  44083. * If a custom mesh has been set (Default: false)
  44084. */
  44085. protected _customMeshSet: boolean;
  44086. /**
  44087. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44088. * * When set, interactions will be enabled
  44089. */
  44090. attachedMesh: Nullable<AbstractMesh>;
  44091. /**
  44092. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44093. * @param mesh The mesh to replace the default mesh of the gizmo
  44094. */
  44095. setCustomMesh(mesh: Mesh): void;
  44096. /**
  44097. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44098. */
  44099. updateGizmoRotationToMatchAttachedMesh: boolean;
  44100. /**
  44101. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44102. */
  44103. updateGizmoPositionToMatchAttachedMesh: boolean;
  44104. /**
  44105. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44106. */
  44107. updateScale: boolean;
  44108. protected _interactionsEnabled: boolean;
  44109. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44110. private _beforeRenderObserver;
  44111. private _tempVector;
  44112. /**
  44113. * Creates a gizmo
  44114. * @param gizmoLayer The utility layer the gizmo will be added to
  44115. */
  44116. constructor(
  44117. /** The utility layer the gizmo will be added to */
  44118. gizmoLayer?: UtilityLayerRenderer);
  44119. /**
  44120. * Updates the gizmo to match the attached mesh's position/rotation
  44121. */
  44122. protected _update(): void;
  44123. /**
  44124. * Disposes of the gizmo
  44125. */
  44126. dispose(): void;
  44127. }
  44128. }
  44129. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44130. import { Observable } from "babylonjs/Misc/observable";
  44131. import { Nullable } from "babylonjs/types";
  44132. import { Vector3 } from "babylonjs/Maths/math.vector";
  44133. import { Color3 } from "babylonjs/Maths/math.color";
  44134. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44136. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44137. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44138. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44139. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44140. import { Scene } from "babylonjs/scene";
  44141. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44142. /**
  44143. * Single plane drag gizmo
  44144. */
  44145. export class PlaneDragGizmo extends Gizmo {
  44146. /**
  44147. * Drag behavior responsible for the gizmos dragging interactions
  44148. */
  44149. dragBehavior: PointerDragBehavior;
  44150. private _pointerObserver;
  44151. /**
  44152. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44153. */
  44154. snapDistance: number;
  44155. /**
  44156. * Event that fires each time the gizmo snaps to a new location.
  44157. * * snapDistance is the the change in distance
  44158. */
  44159. onSnapObservable: Observable<{
  44160. snapDistance: number;
  44161. }>;
  44162. private _plane;
  44163. private _coloredMaterial;
  44164. private _hoverMaterial;
  44165. private _isEnabled;
  44166. private _parent;
  44167. /** @hidden */
  44168. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44169. /** @hidden */
  44170. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44171. /**
  44172. * Creates a PlaneDragGizmo
  44173. * @param gizmoLayer The utility layer the gizmo will be added to
  44174. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44175. * @param color The color of the gizmo
  44176. */
  44177. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44178. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44179. /**
  44180. * If the gizmo is enabled
  44181. */
  44182. isEnabled: boolean;
  44183. /**
  44184. * Disposes of the gizmo
  44185. */
  44186. dispose(): void;
  44187. }
  44188. }
  44189. declare module "babylonjs/Gizmos/positionGizmo" {
  44190. import { Observable } from "babylonjs/Misc/observable";
  44191. import { Nullable } from "babylonjs/types";
  44192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44193. import { Mesh } from "babylonjs/Meshes/mesh";
  44194. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44195. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44196. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44197. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44198. /**
  44199. * Gizmo that enables dragging a mesh along 3 axis
  44200. */
  44201. export class PositionGizmo extends Gizmo {
  44202. /**
  44203. * Internal gizmo used for interactions on the x axis
  44204. */
  44205. xGizmo: AxisDragGizmo;
  44206. /**
  44207. * Internal gizmo used for interactions on the y axis
  44208. */
  44209. yGizmo: AxisDragGizmo;
  44210. /**
  44211. * Internal gizmo used for interactions on the z axis
  44212. */
  44213. zGizmo: AxisDragGizmo;
  44214. /**
  44215. * Internal gizmo used for interactions on the yz plane
  44216. */
  44217. xPlaneGizmo: PlaneDragGizmo;
  44218. /**
  44219. * Internal gizmo used for interactions on the xz plane
  44220. */
  44221. yPlaneGizmo: PlaneDragGizmo;
  44222. /**
  44223. * Internal gizmo used for interactions on the xy plane
  44224. */
  44225. zPlaneGizmo: PlaneDragGizmo;
  44226. /**
  44227. * private variables
  44228. */
  44229. private _meshAttached;
  44230. private _updateGizmoRotationToMatchAttachedMesh;
  44231. private _snapDistance;
  44232. private _scaleRatio;
  44233. /** Fires an event when any of it's sub gizmos are dragged */
  44234. onDragStartObservable: Observable<unknown>;
  44235. /** Fires an event when any of it's sub gizmos are released from dragging */
  44236. onDragEndObservable: Observable<unknown>;
  44237. /**
  44238. * If set to true, planar drag is enabled
  44239. */
  44240. private _planarGizmoEnabled;
  44241. attachedMesh: Nullable<AbstractMesh>;
  44242. /**
  44243. * Creates a PositionGizmo
  44244. * @param gizmoLayer The utility layer the gizmo will be added to
  44245. */
  44246. constructor(gizmoLayer?: UtilityLayerRenderer);
  44247. /**
  44248. * If the planar drag gizmo is enabled
  44249. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44250. */
  44251. planarGizmoEnabled: boolean;
  44252. updateGizmoRotationToMatchAttachedMesh: boolean;
  44253. /**
  44254. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44255. */
  44256. snapDistance: number;
  44257. /**
  44258. * Ratio for the scale of the gizmo (Default: 1)
  44259. */
  44260. scaleRatio: number;
  44261. /**
  44262. * Disposes of the gizmo
  44263. */
  44264. dispose(): void;
  44265. /**
  44266. * CustomMeshes are not supported by this gizmo
  44267. * @param mesh The mesh to replace the default mesh of the gizmo
  44268. */
  44269. setCustomMesh(mesh: Mesh): void;
  44270. }
  44271. }
  44272. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44273. import { Observable } from "babylonjs/Misc/observable";
  44274. import { Nullable } from "babylonjs/types";
  44275. import { Vector3 } from "babylonjs/Maths/math.vector";
  44276. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44278. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44279. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44280. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44281. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44282. import { Scene } from "babylonjs/scene";
  44283. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44284. import { Color3 } from "babylonjs/Maths/math.color";
  44285. /**
  44286. * Single axis drag gizmo
  44287. */
  44288. export class AxisDragGizmo extends Gizmo {
  44289. /**
  44290. * Drag behavior responsible for the gizmos dragging interactions
  44291. */
  44292. dragBehavior: PointerDragBehavior;
  44293. private _pointerObserver;
  44294. /**
  44295. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44296. */
  44297. snapDistance: number;
  44298. /**
  44299. * Event that fires each time the gizmo snaps to a new location.
  44300. * * snapDistance is the the change in distance
  44301. */
  44302. onSnapObservable: Observable<{
  44303. snapDistance: number;
  44304. }>;
  44305. private _isEnabled;
  44306. private _parent;
  44307. private _arrow;
  44308. private _coloredMaterial;
  44309. private _hoverMaterial;
  44310. /** @hidden */
  44311. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44312. /** @hidden */
  44313. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44314. /**
  44315. * Creates an AxisDragGizmo
  44316. * @param gizmoLayer The utility layer the gizmo will be added to
  44317. * @param dragAxis The axis which the gizmo will be able to drag on
  44318. * @param color The color of the gizmo
  44319. */
  44320. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44321. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44322. /**
  44323. * If the gizmo is enabled
  44324. */
  44325. isEnabled: boolean;
  44326. /**
  44327. * Disposes of the gizmo
  44328. */
  44329. dispose(): void;
  44330. }
  44331. }
  44332. declare module "babylonjs/Debug/axesViewer" {
  44333. import { Vector3 } from "babylonjs/Maths/math.vector";
  44334. import { Nullable } from "babylonjs/types";
  44335. import { Scene } from "babylonjs/scene";
  44336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44337. /**
  44338. * The Axes viewer will show 3 axes in a specific point in space
  44339. */
  44340. export class AxesViewer {
  44341. private _xAxis;
  44342. private _yAxis;
  44343. private _zAxis;
  44344. private _scaleLinesFactor;
  44345. private _instanced;
  44346. /**
  44347. * Gets the hosting scene
  44348. */
  44349. scene: Scene;
  44350. /**
  44351. * Gets or sets a number used to scale line length
  44352. */
  44353. scaleLines: number;
  44354. /** Gets the node hierarchy used to render x-axis */
  44355. readonly xAxis: TransformNode;
  44356. /** Gets the node hierarchy used to render y-axis */
  44357. readonly yAxis: TransformNode;
  44358. /** Gets the node hierarchy used to render z-axis */
  44359. readonly zAxis: TransformNode;
  44360. /**
  44361. * Creates a new AxesViewer
  44362. * @param scene defines the hosting scene
  44363. * @param scaleLines defines a number used to scale line length (1 by default)
  44364. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44365. * @param xAxis defines the node hierarchy used to render the x-axis
  44366. * @param yAxis defines the node hierarchy used to render the y-axis
  44367. * @param zAxis defines the node hierarchy used to render the z-axis
  44368. */
  44369. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44370. /**
  44371. * Force the viewer to update
  44372. * @param position defines the position of the viewer
  44373. * @param xaxis defines the x axis of the viewer
  44374. * @param yaxis defines the y axis of the viewer
  44375. * @param zaxis defines the z axis of the viewer
  44376. */
  44377. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44378. /**
  44379. * Creates an instance of this axes viewer.
  44380. * @returns a new axes viewer with instanced meshes
  44381. */
  44382. createInstance(): AxesViewer;
  44383. /** Releases resources */
  44384. dispose(): void;
  44385. private static _SetRenderingGroupId;
  44386. }
  44387. }
  44388. declare module "babylonjs/Debug/boneAxesViewer" {
  44389. import { Nullable } from "babylonjs/types";
  44390. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44391. import { Vector3 } from "babylonjs/Maths/math.vector";
  44392. import { Mesh } from "babylonjs/Meshes/mesh";
  44393. import { Bone } from "babylonjs/Bones/bone";
  44394. import { Scene } from "babylonjs/scene";
  44395. /**
  44396. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44397. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44398. */
  44399. export class BoneAxesViewer extends AxesViewer {
  44400. /**
  44401. * Gets or sets the target mesh where to display the axes viewer
  44402. */
  44403. mesh: Nullable<Mesh>;
  44404. /**
  44405. * Gets or sets the target bone where to display the axes viewer
  44406. */
  44407. bone: Nullable<Bone>;
  44408. /** Gets current position */
  44409. pos: Vector3;
  44410. /** Gets direction of X axis */
  44411. xaxis: Vector3;
  44412. /** Gets direction of Y axis */
  44413. yaxis: Vector3;
  44414. /** Gets direction of Z axis */
  44415. zaxis: Vector3;
  44416. /**
  44417. * Creates a new BoneAxesViewer
  44418. * @param scene defines the hosting scene
  44419. * @param bone defines the target bone
  44420. * @param mesh defines the target mesh
  44421. * @param scaleLines defines a scaling factor for line length (1 by default)
  44422. */
  44423. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44424. /**
  44425. * Force the viewer to update
  44426. */
  44427. update(): void;
  44428. /** Releases resources */
  44429. dispose(): void;
  44430. }
  44431. }
  44432. declare module "babylonjs/Debug/debugLayer" {
  44433. import { Scene } from "babylonjs/scene";
  44434. /**
  44435. * Interface used to define scene explorer extensibility option
  44436. */
  44437. export interface IExplorerExtensibilityOption {
  44438. /**
  44439. * Define the option label
  44440. */
  44441. label: string;
  44442. /**
  44443. * Defines the action to execute on click
  44444. */
  44445. action: (entity: any) => void;
  44446. }
  44447. /**
  44448. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44449. */
  44450. export interface IExplorerExtensibilityGroup {
  44451. /**
  44452. * Defines a predicate to test if a given type mut be extended
  44453. */
  44454. predicate: (entity: any) => boolean;
  44455. /**
  44456. * Gets the list of options added to a type
  44457. */
  44458. entries: IExplorerExtensibilityOption[];
  44459. }
  44460. /**
  44461. * Interface used to define the options to use to create the Inspector
  44462. */
  44463. export interface IInspectorOptions {
  44464. /**
  44465. * Display in overlay mode (default: false)
  44466. */
  44467. overlay?: boolean;
  44468. /**
  44469. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44470. */
  44471. globalRoot?: HTMLElement;
  44472. /**
  44473. * Display the Scene explorer
  44474. */
  44475. showExplorer?: boolean;
  44476. /**
  44477. * Display the property inspector
  44478. */
  44479. showInspector?: boolean;
  44480. /**
  44481. * Display in embed mode (both panes on the right)
  44482. */
  44483. embedMode?: boolean;
  44484. /**
  44485. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44486. */
  44487. handleResize?: boolean;
  44488. /**
  44489. * Allow the panes to popup (default: true)
  44490. */
  44491. enablePopup?: boolean;
  44492. /**
  44493. * Allow the panes to be closed by users (default: true)
  44494. */
  44495. enableClose?: boolean;
  44496. /**
  44497. * Optional list of extensibility entries
  44498. */
  44499. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44500. /**
  44501. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44502. */
  44503. inspectorURL?: string;
  44504. }
  44505. module "babylonjs/scene" {
  44506. interface Scene {
  44507. /**
  44508. * @hidden
  44509. * Backing field
  44510. */
  44511. _debugLayer: DebugLayer;
  44512. /**
  44513. * Gets the debug layer (aka Inspector) associated with the scene
  44514. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44515. */
  44516. debugLayer: DebugLayer;
  44517. }
  44518. }
  44519. /**
  44520. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44521. * what is happening in your scene
  44522. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44523. */
  44524. export class DebugLayer {
  44525. /**
  44526. * Define the url to get the inspector script from.
  44527. * By default it uses the babylonjs CDN.
  44528. * @ignoreNaming
  44529. */
  44530. static InspectorURL: string;
  44531. private _scene;
  44532. private BJSINSPECTOR;
  44533. private _onPropertyChangedObservable?;
  44534. /**
  44535. * Observable triggered when a property is changed through the inspector.
  44536. */
  44537. readonly onPropertyChangedObservable: any;
  44538. /**
  44539. * Instantiates a new debug layer.
  44540. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44541. * what is happening in your scene
  44542. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44543. * @param scene Defines the scene to inspect
  44544. */
  44545. constructor(scene: Scene);
  44546. /** Creates the inspector window. */
  44547. private _createInspector;
  44548. /**
  44549. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44550. * @param entity defines the entity to select
  44551. * @param lineContainerTitle defines the specific block to highlight
  44552. */
  44553. select(entity: any, lineContainerTitle?: string): void;
  44554. /** Get the inspector from bundle or global */
  44555. private _getGlobalInspector;
  44556. /**
  44557. * Get if the inspector is visible or not.
  44558. * @returns true if visible otherwise, false
  44559. */
  44560. isVisible(): boolean;
  44561. /**
  44562. * Hide the inspector and close its window.
  44563. */
  44564. hide(): void;
  44565. /**
  44566. * Launch the debugLayer.
  44567. * @param config Define the configuration of the inspector
  44568. * @return a promise fulfilled when the debug layer is visible
  44569. */
  44570. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44571. }
  44572. }
  44573. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44574. import { Nullable } from "babylonjs/types";
  44575. import { Scene } from "babylonjs/scene";
  44576. import { Vector4 } from "babylonjs/Maths/math.vector";
  44577. import { Color4 } from "babylonjs/Maths/math.color";
  44578. import { Mesh } from "babylonjs/Meshes/mesh";
  44579. /**
  44580. * Class containing static functions to help procedurally build meshes
  44581. */
  44582. export class BoxBuilder {
  44583. /**
  44584. * Creates a box mesh
  44585. * * The parameter `size` sets the size (float) of each box side (default 1)
  44586. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44587. * * 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)
  44588. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44592. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44593. * @param name defines the name of the mesh
  44594. * @param options defines the options used to create the mesh
  44595. * @param scene defines the hosting scene
  44596. * @returns the box mesh
  44597. */
  44598. static CreateBox(name: string, options: {
  44599. size?: number;
  44600. width?: number;
  44601. height?: number;
  44602. depth?: number;
  44603. faceUV?: Vector4[];
  44604. faceColors?: Color4[];
  44605. sideOrientation?: number;
  44606. frontUVs?: Vector4;
  44607. backUVs?: Vector4;
  44608. wrap?: boolean;
  44609. topBaseAt?: number;
  44610. bottomBaseAt?: number;
  44611. updatable?: boolean;
  44612. }, scene?: Nullable<Scene>): Mesh;
  44613. }
  44614. }
  44615. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44616. import { Vector4 } from "babylonjs/Maths/math.vector";
  44617. import { Mesh } from "babylonjs/Meshes/mesh";
  44618. import { Scene } from "babylonjs/scene";
  44619. import { Nullable } from "babylonjs/types";
  44620. /**
  44621. * Class containing static functions to help procedurally build meshes
  44622. */
  44623. export class SphereBuilder {
  44624. /**
  44625. * Creates a sphere mesh
  44626. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44627. * * 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`)
  44628. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44629. * * 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
  44630. * * 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)
  44631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44634. * @param name defines the name of the mesh
  44635. * @param options defines the options used to create the mesh
  44636. * @param scene defines the hosting scene
  44637. * @returns the sphere mesh
  44638. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44639. */
  44640. static CreateSphere(name: string, options: {
  44641. segments?: number;
  44642. diameter?: number;
  44643. diameterX?: number;
  44644. diameterY?: number;
  44645. diameterZ?: number;
  44646. arc?: number;
  44647. slice?: number;
  44648. sideOrientation?: number;
  44649. frontUVs?: Vector4;
  44650. backUVs?: Vector4;
  44651. updatable?: boolean;
  44652. }, scene?: Nullable<Scene>): Mesh;
  44653. }
  44654. }
  44655. declare module "babylonjs/Debug/physicsViewer" {
  44656. import { Nullable } from "babylonjs/types";
  44657. import { Scene } from "babylonjs/scene";
  44658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44659. import { Mesh } from "babylonjs/Meshes/mesh";
  44660. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44661. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44662. /**
  44663. * Used to show the physics impostor around the specific mesh
  44664. */
  44665. export class PhysicsViewer {
  44666. /** @hidden */
  44667. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44668. /** @hidden */
  44669. protected _meshes: Array<Nullable<AbstractMesh>>;
  44670. /** @hidden */
  44671. protected _scene: Nullable<Scene>;
  44672. /** @hidden */
  44673. protected _numMeshes: number;
  44674. /** @hidden */
  44675. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44676. private _renderFunction;
  44677. private _utilityLayer;
  44678. private _debugBoxMesh;
  44679. private _debugSphereMesh;
  44680. private _debugCylinderMesh;
  44681. private _debugMaterial;
  44682. private _debugMeshMeshes;
  44683. /**
  44684. * Creates a new PhysicsViewer
  44685. * @param scene defines the hosting scene
  44686. */
  44687. constructor(scene: Scene);
  44688. /** @hidden */
  44689. protected _updateDebugMeshes(): void;
  44690. /**
  44691. * Renders a specified physic impostor
  44692. * @param impostor defines the impostor to render
  44693. * @param targetMesh defines the mesh represented by the impostor
  44694. * @returns the new debug mesh used to render the impostor
  44695. */
  44696. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44697. /**
  44698. * Hides a specified physic impostor
  44699. * @param impostor defines the impostor to hide
  44700. */
  44701. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44702. private _getDebugMaterial;
  44703. private _getDebugBoxMesh;
  44704. private _getDebugSphereMesh;
  44705. private _getDebugCylinderMesh;
  44706. private _getDebugMeshMesh;
  44707. private _getDebugMesh;
  44708. /** Releases all resources */
  44709. dispose(): void;
  44710. }
  44711. }
  44712. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44713. import { Vector3 } from "babylonjs/Maths/math.vector";
  44714. import { Color4 } from "babylonjs/Maths/math.color";
  44715. import { Nullable } from "babylonjs/types";
  44716. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44717. import { Scene } from "babylonjs/scene";
  44718. /**
  44719. * Class containing static functions to help procedurally build meshes
  44720. */
  44721. export class LinesBuilder {
  44722. /**
  44723. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44724. * * 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
  44725. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44726. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44727. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44728. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44729. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44730. * * 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
  44731. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44734. * @param name defines the name of the new line system
  44735. * @param options defines the options used to create the line system
  44736. * @param scene defines the hosting scene
  44737. * @returns a new line system mesh
  44738. */
  44739. static CreateLineSystem(name: string, options: {
  44740. lines: Vector3[][];
  44741. updatable?: boolean;
  44742. instance?: Nullable<LinesMesh>;
  44743. colors?: Nullable<Color4[][]>;
  44744. useVertexAlpha?: boolean;
  44745. }, scene: Nullable<Scene>): LinesMesh;
  44746. /**
  44747. * Creates a line mesh
  44748. * 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
  44749. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44750. * * The parameter `points` is an array successive Vector3
  44751. * * 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
  44752. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44753. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44754. * * When updating an instance, remember that only point positions can change, not the number of points
  44755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44757. * @param name defines the name of the new line system
  44758. * @param options defines the options used to create the line system
  44759. * @param scene defines the hosting scene
  44760. * @returns a new line mesh
  44761. */
  44762. static CreateLines(name: string, options: {
  44763. points: Vector3[];
  44764. updatable?: boolean;
  44765. instance?: Nullable<LinesMesh>;
  44766. colors?: Color4[];
  44767. useVertexAlpha?: boolean;
  44768. }, scene?: Nullable<Scene>): LinesMesh;
  44769. /**
  44770. * Creates a dashed line mesh
  44771. * * 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
  44772. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44773. * * The parameter `points` is an array successive Vector3
  44774. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44775. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44776. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44777. * * 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
  44778. * * When updating an instance, remember that only point positions can change, not the number of points
  44779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44780. * @param name defines the name of the mesh
  44781. * @param options defines the options used to create the mesh
  44782. * @param scene defines the hosting scene
  44783. * @returns the dashed line mesh
  44784. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44785. */
  44786. static CreateDashedLines(name: string, options: {
  44787. points: Vector3[];
  44788. dashSize?: number;
  44789. gapSize?: number;
  44790. dashNb?: number;
  44791. updatable?: boolean;
  44792. instance?: LinesMesh;
  44793. }, scene?: Nullable<Scene>): LinesMesh;
  44794. }
  44795. }
  44796. declare module "babylonjs/Debug/rayHelper" {
  44797. import { Nullable } from "babylonjs/types";
  44798. import { Ray } from "babylonjs/Culling/ray";
  44799. import { Vector3 } from "babylonjs/Maths/math.vector";
  44800. import { Color3 } from "babylonjs/Maths/math.color";
  44801. import { Scene } from "babylonjs/scene";
  44802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44803. import "babylonjs/Meshes/Builders/linesBuilder";
  44804. /**
  44805. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44806. * in order to better appreciate the issue one might have.
  44807. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44808. */
  44809. export class RayHelper {
  44810. /**
  44811. * Defines the ray we are currently tryin to visualize.
  44812. */
  44813. ray: Nullable<Ray>;
  44814. private _renderPoints;
  44815. private _renderLine;
  44816. private _renderFunction;
  44817. private _scene;
  44818. private _updateToMeshFunction;
  44819. private _attachedToMesh;
  44820. private _meshSpaceDirection;
  44821. private _meshSpaceOrigin;
  44822. /**
  44823. * Helper function to create a colored helper in a scene in one line.
  44824. * @param ray Defines the ray we are currently tryin to visualize
  44825. * @param scene Defines the scene the ray is used in
  44826. * @param color Defines the color we want to see the ray in
  44827. * @returns The newly created ray helper.
  44828. */
  44829. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44830. /**
  44831. * Instantiate a new ray helper.
  44832. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44833. * in order to better appreciate the issue one might have.
  44834. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44835. * @param ray Defines the ray we are currently tryin to visualize
  44836. */
  44837. constructor(ray: Ray);
  44838. /**
  44839. * Shows the ray we are willing to debug.
  44840. * @param scene Defines the scene the ray needs to be rendered in
  44841. * @param color Defines the color the ray needs to be rendered in
  44842. */
  44843. show(scene: Scene, color?: Color3): void;
  44844. /**
  44845. * Hides the ray we are debugging.
  44846. */
  44847. hide(): void;
  44848. private _render;
  44849. /**
  44850. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44851. * @param mesh Defines the mesh we want the helper attached to
  44852. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44853. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44854. * @param length Defines the length of the ray
  44855. */
  44856. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44857. /**
  44858. * Detach the ray helper from the mesh it has previously been attached to.
  44859. */
  44860. detachFromMesh(): void;
  44861. private _updateToMesh;
  44862. /**
  44863. * Dispose the helper and release its associated resources.
  44864. */
  44865. dispose(): void;
  44866. }
  44867. }
  44868. declare module "babylonjs/Debug/skeletonViewer" {
  44869. import { Color3 } from "babylonjs/Maths/math.color";
  44870. import { Scene } from "babylonjs/scene";
  44871. import { Nullable } from "babylonjs/types";
  44872. import { Skeleton } from "babylonjs/Bones/skeleton";
  44873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44874. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44875. /**
  44876. * Class used to render a debug view of a given skeleton
  44877. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44878. */
  44879. export class SkeletonViewer {
  44880. /** defines the skeleton to render */
  44881. skeleton: Skeleton;
  44882. /** defines the mesh attached to the skeleton */
  44883. mesh: AbstractMesh;
  44884. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44885. autoUpdateBonesMatrices: boolean;
  44886. /** defines the rendering group id to use with the viewer */
  44887. renderingGroupId: number;
  44888. /** Gets or sets the color used to render the skeleton */
  44889. color: Color3;
  44890. private _scene;
  44891. private _debugLines;
  44892. private _debugMesh;
  44893. private _isEnabled;
  44894. private _renderFunction;
  44895. private _utilityLayer;
  44896. /**
  44897. * Returns the mesh used to render the bones
  44898. */
  44899. readonly debugMesh: Nullable<LinesMesh>;
  44900. /**
  44901. * Creates a new SkeletonViewer
  44902. * @param skeleton defines the skeleton to render
  44903. * @param mesh defines the mesh attached to the skeleton
  44904. * @param scene defines the hosting scene
  44905. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44906. * @param renderingGroupId defines the rendering group id to use with the viewer
  44907. */
  44908. constructor(
  44909. /** defines the skeleton to render */
  44910. skeleton: Skeleton,
  44911. /** defines the mesh attached to the skeleton */
  44912. mesh: AbstractMesh, scene: Scene,
  44913. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44914. autoUpdateBonesMatrices?: boolean,
  44915. /** defines the rendering group id to use with the viewer */
  44916. renderingGroupId?: number);
  44917. /** Gets or sets a boolean indicating if the viewer is enabled */
  44918. isEnabled: boolean;
  44919. private _getBonePosition;
  44920. private _getLinesForBonesWithLength;
  44921. private _getLinesForBonesNoLength;
  44922. /** Update the viewer to sync with current skeleton state */
  44923. update(): void;
  44924. /** Release associated resources */
  44925. dispose(): void;
  44926. }
  44927. }
  44928. declare module "babylonjs/Debug/index" {
  44929. export * from "babylonjs/Debug/axesViewer";
  44930. export * from "babylonjs/Debug/boneAxesViewer";
  44931. export * from "babylonjs/Debug/debugLayer";
  44932. export * from "babylonjs/Debug/physicsViewer";
  44933. export * from "babylonjs/Debug/rayHelper";
  44934. export * from "babylonjs/Debug/skeletonViewer";
  44935. }
  44936. declare module "babylonjs/Engines/engine.backwardCompatibility" { }
  44937. declare module "babylonjs/Engines/nullEngine" {
  44938. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44939. import { Scene } from "babylonjs/scene";
  44940. import { Engine } from "babylonjs/Engines/engine";
  44941. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44942. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44944. import { Effect } from "babylonjs/Materials/effect";
  44945. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44946. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44947. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44948. /**
  44949. * Options to create the null engine
  44950. */
  44951. export class NullEngineOptions {
  44952. /**
  44953. * Render width (Default: 512)
  44954. */
  44955. renderWidth: number;
  44956. /**
  44957. * Render height (Default: 256)
  44958. */
  44959. renderHeight: number;
  44960. /**
  44961. * Texture size (Default: 512)
  44962. */
  44963. textureSize: number;
  44964. /**
  44965. * If delta time between frames should be constant
  44966. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44967. */
  44968. deterministicLockstep: boolean;
  44969. /**
  44970. * Maximum about of steps between frames (Default: 4)
  44971. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44972. */
  44973. lockstepMaxSteps: number;
  44974. }
  44975. /**
  44976. * The null engine class provides support for headless version of babylon.js.
  44977. * This can be used in server side scenario or for testing purposes
  44978. */
  44979. export class NullEngine extends Engine {
  44980. private _options;
  44981. /**
  44982. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44983. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44984. * @returns true if engine is in deterministic lock step mode
  44985. */
  44986. isDeterministicLockStep(): boolean;
  44987. /**
  44988. * Gets the max steps when engine is running in deterministic lock step
  44989. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44990. * @returns the max steps
  44991. */
  44992. getLockstepMaxSteps(): number;
  44993. /**
  44994. * Gets the current hardware scaling level.
  44995. * By default the hardware scaling level is computed from the window device ratio.
  44996. * 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.
  44997. * @returns a number indicating the current hardware scaling level
  44998. */
  44999. getHardwareScalingLevel(): number;
  45000. constructor(options?: NullEngineOptions);
  45001. /**
  45002. * Creates a vertex buffer
  45003. * @param vertices the data for the vertex buffer
  45004. * @returns the new WebGL static buffer
  45005. */
  45006. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45007. /**
  45008. * Creates a new index buffer
  45009. * @param indices defines the content of the index buffer
  45010. * @param updatable defines if the index buffer must be updatable
  45011. * @returns a new webGL buffer
  45012. */
  45013. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45014. /**
  45015. * Clear the current render buffer or the current render target (if any is set up)
  45016. * @param color defines the color to use
  45017. * @param backBuffer defines if the back buffer must be cleared
  45018. * @param depth defines if the depth buffer must be cleared
  45019. * @param stencil defines if the stencil buffer must be cleared
  45020. */
  45021. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45022. /**
  45023. * Gets the current render width
  45024. * @param useScreen defines if screen size must be used (or the current render target if any)
  45025. * @returns a number defining the current render width
  45026. */
  45027. getRenderWidth(useScreen?: boolean): number;
  45028. /**
  45029. * Gets the current render height
  45030. * @param useScreen defines if screen size must be used (or the current render target if any)
  45031. * @returns a number defining the current render height
  45032. */
  45033. getRenderHeight(useScreen?: boolean): number;
  45034. /**
  45035. * Set the WebGL's viewport
  45036. * @param viewport defines the viewport element to be used
  45037. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45038. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45039. */
  45040. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45041. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45042. /**
  45043. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45044. * @param pipelineContext defines the pipeline context to use
  45045. * @param uniformsNames defines the list of uniform names
  45046. * @returns an array of webGL uniform locations
  45047. */
  45048. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45049. /**
  45050. * Gets the lsit of active attributes for a given webGL program
  45051. * @param pipelineContext defines the pipeline context to use
  45052. * @param attributesNames defines the list of attribute names to get
  45053. * @returns an array of indices indicating the offset of each attribute
  45054. */
  45055. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45056. /**
  45057. * Binds an effect to the webGL context
  45058. * @param effect defines the effect to bind
  45059. */
  45060. bindSamplers(effect: Effect): void;
  45061. /**
  45062. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45063. * @param effect defines the effect to activate
  45064. */
  45065. enableEffect(effect: Effect): void;
  45066. /**
  45067. * Set various states to the webGL context
  45068. * @param culling defines backface culling state
  45069. * @param zOffset defines the value to apply to zOffset (0 by default)
  45070. * @param force defines if states must be applied even if cache is up to date
  45071. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45072. */
  45073. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45074. /**
  45075. * Set the value of an uniform to an array of int32
  45076. * @param uniform defines the webGL uniform location where to store the value
  45077. * @param array defines the array of int32 to store
  45078. */
  45079. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45080. /**
  45081. * Set the value of an uniform to an array of int32 (stored as vec2)
  45082. * @param uniform defines the webGL uniform location where to store the value
  45083. * @param array defines the array of int32 to store
  45084. */
  45085. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45086. /**
  45087. * Set the value of an uniform to an array of int32 (stored as vec3)
  45088. * @param uniform defines the webGL uniform location where to store the value
  45089. * @param array defines the array of int32 to store
  45090. */
  45091. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45092. /**
  45093. * Set the value of an uniform to an array of int32 (stored as vec4)
  45094. * @param uniform defines the webGL uniform location where to store the value
  45095. * @param array defines the array of int32 to store
  45096. */
  45097. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45098. /**
  45099. * Set the value of an uniform to an array of float32
  45100. * @param uniform defines the webGL uniform location where to store the value
  45101. * @param array defines the array of float32 to store
  45102. */
  45103. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45104. /**
  45105. * Set the value of an uniform to an array of float32 (stored as vec2)
  45106. * @param uniform defines the webGL uniform location where to store the value
  45107. * @param array defines the array of float32 to store
  45108. */
  45109. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45110. /**
  45111. * Set the value of an uniform to an array of float32 (stored as vec3)
  45112. * @param uniform defines the webGL uniform location where to store the value
  45113. * @param array defines the array of float32 to store
  45114. */
  45115. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45116. /**
  45117. * Set the value of an uniform to an array of float32 (stored as vec4)
  45118. * @param uniform defines the webGL uniform location where to store the value
  45119. * @param array defines the array of float32 to store
  45120. */
  45121. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45122. /**
  45123. * Set the value of an uniform to an array of number
  45124. * @param uniform defines the webGL uniform location where to store the value
  45125. * @param array defines the array of number to store
  45126. */
  45127. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45128. /**
  45129. * Set the value of an uniform to an array of number (stored as vec2)
  45130. * @param uniform defines the webGL uniform location where to store the value
  45131. * @param array defines the array of number to store
  45132. */
  45133. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45134. /**
  45135. * Set the value of an uniform to an array of number (stored as vec3)
  45136. * @param uniform defines the webGL uniform location where to store the value
  45137. * @param array defines the array of number to store
  45138. */
  45139. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45140. /**
  45141. * Set the value of an uniform to an array of number (stored as vec4)
  45142. * @param uniform defines the webGL uniform location where to store the value
  45143. * @param array defines the array of number to store
  45144. */
  45145. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45146. /**
  45147. * Set the value of an uniform to an array of float32 (stored as matrices)
  45148. * @param uniform defines the webGL uniform location where to store the value
  45149. * @param matrices defines the array of float32 to store
  45150. */
  45151. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45152. /**
  45153. * Set the value of an uniform to a matrix (3x3)
  45154. * @param uniform defines the webGL uniform location where to store the value
  45155. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45156. */
  45157. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45158. /**
  45159. * Set the value of an uniform to a matrix (2x2)
  45160. * @param uniform defines the webGL uniform location where to store the value
  45161. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45162. */
  45163. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45164. /**
  45165. * Set the value of an uniform to a number (float)
  45166. * @param uniform defines the webGL uniform location where to store the value
  45167. * @param value defines the float number to store
  45168. */
  45169. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45170. /**
  45171. * Set the value of an uniform to a vec2
  45172. * @param uniform defines the webGL uniform location where to store the value
  45173. * @param x defines the 1st component of the value
  45174. * @param y defines the 2nd component of the value
  45175. */
  45176. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45177. /**
  45178. * Set the value of an uniform to a vec3
  45179. * @param uniform defines the webGL uniform location where to store the value
  45180. * @param x defines the 1st component of the value
  45181. * @param y defines the 2nd component of the value
  45182. * @param z defines the 3rd component of the value
  45183. */
  45184. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45185. /**
  45186. * Set the value of an uniform to a boolean
  45187. * @param uniform defines the webGL uniform location where to store the value
  45188. * @param bool defines the boolean to store
  45189. */
  45190. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45191. /**
  45192. * Set the value of an uniform to a vec4
  45193. * @param uniform defines the webGL uniform location where to store the value
  45194. * @param x defines the 1st component of the value
  45195. * @param y defines the 2nd component of the value
  45196. * @param z defines the 3rd component of the value
  45197. * @param w defines the 4th component of the value
  45198. */
  45199. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45200. /**
  45201. * Sets the current alpha mode
  45202. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45203. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45204. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45205. */
  45206. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45207. /**
  45208. * Bind webGl buffers directly to the webGL context
  45209. * @param vertexBuffers defines the vertex buffer to bind
  45210. * @param indexBuffer defines the index buffer to bind
  45211. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45212. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45213. * @param effect defines the effect associated with the vertex buffer
  45214. */
  45215. bindBuffers(vertexBuffers: {
  45216. [key: string]: VertexBuffer;
  45217. }, indexBuffer: DataBuffer, effect: Effect): void;
  45218. /**
  45219. * Force the entire cache to be cleared
  45220. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45221. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45222. */
  45223. wipeCaches(bruteForce?: boolean): void;
  45224. /**
  45225. * Send a draw order
  45226. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45227. * @param indexStart defines the starting index
  45228. * @param indexCount defines the number of index to draw
  45229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45230. */
  45231. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45232. /**
  45233. * Draw a list of indexed primitives
  45234. * @param fillMode defines the primitive to use
  45235. * @param indexStart defines the starting index
  45236. * @param indexCount defines the number of index to draw
  45237. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45238. */
  45239. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45240. /**
  45241. * Draw a list of unindexed primitives
  45242. * @param fillMode defines the primitive to use
  45243. * @param verticesStart defines the index of first vertex to draw
  45244. * @param verticesCount defines the count of vertices to draw
  45245. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45246. */
  45247. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45248. /** @hidden */
  45249. _createTexture(): WebGLTexture;
  45250. /** @hidden */
  45251. _releaseTexture(texture: InternalTexture): void;
  45252. /**
  45253. * Usually called from Texture.ts.
  45254. * Passed information to create a WebGLTexture
  45255. * @param urlArg defines a value which contains one of the following:
  45256. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45257. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45258. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45260. * @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)
  45261. * @param scene needed for loading to the correct scene
  45262. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45263. * @param onLoad optional callback to be called upon successful completion
  45264. * @param onError optional callback to be called upon failure
  45265. * @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
  45266. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45267. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45268. * @param forcedExtension defines the extension to use to pick the right loader
  45269. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45270. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45271. */
  45272. 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;
  45273. /**
  45274. * Creates a new render target texture
  45275. * @param size defines the size of the texture
  45276. * @param options defines the options used to create the texture
  45277. * @returns a new render target texture stored in an InternalTexture
  45278. */
  45279. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45280. /**
  45281. * Update the sampling mode of a given texture
  45282. * @param samplingMode defines the required sampling mode
  45283. * @param texture defines the texture to update
  45284. */
  45285. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45286. /**
  45287. * Binds the frame buffer to the specified texture.
  45288. * @param texture The texture to render to or null for the default canvas
  45289. * @param faceIndex The face of the texture to render to in case of cube texture
  45290. * @param requiredWidth The width of the target to render to
  45291. * @param requiredHeight The height of the target to render to
  45292. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45293. * @param depthStencilTexture The depth stencil texture to use to render
  45294. * @param lodLevel defines le lod level to bind to the frame buffer
  45295. */
  45296. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45297. /**
  45298. * Unbind the current render target texture from the webGL context
  45299. * @param texture defines the render target texture to unbind
  45300. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45301. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45302. */
  45303. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45304. /**
  45305. * Creates a dynamic vertex buffer
  45306. * @param vertices the data for the dynamic vertex buffer
  45307. * @returns the new WebGL dynamic buffer
  45308. */
  45309. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45310. /**
  45311. * Update the content of a dynamic texture
  45312. * @param texture defines the texture to update
  45313. * @param canvas defines the canvas containing the source
  45314. * @param invertY defines if data must be stored with Y axis inverted
  45315. * @param premulAlpha defines if alpha is stored as premultiplied
  45316. * @param format defines the format of the data
  45317. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45318. */
  45319. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45320. /**
  45321. * Gets a boolean indicating if all created effects are ready
  45322. * @returns true if all effects are ready
  45323. */
  45324. areAllEffectsReady(): boolean;
  45325. /**
  45326. * @hidden
  45327. * Get the current error code of the webGL context
  45328. * @returns the error code
  45329. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45330. */
  45331. getError(): number;
  45332. /** @hidden */
  45333. _getUnpackAlignement(): number;
  45334. /** @hidden */
  45335. _unpackFlipY(value: boolean): void;
  45336. /**
  45337. * Update a dynamic index buffer
  45338. * @param indexBuffer defines the target index buffer
  45339. * @param indices defines the data to update
  45340. * @param offset defines the offset in the target index buffer where update should start
  45341. */
  45342. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45343. /**
  45344. * Updates a dynamic vertex buffer.
  45345. * @param vertexBuffer the vertex buffer to update
  45346. * @param vertices the data used to update the vertex buffer
  45347. * @param byteOffset the byte offset of the data (optional)
  45348. * @param byteLength the byte length of the data (optional)
  45349. */
  45350. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45351. /** @hidden */
  45352. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45353. /** @hidden */
  45354. _bindTexture(channel: number, texture: InternalTexture): void;
  45355. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45356. /**
  45357. * 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
  45358. */
  45359. releaseEffects(): void;
  45360. displayLoadingUI(): void;
  45361. hideLoadingUI(): void;
  45362. /** @hidden */
  45363. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45364. /** @hidden */
  45365. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45366. /** @hidden */
  45367. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45368. /** @hidden */
  45369. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45370. }
  45371. }
  45372. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45373. import { Nullable, int } from "babylonjs/types";
  45374. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45375. /** @hidden */
  45376. export class _OcclusionDataStorage {
  45377. /** @hidden */
  45378. occlusionInternalRetryCounter: number;
  45379. /** @hidden */
  45380. isOcclusionQueryInProgress: boolean;
  45381. /** @hidden */
  45382. isOccluded: boolean;
  45383. /** @hidden */
  45384. occlusionRetryCount: number;
  45385. /** @hidden */
  45386. occlusionType: number;
  45387. /** @hidden */
  45388. occlusionQueryAlgorithmType: number;
  45389. }
  45390. module "babylonjs/Engines/engine" {
  45391. interface Engine {
  45392. /**
  45393. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45394. * @return the new query
  45395. */
  45396. createQuery(): WebGLQuery;
  45397. /**
  45398. * Delete and release a webGL query
  45399. * @param query defines the query to delete
  45400. * @return the current engine
  45401. */
  45402. deleteQuery(query: WebGLQuery): Engine;
  45403. /**
  45404. * Check if a given query has resolved and got its value
  45405. * @param query defines the query to check
  45406. * @returns true if the query got its value
  45407. */
  45408. isQueryResultAvailable(query: WebGLQuery): boolean;
  45409. /**
  45410. * Gets the value of a given query
  45411. * @param query defines the query to check
  45412. * @returns the value of the query
  45413. */
  45414. getQueryResult(query: WebGLQuery): number;
  45415. /**
  45416. * Initiates an occlusion query
  45417. * @param algorithmType defines the algorithm to use
  45418. * @param query defines the query to use
  45419. * @returns the current engine
  45420. * @see http://doc.babylonjs.com/features/occlusionquery
  45421. */
  45422. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45423. /**
  45424. * Ends an occlusion query
  45425. * @see http://doc.babylonjs.com/features/occlusionquery
  45426. * @param algorithmType defines the algorithm to use
  45427. * @returns the current engine
  45428. */
  45429. endOcclusionQuery(algorithmType: number): Engine;
  45430. /**
  45431. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45432. * Please note that only one query can be issued at a time
  45433. * @returns a time token used to track the time span
  45434. */
  45435. startTimeQuery(): Nullable<_TimeToken>;
  45436. /**
  45437. * Ends a time query
  45438. * @param token defines the token used to measure the time span
  45439. * @returns the time spent (in ns)
  45440. */
  45441. endTimeQuery(token: _TimeToken): int;
  45442. /** @hidden */
  45443. _currentNonTimestampToken: Nullable<_TimeToken>;
  45444. /** @hidden */
  45445. _createTimeQuery(): WebGLQuery;
  45446. /** @hidden */
  45447. _deleteTimeQuery(query: WebGLQuery): void;
  45448. /** @hidden */
  45449. _getGlAlgorithmType(algorithmType: number): number;
  45450. /** @hidden */
  45451. _getTimeQueryResult(query: WebGLQuery): any;
  45452. /** @hidden */
  45453. _getTimeQueryAvailability(query: WebGLQuery): any;
  45454. }
  45455. }
  45456. module "babylonjs/Meshes/abstractMesh" {
  45457. interface AbstractMesh {
  45458. /**
  45459. * Backing filed
  45460. * @hidden
  45461. */
  45462. __occlusionDataStorage: _OcclusionDataStorage;
  45463. /**
  45464. * Access property
  45465. * @hidden
  45466. */
  45467. _occlusionDataStorage: _OcclusionDataStorage;
  45468. /**
  45469. * 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.
  45470. * The default value is -1 which means don't break the query and wait till the result
  45471. * @see http://doc.babylonjs.com/features/occlusionquery
  45472. */
  45473. occlusionRetryCount: number;
  45474. /**
  45475. * 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:
  45476. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45477. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45478. * * 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.
  45479. * @see http://doc.babylonjs.com/features/occlusionquery
  45480. */
  45481. occlusionType: number;
  45482. /**
  45483. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45484. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45485. * * 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.
  45486. * @see http://doc.babylonjs.com/features/occlusionquery
  45487. */
  45488. occlusionQueryAlgorithmType: number;
  45489. /**
  45490. * 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
  45491. * @see http://doc.babylonjs.com/features/occlusionquery
  45492. */
  45493. isOccluded: boolean;
  45494. /**
  45495. * Flag to check the progress status of the query
  45496. * @see http://doc.babylonjs.com/features/occlusionquery
  45497. */
  45498. isOcclusionQueryInProgress: boolean;
  45499. }
  45500. }
  45501. }
  45502. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45503. import { Nullable } from "babylonjs/types";
  45504. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45505. /** @hidden */
  45506. export var _forceTransformFeedbackToBundle: boolean;
  45507. module "babylonjs/Engines/engine" {
  45508. interface Engine {
  45509. /**
  45510. * Creates a webGL transform feedback object
  45511. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45512. * @returns the webGL transform feedback object
  45513. */
  45514. createTransformFeedback(): WebGLTransformFeedback;
  45515. /**
  45516. * Delete a webGL transform feedback object
  45517. * @param value defines the webGL transform feedback object to delete
  45518. */
  45519. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45520. /**
  45521. * Bind a webGL transform feedback object to the webgl context
  45522. * @param value defines the webGL transform feedback object to bind
  45523. */
  45524. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45525. /**
  45526. * Begins a transform feedback operation
  45527. * @param usePoints defines if points or triangles must be used
  45528. */
  45529. beginTransformFeedback(usePoints: boolean): void;
  45530. /**
  45531. * Ends a transform feedback operation
  45532. */
  45533. endTransformFeedback(): void;
  45534. /**
  45535. * Specify the varyings to use with transform feedback
  45536. * @param program defines the associated webGL program
  45537. * @param value defines the list of strings representing the varying names
  45538. */
  45539. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45540. /**
  45541. * Bind a webGL buffer for a transform feedback operation
  45542. * @param value defines the webGL buffer to bind
  45543. */
  45544. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45545. }
  45546. }
  45547. }
  45548. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45549. import { Scene } from "babylonjs/scene";
  45550. import { Engine } from "babylonjs/Engines/engine";
  45551. import { Texture } from "babylonjs/Materials/Textures/texture";
  45552. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45553. import "babylonjs/Engines/Extensions/engine.multiRender";
  45554. /**
  45555. * Creation options of the multi render target texture.
  45556. */
  45557. export interface IMultiRenderTargetOptions {
  45558. /**
  45559. * Define if the texture needs to create mip maps after render.
  45560. */
  45561. generateMipMaps?: boolean;
  45562. /**
  45563. * Define the types of all the draw buffers we want to create
  45564. */
  45565. types?: number[];
  45566. /**
  45567. * Define the sampling modes of all the draw buffers we want to create
  45568. */
  45569. samplingModes?: number[];
  45570. /**
  45571. * Define if a depth buffer is required
  45572. */
  45573. generateDepthBuffer?: boolean;
  45574. /**
  45575. * Define if a stencil buffer is required
  45576. */
  45577. generateStencilBuffer?: boolean;
  45578. /**
  45579. * Define if a depth texture is required instead of a depth buffer
  45580. */
  45581. generateDepthTexture?: boolean;
  45582. /**
  45583. * Define the number of desired draw buffers
  45584. */
  45585. textureCount?: number;
  45586. /**
  45587. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45588. */
  45589. doNotChangeAspectRatio?: boolean;
  45590. /**
  45591. * Define the default type of the buffers we are creating
  45592. */
  45593. defaultType?: number;
  45594. }
  45595. /**
  45596. * A multi render target, like a render target provides the ability to render to a texture.
  45597. * Unlike the render target, it can render to several draw buffers in one draw.
  45598. * This is specially interesting in deferred rendering or for any effects requiring more than
  45599. * just one color from a single pass.
  45600. */
  45601. export class MultiRenderTarget extends RenderTargetTexture {
  45602. private _internalTextures;
  45603. private _textures;
  45604. private _multiRenderTargetOptions;
  45605. /**
  45606. * Get if draw buffers are currently supported by the used hardware and browser.
  45607. */
  45608. readonly isSupported: boolean;
  45609. /**
  45610. * Get the list of textures generated by the multi render target.
  45611. */
  45612. readonly textures: Texture[];
  45613. /**
  45614. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45615. */
  45616. readonly depthTexture: Texture;
  45617. /**
  45618. * Set the wrapping mode on U of all the textures we are rendering to.
  45619. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45620. */
  45621. wrapU: number;
  45622. /**
  45623. * Set the wrapping mode on V of all the textures we are rendering to.
  45624. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45625. */
  45626. wrapV: number;
  45627. /**
  45628. * Instantiate a new multi render target texture.
  45629. * A multi render target, like a render target provides the ability to render to a texture.
  45630. * Unlike the render target, it can render to several draw buffers in one draw.
  45631. * This is specially interesting in deferred rendering or for any effects requiring more than
  45632. * just one color from a single pass.
  45633. * @param name Define the name of the texture
  45634. * @param size Define the size of the buffers to render to
  45635. * @param count Define the number of target we are rendering into
  45636. * @param scene Define the scene the texture belongs to
  45637. * @param options Define the options used to create the multi render target
  45638. */
  45639. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45640. /** @hidden */
  45641. _rebuild(): void;
  45642. private _createInternalTextures;
  45643. private _createTextures;
  45644. /**
  45645. * Define the number of samples used if MSAA is enabled.
  45646. */
  45647. samples: number;
  45648. /**
  45649. * Resize all the textures in the multi render target.
  45650. * Be carrefull as it will recreate all the data in the new texture.
  45651. * @param size Define the new size
  45652. */
  45653. resize(size: any): void;
  45654. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45655. /**
  45656. * Dispose the render targets and their associated resources
  45657. */
  45658. dispose(): void;
  45659. /**
  45660. * Release all the underlying texture used as draw buffers.
  45661. */
  45662. releaseInternalTextures(): void;
  45663. }
  45664. }
  45665. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45666. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45667. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45668. import { Nullable } from "babylonjs/types";
  45669. module "babylonjs/Engines/baseEngine" {
  45670. interface BaseEngine {
  45671. /**
  45672. * Unbind a list of render target textures from the webGL context
  45673. * This is used only when drawBuffer extension or webGL2 are active
  45674. * @param textures defines the render target textures to unbind
  45675. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45676. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45677. */
  45678. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45679. /**
  45680. * Create a multi render target texture
  45681. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45682. * @param size defines the size of the texture
  45683. * @param options defines the creation options
  45684. * @returns the cube texture as an InternalTexture
  45685. */
  45686. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45687. /**
  45688. * Update the sample count for a given multiple render target texture
  45689. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45690. * @param textures defines the textures to update
  45691. * @param samples defines the sample count to set
  45692. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45693. */
  45694. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45695. }
  45696. }
  45697. }
  45698. declare module "babylonjs/Engines/Extensions/index" {
  45699. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45700. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45701. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45702. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45703. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45704. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45705. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45706. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45707. }
  45708. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45709. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45710. /** @hidden */
  45711. export var rgbdEncodePixelShader: {
  45712. name: string;
  45713. shader: string;
  45714. };
  45715. }
  45716. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45717. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45718. /** @hidden */
  45719. export var rgbdDecodePixelShader: {
  45720. name: string;
  45721. shader: string;
  45722. };
  45723. }
  45724. declare module "babylonjs/Misc/environmentTextureTools" {
  45725. import { Nullable } from "babylonjs/types";
  45726. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45727. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45728. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45729. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45730. import "babylonjs/Shaders/rgbdEncode.fragment";
  45731. import "babylonjs/Shaders/rgbdDecode.fragment";
  45732. /**
  45733. * Raw texture data and descriptor sufficient for WebGL texture upload
  45734. */
  45735. export interface EnvironmentTextureInfo {
  45736. /**
  45737. * Version of the environment map
  45738. */
  45739. version: number;
  45740. /**
  45741. * Width of image
  45742. */
  45743. width: number;
  45744. /**
  45745. * Irradiance information stored in the file.
  45746. */
  45747. irradiance: any;
  45748. /**
  45749. * Specular information stored in the file.
  45750. */
  45751. specular: any;
  45752. }
  45753. /**
  45754. * Defines One Image in the file. It requires only the position in the file
  45755. * as well as the length.
  45756. */
  45757. interface BufferImageData {
  45758. /**
  45759. * Length of the image data.
  45760. */
  45761. length: number;
  45762. /**
  45763. * Position of the data from the null terminator delimiting the end of the JSON.
  45764. */
  45765. position: number;
  45766. }
  45767. /**
  45768. * Defines the specular data enclosed in the file.
  45769. * This corresponds to the version 1 of the data.
  45770. */
  45771. export interface EnvironmentTextureSpecularInfoV1 {
  45772. /**
  45773. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45774. */
  45775. specularDataPosition?: number;
  45776. /**
  45777. * This contains all the images data needed to reconstruct the cubemap.
  45778. */
  45779. mipmaps: Array<BufferImageData>;
  45780. /**
  45781. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45782. */
  45783. lodGenerationScale: number;
  45784. }
  45785. /**
  45786. * Sets of helpers addressing the serialization and deserialization of environment texture
  45787. * stored in a BabylonJS env file.
  45788. * Those files are usually stored as .env files.
  45789. */
  45790. export class EnvironmentTextureTools {
  45791. /**
  45792. * Magic number identifying the env file.
  45793. */
  45794. private static _MagicBytes;
  45795. /**
  45796. * Gets the environment info from an env file.
  45797. * @param data The array buffer containing the .env bytes.
  45798. * @returns the environment file info (the json header) if successfully parsed.
  45799. */
  45800. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45801. /**
  45802. * Creates an environment texture from a loaded cube texture.
  45803. * @param texture defines the cube texture to convert in env file
  45804. * @return a promise containing the environment data if succesfull.
  45805. */
  45806. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45807. /**
  45808. * Creates a JSON representation of the spherical data.
  45809. * @param texture defines the texture containing the polynomials
  45810. * @return the JSON representation of the spherical info
  45811. */
  45812. private static _CreateEnvTextureIrradiance;
  45813. /**
  45814. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45815. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45816. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45817. * @return the views described by info providing access to the underlying buffer
  45818. */
  45819. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45820. /**
  45821. * Uploads the texture info contained in the env file to the GPU.
  45822. * @param texture defines the internal texture to upload to
  45823. * @param arrayBuffer defines the buffer cotaining the data to load
  45824. * @param info defines the texture info retrieved through the GetEnvInfo method
  45825. * @returns a promise
  45826. */
  45827. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45828. /**
  45829. * Uploads the levels of image data to the GPU.
  45830. * @param texture defines the internal texture to upload to
  45831. * @param imageData defines the array buffer views of image data [mipmap][face]
  45832. * @returns a promise
  45833. */
  45834. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45835. /**
  45836. * Uploads spherical polynomials information to the texture.
  45837. * @param texture defines the texture we are trying to upload the information to
  45838. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45839. */
  45840. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45841. /** @hidden */
  45842. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45843. }
  45844. }
  45845. declare module "babylonjs/Maths/math.vertexFormat" {
  45846. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45847. /**
  45848. * Contains position and normal vectors for a vertex
  45849. */
  45850. export class PositionNormalVertex {
  45851. /** the position of the vertex (defaut: 0,0,0) */
  45852. position: Vector3;
  45853. /** the normal of the vertex (defaut: 0,1,0) */
  45854. normal: Vector3;
  45855. /**
  45856. * Creates a PositionNormalVertex
  45857. * @param position the position of the vertex (defaut: 0,0,0)
  45858. * @param normal the normal of the vertex (defaut: 0,1,0)
  45859. */
  45860. constructor(
  45861. /** the position of the vertex (defaut: 0,0,0) */
  45862. position?: Vector3,
  45863. /** the normal of the vertex (defaut: 0,1,0) */
  45864. normal?: Vector3);
  45865. /**
  45866. * Clones the PositionNormalVertex
  45867. * @returns the cloned PositionNormalVertex
  45868. */
  45869. clone(): PositionNormalVertex;
  45870. }
  45871. /**
  45872. * Contains position, normal and uv vectors for a vertex
  45873. */
  45874. export class PositionNormalTextureVertex {
  45875. /** the position of the vertex (defaut: 0,0,0) */
  45876. position: Vector3;
  45877. /** the normal of the vertex (defaut: 0,1,0) */
  45878. normal: Vector3;
  45879. /** the uv of the vertex (default: 0,0) */
  45880. uv: Vector2;
  45881. /**
  45882. * Creates a PositionNormalTextureVertex
  45883. * @param position the position of the vertex (defaut: 0,0,0)
  45884. * @param normal the normal of the vertex (defaut: 0,1,0)
  45885. * @param uv the uv of the vertex (default: 0,0)
  45886. */
  45887. constructor(
  45888. /** the position of the vertex (defaut: 0,0,0) */
  45889. position?: Vector3,
  45890. /** the normal of the vertex (defaut: 0,1,0) */
  45891. normal?: Vector3,
  45892. /** the uv of the vertex (default: 0,0) */
  45893. uv?: Vector2);
  45894. /**
  45895. * Clones the PositionNormalTextureVertex
  45896. * @returns the cloned PositionNormalTextureVertex
  45897. */
  45898. clone(): PositionNormalTextureVertex;
  45899. }
  45900. }
  45901. declare module "babylonjs/Maths/math" {
  45902. export * from "babylonjs/Maths/math.axis";
  45903. export * from "babylonjs/Maths/math.color";
  45904. export * from "babylonjs/Maths/math.constants";
  45905. export * from "babylonjs/Maths/math.frustum";
  45906. export * from "babylonjs/Maths/math.path";
  45907. export * from "babylonjs/Maths/math.plane";
  45908. export * from "babylonjs/Maths/math.size";
  45909. export * from "babylonjs/Maths/math.vector";
  45910. export * from "babylonjs/Maths/math.vertexFormat";
  45911. export * from "babylonjs/Maths/math.viewport";
  45912. }
  45913. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45914. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45915. /** @hidden */
  45916. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45917. private _genericAttributeLocation;
  45918. private _varyingLocationCount;
  45919. private _varyingLocationMap;
  45920. private _replacements;
  45921. private _textureCount;
  45922. private _uniforms;
  45923. lineProcessor(line: string): string;
  45924. attributeProcessor(attribute: string): string;
  45925. varyingProcessor(varying: string, isFragment: boolean): string;
  45926. uniformProcessor(uniform: string): string;
  45927. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45928. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45929. }
  45930. }
  45931. declare module "babylonjs/Engines/nativeEngine" {
  45932. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45933. import { Engine } from "babylonjs/Engines/engine";
  45934. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45937. import { Effect } from "babylonjs/Materials/effect";
  45938. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45939. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45940. import { Scene } from "babylonjs/scene";
  45941. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45942. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45943. /**
  45944. * Container for accessors for natively-stored mesh data buffers.
  45945. */
  45946. class NativeDataBuffer extends DataBuffer {
  45947. /**
  45948. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45949. */
  45950. nativeIndexBuffer?: any;
  45951. /**
  45952. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45953. */
  45954. nativeVertexBuffer?: any;
  45955. }
  45956. /** @hidden */
  45957. export class NativeEngine extends Engine {
  45958. private readonly _native;
  45959. getHardwareScalingLevel(): number;
  45960. constructor();
  45961. /**
  45962. * Can be used to override the current requestAnimationFrame requester.
  45963. * @hidden
  45964. */
  45965. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45966. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45967. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45968. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45969. recordVertexArrayObject(vertexBuffers: {
  45970. [key: string]: VertexBuffer;
  45971. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45972. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45973. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45974. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45975. /**
  45976. * Draw a list of indexed primitives
  45977. * @param fillMode defines the primitive to use
  45978. * @param indexStart defines the starting index
  45979. * @param indexCount defines the number of index to draw
  45980. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45981. */
  45982. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45983. /**
  45984. * Draw a list of unindexed primitives
  45985. * @param fillMode defines the primitive to use
  45986. * @param verticesStart defines the index of first vertex to draw
  45987. * @param verticesCount defines the count of vertices to draw
  45988. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45989. */
  45990. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45991. createPipelineContext(): IPipelineContext;
  45992. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45993. /** @hidden */
  45994. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45995. /** @hidden */
  45996. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45997. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45998. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45999. protected _setProgram(program: WebGLProgram): void;
  46000. _releaseEffect(effect: Effect): void;
  46001. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46002. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46003. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46004. bindSamplers(effect: Effect): void;
  46005. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46006. getRenderWidth(useScreen?: boolean): number;
  46007. getRenderHeight(useScreen?: boolean): number;
  46008. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46009. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46010. /**
  46011. * Set the z offset to apply to current rendering
  46012. * @param value defines the offset to apply
  46013. */
  46014. setZOffset(value: number): void;
  46015. /**
  46016. * Gets the current value of the zOffset
  46017. * @returns the current zOffset state
  46018. */
  46019. getZOffset(): number;
  46020. /**
  46021. * Enable or disable depth buffering
  46022. * @param enable defines the state to set
  46023. */
  46024. setDepthBuffer(enable: boolean): void;
  46025. /**
  46026. * Gets a boolean indicating if depth writing is enabled
  46027. * @returns the current depth writing state
  46028. */
  46029. getDepthWrite(): boolean;
  46030. /**
  46031. * Enable or disable depth writing
  46032. * @param enable defines the state to set
  46033. */
  46034. setDepthWrite(enable: boolean): void;
  46035. /**
  46036. * Enable or disable color writing
  46037. * @param enable defines the state to set
  46038. */
  46039. setColorWrite(enable: boolean): void;
  46040. /**
  46041. * Gets a boolean indicating if color writing is enabled
  46042. * @returns the current color writing state
  46043. */
  46044. getColorWrite(): boolean;
  46045. /**
  46046. * Sets alpha constants used by some alpha blending modes
  46047. * @param r defines the red component
  46048. * @param g defines the green component
  46049. * @param b defines the blue component
  46050. * @param a defines the alpha component
  46051. */
  46052. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46053. /**
  46054. * Sets the current alpha mode
  46055. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46056. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46057. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46058. */
  46059. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46060. /**
  46061. * Gets the current alpha mode
  46062. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46063. * @returns the current alpha mode
  46064. */
  46065. getAlphaMode(): number;
  46066. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46067. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46068. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46069. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46070. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46071. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46072. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46073. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46074. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46075. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46076. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46077. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46078. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46079. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46080. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46081. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46082. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46083. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46084. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46085. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46086. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46087. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46088. wipeCaches(bruteForce?: boolean): void;
  46089. _createTexture(): WebGLTexture;
  46090. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46091. /**
  46092. * Usually called from BABYLON.Texture.ts.
  46093. * Passed information to create a WebGLTexture
  46094. * @param urlArg defines a value which contains one of the following:
  46095. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46096. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46097. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46098. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46099. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46100. * @param scene needed for loading to the correct scene
  46101. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46102. * @param onLoad optional callback to be called upon successful completion
  46103. * @param onError optional callback to be called upon failure
  46104. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46105. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46106. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46107. * @param forcedExtension defines the extension to use to pick the right loader
  46108. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46109. */
  46110. 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;
  46111. /**
  46112. * Creates a cube texture
  46113. * @param rootUrl defines the url where the files to load is located
  46114. * @param scene defines the current scene
  46115. * @param files defines the list of files to load (1 per face)
  46116. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46117. * @param onLoad defines an optional callback raised when the texture is loaded
  46118. * @param onError defines an optional callback raised if there is an issue to load the texture
  46119. * @param format defines the format of the data
  46120. * @param forcedExtension defines the extension to use to pick the right loader
  46121. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46122. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46123. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46124. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46125. * @returns the cube texture as an InternalTexture
  46126. */
  46127. 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;
  46128. private _getSamplingFilter;
  46129. private static _GetNativeTextureFormat;
  46130. createRenderTargetTexture(size: number | {
  46131. width: number;
  46132. height: number;
  46133. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46134. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46135. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46136. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46137. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46138. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46139. /**
  46140. * Updates a dynamic vertex buffer.
  46141. * @param vertexBuffer the vertex buffer to update
  46142. * @param data the data used to update the vertex buffer
  46143. * @param byteOffset the byte offset of the data (optional)
  46144. * @param byteLength the byte length of the data (optional)
  46145. */
  46146. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46147. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46148. private _updateAnisotropicLevel;
  46149. private _getAddressMode;
  46150. /** @hidden */
  46151. _bindTexture(channel: number, texture: InternalTexture): void;
  46152. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46153. releaseEffects(): void;
  46154. /** @hidden */
  46155. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46156. /** @hidden */
  46157. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46158. /** @hidden */
  46159. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46160. /** @hidden */
  46161. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46162. }
  46163. }
  46164. declare module "babylonjs/Engines/index" {
  46165. export * from "babylonjs/Engines/constants";
  46166. export * from "babylonjs/Engines/engineCapabilities";
  46167. export * from "babylonjs/Engines/instancingAttributeInfo";
  46168. export * from "babylonjs/Engines/baseEngine";
  46169. export * from "babylonjs/Engines/engine";
  46170. export * from "babylonjs/Engines/engine.backwardCompatibility";
  46171. export * from "babylonjs/Engines/engineStore";
  46172. export * from "babylonjs/Engines/nullEngine";
  46173. export * from "babylonjs/Engines/Extensions/index";
  46174. export * from "babylonjs/Engines/IPipelineContext";
  46175. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46176. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46177. export * from "babylonjs/Engines/nativeEngine";
  46178. }
  46179. declare module "babylonjs/Events/clipboardEvents" {
  46180. /**
  46181. * Gather the list of clipboard event types as constants.
  46182. */
  46183. export class ClipboardEventTypes {
  46184. /**
  46185. * The clipboard event is fired when a copy command is active (pressed).
  46186. */
  46187. static readonly COPY: number;
  46188. /**
  46189. * The clipboard event is fired when a cut command is active (pressed).
  46190. */
  46191. static readonly CUT: number;
  46192. /**
  46193. * The clipboard event is fired when a paste command is active (pressed).
  46194. */
  46195. static readonly PASTE: number;
  46196. }
  46197. /**
  46198. * This class is used to store clipboard related info for the onClipboardObservable event.
  46199. */
  46200. export class ClipboardInfo {
  46201. /**
  46202. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46203. */
  46204. type: number;
  46205. /**
  46206. * Defines the related dom event
  46207. */
  46208. event: ClipboardEvent;
  46209. /**
  46210. *Creates an instance of ClipboardInfo.
  46211. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46212. * @param event Defines the related dom event
  46213. */
  46214. constructor(
  46215. /**
  46216. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46217. */
  46218. type: number,
  46219. /**
  46220. * Defines the related dom event
  46221. */
  46222. event: ClipboardEvent);
  46223. /**
  46224. * Get the clipboard event's type from the keycode.
  46225. * @param keyCode Defines the keyCode for the current keyboard event.
  46226. * @return {number}
  46227. */
  46228. static GetTypeFromCharacter(keyCode: number): number;
  46229. }
  46230. }
  46231. declare module "babylonjs/Events/index" {
  46232. export * from "babylonjs/Events/keyboardEvents";
  46233. export * from "babylonjs/Events/pointerEvents";
  46234. export * from "babylonjs/Events/clipboardEvents";
  46235. }
  46236. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46237. import { Scene } from "babylonjs/scene";
  46238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46239. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46240. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46241. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46242. /**
  46243. * Google Daydream controller
  46244. */
  46245. export class DaydreamController extends WebVRController {
  46246. /**
  46247. * Base Url for the controller model.
  46248. */
  46249. static MODEL_BASE_URL: string;
  46250. /**
  46251. * File name for the controller model.
  46252. */
  46253. static MODEL_FILENAME: string;
  46254. /**
  46255. * Gamepad Id prefix used to identify Daydream Controller.
  46256. */
  46257. static readonly GAMEPAD_ID_PREFIX: string;
  46258. /**
  46259. * Creates a new DaydreamController from a gamepad
  46260. * @param vrGamepad the gamepad that the controller should be created from
  46261. */
  46262. constructor(vrGamepad: any);
  46263. /**
  46264. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46265. * @param scene scene in which to add meshes
  46266. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46267. */
  46268. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46269. /**
  46270. * Called once for each button that changed state since the last frame
  46271. * @param buttonIdx Which button index changed
  46272. * @param state New state of the button
  46273. * @param changes Which properties on the state changed since last frame
  46274. */
  46275. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46276. }
  46277. }
  46278. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46279. import { Scene } from "babylonjs/scene";
  46280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46281. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46282. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46283. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46284. /**
  46285. * Gear VR Controller
  46286. */
  46287. export class GearVRController extends WebVRController {
  46288. /**
  46289. * Base Url for the controller model.
  46290. */
  46291. static MODEL_BASE_URL: string;
  46292. /**
  46293. * File name for the controller model.
  46294. */
  46295. static MODEL_FILENAME: string;
  46296. /**
  46297. * Gamepad Id prefix used to identify this controller.
  46298. */
  46299. static readonly GAMEPAD_ID_PREFIX: string;
  46300. private readonly _buttonIndexToObservableNameMap;
  46301. /**
  46302. * Creates a new GearVRController from a gamepad
  46303. * @param vrGamepad the gamepad that the controller should be created from
  46304. */
  46305. constructor(vrGamepad: any);
  46306. /**
  46307. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46308. * @param scene scene in which to add meshes
  46309. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46310. */
  46311. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46312. /**
  46313. * Called once for each button that changed state since the last frame
  46314. * @param buttonIdx Which button index changed
  46315. * @param state New state of the button
  46316. * @param changes Which properties on the state changed since last frame
  46317. */
  46318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46319. }
  46320. }
  46321. declare module "babylonjs/Gamepads/Controllers/index" {
  46322. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46323. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46324. export * from "babylonjs/Gamepads/Controllers/genericController";
  46325. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46326. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46327. export * from "babylonjs/Gamepads/Controllers/viveController";
  46328. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46329. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46330. }
  46331. declare module "babylonjs/Gamepads/index" {
  46332. export * from "babylonjs/Gamepads/Controllers/index";
  46333. export * from "babylonjs/Gamepads/gamepad";
  46334. export * from "babylonjs/Gamepads/gamepadManager";
  46335. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46336. export * from "babylonjs/Gamepads/xboxGamepad";
  46337. export * from "babylonjs/Gamepads/dualShockGamepad";
  46338. }
  46339. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46340. import { Scene } from "babylonjs/scene";
  46341. import { Vector4 } from "babylonjs/Maths/math.vector";
  46342. import { Color4 } from "babylonjs/Maths/math.color";
  46343. import { Mesh } from "babylonjs/Meshes/mesh";
  46344. import { Nullable } from "babylonjs/types";
  46345. /**
  46346. * Class containing static functions to help procedurally build meshes
  46347. */
  46348. export class PolyhedronBuilder {
  46349. /**
  46350. * Creates a polyhedron mesh
  46351. * * 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
  46352. * * The parameter `size` (positive float, default 1) sets the polygon size
  46353. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46354. * * 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`
  46355. * * 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
  46356. * * 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)`)
  46357. * * 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
  46358. * * 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
  46359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46362. * @param name defines the name of the mesh
  46363. * @param options defines the options used to create the mesh
  46364. * @param scene defines the hosting scene
  46365. * @returns the polyhedron mesh
  46366. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46367. */
  46368. static CreatePolyhedron(name: string, options: {
  46369. type?: number;
  46370. size?: number;
  46371. sizeX?: number;
  46372. sizeY?: number;
  46373. sizeZ?: number;
  46374. custom?: any;
  46375. faceUV?: Vector4[];
  46376. faceColors?: Color4[];
  46377. flat?: boolean;
  46378. updatable?: boolean;
  46379. sideOrientation?: number;
  46380. frontUVs?: Vector4;
  46381. backUVs?: Vector4;
  46382. }, scene?: Nullable<Scene>): Mesh;
  46383. }
  46384. }
  46385. declare module "babylonjs/Gizmos/scaleGizmo" {
  46386. import { Observable } from "babylonjs/Misc/observable";
  46387. import { Nullable } from "babylonjs/types";
  46388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46389. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46390. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46391. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46392. /**
  46393. * Gizmo that enables scaling a mesh along 3 axis
  46394. */
  46395. export class ScaleGizmo extends Gizmo {
  46396. /**
  46397. * Internal gizmo used for interactions on the x axis
  46398. */
  46399. xGizmo: AxisScaleGizmo;
  46400. /**
  46401. * Internal gizmo used for interactions on the y axis
  46402. */
  46403. yGizmo: AxisScaleGizmo;
  46404. /**
  46405. * Internal gizmo used for interactions on the z axis
  46406. */
  46407. zGizmo: AxisScaleGizmo;
  46408. /**
  46409. * Internal gizmo used to scale all axis equally
  46410. */
  46411. uniformScaleGizmo: AxisScaleGizmo;
  46412. private _meshAttached;
  46413. private _updateGizmoRotationToMatchAttachedMesh;
  46414. private _snapDistance;
  46415. private _scaleRatio;
  46416. private _uniformScalingMesh;
  46417. private _octahedron;
  46418. /** Fires an event when any of it's sub gizmos are dragged */
  46419. onDragStartObservable: Observable<unknown>;
  46420. /** Fires an event when any of it's sub gizmos are released from dragging */
  46421. onDragEndObservable: Observable<unknown>;
  46422. attachedMesh: Nullable<AbstractMesh>;
  46423. /**
  46424. * Creates a ScaleGizmo
  46425. * @param gizmoLayer The utility layer the gizmo will be added to
  46426. */
  46427. constructor(gizmoLayer?: UtilityLayerRenderer);
  46428. updateGizmoRotationToMatchAttachedMesh: boolean;
  46429. /**
  46430. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46431. */
  46432. snapDistance: number;
  46433. /**
  46434. * Ratio for the scale of the gizmo (Default: 1)
  46435. */
  46436. scaleRatio: number;
  46437. /**
  46438. * Disposes of the gizmo
  46439. */
  46440. dispose(): void;
  46441. }
  46442. }
  46443. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46444. import { Observable } from "babylonjs/Misc/observable";
  46445. import { Nullable } from "babylonjs/types";
  46446. import { Vector3 } from "babylonjs/Maths/math.vector";
  46447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46448. import { Mesh } from "babylonjs/Meshes/mesh";
  46449. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46450. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46451. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46452. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46453. import { Color3 } from "babylonjs/Maths/math.color";
  46454. /**
  46455. * Single axis scale gizmo
  46456. */
  46457. export class AxisScaleGizmo extends Gizmo {
  46458. /**
  46459. * Drag behavior responsible for the gizmos dragging interactions
  46460. */
  46461. dragBehavior: PointerDragBehavior;
  46462. private _pointerObserver;
  46463. /**
  46464. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46465. */
  46466. snapDistance: number;
  46467. /**
  46468. * Event that fires each time the gizmo snaps to a new location.
  46469. * * snapDistance is the the change in distance
  46470. */
  46471. onSnapObservable: Observable<{
  46472. snapDistance: number;
  46473. }>;
  46474. /**
  46475. * If the scaling operation should be done on all axis (default: false)
  46476. */
  46477. uniformScaling: boolean;
  46478. private _isEnabled;
  46479. private _parent;
  46480. private _arrow;
  46481. private _coloredMaterial;
  46482. private _hoverMaterial;
  46483. /**
  46484. * Creates an AxisScaleGizmo
  46485. * @param gizmoLayer The utility layer the gizmo will be added to
  46486. * @param dragAxis The axis which the gizmo will be able to scale on
  46487. * @param color The color of the gizmo
  46488. */
  46489. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46490. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46491. /**
  46492. * If the gizmo is enabled
  46493. */
  46494. isEnabled: boolean;
  46495. /**
  46496. * Disposes of the gizmo
  46497. */
  46498. dispose(): void;
  46499. /**
  46500. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46501. * @param mesh The mesh to replace the default mesh of the gizmo
  46502. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46503. */
  46504. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46505. }
  46506. }
  46507. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46508. import { Observable } from "babylonjs/Misc/observable";
  46509. import { Nullable } from "babylonjs/types";
  46510. import { Vector3 } from "babylonjs/Maths/math.vector";
  46511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46512. import { Mesh } from "babylonjs/Meshes/mesh";
  46513. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46514. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46515. import { Color3 } from "babylonjs/Maths/math.color";
  46516. import "babylonjs/Meshes/Builders/boxBuilder";
  46517. /**
  46518. * Bounding box gizmo
  46519. */
  46520. export class BoundingBoxGizmo extends Gizmo {
  46521. private _lineBoundingBox;
  46522. private _rotateSpheresParent;
  46523. private _scaleBoxesParent;
  46524. private _boundingDimensions;
  46525. private _renderObserver;
  46526. private _pointerObserver;
  46527. private _scaleDragSpeed;
  46528. private _tmpQuaternion;
  46529. private _tmpVector;
  46530. private _tmpRotationMatrix;
  46531. /**
  46532. * 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)
  46533. */
  46534. ignoreChildren: boolean;
  46535. /**
  46536. * 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)
  46537. */
  46538. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46539. /**
  46540. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46541. */
  46542. rotationSphereSize: number;
  46543. /**
  46544. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46545. */
  46546. scaleBoxSize: number;
  46547. /**
  46548. * 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)
  46549. */
  46550. fixedDragMeshScreenSize: boolean;
  46551. /**
  46552. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46553. */
  46554. fixedDragMeshScreenSizeDistanceFactor: number;
  46555. /**
  46556. * Fired when a rotation sphere or scale box is dragged
  46557. */
  46558. onDragStartObservable: Observable<{}>;
  46559. /**
  46560. * Fired when a scale box is dragged
  46561. */
  46562. onScaleBoxDragObservable: Observable<{}>;
  46563. /**
  46564. * Fired when a scale box drag is ended
  46565. */
  46566. onScaleBoxDragEndObservable: Observable<{}>;
  46567. /**
  46568. * Fired when a rotation sphere is dragged
  46569. */
  46570. onRotationSphereDragObservable: Observable<{}>;
  46571. /**
  46572. * Fired when a rotation sphere drag is ended
  46573. */
  46574. onRotationSphereDragEndObservable: Observable<{}>;
  46575. /**
  46576. * 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)
  46577. */
  46578. scalePivot: Nullable<Vector3>;
  46579. /**
  46580. * Mesh used as a pivot to rotate the attached mesh
  46581. */
  46582. private _anchorMesh;
  46583. private _existingMeshScale;
  46584. private _dragMesh;
  46585. private pointerDragBehavior;
  46586. private coloredMaterial;
  46587. private hoverColoredMaterial;
  46588. /**
  46589. * Sets the color of the bounding box gizmo
  46590. * @param color the color to set
  46591. */
  46592. setColor(color: Color3): void;
  46593. /**
  46594. * Creates an BoundingBoxGizmo
  46595. * @param gizmoLayer The utility layer the gizmo will be added to
  46596. * @param color The color of the gizmo
  46597. */
  46598. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46599. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46600. private _selectNode;
  46601. /**
  46602. * Updates the bounding box information for the Gizmo
  46603. */
  46604. updateBoundingBox(): void;
  46605. private _updateRotationSpheres;
  46606. private _updateScaleBoxes;
  46607. /**
  46608. * Enables rotation on the specified axis and disables rotation on the others
  46609. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46610. */
  46611. setEnabledRotationAxis(axis: string): void;
  46612. /**
  46613. * Enables/disables scaling
  46614. * @param enable if scaling should be enabled
  46615. */
  46616. setEnabledScaling(enable: boolean): void;
  46617. private _updateDummy;
  46618. /**
  46619. * Enables a pointer drag behavior on the bounding box of the gizmo
  46620. */
  46621. enableDragBehavior(): void;
  46622. /**
  46623. * Disposes of the gizmo
  46624. */
  46625. dispose(): void;
  46626. /**
  46627. * 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)
  46628. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46629. * @returns the bounding box mesh with the passed in mesh as a child
  46630. */
  46631. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46632. /**
  46633. * CustomMeshes are not supported by this gizmo
  46634. * @param mesh The mesh to replace the default mesh of the gizmo
  46635. */
  46636. setCustomMesh(mesh: Mesh): void;
  46637. }
  46638. }
  46639. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46640. import { Observable } from "babylonjs/Misc/observable";
  46641. import { Nullable } from "babylonjs/types";
  46642. import { Vector3 } from "babylonjs/Maths/math.vector";
  46643. import { Color3 } from "babylonjs/Maths/math.color";
  46644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46645. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46646. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46647. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46648. import "babylonjs/Meshes/Builders/linesBuilder";
  46649. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46650. /**
  46651. * Single plane rotation gizmo
  46652. */
  46653. export class PlaneRotationGizmo extends Gizmo {
  46654. /**
  46655. * Drag behavior responsible for the gizmos dragging interactions
  46656. */
  46657. dragBehavior: PointerDragBehavior;
  46658. private _pointerObserver;
  46659. /**
  46660. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46661. */
  46662. snapDistance: number;
  46663. /**
  46664. * Event that fires each time the gizmo snaps to a new location.
  46665. * * snapDistance is the the change in distance
  46666. */
  46667. onSnapObservable: Observable<{
  46668. snapDistance: number;
  46669. }>;
  46670. private _isEnabled;
  46671. private _parent;
  46672. /**
  46673. * Creates a PlaneRotationGizmo
  46674. * @param gizmoLayer The utility layer the gizmo will be added to
  46675. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46676. * @param color The color of the gizmo
  46677. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46678. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46679. */
  46680. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46681. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46682. /**
  46683. * If the gizmo is enabled
  46684. */
  46685. isEnabled: boolean;
  46686. /**
  46687. * Disposes of the gizmo
  46688. */
  46689. dispose(): void;
  46690. }
  46691. }
  46692. declare module "babylonjs/Gizmos/rotationGizmo" {
  46693. import { Observable } from "babylonjs/Misc/observable";
  46694. import { Nullable } from "babylonjs/types";
  46695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46696. import { Mesh } from "babylonjs/Meshes/mesh";
  46697. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46698. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46699. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46700. /**
  46701. * Gizmo that enables rotating a mesh along 3 axis
  46702. */
  46703. export class RotationGizmo extends Gizmo {
  46704. /**
  46705. * Internal gizmo used for interactions on the x axis
  46706. */
  46707. xGizmo: PlaneRotationGizmo;
  46708. /**
  46709. * Internal gizmo used for interactions on the y axis
  46710. */
  46711. yGizmo: PlaneRotationGizmo;
  46712. /**
  46713. * Internal gizmo used for interactions on the z axis
  46714. */
  46715. zGizmo: PlaneRotationGizmo;
  46716. /** Fires an event when any of it's sub gizmos are dragged */
  46717. onDragStartObservable: Observable<unknown>;
  46718. /** Fires an event when any of it's sub gizmos are released from dragging */
  46719. onDragEndObservable: Observable<unknown>;
  46720. private _meshAttached;
  46721. attachedMesh: Nullable<AbstractMesh>;
  46722. /**
  46723. * Creates a RotationGizmo
  46724. * @param gizmoLayer The utility layer the gizmo will be added to
  46725. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46726. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46727. */
  46728. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46729. updateGizmoRotationToMatchAttachedMesh: boolean;
  46730. /**
  46731. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46732. */
  46733. snapDistance: number;
  46734. /**
  46735. * Ratio for the scale of the gizmo (Default: 1)
  46736. */
  46737. scaleRatio: number;
  46738. /**
  46739. * Disposes of the gizmo
  46740. */
  46741. dispose(): void;
  46742. /**
  46743. * CustomMeshes are not supported by this gizmo
  46744. * @param mesh The mesh to replace the default mesh of the gizmo
  46745. */
  46746. setCustomMesh(mesh: Mesh): void;
  46747. }
  46748. }
  46749. declare module "babylonjs/Gizmos/gizmoManager" {
  46750. import { Observable } from "babylonjs/Misc/observable";
  46751. import { Nullable } from "babylonjs/types";
  46752. import { Scene, IDisposable } from "babylonjs/scene";
  46753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46754. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46755. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46756. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46757. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46758. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46759. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46760. /**
  46761. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46762. */
  46763. export class GizmoManager implements IDisposable {
  46764. private scene;
  46765. /**
  46766. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46767. */
  46768. gizmos: {
  46769. positionGizmo: Nullable<PositionGizmo>;
  46770. rotationGizmo: Nullable<RotationGizmo>;
  46771. scaleGizmo: Nullable<ScaleGizmo>;
  46772. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46773. };
  46774. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46775. clearGizmoOnEmptyPointerEvent: boolean;
  46776. /** Fires an event when the manager is attached to a mesh */
  46777. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46778. private _gizmosEnabled;
  46779. private _pointerObserver;
  46780. private _attachedMesh;
  46781. private _boundingBoxColor;
  46782. private _defaultUtilityLayer;
  46783. private _defaultKeepDepthUtilityLayer;
  46784. /**
  46785. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46786. */
  46787. boundingBoxDragBehavior: SixDofDragBehavior;
  46788. /**
  46789. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46790. */
  46791. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46792. /**
  46793. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46794. */
  46795. usePointerToAttachGizmos: boolean;
  46796. /**
  46797. * Utility layer that the bounding box gizmo belongs to
  46798. */
  46799. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46800. /**
  46801. * Utility layer that all gizmos besides bounding box belong to
  46802. */
  46803. readonly utilityLayer: UtilityLayerRenderer;
  46804. /**
  46805. * Instatiates a gizmo manager
  46806. * @param scene the scene to overlay the gizmos on top of
  46807. */
  46808. constructor(scene: Scene);
  46809. /**
  46810. * Attaches a set of gizmos to the specified mesh
  46811. * @param mesh The mesh the gizmo's should be attached to
  46812. */
  46813. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46814. /**
  46815. * If the position gizmo is enabled
  46816. */
  46817. positionGizmoEnabled: boolean;
  46818. /**
  46819. * If the rotation gizmo is enabled
  46820. */
  46821. rotationGizmoEnabled: boolean;
  46822. /**
  46823. * If the scale gizmo is enabled
  46824. */
  46825. scaleGizmoEnabled: boolean;
  46826. /**
  46827. * If the boundingBox gizmo is enabled
  46828. */
  46829. boundingBoxGizmoEnabled: boolean;
  46830. /**
  46831. * Disposes of the gizmo manager
  46832. */
  46833. dispose(): void;
  46834. }
  46835. }
  46836. declare module "babylonjs/Lights/directionalLight" {
  46837. import { Camera } from "babylonjs/Cameras/camera";
  46838. import { Scene } from "babylonjs/scene";
  46839. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46841. import { Light } from "babylonjs/Lights/light";
  46842. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46843. import { Effect } from "babylonjs/Materials/effect";
  46844. /**
  46845. * A directional light is defined by a direction (what a surprise!).
  46846. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46847. * 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.
  46848. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46849. */
  46850. export class DirectionalLight extends ShadowLight {
  46851. private _shadowFrustumSize;
  46852. /**
  46853. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46854. */
  46855. /**
  46856. * Specifies a fix frustum size for the shadow generation.
  46857. */
  46858. shadowFrustumSize: number;
  46859. private _shadowOrthoScale;
  46860. /**
  46861. * Gets the shadow projection scale against the optimal computed one.
  46862. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46863. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46864. */
  46865. /**
  46866. * Sets the shadow projection scale against the optimal computed one.
  46867. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46868. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46869. */
  46870. shadowOrthoScale: number;
  46871. /**
  46872. * Automatically compute the projection matrix to best fit (including all the casters)
  46873. * on each frame.
  46874. */
  46875. autoUpdateExtends: boolean;
  46876. private _orthoLeft;
  46877. private _orthoRight;
  46878. private _orthoTop;
  46879. private _orthoBottom;
  46880. /**
  46881. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46882. * The directional light is emitted from everywhere in the given direction.
  46883. * It can cast shadows.
  46884. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46885. * @param name The friendly name of the light
  46886. * @param direction The direction of the light
  46887. * @param scene The scene the light belongs to
  46888. */
  46889. constructor(name: string, direction: Vector3, scene: Scene);
  46890. /**
  46891. * Returns the string "DirectionalLight".
  46892. * @return The class name
  46893. */
  46894. getClassName(): string;
  46895. /**
  46896. * Returns the integer 1.
  46897. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46898. */
  46899. getTypeID(): number;
  46900. /**
  46901. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46902. * Returns the DirectionalLight Shadow projection matrix.
  46903. */
  46904. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46905. /**
  46906. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46907. * Returns the DirectionalLight Shadow projection matrix.
  46908. */
  46909. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46910. /**
  46911. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46912. * Returns the DirectionalLight Shadow projection matrix.
  46913. */
  46914. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46915. protected _buildUniformLayout(): void;
  46916. /**
  46917. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46918. * @param effect The effect to update
  46919. * @param lightIndex The index of the light in the effect to update
  46920. * @returns The directional light
  46921. */
  46922. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46923. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46924. /**
  46925. * Gets the minZ used for shadow according to both the scene and the light.
  46926. *
  46927. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46928. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46929. * @param activeCamera The camera we are returning the min for
  46930. * @returns the depth min z
  46931. */
  46932. getDepthMinZ(activeCamera: Camera): number;
  46933. /**
  46934. * Gets the maxZ used for shadow according to both the scene and the light.
  46935. *
  46936. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46937. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46938. * @param activeCamera The camera we are returning the max for
  46939. * @returns the depth max z
  46940. */
  46941. getDepthMaxZ(activeCamera: Camera): number;
  46942. /**
  46943. * Prepares the list of defines specific to the light type.
  46944. * @param defines the list of defines
  46945. * @param lightIndex defines the index of the light for the effect
  46946. */
  46947. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46948. }
  46949. }
  46950. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46951. import { Mesh } from "babylonjs/Meshes/mesh";
  46952. /**
  46953. * Class containing static functions to help procedurally build meshes
  46954. */
  46955. export class HemisphereBuilder {
  46956. /**
  46957. * Creates a hemisphere mesh
  46958. * @param name defines the name of the mesh
  46959. * @param options defines the options used to create the mesh
  46960. * @param scene defines the hosting scene
  46961. * @returns the hemisphere mesh
  46962. */
  46963. static CreateHemisphere(name: string, options: {
  46964. segments?: number;
  46965. diameter?: number;
  46966. sideOrientation?: number;
  46967. }, scene: any): Mesh;
  46968. }
  46969. }
  46970. declare module "babylonjs/Lights/spotLight" {
  46971. import { Nullable } from "babylonjs/types";
  46972. import { Scene } from "babylonjs/scene";
  46973. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46975. import { Effect } from "babylonjs/Materials/effect";
  46976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46977. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46978. /**
  46979. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46980. * These values define a cone of light starting from the position, emitting toward the direction.
  46981. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46982. * and the exponent defines the speed of the decay of the light with distance (reach).
  46983. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46984. */
  46985. export class SpotLight extends ShadowLight {
  46986. private _angle;
  46987. private _innerAngle;
  46988. private _cosHalfAngle;
  46989. private _lightAngleScale;
  46990. private _lightAngleOffset;
  46991. /**
  46992. * Gets the cone angle of the spot light in Radians.
  46993. */
  46994. /**
  46995. * Sets the cone angle of the spot light in Radians.
  46996. */
  46997. angle: number;
  46998. /**
  46999. * Only used in gltf falloff mode, this defines the angle where
  47000. * the directional falloff will start before cutting at angle which could be seen
  47001. * as outer angle.
  47002. */
  47003. /**
  47004. * Only used in gltf falloff mode, this defines the angle where
  47005. * the directional falloff will start before cutting at angle which could be seen
  47006. * as outer angle.
  47007. */
  47008. innerAngle: number;
  47009. private _shadowAngleScale;
  47010. /**
  47011. * Allows scaling the angle of the light for shadow generation only.
  47012. */
  47013. /**
  47014. * Allows scaling the angle of the light for shadow generation only.
  47015. */
  47016. shadowAngleScale: number;
  47017. /**
  47018. * The light decay speed with the distance from the emission spot.
  47019. */
  47020. exponent: number;
  47021. private _projectionTextureMatrix;
  47022. /**
  47023. * Allows reading the projecton texture
  47024. */
  47025. readonly projectionTextureMatrix: Matrix;
  47026. protected _projectionTextureLightNear: number;
  47027. /**
  47028. * Gets the near clip of the Spotlight for texture projection.
  47029. */
  47030. /**
  47031. * Sets the near clip of the Spotlight for texture projection.
  47032. */
  47033. projectionTextureLightNear: number;
  47034. protected _projectionTextureLightFar: number;
  47035. /**
  47036. * Gets the far clip of the Spotlight for texture projection.
  47037. */
  47038. /**
  47039. * Sets the far clip of the Spotlight for texture projection.
  47040. */
  47041. projectionTextureLightFar: number;
  47042. protected _projectionTextureUpDirection: Vector3;
  47043. /**
  47044. * Gets the Up vector of the Spotlight for texture projection.
  47045. */
  47046. /**
  47047. * Sets the Up vector of the Spotlight for texture projection.
  47048. */
  47049. projectionTextureUpDirection: Vector3;
  47050. private _projectionTexture;
  47051. /**
  47052. * Gets the projection texture of the light.
  47053. */
  47054. /**
  47055. * Sets the projection texture of the light.
  47056. */
  47057. projectionTexture: Nullable<BaseTexture>;
  47058. private _projectionTextureViewLightDirty;
  47059. private _projectionTextureProjectionLightDirty;
  47060. private _projectionTextureDirty;
  47061. private _projectionTextureViewTargetVector;
  47062. private _projectionTextureViewLightMatrix;
  47063. private _projectionTextureProjectionLightMatrix;
  47064. private _projectionTextureScalingMatrix;
  47065. /**
  47066. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47067. * It can cast shadows.
  47068. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47069. * @param name The light friendly name
  47070. * @param position The position of the spot light in the scene
  47071. * @param direction The direction of the light in the scene
  47072. * @param angle The cone angle of the light in Radians
  47073. * @param exponent The light decay speed with the distance from the emission spot
  47074. * @param scene The scene the lights belongs to
  47075. */
  47076. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47077. /**
  47078. * Returns the string "SpotLight".
  47079. * @returns the class name
  47080. */
  47081. getClassName(): string;
  47082. /**
  47083. * Returns the integer 2.
  47084. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47085. */
  47086. getTypeID(): number;
  47087. /**
  47088. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47089. */
  47090. protected _setDirection(value: Vector3): void;
  47091. /**
  47092. * Overrides the position setter to recompute the projection texture view light Matrix.
  47093. */
  47094. protected _setPosition(value: Vector3): void;
  47095. /**
  47096. * 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.
  47097. * Returns the SpotLight.
  47098. */
  47099. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47100. protected _computeProjectionTextureViewLightMatrix(): void;
  47101. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47102. /**
  47103. * Main function for light texture projection matrix computing.
  47104. */
  47105. protected _computeProjectionTextureMatrix(): void;
  47106. protected _buildUniformLayout(): void;
  47107. private _computeAngleValues;
  47108. /**
  47109. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47110. * @param effect The effect to update
  47111. * @param lightIndex The index of the light in the effect to update
  47112. * @returns The spot light
  47113. */
  47114. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47115. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47116. /**
  47117. * Disposes the light and the associated resources.
  47118. */
  47119. dispose(): void;
  47120. /**
  47121. * Prepares the list of defines specific to the light type.
  47122. * @param defines the list of defines
  47123. * @param lightIndex defines the index of the light for the effect
  47124. */
  47125. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47126. }
  47127. }
  47128. declare module "babylonjs/Gizmos/lightGizmo" {
  47129. import { Nullable } from "babylonjs/types";
  47130. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47131. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47132. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47133. import { Light } from "babylonjs/Lights/light";
  47134. /**
  47135. * Gizmo that enables viewing a light
  47136. */
  47137. export class LightGizmo extends Gizmo {
  47138. private _lightMesh;
  47139. private _material;
  47140. private cachedPosition;
  47141. private cachedForward;
  47142. /**
  47143. * Creates a LightGizmo
  47144. * @param gizmoLayer The utility layer the gizmo will be added to
  47145. */
  47146. constructor(gizmoLayer?: UtilityLayerRenderer);
  47147. private _light;
  47148. /**
  47149. * The light that the gizmo is attached to
  47150. */
  47151. light: Nullable<Light>;
  47152. /**
  47153. * Gets the material used to render the light gizmo
  47154. */
  47155. readonly material: StandardMaterial;
  47156. /**
  47157. * @hidden
  47158. * Updates the gizmo to match the attached mesh's position/rotation
  47159. */
  47160. protected _update(): void;
  47161. private static _Scale;
  47162. /**
  47163. * Creates the lines for a light mesh
  47164. */
  47165. private static _createLightLines;
  47166. /**
  47167. * Disposes of the light gizmo
  47168. */
  47169. dispose(): void;
  47170. private static _CreateHemisphericLightMesh;
  47171. private static _CreatePointLightMesh;
  47172. private static _CreateSpotLightMesh;
  47173. private static _CreateDirectionalLightMesh;
  47174. }
  47175. }
  47176. declare module "babylonjs/Gizmos/index" {
  47177. export * from "babylonjs/Gizmos/axisDragGizmo";
  47178. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47179. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47180. export * from "babylonjs/Gizmos/gizmo";
  47181. export * from "babylonjs/Gizmos/gizmoManager";
  47182. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47183. export * from "babylonjs/Gizmos/positionGizmo";
  47184. export * from "babylonjs/Gizmos/rotationGizmo";
  47185. export * from "babylonjs/Gizmos/scaleGizmo";
  47186. export * from "babylonjs/Gizmos/lightGizmo";
  47187. export * from "babylonjs/Gizmos/planeDragGizmo";
  47188. }
  47189. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47190. /** @hidden */
  47191. export var backgroundFragmentDeclaration: {
  47192. name: string;
  47193. shader: string;
  47194. };
  47195. }
  47196. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47197. /** @hidden */
  47198. export var backgroundUboDeclaration: {
  47199. name: string;
  47200. shader: string;
  47201. };
  47202. }
  47203. declare module "babylonjs/Shaders/background.fragment" {
  47204. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47205. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47206. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47207. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47208. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47209. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47210. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47211. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47212. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47213. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47214. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47215. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47216. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47217. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47218. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47219. /** @hidden */
  47220. export var backgroundPixelShader: {
  47221. name: string;
  47222. shader: string;
  47223. };
  47224. }
  47225. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47226. /** @hidden */
  47227. export var backgroundVertexDeclaration: {
  47228. name: string;
  47229. shader: string;
  47230. };
  47231. }
  47232. declare module "babylonjs/Shaders/background.vertex" {
  47233. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47234. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47235. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47236. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47237. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47238. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47239. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47240. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47241. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47242. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47243. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47244. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47245. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47246. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47247. /** @hidden */
  47248. export var backgroundVertexShader: {
  47249. name: string;
  47250. shader: string;
  47251. };
  47252. }
  47253. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47254. import { Nullable, int, float } from "babylonjs/types";
  47255. import { Scene } from "babylonjs/scene";
  47256. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47257. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47259. import { Mesh } from "babylonjs/Meshes/mesh";
  47260. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47261. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47262. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47264. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47265. import { Color3 } from "babylonjs/Maths/math.color";
  47266. import "babylonjs/Shaders/background.fragment";
  47267. import "babylonjs/Shaders/background.vertex";
  47268. /**
  47269. * Background material used to create an efficient environement around your scene.
  47270. */
  47271. export class BackgroundMaterial extends PushMaterial {
  47272. /**
  47273. * Standard reflectance value at parallel view angle.
  47274. */
  47275. static StandardReflectance0: number;
  47276. /**
  47277. * Standard reflectance value at grazing angle.
  47278. */
  47279. static StandardReflectance90: number;
  47280. protected _primaryColor: Color3;
  47281. /**
  47282. * Key light Color (multiply against the environement texture)
  47283. */
  47284. primaryColor: Color3;
  47285. protected __perceptualColor: Nullable<Color3>;
  47286. /**
  47287. * Experimental Internal Use Only.
  47288. *
  47289. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47290. * This acts as a helper to set the primary color to a more "human friendly" value.
  47291. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47292. * output color as close as possible from the chosen value.
  47293. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47294. * part of lighting setup.)
  47295. */
  47296. _perceptualColor: Nullable<Color3>;
  47297. protected _primaryColorShadowLevel: float;
  47298. /**
  47299. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47300. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47301. */
  47302. primaryColorShadowLevel: float;
  47303. protected _primaryColorHighlightLevel: float;
  47304. /**
  47305. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47306. * The primary color is used at the level chosen to define what the white area would look.
  47307. */
  47308. primaryColorHighlightLevel: float;
  47309. protected _reflectionTexture: Nullable<BaseTexture>;
  47310. /**
  47311. * Reflection Texture used in the material.
  47312. * Should be author in a specific way for the best result (refer to the documentation).
  47313. */
  47314. reflectionTexture: Nullable<BaseTexture>;
  47315. protected _reflectionBlur: float;
  47316. /**
  47317. * Reflection Texture level of blur.
  47318. *
  47319. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47320. * texture twice.
  47321. */
  47322. reflectionBlur: float;
  47323. protected _diffuseTexture: Nullable<BaseTexture>;
  47324. /**
  47325. * Diffuse Texture used in the material.
  47326. * Should be author in a specific way for the best result (refer to the documentation).
  47327. */
  47328. diffuseTexture: Nullable<BaseTexture>;
  47329. protected _shadowLights: Nullable<IShadowLight[]>;
  47330. /**
  47331. * Specify the list of lights casting shadow on the material.
  47332. * All scene shadow lights will be included if null.
  47333. */
  47334. shadowLights: Nullable<IShadowLight[]>;
  47335. protected _shadowLevel: float;
  47336. /**
  47337. * Helps adjusting the shadow to a softer level if required.
  47338. * 0 means black shadows and 1 means no shadows.
  47339. */
  47340. shadowLevel: float;
  47341. protected _sceneCenter: Vector3;
  47342. /**
  47343. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47344. * It is usually zero but might be interesting to modify according to your setup.
  47345. */
  47346. sceneCenter: Vector3;
  47347. protected _opacityFresnel: boolean;
  47348. /**
  47349. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47350. * This helps ensuring a nice transition when the camera goes under the ground.
  47351. */
  47352. opacityFresnel: boolean;
  47353. protected _reflectionFresnel: boolean;
  47354. /**
  47355. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47356. * This helps adding a mirror texture on the ground.
  47357. */
  47358. reflectionFresnel: boolean;
  47359. protected _reflectionFalloffDistance: number;
  47360. /**
  47361. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47362. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47363. */
  47364. reflectionFalloffDistance: number;
  47365. protected _reflectionAmount: number;
  47366. /**
  47367. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47368. */
  47369. reflectionAmount: number;
  47370. protected _reflectionReflectance0: number;
  47371. /**
  47372. * This specifies the weight of the reflection at grazing angle.
  47373. */
  47374. reflectionReflectance0: number;
  47375. protected _reflectionReflectance90: number;
  47376. /**
  47377. * This specifies the weight of the reflection at a perpendicular point of view.
  47378. */
  47379. reflectionReflectance90: number;
  47380. /**
  47381. * Sets the reflection reflectance fresnel values according to the default standard
  47382. * empirically know to work well :-)
  47383. */
  47384. reflectionStandardFresnelWeight: number;
  47385. protected _useRGBColor: boolean;
  47386. /**
  47387. * Helps to directly use the maps channels instead of their level.
  47388. */
  47389. useRGBColor: boolean;
  47390. protected _enableNoise: boolean;
  47391. /**
  47392. * This helps reducing the banding effect that could occur on the background.
  47393. */
  47394. enableNoise: boolean;
  47395. /**
  47396. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47397. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47398. * Recommended to be keep at 1.0 except for special cases.
  47399. */
  47400. fovMultiplier: number;
  47401. private _fovMultiplier;
  47402. /**
  47403. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47404. */
  47405. useEquirectangularFOV: boolean;
  47406. private _maxSimultaneousLights;
  47407. /**
  47408. * Number of Simultaneous lights allowed on the material.
  47409. */
  47410. maxSimultaneousLights: int;
  47411. /**
  47412. * Default configuration related to image processing available in the Background Material.
  47413. */
  47414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47415. /**
  47416. * Keep track of the image processing observer to allow dispose and replace.
  47417. */
  47418. private _imageProcessingObserver;
  47419. /**
  47420. * Attaches a new image processing configuration to the PBR Material.
  47421. * @param configuration (if null the scene configuration will be use)
  47422. */
  47423. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47424. /**
  47425. * Gets the image processing configuration used either in this material.
  47426. */
  47427. /**
  47428. * Sets the Default image processing configuration used either in the this material.
  47429. *
  47430. * If sets to null, the scene one is in use.
  47431. */
  47432. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47433. /**
  47434. * Gets wether the color curves effect is enabled.
  47435. */
  47436. /**
  47437. * Sets wether the color curves effect is enabled.
  47438. */
  47439. cameraColorCurvesEnabled: boolean;
  47440. /**
  47441. * Gets wether the color grading effect is enabled.
  47442. */
  47443. /**
  47444. * Gets wether the color grading effect is enabled.
  47445. */
  47446. cameraColorGradingEnabled: boolean;
  47447. /**
  47448. * Gets wether tonemapping is enabled or not.
  47449. */
  47450. /**
  47451. * Sets wether tonemapping is enabled or not
  47452. */
  47453. cameraToneMappingEnabled: boolean;
  47454. /**
  47455. * The camera exposure used on this material.
  47456. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47457. * This corresponds to a photographic exposure.
  47458. */
  47459. /**
  47460. * The camera exposure used on this material.
  47461. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47462. * This corresponds to a photographic exposure.
  47463. */
  47464. cameraExposure: float;
  47465. /**
  47466. * Gets The camera contrast used on this material.
  47467. */
  47468. /**
  47469. * Sets The camera contrast used on this material.
  47470. */
  47471. cameraContrast: float;
  47472. /**
  47473. * Gets the Color Grading 2D Lookup Texture.
  47474. */
  47475. /**
  47476. * Sets the Color Grading 2D Lookup Texture.
  47477. */
  47478. cameraColorGradingTexture: Nullable<BaseTexture>;
  47479. /**
  47480. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47481. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47482. * 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;
  47483. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47484. */
  47485. /**
  47486. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47487. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47488. * 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;
  47489. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47490. */
  47491. cameraColorCurves: Nullable<ColorCurves>;
  47492. /**
  47493. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47494. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47495. */
  47496. switchToBGR: boolean;
  47497. private _renderTargets;
  47498. private _reflectionControls;
  47499. private _white;
  47500. private _primaryShadowColor;
  47501. private _primaryHighlightColor;
  47502. /**
  47503. * Instantiates a Background Material in the given scene
  47504. * @param name The friendly name of the material
  47505. * @param scene The scene to add the material to
  47506. */
  47507. constructor(name: string, scene: Scene);
  47508. /**
  47509. * Gets a boolean indicating that current material needs to register RTT
  47510. */
  47511. readonly hasRenderTargetTextures: boolean;
  47512. /**
  47513. * The entire material has been created in order to prevent overdraw.
  47514. * @returns false
  47515. */
  47516. needAlphaTesting(): boolean;
  47517. /**
  47518. * The entire material has been created in order to prevent overdraw.
  47519. * @returns true if blending is enable
  47520. */
  47521. needAlphaBlending(): boolean;
  47522. /**
  47523. * Checks wether the material is ready to be rendered for a given mesh.
  47524. * @param mesh The mesh to render
  47525. * @param subMesh The submesh to check against
  47526. * @param useInstances Specify wether or not the material is used with instances
  47527. * @returns true if all the dependencies are ready (Textures, Effects...)
  47528. */
  47529. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47530. /**
  47531. * Compute the primary color according to the chosen perceptual color.
  47532. */
  47533. private _computePrimaryColorFromPerceptualColor;
  47534. /**
  47535. * Compute the highlights and shadow colors according to their chosen levels.
  47536. */
  47537. private _computePrimaryColors;
  47538. /**
  47539. * Build the uniform buffer used in the material.
  47540. */
  47541. buildUniformLayout(): void;
  47542. /**
  47543. * Unbind the material.
  47544. */
  47545. unbind(): void;
  47546. /**
  47547. * Bind only the world matrix to the material.
  47548. * @param world The world matrix to bind.
  47549. */
  47550. bindOnlyWorldMatrix(world: Matrix): void;
  47551. /**
  47552. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47553. * @param world The world matrix to bind.
  47554. * @param subMesh The submesh to bind for.
  47555. */
  47556. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47557. /**
  47558. * Checks to see if a texture is used in the material.
  47559. * @param texture - Base texture to use.
  47560. * @returns - Boolean specifying if a texture is used in the material.
  47561. */
  47562. hasTexture(texture: BaseTexture): boolean;
  47563. /**
  47564. * Dispose the material.
  47565. * @param forceDisposeEffect Force disposal of the associated effect.
  47566. * @param forceDisposeTextures Force disposal of the associated textures.
  47567. */
  47568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47569. /**
  47570. * Clones the material.
  47571. * @param name The cloned name.
  47572. * @returns The cloned material.
  47573. */
  47574. clone(name: string): BackgroundMaterial;
  47575. /**
  47576. * Serializes the current material to its JSON representation.
  47577. * @returns The JSON representation.
  47578. */
  47579. serialize(): any;
  47580. /**
  47581. * Gets the class name of the material
  47582. * @returns "BackgroundMaterial"
  47583. */
  47584. getClassName(): string;
  47585. /**
  47586. * Parse a JSON input to create back a background material.
  47587. * @param source The JSON data to parse
  47588. * @param scene The scene to create the parsed material in
  47589. * @param rootUrl The root url of the assets the material depends upon
  47590. * @returns the instantiated BackgroundMaterial.
  47591. */
  47592. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47593. }
  47594. }
  47595. declare module "babylonjs/Helpers/environmentHelper" {
  47596. import { Observable } from "babylonjs/Misc/observable";
  47597. import { Nullable } from "babylonjs/types";
  47598. import { Scene } from "babylonjs/scene";
  47599. import { Vector3 } from "babylonjs/Maths/math.vector";
  47600. import { Color3 } from "babylonjs/Maths/math.color";
  47601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47602. import { Mesh } from "babylonjs/Meshes/mesh";
  47603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47604. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47605. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47606. import "babylonjs/Meshes/Builders/planeBuilder";
  47607. import "babylonjs/Meshes/Builders/boxBuilder";
  47608. /**
  47609. * Represents the different options available during the creation of
  47610. * a Environment helper.
  47611. *
  47612. * This can control the default ground, skybox and image processing setup of your scene.
  47613. */
  47614. export interface IEnvironmentHelperOptions {
  47615. /**
  47616. * Specifies wether or not to create a ground.
  47617. * True by default.
  47618. */
  47619. createGround: boolean;
  47620. /**
  47621. * Specifies the ground size.
  47622. * 15 by default.
  47623. */
  47624. groundSize: number;
  47625. /**
  47626. * The texture used on the ground for the main color.
  47627. * Comes from the BabylonJS CDN by default.
  47628. *
  47629. * Remarks: Can be either a texture or a url.
  47630. */
  47631. groundTexture: string | BaseTexture;
  47632. /**
  47633. * The color mixed in the ground texture by default.
  47634. * BabylonJS clearColor by default.
  47635. */
  47636. groundColor: Color3;
  47637. /**
  47638. * Specifies the ground opacity.
  47639. * 1 by default.
  47640. */
  47641. groundOpacity: number;
  47642. /**
  47643. * Enables the ground to receive shadows.
  47644. * True by default.
  47645. */
  47646. enableGroundShadow: boolean;
  47647. /**
  47648. * Helps preventing the shadow to be fully black on the ground.
  47649. * 0.5 by default.
  47650. */
  47651. groundShadowLevel: number;
  47652. /**
  47653. * Creates a mirror texture attach to the ground.
  47654. * false by default.
  47655. */
  47656. enableGroundMirror: boolean;
  47657. /**
  47658. * Specifies the ground mirror size ratio.
  47659. * 0.3 by default as the default kernel is 64.
  47660. */
  47661. groundMirrorSizeRatio: number;
  47662. /**
  47663. * Specifies the ground mirror blur kernel size.
  47664. * 64 by default.
  47665. */
  47666. groundMirrorBlurKernel: number;
  47667. /**
  47668. * Specifies the ground mirror visibility amount.
  47669. * 1 by default
  47670. */
  47671. groundMirrorAmount: number;
  47672. /**
  47673. * Specifies the ground mirror reflectance weight.
  47674. * This uses the standard weight of the background material to setup the fresnel effect
  47675. * of the mirror.
  47676. * 1 by default.
  47677. */
  47678. groundMirrorFresnelWeight: number;
  47679. /**
  47680. * Specifies the ground mirror Falloff distance.
  47681. * This can helps reducing the size of the reflection.
  47682. * 0 by Default.
  47683. */
  47684. groundMirrorFallOffDistance: number;
  47685. /**
  47686. * Specifies the ground mirror texture type.
  47687. * Unsigned Int by Default.
  47688. */
  47689. groundMirrorTextureType: number;
  47690. /**
  47691. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47692. * the shown objects.
  47693. */
  47694. groundYBias: number;
  47695. /**
  47696. * Specifies wether or not to create a skybox.
  47697. * True by default.
  47698. */
  47699. createSkybox: boolean;
  47700. /**
  47701. * Specifies the skybox size.
  47702. * 20 by default.
  47703. */
  47704. skyboxSize: number;
  47705. /**
  47706. * The texture used on the skybox for the main color.
  47707. * Comes from the BabylonJS CDN by default.
  47708. *
  47709. * Remarks: Can be either a texture or a url.
  47710. */
  47711. skyboxTexture: string | BaseTexture;
  47712. /**
  47713. * The color mixed in the skybox texture by default.
  47714. * BabylonJS clearColor by default.
  47715. */
  47716. skyboxColor: Color3;
  47717. /**
  47718. * The background rotation around the Y axis of the scene.
  47719. * This helps aligning the key lights of your scene with the background.
  47720. * 0 by default.
  47721. */
  47722. backgroundYRotation: number;
  47723. /**
  47724. * Compute automatically the size of the elements to best fit with the scene.
  47725. */
  47726. sizeAuto: boolean;
  47727. /**
  47728. * Default position of the rootMesh if autoSize is not true.
  47729. */
  47730. rootPosition: Vector3;
  47731. /**
  47732. * Sets up the image processing in the scene.
  47733. * true by default.
  47734. */
  47735. setupImageProcessing: boolean;
  47736. /**
  47737. * The texture used as your environment texture in the scene.
  47738. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47739. *
  47740. * Remarks: Can be either a texture or a url.
  47741. */
  47742. environmentTexture: string | BaseTexture;
  47743. /**
  47744. * The value of the exposure to apply to the scene.
  47745. * 0.6 by default if setupImageProcessing is true.
  47746. */
  47747. cameraExposure: number;
  47748. /**
  47749. * The value of the contrast to apply to the scene.
  47750. * 1.6 by default if setupImageProcessing is true.
  47751. */
  47752. cameraContrast: number;
  47753. /**
  47754. * Specifies wether or not tonemapping should be enabled in the scene.
  47755. * true by default if setupImageProcessing is true.
  47756. */
  47757. toneMappingEnabled: boolean;
  47758. }
  47759. /**
  47760. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47761. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47762. * It also helps with the default setup of your imageProcessing configuration.
  47763. */
  47764. export class EnvironmentHelper {
  47765. /**
  47766. * Default ground texture URL.
  47767. */
  47768. private static _groundTextureCDNUrl;
  47769. /**
  47770. * Default skybox texture URL.
  47771. */
  47772. private static _skyboxTextureCDNUrl;
  47773. /**
  47774. * Default environment texture URL.
  47775. */
  47776. private static _environmentTextureCDNUrl;
  47777. /**
  47778. * Creates the default options for the helper.
  47779. */
  47780. private static _getDefaultOptions;
  47781. private _rootMesh;
  47782. /**
  47783. * Gets the root mesh created by the helper.
  47784. */
  47785. readonly rootMesh: Mesh;
  47786. private _skybox;
  47787. /**
  47788. * Gets the skybox created by the helper.
  47789. */
  47790. readonly skybox: Nullable<Mesh>;
  47791. private _skyboxTexture;
  47792. /**
  47793. * Gets the skybox texture created by the helper.
  47794. */
  47795. readonly skyboxTexture: Nullable<BaseTexture>;
  47796. private _skyboxMaterial;
  47797. /**
  47798. * Gets the skybox material created by the helper.
  47799. */
  47800. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47801. private _ground;
  47802. /**
  47803. * Gets the ground mesh created by the helper.
  47804. */
  47805. readonly ground: Nullable<Mesh>;
  47806. private _groundTexture;
  47807. /**
  47808. * Gets the ground texture created by the helper.
  47809. */
  47810. readonly groundTexture: Nullable<BaseTexture>;
  47811. private _groundMirror;
  47812. /**
  47813. * Gets the ground mirror created by the helper.
  47814. */
  47815. readonly groundMirror: Nullable<MirrorTexture>;
  47816. /**
  47817. * Gets the ground mirror render list to helps pushing the meshes
  47818. * you wish in the ground reflection.
  47819. */
  47820. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47821. private _groundMaterial;
  47822. /**
  47823. * Gets the ground material created by the helper.
  47824. */
  47825. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47826. /**
  47827. * Stores the creation options.
  47828. */
  47829. private readonly _scene;
  47830. private _options;
  47831. /**
  47832. * This observable will be notified with any error during the creation of the environment,
  47833. * mainly texture creation errors.
  47834. */
  47835. onErrorObservable: Observable<{
  47836. message?: string;
  47837. exception?: any;
  47838. }>;
  47839. /**
  47840. * constructor
  47841. * @param options Defines the options we want to customize the helper
  47842. * @param scene The scene to add the material to
  47843. */
  47844. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47845. /**
  47846. * Updates the background according to the new options
  47847. * @param options
  47848. */
  47849. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47850. /**
  47851. * Sets the primary color of all the available elements.
  47852. * @param color the main color to affect to the ground and the background
  47853. */
  47854. setMainColor(color: Color3): void;
  47855. /**
  47856. * Setup the image processing according to the specified options.
  47857. */
  47858. private _setupImageProcessing;
  47859. /**
  47860. * Setup the environment texture according to the specified options.
  47861. */
  47862. private _setupEnvironmentTexture;
  47863. /**
  47864. * Setup the background according to the specified options.
  47865. */
  47866. private _setupBackground;
  47867. /**
  47868. * Get the scene sizes according to the setup.
  47869. */
  47870. private _getSceneSize;
  47871. /**
  47872. * Setup the ground according to the specified options.
  47873. */
  47874. private _setupGround;
  47875. /**
  47876. * Setup the ground material according to the specified options.
  47877. */
  47878. private _setupGroundMaterial;
  47879. /**
  47880. * Setup the ground diffuse texture according to the specified options.
  47881. */
  47882. private _setupGroundDiffuseTexture;
  47883. /**
  47884. * Setup the ground mirror texture according to the specified options.
  47885. */
  47886. private _setupGroundMirrorTexture;
  47887. /**
  47888. * Setup the ground to receive the mirror texture.
  47889. */
  47890. private _setupMirrorInGroundMaterial;
  47891. /**
  47892. * Setup the skybox according to the specified options.
  47893. */
  47894. private _setupSkybox;
  47895. /**
  47896. * Setup the skybox material according to the specified options.
  47897. */
  47898. private _setupSkyboxMaterial;
  47899. /**
  47900. * Setup the skybox reflection texture according to the specified options.
  47901. */
  47902. private _setupSkyboxReflectionTexture;
  47903. private _errorHandler;
  47904. /**
  47905. * Dispose all the elements created by the Helper.
  47906. */
  47907. dispose(): void;
  47908. }
  47909. }
  47910. declare module "babylonjs/Helpers/photoDome" {
  47911. import { Observable } from "babylonjs/Misc/observable";
  47912. import { Nullable } from "babylonjs/types";
  47913. import { Scene } from "babylonjs/scene";
  47914. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47915. import { Mesh } from "babylonjs/Meshes/mesh";
  47916. import { Texture } from "babylonjs/Materials/Textures/texture";
  47917. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47918. import "babylonjs/Meshes/Builders/sphereBuilder";
  47919. /**
  47920. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47921. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47922. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47923. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47924. */
  47925. export class PhotoDome extends TransformNode {
  47926. /**
  47927. * Define the image as a Monoscopic panoramic 360 image.
  47928. */
  47929. static readonly MODE_MONOSCOPIC: number;
  47930. /**
  47931. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47932. */
  47933. static readonly MODE_TOPBOTTOM: number;
  47934. /**
  47935. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47936. */
  47937. static readonly MODE_SIDEBYSIDE: number;
  47938. private _useDirectMapping;
  47939. /**
  47940. * The texture being displayed on the sphere
  47941. */
  47942. protected _photoTexture: Texture;
  47943. /**
  47944. * Gets or sets the texture being displayed on the sphere
  47945. */
  47946. photoTexture: Texture;
  47947. /**
  47948. * Observable raised when an error occured while loading the 360 image
  47949. */
  47950. onLoadErrorObservable: Observable<string>;
  47951. /**
  47952. * The skybox material
  47953. */
  47954. protected _material: BackgroundMaterial;
  47955. /**
  47956. * The surface used for the skybox
  47957. */
  47958. protected _mesh: Mesh;
  47959. /**
  47960. * Gets the mesh used for the skybox.
  47961. */
  47962. readonly mesh: Mesh;
  47963. /**
  47964. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47965. * Also see the options.resolution property.
  47966. */
  47967. fovMultiplier: number;
  47968. private _imageMode;
  47969. /**
  47970. * Gets or set the current video mode for the video. It can be:
  47971. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47972. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47973. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47974. */
  47975. imageMode: number;
  47976. /**
  47977. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47978. * @param name Element's name, child elements will append suffixes for their own names.
  47979. * @param urlsOfPhoto defines the url of the photo to display
  47980. * @param options defines an object containing optional or exposed sub element properties
  47981. * @param onError defines a callback called when an error occured while loading the texture
  47982. */
  47983. constructor(name: string, urlOfPhoto: string, options: {
  47984. resolution?: number;
  47985. size?: number;
  47986. useDirectMapping?: boolean;
  47987. faceForward?: boolean;
  47988. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47989. private _onBeforeCameraRenderObserver;
  47990. private _changeImageMode;
  47991. /**
  47992. * Releases resources associated with this node.
  47993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47995. */
  47996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47997. }
  47998. }
  47999. declare module "babylonjs/Misc/rgbdTextureTools" {
  48000. import "babylonjs/Shaders/rgbdDecode.fragment";
  48001. import { Texture } from "babylonjs/Materials/Textures/texture";
  48002. /**
  48003. * Class used to host RGBD texture specific utilities
  48004. */
  48005. export class RGBDTextureTools {
  48006. /**
  48007. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48008. * @param texture the texture to expand.
  48009. */
  48010. static ExpandRGBDTexture(texture: Texture): void;
  48011. }
  48012. }
  48013. declare module "babylonjs/Misc/brdfTextureTools" {
  48014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48015. import { Scene } from "babylonjs/scene";
  48016. /**
  48017. * Class used to host texture specific utilities
  48018. */
  48019. export class BRDFTextureTools {
  48020. /**
  48021. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48022. * @param scene defines the hosting scene
  48023. * @returns the environment BRDF texture
  48024. */
  48025. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48026. private static _environmentBRDFBase64Texture;
  48027. }
  48028. }
  48029. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48030. import { Nullable } from "babylonjs/types";
  48031. import { Color3 } from "babylonjs/Maths/math.color";
  48032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48033. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48034. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48035. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48036. import { Engine } from "babylonjs/Engines/engine";
  48037. import { Scene } from "babylonjs/scene";
  48038. /**
  48039. * @hidden
  48040. */
  48041. export interface IMaterialClearCoatDefines {
  48042. CLEARCOAT: boolean;
  48043. CLEARCOAT_DEFAULTIOR: boolean;
  48044. CLEARCOAT_TEXTURE: boolean;
  48045. CLEARCOAT_TEXTUREDIRECTUV: number;
  48046. CLEARCOAT_BUMP: boolean;
  48047. CLEARCOAT_BUMPDIRECTUV: number;
  48048. CLEARCOAT_TINT: boolean;
  48049. CLEARCOAT_TINT_TEXTURE: boolean;
  48050. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48051. /** @hidden */
  48052. _areTexturesDirty: boolean;
  48053. }
  48054. /**
  48055. * Define the code related to the clear coat parameters of the pbr material.
  48056. */
  48057. export class PBRClearCoatConfiguration {
  48058. /**
  48059. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48060. * The default fits with a polyurethane material.
  48061. */
  48062. private static readonly _DefaultIndexOfRefraction;
  48063. private _isEnabled;
  48064. /**
  48065. * Defines if the clear coat is enabled in the material.
  48066. */
  48067. isEnabled: boolean;
  48068. /**
  48069. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48070. */
  48071. intensity: number;
  48072. /**
  48073. * Defines the clear coat layer roughness.
  48074. */
  48075. roughness: number;
  48076. private _indexOfRefraction;
  48077. /**
  48078. * Defines the index of refraction of the clear coat.
  48079. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48080. * The default fits with a polyurethane material.
  48081. * Changing the default value is more performance intensive.
  48082. */
  48083. indexOfRefraction: number;
  48084. private _texture;
  48085. /**
  48086. * Stores the clear coat values in a texture.
  48087. */
  48088. texture: Nullable<BaseTexture>;
  48089. private _bumpTexture;
  48090. /**
  48091. * Define the clear coat specific bump texture.
  48092. */
  48093. bumpTexture: Nullable<BaseTexture>;
  48094. private _isTintEnabled;
  48095. /**
  48096. * Defines if the clear coat tint is enabled in the material.
  48097. */
  48098. isTintEnabled: boolean;
  48099. /**
  48100. * Defines the clear coat tint of the material.
  48101. * This is only use if tint is enabled
  48102. */
  48103. tintColor: Color3;
  48104. /**
  48105. * Defines the distance at which the tint color should be found in the
  48106. * clear coat media.
  48107. * This is only use if tint is enabled
  48108. */
  48109. tintColorAtDistance: number;
  48110. /**
  48111. * Defines the clear coat layer thickness.
  48112. * This is only use if tint is enabled
  48113. */
  48114. tintThickness: number;
  48115. private _tintTexture;
  48116. /**
  48117. * Stores the clear tint values in a texture.
  48118. * rgb is tint
  48119. * a is a thickness factor
  48120. */
  48121. tintTexture: Nullable<BaseTexture>;
  48122. /** @hidden */
  48123. private _internalMarkAllSubMeshesAsTexturesDirty;
  48124. /** @hidden */
  48125. _markAllSubMeshesAsTexturesDirty(): void;
  48126. /**
  48127. * Instantiate a new istance of clear coat configuration.
  48128. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48129. */
  48130. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48131. /**
  48132. * Gets wehter the submesh is ready to be used or not.
  48133. * @param defines the list of "defines" to update.
  48134. * @param scene defines the scene the material belongs to.
  48135. * @param engine defines the engine the material belongs to.
  48136. * @param disableBumpMap defines wether the material disables bump or not.
  48137. * @returns - boolean indicating that the submesh is ready or not.
  48138. */
  48139. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48140. /**
  48141. * Checks to see if a texture is used in the material.
  48142. * @param defines the list of "defines" to update.
  48143. * @param scene defines the scene to the material belongs to.
  48144. */
  48145. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48146. /**
  48147. * Binds the material data.
  48148. * @param uniformBuffer defines the Uniform buffer to fill in.
  48149. * @param scene defines the scene the material belongs to.
  48150. * @param engine defines the engine the material belongs to.
  48151. * @param disableBumpMap defines wether the material disables bump or not.
  48152. * @param isFrozen defines wether the material is frozen or not.
  48153. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48154. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48155. */
  48156. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48157. /**
  48158. * Checks to see if a texture is used in the material.
  48159. * @param texture - Base texture to use.
  48160. * @returns - Boolean specifying if a texture is used in the material.
  48161. */
  48162. hasTexture(texture: BaseTexture): boolean;
  48163. /**
  48164. * Returns an array of the actively used textures.
  48165. * @param activeTextures Array of BaseTextures
  48166. */
  48167. getActiveTextures(activeTextures: BaseTexture[]): void;
  48168. /**
  48169. * Returns the animatable textures.
  48170. * @param animatables Array of animatable textures.
  48171. */
  48172. getAnimatables(animatables: IAnimatable[]): void;
  48173. /**
  48174. * Disposes the resources of the material.
  48175. * @param forceDisposeTextures - Forces the disposal of all textures.
  48176. */
  48177. dispose(forceDisposeTextures?: boolean): void;
  48178. /**
  48179. * Get the current class name of the texture useful for serialization or dynamic coding.
  48180. * @returns "PBRClearCoatConfiguration"
  48181. */
  48182. getClassName(): string;
  48183. /**
  48184. * Add fallbacks to the effect fallbacks list.
  48185. * @param defines defines the Base texture to use.
  48186. * @param fallbacks defines the current fallback list.
  48187. * @param currentRank defines the current fallback rank.
  48188. * @returns the new fallback rank.
  48189. */
  48190. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48191. /**
  48192. * Add the required uniforms to the current list.
  48193. * @param uniforms defines the current uniform list.
  48194. */
  48195. static AddUniforms(uniforms: string[]): void;
  48196. /**
  48197. * Add the required samplers to the current list.
  48198. * @param samplers defines the current sampler list.
  48199. */
  48200. static AddSamplers(samplers: string[]): void;
  48201. /**
  48202. * Add the required uniforms to the current buffer.
  48203. * @param uniformBuffer defines the current uniform buffer.
  48204. */
  48205. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48206. /**
  48207. * Makes a duplicate of the current configuration into another one.
  48208. * @param clearCoatConfiguration define the config where to copy the info
  48209. */
  48210. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48211. /**
  48212. * Serializes this clear coat configuration.
  48213. * @returns - An object with the serialized config.
  48214. */
  48215. serialize(): any;
  48216. /**
  48217. * Parses a anisotropy Configuration from a serialized object.
  48218. * @param source - Serialized object.
  48219. * @param scene Defines the scene we are parsing for
  48220. * @param rootUrl Defines the rootUrl to load from
  48221. */
  48222. parse(source: any, scene: Scene, rootUrl: string): void;
  48223. }
  48224. }
  48225. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48226. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48227. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48229. import { Vector2 } from "babylonjs/Maths/math.vector";
  48230. import { Scene } from "babylonjs/scene";
  48231. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48232. import { Nullable } from "babylonjs/types";
  48233. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48234. /**
  48235. * @hidden
  48236. */
  48237. export interface IMaterialAnisotropicDefines {
  48238. ANISOTROPIC: boolean;
  48239. ANISOTROPIC_TEXTURE: boolean;
  48240. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48241. MAINUV1: boolean;
  48242. _areTexturesDirty: boolean;
  48243. _needUVs: boolean;
  48244. }
  48245. /**
  48246. * Define the code related to the anisotropic parameters of the pbr material.
  48247. */
  48248. export class PBRAnisotropicConfiguration {
  48249. private _isEnabled;
  48250. /**
  48251. * Defines if the anisotropy is enabled in the material.
  48252. */
  48253. isEnabled: boolean;
  48254. /**
  48255. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48256. */
  48257. intensity: number;
  48258. /**
  48259. * Defines if the effect is along the tangents, bitangents or in between.
  48260. * By default, the effect is "strectching" the highlights along the tangents.
  48261. */
  48262. direction: Vector2;
  48263. private _texture;
  48264. /**
  48265. * Stores the anisotropy values in a texture.
  48266. * rg is direction (like normal from -1 to 1)
  48267. * b is a intensity
  48268. */
  48269. texture: Nullable<BaseTexture>;
  48270. /** @hidden */
  48271. private _internalMarkAllSubMeshesAsTexturesDirty;
  48272. /** @hidden */
  48273. _markAllSubMeshesAsTexturesDirty(): void;
  48274. /**
  48275. * Instantiate a new istance of anisotropy configuration.
  48276. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48277. */
  48278. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48279. /**
  48280. * Specifies that the submesh is ready to be used.
  48281. * @param defines the list of "defines" to update.
  48282. * @param scene defines the scene the material belongs to.
  48283. * @returns - boolean indicating that the submesh is ready or not.
  48284. */
  48285. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48286. /**
  48287. * Checks to see if a texture is used in the material.
  48288. * @param defines the list of "defines" to update.
  48289. * @param mesh the mesh we are preparing the defines for.
  48290. * @param scene defines the scene the material belongs to.
  48291. */
  48292. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48293. /**
  48294. * Binds the material data.
  48295. * @param uniformBuffer defines the Uniform buffer to fill in.
  48296. * @param scene defines the scene the material belongs to.
  48297. * @param isFrozen defines wether the material is frozen or not.
  48298. */
  48299. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48300. /**
  48301. * Checks to see if a texture is used in the material.
  48302. * @param texture - Base texture to use.
  48303. * @returns - Boolean specifying if a texture is used in the material.
  48304. */
  48305. hasTexture(texture: BaseTexture): boolean;
  48306. /**
  48307. * Returns an array of the actively used textures.
  48308. * @param activeTextures Array of BaseTextures
  48309. */
  48310. getActiveTextures(activeTextures: BaseTexture[]): void;
  48311. /**
  48312. * Returns the animatable textures.
  48313. * @param animatables Array of animatable textures.
  48314. */
  48315. getAnimatables(animatables: IAnimatable[]): void;
  48316. /**
  48317. * Disposes the resources of the material.
  48318. * @param forceDisposeTextures - Forces the disposal of all textures.
  48319. */
  48320. dispose(forceDisposeTextures?: boolean): void;
  48321. /**
  48322. * Get the current class name of the texture useful for serialization or dynamic coding.
  48323. * @returns "PBRAnisotropicConfiguration"
  48324. */
  48325. getClassName(): string;
  48326. /**
  48327. * Add fallbacks to the effect fallbacks list.
  48328. * @param defines defines the Base texture to use.
  48329. * @param fallbacks defines the current fallback list.
  48330. * @param currentRank defines the current fallback rank.
  48331. * @returns the new fallback rank.
  48332. */
  48333. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48334. /**
  48335. * Add the required uniforms to the current list.
  48336. * @param uniforms defines the current uniform list.
  48337. */
  48338. static AddUniforms(uniforms: string[]): void;
  48339. /**
  48340. * Add the required uniforms to the current buffer.
  48341. * @param uniformBuffer defines the current uniform buffer.
  48342. */
  48343. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48344. /**
  48345. * Add the required samplers to the current list.
  48346. * @param samplers defines the current sampler list.
  48347. */
  48348. static AddSamplers(samplers: string[]): void;
  48349. /**
  48350. * Makes a duplicate of the current configuration into another one.
  48351. * @param anisotropicConfiguration define the config where to copy the info
  48352. */
  48353. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48354. /**
  48355. * Serializes this anisotropy configuration.
  48356. * @returns - An object with the serialized config.
  48357. */
  48358. serialize(): any;
  48359. /**
  48360. * Parses a anisotropy Configuration from a serialized object.
  48361. * @param source - Serialized object.
  48362. * @param scene Defines the scene we are parsing for
  48363. * @param rootUrl Defines the rootUrl to load from
  48364. */
  48365. parse(source: any, scene: Scene, rootUrl: string): void;
  48366. }
  48367. }
  48368. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48369. import { Scene } from "babylonjs/scene";
  48370. /**
  48371. * @hidden
  48372. */
  48373. export interface IMaterialBRDFDefines {
  48374. BRDF_V_HEIGHT_CORRELATED: boolean;
  48375. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48376. SPHERICAL_HARMONICS: boolean;
  48377. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48378. /** @hidden */
  48379. _areMiscDirty: boolean;
  48380. }
  48381. /**
  48382. * Define the code related to the BRDF parameters of the pbr material.
  48383. */
  48384. export class PBRBRDFConfiguration {
  48385. /**
  48386. * Default value used for the energy conservation.
  48387. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48388. */
  48389. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48390. /**
  48391. * Default value used for the Smith Visibility Height Correlated mode.
  48392. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48393. */
  48394. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48395. /**
  48396. * Default value used for the IBL diffuse part.
  48397. * This can help switching back to the polynomials mode globally which is a tiny bit
  48398. * less GPU intensive at the drawback of a lower quality.
  48399. */
  48400. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48401. /**
  48402. * Default value used for activating energy conservation for the specular workflow.
  48403. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48404. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48405. */
  48406. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48407. private _useEnergyConservation;
  48408. /**
  48409. * Defines if the material uses energy conservation.
  48410. */
  48411. useEnergyConservation: boolean;
  48412. private _useSmithVisibilityHeightCorrelated;
  48413. /**
  48414. * LEGACY Mode set to false
  48415. * Defines if the material uses height smith correlated visibility term.
  48416. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48417. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48418. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48419. * Not relying on height correlated will also disable energy conservation.
  48420. */
  48421. useSmithVisibilityHeightCorrelated: boolean;
  48422. private _useSphericalHarmonics;
  48423. /**
  48424. * LEGACY Mode set to false
  48425. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48426. * diffuse part of the IBL.
  48427. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48428. * to the ground truth.
  48429. */
  48430. useSphericalHarmonics: boolean;
  48431. private _useSpecularGlossinessInputEnergyConservation;
  48432. /**
  48433. * Defines if the material uses energy conservation, when the specular workflow is active.
  48434. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48435. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48436. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48437. */
  48438. useSpecularGlossinessInputEnergyConservation: boolean;
  48439. /** @hidden */
  48440. private _internalMarkAllSubMeshesAsMiscDirty;
  48441. /** @hidden */
  48442. _markAllSubMeshesAsMiscDirty(): void;
  48443. /**
  48444. * Instantiate a new istance of clear coat configuration.
  48445. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48446. */
  48447. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48448. /**
  48449. * Checks to see if a texture is used in the material.
  48450. * @param defines the list of "defines" to update.
  48451. */
  48452. prepareDefines(defines: IMaterialBRDFDefines): void;
  48453. /**
  48454. * Get the current class name of the texture useful for serialization or dynamic coding.
  48455. * @returns "PBRClearCoatConfiguration"
  48456. */
  48457. getClassName(): string;
  48458. /**
  48459. * Makes a duplicate of the current configuration into another one.
  48460. * @param brdfConfiguration define the config where to copy the info
  48461. */
  48462. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48463. /**
  48464. * Serializes this BRDF configuration.
  48465. * @returns - An object with the serialized config.
  48466. */
  48467. serialize(): any;
  48468. /**
  48469. * Parses a anisotropy Configuration from a serialized object.
  48470. * @param source - Serialized object.
  48471. * @param scene Defines the scene we are parsing for
  48472. * @param rootUrl Defines the rootUrl to load from
  48473. */
  48474. parse(source: any, scene: Scene, rootUrl: string): void;
  48475. }
  48476. }
  48477. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48478. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48479. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48480. import { Color3 } from "babylonjs/Maths/math.color";
  48481. import { Scene } from "babylonjs/scene";
  48482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48483. import { Nullable } from "babylonjs/types";
  48484. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48485. /**
  48486. * @hidden
  48487. */
  48488. export interface IMaterialSheenDefines {
  48489. SHEEN: boolean;
  48490. SHEEN_TEXTURE: boolean;
  48491. SHEEN_TEXTUREDIRECTUV: number;
  48492. SHEEN_LINKWITHALBEDO: boolean;
  48493. /** @hidden */
  48494. _areTexturesDirty: boolean;
  48495. }
  48496. /**
  48497. * Define the code related to the Sheen parameters of the pbr material.
  48498. */
  48499. export class PBRSheenConfiguration {
  48500. private _isEnabled;
  48501. /**
  48502. * Defines if the material uses sheen.
  48503. */
  48504. isEnabled: boolean;
  48505. private _linkSheenWithAlbedo;
  48506. /**
  48507. * Defines if the sheen is linked to the sheen color.
  48508. */
  48509. linkSheenWithAlbedo: boolean;
  48510. /**
  48511. * Defines the sheen intensity.
  48512. */
  48513. intensity: number;
  48514. /**
  48515. * Defines the sheen color.
  48516. */
  48517. color: Color3;
  48518. private _texture;
  48519. /**
  48520. * Stores the sheen tint values in a texture.
  48521. * rgb is tint
  48522. * a is a intensity
  48523. */
  48524. texture: Nullable<BaseTexture>;
  48525. /** @hidden */
  48526. private _internalMarkAllSubMeshesAsTexturesDirty;
  48527. /** @hidden */
  48528. _markAllSubMeshesAsTexturesDirty(): void;
  48529. /**
  48530. * Instantiate a new istance of clear coat configuration.
  48531. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48532. */
  48533. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48534. /**
  48535. * Specifies that the submesh is ready to be used.
  48536. * @param defines the list of "defines" to update.
  48537. * @param scene defines the scene the material belongs to.
  48538. * @returns - boolean indicating that the submesh is ready or not.
  48539. */
  48540. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48541. /**
  48542. * Checks to see if a texture is used in the material.
  48543. * @param defines the list of "defines" to update.
  48544. * @param scene defines the scene the material belongs to.
  48545. */
  48546. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48547. /**
  48548. * Binds the material data.
  48549. * @param uniformBuffer defines the Uniform buffer to fill in.
  48550. * @param scene defines the scene the material belongs to.
  48551. * @param isFrozen defines wether the material is frozen or not.
  48552. */
  48553. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48554. /**
  48555. * Checks to see if a texture is used in the material.
  48556. * @param texture - Base texture to use.
  48557. * @returns - Boolean specifying if a texture is used in the material.
  48558. */
  48559. hasTexture(texture: BaseTexture): boolean;
  48560. /**
  48561. * Returns an array of the actively used textures.
  48562. * @param activeTextures Array of BaseTextures
  48563. */
  48564. getActiveTextures(activeTextures: BaseTexture[]): void;
  48565. /**
  48566. * Returns the animatable textures.
  48567. * @param animatables Array of animatable textures.
  48568. */
  48569. getAnimatables(animatables: IAnimatable[]): void;
  48570. /**
  48571. * Disposes the resources of the material.
  48572. * @param forceDisposeTextures - Forces the disposal of all textures.
  48573. */
  48574. dispose(forceDisposeTextures?: boolean): void;
  48575. /**
  48576. * Get the current class name of the texture useful for serialization or dynamic coding.
  48577. * @returns "PBRSheenConfiguration"
  48578. */
  48579. getClassName(): string;
  48580. /**
  48581. * Add fallbacks to the effect fallbacks list.
  48582. * @param defines defines the Base texture to use.
  48583. * @param fallbacks defines the current fallback list.
  48584. * @param currentRank defines the current fallback rank.
  48585. * @returns the new fallback rank.
  48586. */
  48587. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48588. /**
  48589. * Add the required uniforms to the current list.
  48590. * @param uniforms defines the current uniform list.
  48591. */
  48592. static AddUniforms(uniforms: string[]): void;
  48593. /**
  48594. * Add the required uniforms to the current buffer.
  48595. * @param uniformBuffer defines the current uniform buffer.
  48596. */
  48597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48598. /**
  48599. * Add the required samplers to the current list.
  48600. * @param samplers defines the current sampler list.
  48601. */
  48602. static AddSamplers(samplers: string[]): void;
  48603. /**
  48604. * Makes a duplicate of the current configuration into another one.
  48605. * @param sheenConfiguration define the config where to copy the info
  48606. */
  48607. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48608. /**
  48609. * Serializes this BRDF configuration.
  48610. * @returns - An object with the serialized config.
  48611. */
  48612. serialize(): any;
  48613. /**
  48614. * Parses a anisotropy Configuration from a serialized object.
  48615. * @param source - Serialized object.
  48616. * @param scene Defines the scene we are parsing for
  48617. * @param rootUrl Defines the rootUrl to load from
  48618. */
  48619. parse(source: any, scene: Scene, rootUrl: string): void;
  48620. }
  48621. }
  48622. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48623. import { Nullable } from "babylonjs/types";
  48624. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48625. import { Color3 } from "babylonjs/Maths/math.color";
  48626. import { SmartArray } from "babylonjs/Misc/smartArray";
  48627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48628. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48629. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48630. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48631. import { Engine } from "babylonjs/Engines/engine";
  48632. import { Scene } from "babylonjs/scene";
  48633. /**
  48634. * @hidden
  48635. */
  48636. export interface IMaterialSubSurfaceDefines {
  48637. SUBSURFACE: boolean;
  48638. SS_REFRACTION: boolean;
  48639. SS_TRANSLUCENCY: boolean;
  48640. SS_SCATERRING: boolean;
  48641. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48642. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48643. SS_REFRACTIONMAP_3D: boolean;
  48644. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48645. SS_LODINREFRACTIONALPHA: boolean;
  48646. SS_GAMMAREFRACTION: boolean;
  48647. SS_RGBDREFRACTION: boolean;
  48648. SS_LINEARSPECULARREFRACTION: boolean;
  48649. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48650. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48651. /** @hidden */
  48652. _areTexturesDirty: boolean;
  48653. }
  48654. /**
  48655. * Define the code related to the sub surface parameters of the pbr material.
  48656. */
  48657. export class PBRSubSurfaceConfiguration {
  48658. private _isRefractionEnabled;
  48659. /**
  48660. * Defines if the refraction is enabled in the material.
  48661. */
  48662. isRefractionEnabled: boolean;
  48663. private _isTranslucencyEnabled;
  48664. /**
  48665. * Defines if the translucency is enabled in the material.
  48666. */
  48667. isTranslucencyEnabled: boolean;
  48668. private _isScatteringEnabled;
  48669. /**
  48670. * Defines the refraction intensity of the material.
  48671. * The refraction when enabled replaces the Diffuse part of the material.
  48672. * The intensity helps transitionning between diffuse and refraction.
  48673. */
  48674. refractionIntensity: number;
  48675. /**
  48676. * Defines the translucency intensity of the material.
  48677. * When translucency has been enabled, this defines how much of the "translucency"
  48678. * is addded to the diffuse part of the material.
  48679. */
  48680. translucencyIntensity: number;
  48681. /**
  48682. * Defines the scattering intensity of the material.
  48683. * When scattering has been enabled, this defines how much of the "scattered light"
  48684. * is addded to the diffuse part of the material.
  48685. */
  48686. scatteringIntensity: number;
  48687. private _thicknessTexture;
  48688. /**
  48689. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48690. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48691. * 0 would mean minimumThickness
  48692. * 1 would mean maximumThickness
  48693. * The other channels might be use as a mask to vary the different effects intensity.
  48694. */
  48695. thicknessTexture: Nullable<BaseTexture>;
  48696. private _refractionTexture;
  48697. /**
  48698. * Defines the texture to use for refraction.
  48699. */
  48700. refractionTexture: Nullable<BaseTexture>;
  48701. private _indexOfRefraction;
  48702. /**
  48703. * Defines the index of refraction used in the material.
  48704. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48705. */
  48706. indexOfRefraction: number;
  48707. private _invertRefractionY;
  48708. /**
  48709. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48710. */
  48711. invertRefractionY: boolean;
  48712. private _linkRefractionWithTransparency;
  48713. /**
  48714. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48715. * Materials half opaque for instance using refraction could benefit from this control.
  48716. */
  48717. linkRefractionWithTransparency: boolean;
  48718. /**
  48719. * Defines the minimum thickness stored in the thickness map.
  48720. * If no thickness map is defined, this value will be used to simulate thickness.
  48721. */
  48722. minimumThickness: number;
  48723. /**
  48724. * Defines the maximum thickness stored in the thickness map.
  48725. */
  48726. maximumThickness: number;
  48727. /**
  48728. * Defines the volume tint of the material.
  48729. * This is used for both translucency and scattering.
  48730. */
  48731. tintColor: Color3;
  48732. /**
  48733. * Defines the distance at which the tint color should be found in the media.
  48734. * This is used for refraction only.
  48735. */
  48736. tintColorAtDistance: number;
  48737. /**
  48738. * Defines how far each channel transmit through the media.
  48739. * It is defined as a color to simplify it selection.
  48740. */
  48741. diffusionDistance: Color3;
  48742. private _useMaskFromThicknessTexture;
  48743. /**
  48744. * Stores the intensity of the different subsurface effects in the thickness texture.
  48745. * * the green channel is the translucency intensity.
  48746. * * the blue channel is the scattering intensity.
  48747. * * the alpha channel is the refraction intensity.
  48748. */
  48749. useMaskFromThicknessTexture: boolean;
  48750. /** @hidden */
  48751. private _internalMarkAllSubMeshesAsTexturesDirty;
  48752. /** @hidden */
  48753. _markAllSubMeshesAsTexturesDirty(): void;
  48754. /**
  48755. * Instantiate a new istance of sub surface configuration.
  48756. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48757. */
  48758. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48759. /**
  48760. * Gets wehter the submesh is ready to be used or not.
  48761. * @param defines the list of "defines" to update.
  48762. * @param scene defines the scene the material belongs to.
  48763. * @returns - boolean indicating that the submesh is ready or not.
  48764. */
  48765. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48766. /**
  48767. * Checks to see if a texture is used in the material.
  48768. * @param defines the list of "defines" to update.
  48769. * @param scene defines the scene to the material belongs to.
  48770. */
  48771. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48772. /**
  48773. * Binds the material data.
  48774. * @param uniformBuffer defines the Uniform buffer to fill in.
  48775. * @param scene defines the scene the material belongs to.
  48776. * @param engine defines the engine the material belongs to.
  48777. * @param isFrozen defines wether the material is frozen or not.
  48778. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48779. */
  48780. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48781. /**
  48782. * Unbinds the material from the mesh.
  48783. * @param activeEffect defines the effect that should be unbound from.
  48784. * @returns true if unbound, otherwise false
  48785. */
  48786. unbind(activeEffect: Effect): boolean;
  48787. /**
  48788. * Returns the texture used for refraction or null if none is used.
  48789. * @param scene defines the scene the material belongs to.
  48790. * @returns - Refraction texture if present. If no refraction texture and refraction
  48791. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48792. */
  48793. private _getRefractionTexture;
  48794. /**
  48795. * Returns true if alpha blending should be disabled.
  48796. */
  48797. readonly disableAlphaBlending: boolean;
  48798. /**
  48799. * Fills the list of render target textures.
  48800. * @param renderTargets the list of render targets to update
  48801. */
  48802. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48803. /**
  48804. * Checks to see if a texture is used in the material.
  48805. * @param texture - Base texture to use.
  48806. * @returns - Boolean specifying if a texture is used in the material.
  48807. */
  48808. hasTexture(texture: BaseTexture): boolean;
  48809. /**
  48810. * Gets a boolean indicating that current material needs to register RTT
  48811. * @returns true if this uses a render target otherwise false.
  48812. */
  48813. hasRenderTargetTextures(): boolean;
  48814. /**
  48815. * Returns an array of the actively used textures.
  48816. * @param activeTextures Array of BaseTextures
  48817. */
  48818. getActiveTextures(activeTextures: BaseTexture[]): void;
  48819. /**
  48820. * Returns the animatable textures.
  48821. * @param animatables Array of animatable textures.
  48822. */
  48823. getAnimatables(animatables: IAnimatable[]): void;
  48824. /**
  48825. * Disposes the resources of the material.
  48826. * @param forceDisposeTextures - Forces the disposal of all textures.
  48827. */
  48828. dispose(forceDisposeTextures?: boolean): void;
  48829. /**
  48830. * Get the current class name of the texture useful for serialization or dynamic coding.
  48831. * @returns "PBRSubSurfaceConfiguration"
  48832. */
  48833. getClassName(): string;
  48834. /**
  48835. * Add fallbacks to the effect fallbacks list.
  48836. * @param defines defines the Base texture to use.
  48837. * @param fallbacks defines the current fallback list.
  48838. * @param currentRank defines the current fallback rank.
  48839. * @returns the new fallback rank.
  48840. */
  48841. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48842. /**
  48843. * Add the required uniforms to the current list.
  48844. * @param uniforms defines the current uniform list.
  48845. */
  48846. static AddUniforms(uniforms: string[]): void;
  48847. /**
  48848. * Add the required samplers to the current list.
  48849. * @param samplers defines the current sampler list.
  48850. */
  48851. static AddSamplers(samplers: string[]): void;
  48852. /**
  48853. * Add the required uniforms to the current buffer.
  48854. * @param uniformBuffer defines the current uniform buffer.
  48855. */
  48856. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48857. /**
  48858. * Makes a duplicate of the current configuration into another one.
  48859. * @param configuration define the config where to copy the info
  48860. */
  48861. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48862. /**
  48863. * Serializes this Sub Surface configuration.
  48864. * @returns - An object with the serialized config.
  48865. */
  48866. serialize(): any;
  48867. /**
  48868. * Parses a anisotropy Configuration from a serialized object.
  48869. * @param source - Serialized object.
  48870. * @param scene Defines the scene we are parsing for
  48871. * @param rootUrl Defines the rootUrl to load from
  48872. */
  48873. parse(source: any, scene: Scene, rootUrl: string): void;
  48874. }
  48875. }
  48876. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48877. /** @hidden */
  48878. export var pbrFragmentDeclaration: {
  48879. name: string;
  48880. shader: string;
  48881. };
  48882. }
  48883. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48884. /** @hidden */
  48885. export var pbrUboDeclaration: {
  48886. name: string;
  48887. shader: string;
  48888. };
  48889. }
  48890. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48891. /** @hidden */
  48892. export var pbrFragmentExtraDeclaration: {
  48893. name: string;
  48894. shader: string;
  48895. };
  48896. }
  48897. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48898. /** @hidden */
  48899. export var pbrFragmentSamplersDeclaration: {
  48900. name: string;
  48901. shader: string;
  48902. };
  48903. }
  48904. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48905. /** @hidden */
  48906. export var pbrHelperFunctions: {
  48907. name: string;
  48908. shader: string;
  48909. };
  48910. }
  48911. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48912. /** @hidden */
  48913. export var harmonicsFunctions: {
  48914. name: string;
  48915. shader: string;
  48916. };
  48917. }
  48918. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48919. /** @hidden */
  48920. export var pbrDirectLightingSetupFunctions: {
  48921. name: string;
  48922. shader: string;
  48923. };
  48924. }
  48925. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48926. /** @hidden */
  48927. export var pbrDirectLightingFalloffFunctions: {
  48928. name: string;
  48929. shader: string;
  48930. };
  48931. }
  48932. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48933. /** @hidden */
  48934. export var pbrBRDFFunctions: {
  48935. name: string;
  48936. shader: string;
  48937. };
  48938. }
  48939. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48940. /** @hidden */
  48941. export var pbrDirectLightingFunctions: {
  48942. name: string;
  48943. shader: string;
  48944. };
  48945. }
  48946. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48947. /** @hidden */
  48948. export var pbrIBLFunctions: {
  48949. name: string;
  48950. shader: string;
  48951. };
  48952. }
  48953. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48954. /** @hidden */
  48955. export var pbrDebug: {
  48956. name: string;
  48957. shader: string;
  48958. };
  48959. }
  48960. declare module "babylonjs/Shaders/pbr.fragment" {
  48961. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48962. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48963. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48964. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48965. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48966. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48967. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48968. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48969. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48970. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48972. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48973. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48974. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48975. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48976. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48977. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48978. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48979. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48980. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48981. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48982. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48983. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48984. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48985. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48986. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48987. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48988. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48989. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48990. /** @hidden */
  48991. export var pbrPixelShader: {
  48992. name: string;
  48993. shader: string;
  48994. };
  48995. }
  48996. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48997. /** @hidden */
  48998. export var pbrVertexDeclaration: {
  48999. name: string;
  49000. shader: string;
  49001. };
  49002. }
  49003. declare module "babylonjs/Shaders/pbr.vertex" {
  49004. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49005. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49006. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49007. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49008. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49009. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49010. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49011. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49012. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49013. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49014. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49015. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49016. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49017. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49018. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49019. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49020. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49021. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49022. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49023. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49024. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49025. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49026. /** @hidden */
  49027. export var pbrVertexShader: {
  49028. name: string;
  49029. shader: string;
  49030. };
  49031. }
  49032. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49033. import { Nullable } from "babylonjs/types";
  49034. import { Scene } from "babylonjs/scene";
  49035. import { Matrix } from "babylonjs/Maths/math.vector";
  49036. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49038. import { Mesh } from "babylonjs/Meshes/mesh";
  49039. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49040. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49041. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49042. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49043. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49044. import { Color3 } from "babylonjs/Maths/math.color";
  49045. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49046. import { Material } from "babylonjs/Materials/material";
  49047. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49048. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49050. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49051. import "babylonjs/Shaders/pbr.fragment";
  49052. import "babylonjs/Shaders/pbr.vertex";
  49053. /**
  49054. * Manages the defines for the PBR Material.
  49055. * @hidden
  49056. */
  49057. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49058. PBR: boolean;
  49059. MAINUV1: boolean;
  49060. MAINUV2: boolean;
  49061. UV1: boolean;
  49062. UV2: boolean;
  49063. ALBEDO: boolean;
  49064. ALBEDODIRECTUV: number;
  49065. VERTEXCOLOR: boolean;
  49066. AMBIENT: boolean;
  49067. AMBIENTDIRECTUV: number;
  49068. AMBIENTINGRAYSCALE: boolean;
  49069. OPACITY: boolean;
  49070. VERTEXALPHA: boolean;
  49071. OPACITYDIRECTUV: number;
  49072. OPACITYRGB: boolean;
  49073. ALPHATEST: boolean;
  49074. DEPTHPREPASS: boolean;
  49075. ALPHABLEND: boolean;
  49076. ALPHAFROMALBEDO: boolean;
  49077. ALPHATESTVALUE: string;
  49078. SPECULAROVERALPHA: boolean;
  49079. RADIANCEOVERALPHA: boolean;
  49080. ALPHAFRESNEL: boolean;
  49081. LINEARALPHAFRESNEL: boolean;
  49082. PREMULTIPLYALPHA: boolean;
  49083. EMISSIVE: boolean;
  49084. EMISSIVEDIRECTUV: number;
  49085. REFLECTIVITY: boolean;
  49086. REFLECTIVITYDIRECTUV: number;
  49087. SPECULARTERM: boolean;
  49088. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49089. MICROSURFACEAUTOMATIC: boolean;
  49090. LODBASEDMICROSFURACE: boolean;
  49091. MICROSURFACEMAP: boolean;
  49092. MICROSURFACEMAPDIRECTUV: number;
  49093. METALLICWORKFLOW: boolean;
  49094. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49095. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49096. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49097. AOSTOREINMETALMAPRED: boolean;
  49098. ENVIRONMENTBRDF: boolean;
  49099. ENVIRONMENTBRDF_RGBD: boolean;
  49100. NORMAL: boolean;
  49101. TANGENT: boolean;
  49102. BUMP: boolean;
  49103. BUMPDIRECTUV: number;
  49104. OBJECTSPACE_NORMALMAP: boolean;
  49105. PARALLAX: boolean;
  49106. PARALLAXOCCLUSION: boolean;
  49107. NORMALXYSCALE: boolean;
  49108. LIGHTMAP: boolean;
  49109. LIGHTMAPDIRECTUV: number;
  49110. USELIGHTMAPASSHADOWMAP: boolean;
  49111. GAMMALIGHTMAP: boolean;
  49112. RGBDLIGHTMAP: boolean;
  49113. REFLECTION: boolean;
  49114. REFLECTIONMAP_3D: boolean;
  49115. REFLECTIONMAP_SPHERICAL: boolean;
  49116. REFLECTIONMAP_PLANAR: boolean;
  49117. REFLECTIONMAP_CUBIC: boolean;
  49118. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49119. REFLECTIONMAP_PROJECTION: boolean;
  49120. REFLECTIONMAP_SKYBOX: boolean;
  49121. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49122. REFLECTIONMAP_EXPLICIT: boolean;
  49123. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49124. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49125. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49126. INVERTCUBICMAP: boolean;
  49127. USESPHERICALFROMREFLECTIONMAP: boolean;
  49128. USEIRRADIANCEMAP: boolean;
  49129. SPHERICAL_HARMONICS: boolean;
  49130. USESPHERICALINVERTEX: boolean;
  49131. REFLECTIONMAP_OPPOSITEZ: boolean;
  49132. LODINREFLECTIONALPHA: boolean;
  49133. GAMMAREFLECTION: boolean;
  49134. RGBDREFLECTION: boolean;
  49135. LINEARSPECULARREFLECTION: boolean;
  49136. RADIANCEOCCLUSION: boolean;
  49137. HORIZONOCCLUSION: boolean;
  49138. INSTANCES: boolean;
  49139. NUM_BONE_INFLUENCERS: number;
  49140. BonesPerMesh: number;
  49141. BONETEXTURE: boolean;
  49142. NONUNIFORMSCALING: boolean;
  49143. MORPHTARGETS: boolean;
  49144. MORPHTARGETS_NORMAL: boolean;
  49145. MORPHTARGETS_TANGENT: boolean;
  49146. MORPHTARGETS_UV: boolean;
  49147. NUM_MORPH_INFLUENCERS: number;
  49148. IMAGEPROCESSING: boolean;
  49149. VIGNETTE: boolean;
  49150. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49151. VIGNETTEBLENDMODEOPAQUE: boolean;
  49152. TONEMAPPING: boolean;
  49153. TONEMAPPING_ACES: boolean;
  49154. CONTRAST: boolean;
  49155. COLORCURVES: boolean;
  49156. COLORGRADING: boolean;
  49157. COLORGRADING3D: boolean;
  49158. SAMPLER3DGREENDEPTH: boolean;
  49159. SAMPLER3DBGRMAP: boolean;
  49160. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49161. EXPOSURE: boolean;
  49162. MULTIVIEW: boolean;
  49163. USEPHYSICALLIGHTFALLOFF: boolean;
  49164. USEGLTFLIGHTFALLOFF: boolean;
  49165. TWOSIDEDLIGHTING: boolean;
  49166. SHADOWFLOAT: boolean;
  49167. CLIPPLANE: boolean;
  49168. CLIPPLANE2: boolean;
  49169. CLIPPLANE3: boolean;
  49170. CLIPPLANE4: boolean;
  49171. POINTSIZE: boolean;
  49172. FOG: boolean;
  49173. LOGARITHMICDEPTH: boolean;
  49174. FORCENORMALFORWARD: boolean;
  49175. SPECULARAA: boolean;
  49176. CLEARCOAT: boolean;
  49177. CLEARCOAT_DEFAULTIOR: boolean;
  49178. CLEARCOAT_TEXTURE: boolean;
  49179. CLEARCOAT_TEXTUREDIRECTUV: number;
  49180. CLEARCOAT_BUMP: boolean;
  49181. CLEARCOAT_BUMPDIRECTUV: number;
  49182. CLEARCOAT_TINT: boolean;
  49183. CLEARCOAT_TINT_TEXTURE: boolean;
  49184. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49185. ANISOTROPIC: boolean;
  49186. ANISOTROPIC_TEXTURE: boolean;
  49187. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49188. BRDF_V_HEIGHT_CORRELATED: boolean;
  49189. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49190. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49191. SHEEN: boolean;
  49192. SHEEN_TEXTURE: boolean;
  49193. SHEEN_TEXTUREDIRECTUV: number;
  49194. SHEEN_LINKWITHALBEDO: boolean;
  49195. SUBSURFACE: boolean;
  49196. SS_REFRACTION: boolean;
  49197. SS_TRANSLUCENCY: boolean;
  49198. SS_SCATERRING: boolean;
  49199. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49200. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49201. SS_REFRACTIONMAP_3D: boolean;
  49202. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49203. SS_LODINREFRACTIONALPHA: boolean;
  49204. SS_GAMMAREFRACTION: boolean;
  49205. SS_RGBDREFRACTION: boolean;
  49206. SS_LINEARSPECULARREFRACTION: boolean;
  49207. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49208. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49209. UNLIT: boolean;
  49210. DEBUGMODE: number;
  49211. /**
  49212. * Initializes the PBR Material defines.
  49213. */
  49214. constructor();
  49215. /**
  49216. * Resets the PBR Material defines.
  49217. */
  49218. reset(): void;
  49219. }
  49220. /**
  49221. * The Physically based material base class of BJS.
  49222. *
  49223. * This offers the main features of a standard PBR material.
  49224. * For more information, please refer to the documentation :
  49225. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49226. */
  49227. export abstract class PBRBaseMaterial extends PushMaterial {
  49228. /**
  49229. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49230. */
  49231. static readonly PBRMATERIAL_OPAQUE: number;
  49232. /**
  49233. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49234. */
  49235. static readonly PBRMATERIAL_ALPHATEST: number;
  49236. /**
  49237. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49238. */
  49239. static readonly PBRMATERIAL_ALPHABLEND: number;
  49240. /**
  49241. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49242. * They are also discarded below the alpha cutoff threshold to improve performances.
  49243. */
  49244. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49245. /**
  49246. * Defines the default value of how much AO map is occluding the analytical lights
  49247. * (point spot...).
  49248. */
  49249. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49250. /**
  49251. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49252. */
  49253. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49254. /**
  49255. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49256. * to enhance interoperability with other engines.
  49257. */
  49258. static readonly LIGHTFALLOFF_GLTF: number;
  49259. /**
  49260. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49261. * to enhance interoperability with other materials.
  49262. */
  49263. static readonly LIGHTFALLOFF_STANDARD: number;
  49264. /**
  49265. * Intensity of the direct lights e.g. the four lights available in your scene.
  49266. * This impacts both the direct diffuse and specular highlights.
  49267. */
  49268. protected _directIntensity: number;
  49269. /**
  49270. * Intensity of the emissive part of the material.
  49271. * This helps controlling the emissive effect without modifying the emissive color.
  49272. */
  49273. protected _emissiveIntensity: number;
  49274. /**
  49275. * Intensity of the environment e.g. how much the environment will light the object
  49276. * either through harmonics for rough material or through the refelction for shiny ones.
  49277. */
  49278. protected _environmentIntensity: number;
  49279. /**
  49280. * This is a special control allowing the reduction of the specular highlights coming from the
  49281. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49282. */
  49283. protected _specularIntensity: number;
  49284. /**
  49285. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49286. */
  49287. private _lightingInfos;
  49288. /**
  49289. * Debug Control allowing disabling the bump map on this material.
  49290. */
  49291. protected _disableBumpMap: boolean;
  49292. /**
  49293. * AKA Diffuse Texture in standard nomenclature.
  49294. */
  49295. protected _albedoTexture: Nullable<BaseTexture>;
  49296. /**
  49297. * AKA Occlusion Texture in other nomenclature.
  49298. */
  49299. protected _ambientTexture: Nullable<BaseTexture>;
  49300. /**
  49301. * AKA Occlusion Texture Intensity in other nomenclature.
  49302. */
  49303. protected _ambientTextureStrength: number;
  49304. /**
  49305. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49306. * 1 means it completely occludes it
  49307. * 0 mean it has no impact
  49308. */
  49309. protected _ambientTextureImpactOnAnalyticalLights: number;
  49310. /**
  49311. * Stores the alpha values in a texture.
  49312. */
  49313. protected _opacityTexture: Nullable<BaseTexture>;
  49314. /**
  49315. * Stores the reflection values in a texture.
  49316. */
  49317. protected _reflectionTexture: Nullable<BaseTexture>;
  49318. /**
  49319. * Stores the emissive values in a texture.
  49320. */
  49321. protected _emissiveTexture: Nullable<BaseTexture>;
  49322. /**
  49323. * AKA Specular texture in other nomenclature.
  49324. */
  49325. protected _reflectivityTexture: Nullable<BaseTexture>;
  49326. /**
  49327. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49328. */
  49329. protected _metallicTexture: Nullable<BaseTexture>;
  49330. /**
  49331. * Specifies the metallic scalar of the metallic/roughness workflow.
  49332. * Can also be used to scale the metalness values of the metallic texture.
  49333. */
  49334. protected _metallic: Nullable<number>;
  49335. /**
  49336. * Specifies the roughness scalar of the metallic/roughness workflow.
  49337. * Can also be used to scale the roughness values of the metallic texture.
  49338. */
  49339. protected _roughness: Nullable<number>;
  49340. /**
  49341. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49342. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49343. */
  49344. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49345. /**
  49346. * Stores surface normal data used to displace a mesh in a texture.
  49347. */
  49348. protected _bumpTexture: Nullable<BaseTexture>;
  49349. /**
  49350. * Stores the pre-calculated light information of a mesh in a texture.
  49351. */
  49352. protected _lightmapTexture: Nullable<BaseTexture>;
  49353. /**
  49354. * The color of a material in ambient lighting.
  49355. */
  49356. protected _ambientColor: Color3;
  49357. /**
  49358. * AKA Diffuse Color in other nomenclature.
  49359. */
  49360. protected _albedoColor: Color3;
  49361. /**
  49362. * AKA Specular Color in other nomenclature.
  49363. */
  49364. protected _reflectivityColor: Color3;
  49365. /**
  49366. * The color applied when light is reflected from a material.
  49367. */
  49368. protected _reflectionColor: Color3;
  49369. /**
  49370. * The color applied when light is emitted from a material.
  49371. */
  49372. protected _emissiveColor: Color3;
  49373. /**
  49374. * AKA Glossiness in other nomenclature.
  49375. */
  49376. protected _microSurface: number;
  49377. /**
  49378. * Specifies that the material will use the light map as a show map.
  49379. */
  49380. protected _useLightmapAsShadowmap: boolean;
  49381. /**
  49382. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49383. * makes the reflect vector face the model (under horizon).
  49384. */
  49385. protected _useHorizonOcclusion: boolean;
  49386. /**
  49387. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49388. * too much the area relying on ambient texture to define their ambient occlusion.
  49389. */
  49390. protected _useRadianceOcclusion: boolean;
  49391. /**
  49392. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49393. */
  49394. protected _useAlphaFromAlbedoTexture: boolean;
  49395. /**
  49396. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49397. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49398. */
  49399. protected _useSpecularOverAlpha: boolean;
  49400. /**
  49401. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49402. */
  49403. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49404. /**
  49405. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49406. */
  49407. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49408. /**
  49409. * Specifies if the metallic texture contains the roughness information in its green channel.
  49410. */
  49411. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49412. /**
  49413. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49414. */
  49415. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49416. /**
  49417. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49418. */
  49419. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49420. /**
  49421. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49422. */
  49423. protected _useAmbientInGrayScale: boolean;
  49424. /**
  49425. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49426. * The material will try to infer what glossiness each pixel should be.
  49427. */
  49428. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49429. /**
  49430. * Defines the falloff type used in this material.
  49431. * It by default is Physical.
  49432. */
  49433. protected _lightFalloff: number;
  49434. /**
  49435. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49436. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49437. */
  49438. protected _useRadianceOverAlpha: boolean;
  49439. /**
  49440. * Allows using an object space normal map (instead of tangent space).
  49441. */
  49442. protected _useObjectSpaceNormalMap: boolean;
  49443. /**
  49444. * Allows using the bump map in parallax mode.
  49445. */
  49446. protected _useParallax: boolean;
  49447. /**
  49448. * Allows using the bump map in parallax occlusion mode.
  49449. */
  49450. protected _useParallaxOcclusion: boolean;
  49451. /**
  49452. * Controls the scale bias of the parallax mode.
  49453. */
  49454. protected _parallaxScaleBias: number;
  49455. /**
  49456. * If sets to true, disables all the lights affecting the material.
  49457. */
  49458. protected _disableLighting: boolean;
  49459. /**
  49460. * Number of Simultaneous lights allowed on the material.
  49461. */
  49462. protected _maxSimultaneousLights: number;
  49463. /**
  49464. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49465. */
  49466. protected _invertNormalMapX: boolean;
  49467. /**
  49468. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49469. */
  49470. protected _invertNormalMapY: boolean;
  49471. /**
  49472. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49473. */
  49474. protected _twoSidedLighting: boolean;
  49475. /**
  49476. * Defines the alpha limits in alpha test mode.
  49477. */
  49478. protected _alphaCutOff: number;
  49479. /**
  49480. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49481. */
  49482. protected _forceAlphaTest: boolean;
  49483. /**
  49484. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49485. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49486. */
  49487. protected _useAlphaFresnel: boolean;
  49488. /**
  49489. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49490. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49491. */
  49492. protected _useLinearAlphaFresnel: boolean;
  49493. /**
  49494. * The transparency mode of the material.
  49495. */
  49496. protected _transparencyMode: Nullable<number>;
  49497. /**
  49498. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49499. * from cos thetav and roughness:
  49500. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49501. */
  49502. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49503. /**
  49504. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49505. */
  49506. protected _forceIrradianceInFragment: boolean;
  49507. /**
  49508. * Force normal to face away from face.
  49509. */
  49510. protected _forceNormalForward: boolean;
  49511. /**
  49512. * Enables specular anti aliasing in the PBR shader.
  49513. * It will both interacts on the Geometry for analytical and IBL lighting.
  49514. * It also prefilter the roughness map based on the bump values.
  49515. */
  49516. protected _enableSpecularAntiAliasing: boolean;
  49517. /**
  49518. * Default configuration related to image processing available in the PBR Material.
  49519. */
  49520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49521. /**
  49522. * Keep track of the image processing observer to allow dispose and replace.
  49523. */
  49524. private _imageProcessingObserver;
  49525. /**
  49526. * Attaches a new image processing configuration to the PBR Material.
  49527. * @param configuration
  49528. */
  49529. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49530. /**
  49531. * Stores the available render targets.
  49532. */
  49533. private _renderTargets;
  49534. /**
  49535. * Sets the global ambient color for the material used in lighting calculations.
  49536. */
  49537. private _globalAmbientColor;
  49538. /**
  49539. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49540. */
  49541. private _useLogarithmicDepth;
  49542. /**
  49543. * If set to true, no lighting calculations will be applied.
  49544. */
  49545. private _unlit;
  49546. private _debugMode;
  49547. /**
  49548. * @hidden
  49549. * This is reserved for the inspector.
  49550. * Defines the material debug mode.
  49551. * It helps seeing only some components of the material while troubleshooting.
  49552. */
  49553. debugMode: number;
  49554. /**
  49555. * @hidden
  49556. * This is reserved for the inspector.
  49557. * Specify from where on screen the debug mode should start.
  49558. * The value goes from -1 (full screen) to 1 (not visible)
  49559. * It helps with side by side comparison against the final render
  49560. * This defaults to -1
  49561. */
  49562. private debugLimit;
  49563. /**
  49564. * @hidden
  49565. * This is reserved for the inspector.
  49566. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49567. * You can use the factor to better multiply the final value.
  49568. */
  49569. private debugFactor;
  49570. /**
  49571. * Defines the clear coat layer parameters for the material.
  49572. */
  49573. readonly clearCoat: PBRClearCoatConfiguration;
  49574. /**
  49575. * Defines the anisotropic parameters for the material.
  49576. */
  49577. readonly anisotropy: PBRAnisotropicConfiguration;
  49578. /**
  49579. * Defines the BRDF parameters for the material.
  49580. */
  49581. readonly brdf: PBRBRDFConfiguration;
  49582. /**
  49583. * Defines the Sheen parameters for the material.
  49584. */
  49585. readonly sheen: PBRSheenConfiguration;
  49586. /**
  49587. * Defines the SubSurface parameters for the material.
  49588. */
  49589. readonly subSurface: PBRSubSurfaceConfiguration;
  49590. /**
  49591. * Custom callback helping to override the default shader used in the material.
  49592. */
  49593. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49594. protected _rebuildInParallel: boolean;
  49595. /**
  49596. * Instantiates a new PBRMaterial instance.
  49597. *
  49598. * @param name The material name
  49599. * @param scene The scene the material will be use in.
  49600. */
  49601. constructor(name: string, scene: Scene);
  49602. /**
  49603. * Gets a boolean indicating that current material needs to register RTT
  49604. */
  49605. readonly hasRenderTargetTextures: boolean;
  49606. /**
  49607. * Gets the name of the material class.
  49608. */
  49609. getClassName(): string;
  49610. /**
  49611. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49612. */
  49613. /**
  49614. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49615. */
  49616. useLogarithmicDepth: boolean;
  49617. /**
  49618. * Gets the current transparency mode.
  49619. */
  49620. /**
  49621. * Sets the transparency mode of the material.
  49622. *
  49623. * | Value | Type | Description |
  49624. * | ----- | ----------------------------------- | ----------- |
  49625. * | 0 | OPAQUE | |
  49626. * | 1 | ALPHATEST | |
  49627. * | 2 | ALPHABLEND | |
  49628. * | 3 | ALPHATESTANDBLEND | |
  49629. *
  49630. */
  49631. transparencyMode: Nullable<number>;
  49632. /**
  49633. * Returns true if alpha blending should be disabled.
  49634. */
  49635. private readonly _disableAlphaBlending;
  49636. /**
  49637. * Specifies whether or not this material should be rendered in alpha blend mode.
  49638. */
  49639. needAlphaBlending(): boolean;
  49640. /**
  49641. * Specifies if the mesh will require alpha blending.
  49642. * @param mesh - BJS mesh.
  49643. */
  49644. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49645. /**
  49646. * Specifies whether or not this material should be rendered in alpha test mode.
  49647. */
  49648. needAlphaTesting(): boolean;
  49649. /**
  49650. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49651. */
  49652. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49653. /**
  49654. * Gets the texture used for the alpha test.
  49655. */
  49656. getAlphaTestTexture(): Nullable<BaseTexture>;
  49657. /**
  49658. * Specifies that the submesh is ready to be used.
  49659. * @param mesh - BJS mesh.
  49660. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49661. * @param useInstances - Specifies that instances should be used.
  49662. * @returns - boolean indicating that the submesh is ready or not.
  49663. */
  49664. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49665. /**
  49666. * Specifies if the material uses metallic roughness workflow.
  49667. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49668. */
  49669. isMetallicWorkflow(): boolean;
  49670. private _prepareEffect;
  49671. private _prepareDefines;
  49672. /**
  49673. * Force shader compilation
  49674. */
  49675. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49676. clipPlane: boolean;
  49677. }>): void;
  49678. /**
  49679. * Initializes the uniform buffer layout for the shader.
  49680. */
  49681. buildUniformLayout(): void;
  49682. /**
  49683. * Unbinds the material from the mesh
  49684. */
  49685. unbind(): void;
  49686. /**
  49687. * Binds the submesh data.
  49688. * @param world - The world matrix.
  49689. * @param mesh - The BJS mesh.
  49690. * @param subMesh - A submesh of the BJS mesh.
  49691. */
  49692. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49693. /**
  49694. * Returns the animatable textures.
  49695. * @returns - Array of animatable textures.
  49696. */
  49697. getAnimatables(): IAnimatable[];
  49698. /**
  49699. * Returns the texture used for reflections.
  49700. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49701. */
  49702. private _getReflectionTexture;
  49703. /**
  49704. * Returns an array of the actively used textures.
  49705. * @returns - Array of BaseTextures
  49706. */
  49707. getActiveTextures(): BaseTexture[];
  49708. /**
  49709. * Checks to see if a texture is used in the material.
  49710. * @param texture - Base texture to use.
  49711. * @returns - Boolean specifying if a texture is used in the material.
  49712. */
  49713. hasTexture(texture: BaseTexture): boolean;
  49714. /**
  49715. * Disposes the resources of the material.
  49716. * @param forceDisposeEffect - Forces the disposal of effects.
  49717. * @param forceDisposeTextures - Forces the disposal of all textures.
  49718. */
  49719. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49720. }
  49721. }
  49722. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49723. import { Nullable } from "babylonjs/types";
  49724. import { Scene } from "babylonjs/scene";
  49725. import { Color3 } from "babylonjs/Maths/math.color";
  49726. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49727. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49729. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49730. /**
  49731. * The Physically based material of BJS.
  49732. *
  49733. * This offers the main features of a standard PBR material.
  49734. * For more information, please refer to the documentation :
  49735. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49736. */
  49737. export class PBRMaterial extends PBRBaseMaterial {
  49738. /**
  49739. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49740. */
  49741. static readonly PBRMATERIAL_OPAQUE: number;
  49742. /**
  49743. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49744. */
  49745. static readonly PBRMATERIAL_ALPHATEST: number;
  49746. /**
  49747. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49748. */
  49749. static readonly PBRMATERIAL_ALPHABLEND: number;
  49750. /**
  49751. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49752. * They are also discarded below the alpha cutoff threshold to improve performances.
  49753. */
  49754. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49755. /**
  49756. * Defines the default value of how much AO map is occluding the analytical lights
  49757. * (point spot...).
  49758. */
  49759. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49760. /**
  49761. * Intensity of the direct lights e.g. the four lights available in your scene.
  49762. * This impacts both the direct diffuse and specular highlights.
  49763. */
  49764. directIntensity: number;
  49765. /**
  49766. * Intensity of the emissive part of the material.
  49767. * This helps controlling the emissive effect without modifying the emissive color.
  49768. */
  49769. emissiveIntensity: number;
  49770. /**
  49771. * Intensity of the environment e.g. how much the environment will light the object
  49772. * either through harmonics for rough material or through the refelction for shiny ones.
  49773. */
  49774. environmentIntensity: number;
  49775. /**
  49776. * This is a special control allowing the reduction of the specular highlights coming from the
  49777. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49778. */
  49779. specularIntensity: number;
  49780. /**
  49781. * Debug Control allowing disabling the bump map on this material.
  49782. */
  49783. disableBumpMap: boolean;
  49784. /**
  49785. * AKA Diffuse Texture in standard nomenclature.
  49786. */
  49787. albedoTexture: BaseTexture;
  49788. /**
  49789. * AKA Occlusion Texture in other nomenclature.
  49790. */
  49791. ambientTexture: BaseTexture;
  49792. /**
  49793. * AKA Occlusion Texture Intensity in other nomenclature.
  49794. */
  49795. ambientTextureStrength: number;
  49796. /**
  49797. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49798. * 1 means it completely occludes it
  49799. * 0 mean it has no impact
  49800. */
  49801. ambientTextureImpactOnAnalyticalLights: number;
  49802. /**
  49803. * Stores the alpha values in a texture.
  49804. */
  49805. opacityTexture: BaseTexture;
  49806. /**
  49807. * Stores the reflection values in a texture.
  49808. */
  49809. reflectionTexture: Nullable<BaseTexture>;
  49810. /**
  49811. * Stores the emissive values in a texture.
  49812. */
  49813. emissiveTexture: BaseTexture;
  49814. /**
  49815. * AKA Specular texture in other nomenclature.
  49816. */
  49817. reflectivityTexture: BaseTexture;
  49818. /**
  49819. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49820. */
  49821. metallicTexture: BaseTexture;
  49822. /**
  49823. * Specifies the metallic scalar of the metallic/roughness workflow.
  49824. * Can also be used to scale the metalness values of the metallic texture.
  49825. */
  49826. metallic: Nullable<number>;
  49827. /**
  49828. * Specifies the roughness scalar of the metallic/roughness workflow.
  49829. * Can also be used to scale the roughness values of the metallic texture.
  49830. */
  49831. roughness: Nullable<number>;
  49832. /**
  49833. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49834. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49835. */
  49836. microSurfaceTexture: BaseTexture;
  49837. /**
  49838. * Stores surface normal data used to displace a mesh in a texture.
  49839. */
  49840. bumpTexture: BaseTexture;
  49841. /**
  49842. * Stores the pre-calculated light information of a mesh in a texture.
  49843. */
  49844. lightmapTexture: BaseTexture;
  49845. /**
  49846. * Stores the refracted light information in a texture.
  49847. */
  49848. refractionTexture: Nullable<BaseTexture>;
  49849. /**
  49850. * The color of a material in ambient lighting.
  49851. */
  49852. ambientColor: Color3;
  49853. /**
  49854. * AKA Diffuse Color in other nomenclature.
  49855. */
  49856. albedoColor: Color3;
  49857. /**
  49858. * AKA Specular Color in other nomenclature.
  49859. */
  49860. reflectivityColor: Color3;
  49861. /**
  49862. * The color reflected from the material.
  49863. */
  49864. reflectionColor: Color3;
  49865. /**
  49866. * The color emitted from the material.
  49867. */
  49868. emissiveColor: Color3;
  49869. /**
  49870. * AKA Glossiness in other nomenclature.
  49871. */
  49872. microSurface: number;
  49873. /**
  49874. * source material index of refraction (IOR)' / 'destination material IOR.
  49875. */
  49876. indexOfRefraction: number;
  49877. /**
  49878. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49879. */
  49880. invertRefractionY: boolean;
  49881. /**
  49882. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49883. * Materials half opaque for instance using refraction could benefit from this control.
  49884. */
  49885. linkRefractionWithTransparency: boolean;
  49886. /**
  49887. * If true, the light map contains occlusion information instead of lighting info.
  49888. */
  49889. useLightmapAsShadowmap: boolean;
  49890. /**
  49891. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49892. */
  49893. useAlphaFromAlbedoTexture: boolean;
  49894. /**
  49895. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49896. */
  49897. forceAlphaTest: boolean;
  49898. /**
  49899. * Defines the alpha limits in alpha test mode.
  49900. */
  49901. alphaCutOff: number;
  49902. /**
  49903. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49904. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49905. */
  49906. useSpecularOverAlpha: boolean;
  49907. /**
  49908. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49909. */
  49910. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49911. /**
  49912. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49913. */
  49914. useRoughnessFromMetallicTextureAlpha: boolean;
  49915. /**
  49916. * Specifies if the metallic texture contains the roughness information in its green channel.
  49917. */
  49918. useRoughnessFromMetallicTextureGreen: boolean;
  49919. /**
  49920. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49921. */
  49922. useMetallnessFromMetallicTextureBlue: boolean;
  49923. /**
  49924. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49925. */
  49926. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49927. /**
  49928. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49929. */
  49930. useAmbientInGrayScale: boolean;
  49931. /**
  49932. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49933. * The material will try to infer what glossiness each pixel should be.
  49934. */
  49935. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49936. /**
  49937. * BJS is using an harcoded light falloff based on a manually sets up range.
  49938. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49939. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49940. */
  49941. /**
  49942. * BJS is using an harcoded light falloff based on a manually sets up range.
  49943. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49944. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49945. */
  49946. usePhysicalLightFalloff: boolean;
  49947. /**
  49948. * In order to support the falloff compatibility with gltf, a special mode has been added
  49949. * to reproduce the gltf light falloff.
  49950. */
  49951. /**
  49952. * In order to support the falloff compatibility with gltf, a special mode has been added
  49953. * to reproduce the gltf light falloff.
  49954. */
  49955. useGLTFLightFalloff: boolean;
  49956. /**
  49957. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49958. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49959. */
  49960. useRadianceOverAlpha: boolean;
  49961. /**
  49962. * Allows using an object space normal map (instead of tangent space).
  49963. */
  49964. useObjectSpaceNormalMap: boolean;
  49965. /**
  49966. * Allows using the bump map in parallax mode.
  49967. */
  49968. useParallax: boolean;
  49969. /**
  49970. * Allows using the bump map in parallax occlusion mode.
  49971. */
  49972. useParallaxOcclusion: boolean;
  49973. /**
  49974. * Controls the scale bias of the parallax mode.
  49975. */
  49976. parallaxScaleBias: number;
  49977. /**
  49978. * If sets to true, disables all the lights affecting the material.
  49979. */
  49980. disableLighting: boolean;
  49981. /**
  49982. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49983. */
  49984. forceIrradianceInFragment: boolean;
  49985. /**
  49986. * Number of Simultaneous lights allowed on the material.
  49987. */
  49988. maxSimultaneousLights: number;
  49989. /**
  49990. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49991. */
  49992. invertNormalMapX: boolean;
  49993. /**
  49994. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49995. */
  49996. invertNormalMapY: boolean;
  49997. /**
  49998. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49999. */
  50000. twoSidedLighting: boolean;
  50001. /**
  50002. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50003. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50004. */
  50005. useAlphaFresnel: boolean;
  50006. /**
  50007. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50008. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50009. */
  50010. useLinearAlphaFresnel: boolean;
  50011. /**
  50012. * Let user defines the brdf lookup texture used for IBL.
  50013. * A default 8bit version is embedded but you could point at :
  50014. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50015. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50016. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50017. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50018. */
  50019. environmentBRDFTexture: Nullable<BaseTexture>;
  50020. /**
  50021. * Force normal to face away from face.
  50022. */
  50023. forceNormalForward: boolean;
  50024. /**
  50025. * Enables specular anti aliasing in the PBR shader.
  50026. * It will both interacts on the Geometry for analytical and IBL lighting.
  50027. * It also prefilter the roughness map based on the bump values.
  50028. */
  50029. enableSpecularAntiAliasing: boolean;
  50030. /**
  50031. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50032. * makes the reflect vector face the model (under horizon).
  50033. */
  50034. useHorizonOcclusion: boolean;
  50035. /**
  50036. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50037. * too much the area relying on ambient texture to define their ambient occlusion.
  50038. */
  50039. useRadianceOcclusion: boolean;
  50040. /**
  50041. * If set to true, no lighting calculations will be applied.
  50042. */
  50043. unlit: boolean;
  50044. /**
  50045. * Gets the image processing configuration used either in this material.
  50046. */
  50047. /**
  50048. * Sets the Default image processing configuration used either in the this material.
  50049. *
  50050. * If sets to null, the scene one is in use.
  50051. */
  50052. imageProcessingConfiguration: ImageProcessingConfiguration;
  50053. /**
  50054. * Gets wether the color curves effect is enabled.
  50055. */
  50056. /**
  50057. * Sets wether the color curves effect is enabled.
  50058. */
  50059. cameraColorCurvesEnabled: boolean;
  50060. /**
  50061. * Gets wether the color grading effect is enabled.
  50062. */
  50063. /**
  50064. * Gets wether the color grading effect is enabled.
  50065. */
  50066. cameraColorGradingEnabled: boolean;
  50067. /**
  50068. * Gets wether tonemapping is enabled or not.
  50069. */
  50070. /**
  50071. * Sets wether tonemapping is enabled or not
  50072. */
  50073. cameraToneMappingEnabled: boolean;
  50074. /**
  50075. * The camera exposure used on this material.
  50076. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50077. * This corresponds to a photographic exposure.
  50078. */
  50079. /**
  50080. * The camera exposure used on this material.
  50081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50082. * This corresponds to a photographic exposure.
  50083. */
  50084. cameraExposure: number;
  50085. /**
  50086. * Gets The camera contrast used on this material.
  50087. */
  50088. /**
  50089. * Sets The camera contrast used on this material.
  50090. */
  50091. cameraContrast: number;
  50092. /**
  50093. * Gets the Color Grading 2D Lookup Texture.
  50094. */
  50095. /**
  50096. * Sets the Color Grading 2D Lookup Texture.
  50097. */
  50098. cameraColorGradingTexture: Nullable<BaseTexture>;
  50099. /**
  50100. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50101. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50102. * 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;
  50103. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50104. */
  50105. /**
  50106. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50107. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50108. * 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;
  50109. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50110. */
  50111. cameraColorCurves: Nullable<ColorCurves>;
  50112. /**
  50113. * Instantiates a new PBRMaterial instance.
  50114. *
  50115. * @param name The material name
  50116. * @param scene The scene the material will be use in.
  50117. */
  50118. constructor(name: string, scene: Scene);
  50119. /**
  50120. * Returns the name of this material class.
  50121. */
  50122. getClassName(): string;
  50123. /**
  50124. * Makes a duplicate of the current material.
  50125. * @param name - name to use for the new material.
  50126. */
  50127. clone(name: string): PBRMaterial;
  50128. /**
  50129. * Serializes this PBR Material.
  50130. * @returns - An object with the serialized material.
  50131. */
  50132. serialize(): any;
  50133. /**
  50134. * Parses a PBR Material from a serialized object.
  50135. * @param source - Serialized object.
  50136. * @param scene - BJS scene instance.
  50137. * @param rootUrl - url for the scene object
  50138. * @returns - PBRMaterial
  50139. */
  50140. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50141. }
  50142. }
  50143. declare module "babylonjs/Misc/dds" {
  50144. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50145. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50146. import { Nullable } from "babylonjs/types";
  50147. import { Scene } from "babylonjs/scene";
  50148. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50149. import { BaseEngine } from "babylonjs/Engines/baseEngine";
  50150. /**
  50151. * Direct draw surface info
  50152. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50153. */
  50154. export interface DDSInfo {
  50155. /**
  50156. * Width of the texture
  50157. */
  50158. width: number;
  50159. /**
  50160. * Width of the texture
  50161. */
  50162. height: number;
  50163. /**
  50164. * Number of Mipmaps for the texture
  50165. * @see https://en.wikipedia.org/wiki/Mipmap
  50166. */
  50167. mipmapCount: number;
  50168. /**
  50169. * If the textures format is a known fourCC format
  50170. * @see https://www.fourcc.org/
  50171. */
  50172. isFourCC: boolean;
  50173. /**
  50174. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50175. */
  50176. isRGB: boolean;
  50177. /**
  50178. * If the texture is a lumincance format
  50179. */
  50180. isLuminance: boolean;
  50181. /**
  50182. * If this is a cube texture
  50183. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50184. */
  50185. isCube: boolean;
  50186. /**
  50187. * If the texture is a compressed format eg. FOURCC_DXT1
  50188. */
  50189. isCompressed: boolean;
  50190. /**
  50191. * The dxgiFormat of the texture
  50192. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50193. */
  50194. dxgiFormat: number;
  50195. /**
  50196. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50197. */
  50198. textureType: number;
  50199. /**
  50200. * Sphericle polynomial created for the dds texture
  50201. */
  50202. sphericalPolynomial?: SphericalPolynomial;
  50203. }
  50204. /**
  50205. * Class used to provide DDS decompression tools
  50206. */
  50207. export class DDSTools {
  50208. /**
  50209. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50210. */
  50211. static StoreLODInAlphaChannel: boolean;
  50212. /**
  50213. * Gets DDS information from an array buffer
  50214. * @param arrayBuffer defines the array buffer to read data from
  50215. * @returns the DDS information
  50216. */
  50217. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50218. private static _FloatView;
  50219. private static _Int32View;
  50220. private static _ToHalfFloat;
  50221. private static _FromHalfFloat;
  50222. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50223. private static _GetHalfFloatRGBAArrayBuffer;
  50224. private static _GetFloatRGBAArrayBuffer;
  50225. private static _GetFloatAsUIntRGBAArrayBuffer;
  50226. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50227. private static _GetRGBAArrayBuffer;
  50228. private static _ExtractLongWordOrder;
  50229. private static _GetRGBArrayBuffer;
  50230. private static _GetLuminanceArrayBuffer;
  50231. /**
  50232. * Uploads DDS Levels to a Babylon Texture
  50233. * @hidden
  50234. */
  50235. static UploadDDSLevels(engine: BaseEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50236. }
  50237. module "babylonjs/Engines/baseEngine" {
  50238. interface BaseEngine {
  50239. /**
  50240. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50241. * @param rootUrl defines the url where the file to load is located
  50242. * @param scene defines the current scene
  50243. * @param lodScale defines scale to apply to the mip map selection
  50244. * @param lodOffset defines offset to apply to the mip map selection
  50245. * @param onLoad defines an optional callback raised when the texture is loaded
  50246. * @param onError defines an optional callback raised if there is an issue to load the texture
  50247. * @param format defines the format of the data
  50248. * @param forcedExtension defines the extension to use to pick the right loader
  50249. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50250. * @returns the cube texture as an InternalTexture
  50251. */
  50252. 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;
  50253. }
  50254. }
  50255. }
  50256. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50257. import { Nullable } from "babylonjs/types";
  50258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50259. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50260. /**
  50261. * Implementation of the DDS Texture Loader.
  50262. * @hidden
  50263. */
  50264. export class _DDSTextureLoader implements IInternalTextureLoader {
  50265. /**
  50266. * Defines wether the loader supports cascade loading the different faces.
  50267. */
  50268. readonly supportCascades: boolean;
  50269. /**
  50270. * This returns if the loader support the current file information.
  50271. * @param extension defines the file extension of the file being loaded
  50272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50273. * @param fallback defines the fallback internal texture if any
  50274. * @param isBase64 defines whether the texture is encoded as a base64
  50275. * @param isBuffer defines whether the texture data are stored as a buffer
  50276. * @returns true if the loader can load the specified file
  50277. */
  50278. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50279. /**
  50280. * Transform the url before loading if required.
  50281. * @param rootUrl the url of the texture
  50282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50283. * @returns the transformed texture
  50284. */
  50285. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50286. /**
  50287. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50288. * @param rootUrl the url of the texture
  50289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50290. * @returns the fallback texture
  50291. */
  50292. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50293. /**
  50294. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50295. * @param data contains the texture data
  50296. * @param texture defines the BabylonJS internal texture
  50297. * @param createPolynomials will be true if polynomials have been requested
  50298. * @param onLoad defines the callback to trigger once the texture is ready
  50299. * @param onError defines the callback to trigger in case of error
  50300. */
  50301. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50302. /**
  50303. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50304. * @param data contains the texture data
  50305. * @param texture defines the BabylonJS internal texture
  50306. * @param callback defines the method to call once ready to upload
  50307. */
  50308. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50309. }
  50310. }
  50311. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50312. import { Nullable } from "babylonjs/types";
  50313. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50314. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50315. /**
  50316. * Implementation of the ENV Texture Loader.
  50317. * @hidden
  50318. */
  50319. export class _ENVTextureLoader implements IInternalTextureLoader {
  50320. /**
  50321. * Defines wether the loader supports cascade loading the different faces.
  50322. */
  50323. readonly supportCascades: boolean;
  50324. /**
  50325. * This returns if the loader support the current file information.
  50326. * @param extension defines the file extension of the file being loaded
  50327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50328. * @param fallback defines the fallback internal texture if any
  50329. * @param isBase64 defines whether the texture is encoded as a base64
  50330. * @param isBuffer defines whether the texture data are stored as a buffer
  50331. * @returns true if the loader can load the specified file
  50332. */
  50333. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50334. /**
  50335. * Transform the url before loading if required.
  50336. * @param rootUrl the url of the texture
  50337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50338. * @returns the transformed texture
  50339. */
  50340. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50341. /**
  50342. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50343. * @param rootUrl the url of the texture
  50344. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50345. * @returns the fallback texture
  50346. */
  50347. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50348. /**
  50349. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50350. * @param data contains the texture data
  50351. * @param texture defines the BabylonJS internal texture
  50352. * @param createPolynomials will be true if polynomials have been requested
  50353. * @param onLoad defines the callback to trigger once the texture is ready
  50354. * @param onError defines the callback to trigger in case of error
  50355. */
  50356. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50357. /**
  50358. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50359. * @param data contains the texture data
  50360. * @param texture defines the BabylonJS internal texture
  50361. * @param callback defines the method to call once ready to upload
  50362. */
  50363. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50364. }
  50365. }
  50366. declare module "babylonjs/Misc/khronosTextureContainer" {
  50367. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50368. /**
  50369. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50370. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50371. */
  50372. export class KhronosTextureContainer {
  50373. /** contents of the KTX container file */
  50374. arrayBuffer: any;
  50375. private static HEADER_LEN;
  50376. private static COMPRESSED_2D;
  50377. private static COMPRESSED_3D;
  50378. private static TEX_2D;
  50379. private static TEX_3D;
  50380. /**
  50381. * Gets the openGL type
  50382. */
  50383. glType: number;
  50384. /**
  50385. * Gets the openGL type size
  50386. */
  50387. glTypeSize: number;
  50388. /**
  50389. * Gets the openGL format
  50390. */
  50391. glFormat: number;
  50392. /**
  50393. * Gets the openGL internal format
  50394. */
  50395. glInternalFormat: number;
  50396. /**
  50397. * Gets the base internal format
  50398. */
  50399. glBaseInternalFormat: number;
  50400. /**
  50401. * Gets image width in pixel
  50402. */
  50403. pixelWidth: number;
  50404. /**
  50405. * Gets image height in pixel
  50406. */
  50407. pixelHeight: number;
  50408. /**
  50409. * Gets image depth in pixels
  50410. */
  50411. pixelDepth: number;
  50412. /**
  50413. * Gets the number of array elements
  50414. */
  50415. numberOfArrayElements: number;
  50416. /**
  50417. * Gets the number of faces
  50418. */
  50419. numberOfFaces: number;
  50420. /**
  50421. * Gets the number of mipmap levels
  50422. */
  50423. numberOfMipmapLevels: number;
  50424. /**
  50425. * Gets the bytes of key value data
  50426. */
  50427. bytesOfKeyValueData: number;
  50428. /**
  50429. * Gets the load type
  50430. */
  50431. loadType: number;
  50432. /**
  50433. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50434. */
  50435. isInvalid: boolean;
  50436. /**
  50437. * Creates a new KhronosTextureContainer
  50438. * @param arrayBuffer contents of the KTX container file
  50439. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50440. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50441. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50442. */
  50443. constructor(
  50444. /** contents of the KTX container file */
  50445. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50446. /**
  50447. * Uploads KTX content to a Babylon Texture.
  50448. * It is assumed that the texture has already been created & is currently bound
  50449. * @hidden
  50450. */
  50451. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50452. private _upload2DCompressedLevels;
  50453. }
  50454. }
  50455. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50456. import { Nullable } from "babylonjs/types";
  50457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50458. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50459. /**
  50460. * Implementation of the KTX Texture Loader.
  50461. * @hidden
  50462. */
  50463. export class _KTXTextureLoader implements IInternalTextureLoader {
  50464. /**
  50465. * Defines wether the loader supports cascade loading the different faces.
  50466. */
  50467. readonly supportCascades: boolean;
  50468. /**
  50469. * This returns if the loader support the current file information.
  50470. * @param extension defines the file extension of the file being loaded
  50471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50472. * @param fallback defines the fallback internal texture if any
  50473. * @param isBase64 defines whether the texture is encoded as a base64
  50474. * @param isBuffer defines whether the texture data are stored as a buffer
  50475. * @returns true if the loader can load the specified file
  50476. */
  50477. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50478. /**
  50479. * Transform the url before loading if required.
  50480. * @param rootUrl the url of the texture
  50481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50482. * @returns the transformed texture
  50483. */
  50484. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50485. /**
  50486. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50487. * @param rootUrl the url of the texture
  50488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50489. * @returns the fallback texture
  50490. */
  50491. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50492. /**
  50493. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50494. * @param data contains the texture data
  50495. * @param texture defines the BabylonJS internal texture
  50496. * @param createPolynomials will be true if polynomials have been requested
  50497. * @param onLoad defines the callback to trigger once the texture is ready
  50498. * @param onError defines the callback to trigger in case of error
  50499. */
  50500. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50501. /**
  50502. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50503. * @param data contains the texture data
  50504. * @param texture defines the BabylonJS internal texture
  50505. * @param callback defines the method to call once ready to upload
  50506. */
  50507. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50508. }
  50509. }
  50510. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50511. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50512. import { Scene } from "babylonjs/scene";
  50513. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50514. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50515. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50516. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50517. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50518. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50520. /**
  50521. * Options for the default xr helper
  50522. */
  50523. export class WebXRDefaultExperienceOptions {
  50524. /**
  50525. * Floor meshes that should be used for teleporting
  50526. */
  50527. floorMeshes: Array<AbstractMesh>;
  50528. }
  50529. /**
  50530. * Default experience which provides a similar setup to the previous webVRExperience
  50531. */
  50532. export class WebXRDefaultExperience {
  50533. /**
  50534. * Base experience
  50535. */
  50536. baseExperience: WebXRExperienceHelper;
  50537. /**
  50538. * Input experience extension
  50539. */
  50540. input: WebXRInput;
  50541. /**
  50542. * Loads the controller models
  50543. */
  50544. controllerModelLoader: WebXRControllerModelLoader;
  50545. /**
  50546. * Enables laser pointer and selection
  50547. */
  50548. pointerSelection: WebXRControllerPointerSelection;
  50549. /**
  50550. * Enables teleportation
  50551. */
  50552. teleportation: WebXRControllerTeleportation;
  50553. /**
  50554. * Enables ui for enetering/exiting xr
  50555. */
  50556. enterExitUI: WebXREnterExitUI;
  50557. /**
  50558. * Default output canvas xr should render to
  50559. */
  50560. outputCanvas: WebXRManagedOutputCanvas;
  50561. /**
  50562. * Creates the default xr experience
  50563. * @param scene scene
  50564. * @param options options for basic configuration
  50565. * @returns resulting WebXRDefaultExperience
  50566. */
  50567. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50568. private constructor();
  50569. /**
  50570. * DIsposes of the experience helper
  50571. */
  50572. dispose(): void;
  50573. }
  50574. }
  50575. declare module "babylonjs/Helpers/sceneHelpers" {
  50576. import { Nullable } from "babylonjs/types";
  50577. import { Mesh } from "babylonjs/Meshes/mesh";
  50578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50579. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50580. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50581. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50582. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50583. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50584. import "babylonjs/Meshes/Builders/boxBuilder";
  50585. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50586. /** @hidden */
  50587. export var _forceSceneHelpersToBundle: boolean;
  50588. module "babylonjs/scene" {
  50589. interface Scene {
  50590. /**
  50591. * Creates a default light for the scene.
  50592. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50593. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50594. */
  50595. createDefaultLight(replace?: boolean): void;
  50596. /**
  50597. * Creates a default camera for the scene.
  50598. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50599. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50600. * @param replace has default false, when true replaces the active camera in the scene
  50601. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50602. */
  50603. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50604. /**
  50605. * Creates a default camera and a default light.
  50606. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50607. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50608. * @param replace has the default false, when true replaces the active camera/light in the scene
  50609. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50610. */
  50611. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50612. /**
  50613. * Creates a new sky box
  50614. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50615. * @param environmentTexture defines the texture to use as environment texture
  50616. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50617. * @param scale defines the overall scale of the skybox
  50618. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50619. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50620. * @returns a new mesh holding the sky box
  50621. */
  50622. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50623. /**
  50624. * Creates a new environment
  50625. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50626. * @param options defines the options you can use to configure the environment
  50627. * @returns the new EnvironmentHelper
  50628. */
  50629. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50630. /**
  50631. * Creates a new VREXperienceHelper
  50632. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50633. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50634. * @returns a new VREXperienceHelper
  50635. */
  50636. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50637. /**
  50638. * Creates a new WebXRDefaultExperience
  50639. * @see http://doc.babylonjs.com/how_to/webxr
  50640. * @param options experience options
  50641. * @returns a promise for a new WebXRDefaultExperience
  50642. */
  50643. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50644. }
  50645. }
  50646. }
  50647. declare module "babylonjs/Helpers/videoDome" {
  50648. import { Scene } from "babylonjs/scene";
  50649. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50650. import { Mesh } from "babylonjs/Meshes/mesh";
  50651. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50652. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50653. import "babylonjs/Meshes/Builders/sphereBuilder";
  50654. /**
  50655. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50656. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50657. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50658. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50659. */
  50660. export class VideoDome extends TransformNode {
  50661. /**
  50662. * Define the video source as a Monoscopic panoramic 360 video.
  50663. */
  50664. static readonly MODE_MONOSCOPIC: number;
  50665. /**
  50666. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50667. */
  50668. static readonly MODE_TOPBOTTOM: number;
  50669. /**
  50670. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50671. */
  50672. static readonly MODE_SIDEBYSIDE: number;
  50673. private _halfDome;
  50674. private _useDirectMapping;
  50675. /**
  50676. * The video texture being displayed on the sphere
  50677. */
  50678. protected _videoTexture: VideoTexture;
  50679. /**
  50680. * Gets the video texture being displayed on the sphere
  50681. */
  50682. readonly videoTexture: VideoTexture;
  50683. /**
  50684. * The skybox material
  50685. */
  50686. protected _material: BackgroundMaterial;
  50687. /**
  50688. * The surface used for the skybox
  50689. */
  50690. protected _mesh: Mesh;
  50691. /**
  50692. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50693. */
  50694. private _halfDomeMask;
  50695. /**
  50696. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50697. * Also see the options.resolution property.
  50698. */
  50699. fovMultiplier: number;
  50700. private _videoMode;
  50701. /**
  50702. * Gets or set the current video mode for the video. It can be:
  50703. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50704. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50705. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50706. */
  50707. videoMode: number;
  50708. /**
  50709. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50710. *
  50711. */
  50712. /**
  50713. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50714. */
  50715. halfDome: boolean;
  50716. /**
  50717. * Oberserver used in Stereoscopic VR Mode.
  50718. */
  50719. private _onBeforeCameraRenderObserver;
  50720. /**
  50721. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50722. * @param name Element's name, child elements will append suffixes for their own names.
  50723. * @param urlsOrVideo defines the url(s) or the video element to use
  50724. * @param options An object containing optional or exposed sub element properties
  50725. */
  50726. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50727. resolution?: number;
  50728. clickToPlay?: boolean;
  50729. autoPlay?: boolean;
  50730. loop?: boolean;
  50731. size?: number;
  50732. poster?: string;
  50733. faceForward?: boolean;
  50734. useDirectMapping?: boolean;
  50735. halfDomeMode?: boolean;
  50736. }, scene: Scene);
  50737. private _changeVideoMode;
  50738. /**
  50739. * Releases resources associated with this node.
  50740. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50741. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50742. */
  50743. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50744. }
  50745. }
  50746. declare module "babylonjs/Helpers/index" {
  50747. export * from "babylonjs/Helpers/environmentHelper";
  50748. export * from "babylonjs/Helpers/photoDome";
  50749. export * from "babylonjs/Helpers/sceneHelpers";
  50750. export * from "babylonjs/Helpers/videoDome";
  50751. }
  50752. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50753. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50754. import { IDisposable } from "babylonjs/scene";
  50755. import { Engine } from "babylonjs/Engines/engine";
  50756. /**
  50757. * This class can be used to get instrumentation data from a Babylon engine
  50758. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50759. */
  50760. export class EngineInstrumentation implements IDisposable {
  50761. /**
  50762. * Define the instrumented engine.
  50763. */
  50764. engine: Engine;
  50765. private _captureGPUFrameTime;
  50766. private _gpuFrameTimeToken;
  50767. private _gpuFrameTime;
  50768. private _captureShaderCompilationTime;
  50769. private _shaderCompilationTime;
  50770. private _onBeginFrameObserver;
  50771. private _onEndFrameObserver;
  50772. private _onBeforeShaderCompilationObserver;
  50773. private _onAfterShaderCompilationObserver;
  50774. /**
  50775. * Gets the perf counter used for GPU frame time
  50776. */
  50777. readonly gpuFrameTimeCounter: PerfCounter;
  50778. /**
  50779. * Gets the GPU frame time capture status
  50780. */
  50781. /**
  50782. * Enable or disable the GPU frame time capture
  50783. */
  50784. captureGPUFrameTime: boolean;
  50785. /**
  50786. * Gets the perf counter used for shader compilation time
  50787. */
  50788. readonly shaderCompilationTimeCounter: PerfCounter;
  50789. /**
  50790. * Gets the shader compilation time capture status
  50791. */
  50792. /**
  50793. * Enable or disable the shader compilation time capture
  50794. */
  50795. captureShaderCompilationTime: boolean;
  50796. /**
  50797. * Instantiates a new engine instrumentation.
  50798. * This class can be used to get instrumentation data from a Babylon engine
  50799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50800. * @param engine Defines the engine to instrument
  50801. */
  50802. constructor(
  50803. /**
  50804. * Define the instrumented engine.
  50805. */
  50806. engine: Engine);
  50807. /**
  50808. * Dispose and release associated resources.
  50809. */
  50810. dispose(): void;
  50811. }
  50812. }
  50813. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50814. import { Scene, IDisposable } from "babylonjs/scene";
  50815. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50816. /**
  50817. * This class can be used to get instrumentation data from a Babylon engine
  50818. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50819. */
  50820. export class SceneInstrumentation implements IDisposable {
  50821. /**
  50822. * Defines the scene to instrument
  50823. */
  50824. scene: Scene;
  50825. private _captureActiveMeshesEvaluationTime;
  50826. private _activeMeshesEvaluationTime;
  50827. private _captureRenderTargetsRenderTime;
  50828. private _renderTargetsRenderTime;
  50829. private _captureFrameTime;
  50830. private _frameTime;
  50831. private _captureRenderTime;
  50832. private _renderTime;
  50833. private _captureInterFrameTime;
  50834. private _interFrameTime;
  50835. private _captureParticlesRenderTime;
  50836. private _particlesRenderTime;
  50837. private _captureSpritesRenderTime;
  50838. private _spritesRenderTime;
  50839. private _capturePhysicsTime;
  50840. private _physicsTime;
  50841. private _captureAnimationsTime;
  50842. private _animationsTime;
  50843. private _captureCameraRenderTime;
  50844. private _cameraRenderTime;
  50845. private _onBeforeActiveMeshesEvaluationObserver;
  50846. private _onAfterActiveMeshesEvaluationObserver;
  50847. private _onBeforeRenderTargetsRenderObserver;
  50848. private _onAfterRenderTargetsRenderObserver;
  50849. private _onAfterRenderObserver;
  50850. private _onBeforeDrawPhaseObserver;
  50851. private _onAfterDrawPhaseObserver;
  50852. private _onBeforeAnimationsObserver;
  50853. private _onBeforeParticlesRenderingObserver;
  50854. private _onAfterParticlesRenderingObserver;
  50855. private _onBeforeSpritesRenderingObserver;
  50856. private _onAfterSpritesRenderingObserver;
  50857. private _onBeforePhysicsObserver;
  50858. private _onAfterPhysicsObserver;
  50859. private _onAfterAnimationsObserver;
  50860. private _onBeforeCameraRenderObserver;
  50861. private _onAfterCameraRenderObserver;
  50862. /**
  50863. * Gets the perf counter used for active meshes evaluation time
  50864. */
  50865. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50866. /**
  50867. * Gets the active meshes evaluation time capture status
  50868. */
  50869. /**
  50870. * Enable or disable the active meshes evaluation time capture
  50871. */
  50872. captureActiveMeshesEvaluationTime: boolean;
  50873. /**
  50874. * Gets the perf counter used for render targets render time
  50875. */
  50876. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50877. /**
  50878. * Gets the render targets render time capture status
  50879. */
  50880. /**
  50881. * Enable or disable the render targets render time capture
  50882. */
  50883. captureRenderTargetsRenderTime: boolean;
  50884. /**
  50885. * Gets the perf counter used for particles render time
  50886. */
  50887. readonly particlesRenderTimeCounter: PerfCounter;
  50888. /**
  50889. * Gets the particles render time capture status
  50890. */
  50891. /**
  50892. * Enable or disable the particles render time capture
  50893. */
  50894. captureParticlesRenderTime: boolean;
  50895. /**
  50896. * Gets the perf counter used for sprites render time
  50897. */
  50898. readonly spritesRenderTimeCounter: PerfCounter;
  50899. /**
  50900. * Gets the sprites render time capture status
  50901. */
  50902. /**
  50903. * Enable or disable the sprites render time capture
  50904. */
  50905. captureSpritesRenderTime: boolean;
  50906. /**
  50907. * Gets the perf counter used for physics time
  50908. */
  50909. readonly physicsTimeCounter: PerfCounter;
  50910. /**
  50911. * Gets the physics time capture status
  50912. */
  50913. /**
  50914. * Enable or disable the physics time capture
  50915. */
  50916. capturePhysicsTime: boolean;
  50917. /**
  50918. * Gets the perf counter used for animations time
  50919. */
  50920. readonly animationsTimeCounter: PerfCounter;
  50921. /**
  50922. * Gets the animations time capture status
  50923. */
  50924. /**
  50925. * Enable or disable the animations time capture
  50926. */
  50927. captureAnimationsTime: boolean;
  50928. /**
  50929. * Gets the perf counter used for frame time capture
  50930. */
  50931. readonly frameTimeCounter: PerfCounter;
  50932. /**
  50933. * Gets the frame time capture status
  50934. */
  50935. /**
  50936. * Enable or disable the frame time capture
  50937. */
  50938. captureFrameTime: boolean;
  50939. /**
  50940. * Gets the perf counter used for inter-frames time capture
  50941. */
  50942. readonly interFrameTimeCounter: PerfCounter;
  50943. /**
  50944. * Gets the inter-frames time capture status
  50945. */
  50946. /**
  50947. * Enable or disable the inter-frames time capture
  50948. */
  50949. captureInterFrameTime: boolean;
  50950. /**
  50951. * Gets the perf counter used for render time capture
  50952. */
  50953. readonly renderTimeCounter: PerfCounter;
  50954. /**
  50955. * Gets the render time capture status
  50956. */
  50957. /**
  50958. * Enable or disable the render time capture
  50959. */
  50960. captureRenderTime: boolean;
  50961. /**
  50962. * Gets the perf counter used for camera render time capture
  50963. */
  50964. readonly cameraRenderTimeCounter: PerfCounter;
  50965. /**
  50966. * Gets the camera render time capture status
  50967. */
  50968. /**
  50969. * Enable or disable the camera render time capture
  50970. */
  50971. captureCameraRenderTime: boolean;
  50972. /**
  50973. * Gets the perf counter used for draw calls
  50974. */
  50975. readonly drawCallsCounter: PerfCounter;
  50976. /**
  50977. * Instantiates a new scene instrumentation.
  50978. * This class can be used to get instrumentation data from a Babylon engine
  50979. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50980. * @param scene Defines the scene to instrument
  50981. */
  50982. constructor(
  50983. /**
  50984. * Defines the scene to instrument
  50985. */
  50986. scene: Scene);
  50987. /**
  50988. * Dispose and release associated resources.
  50989. */
  50990. dispose(): void;
  50991. }
  50992. }
  50993. declare module "babylonjs/Instrumentation/index" {
  50994. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50995. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50996. export * from "babylonjs/Instrumentation/timeToken";
  50997. }
  50998. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50999. /** @hidden */
  51000. export var glowMapGenerationPixelShader: {
  51001. name: string;
  51002. shader: string;
  51003. };
  51004. }
  51005. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51006. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51009. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51010. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51013. /** @hidden */
  51014. export var glowMapGenerationVertexShader: {
  51015. name: string;
  51016. shader: string;
  51017. };
  51018. }
  51019. declare module "babylonjs/Layers/effectLayer" {
  51020. import { Observable } from "babylonjs/Misc/observable";
  51021. import { Nullable } from "babylonjs/types";
  51022. import { Camera } from "babylonjs/Cameras/camera";
  51023. import { Scene } from "babylonjs/scene";
  51024. import { ISize } from "babylonjs/Maths/math.size";
  51025. import { Color4 } from "babylonjs/Maths/math.color";
  51026. import { Engine } from "babylonjs/Engines/engine";
  51027. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51029. import { Mesh } from "babylonjs/Meshes/mesh";
  51030. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51033. import { Effect } from "babylonjs/Materials/effect";
  51034. import { Material } from "babylonjs/Materials/material";
  51035. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51036. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51037. /**
  51038. * Effect layer options. This helps customizing the behaviour
  51039. * of the effect layer.
  51040. */
  51041. export interface IEffectLayerOptions {
  51042. /**
  51043. * Multiplication factor apply to the canvas size to compute the render target size
  51044. * used to generated the objects (the smaller the faster).
  51045. */
  51046. mainTextureRatio: number;
  51047. /**
  51048. * Enforces a fixed size texture to ensure effect stability across devices.
  51049. */
  51050. mainTextureFixedSize?: number;
  51051. /**
  51052. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51053. */
  51054. alphaBlendingMode: number;
  51055. /**
  51056. * The camera attached to the layer.
  51057. */
  51058. camera: Nullable<Camera>;
  51059. /**
  51060. * The rendering group to draw the layer in.
  51061. */
  51062. renderingGroupId: number;
  51063. }
  51064. /**
  51065. * The effect layer Helps adding post process effect blended with the main pass.
  51066. *
  51067. * This can be for instance use to generate glow or higlight effects on the scene.
  51068. *
  51069. * The effect layer class can not be used directly and is intented to inherited from to be
  51070. * customized per effects.
  51071. */
  51072. export abstract class EffectLayer {
  51073. private _vertexBuffers;
  51074. private _indexBuffer;
  51075. private _cachedDefines;
  51076. private _effectLayerMapGenerationEffect;
  51077. private _effectLayerOptions;
  51078. private _mergeEffect;
  51079. protected _scene: Scene;
  51080. protected _engine: Engine;
  51081. protected _maxSize: number;
  51082. protected _mainTextureDesiredSize: ISize;
  51083. protected _mainTexture: RenderTargetTexture;
  51084. protected _shouldRender: boolean;
  51085. protected _postProcesses: PostProcess[];
  51086. protected _textures: BaseTexture[];
  51087. protected _emissiveTextureAndColor: {
  51088. texture: Nullable<BaseTexture>;
  51089. color: Color4;
  51090. };
  51091. /**
  51092. * The name of the layer
  51093. */
  51094. name: string;
  51095. /**
  51096. * The clear color of the texture used to generate the glow map.
  51097. */
  51098. neutralColor: Color4;
  51099. /**
  51100. * Specifies wether the highlight layer is enabled or not.
  51101. */
  51102. isEnabled: boolean;
  51103. /**
  51104. * Gets the camera attached to the layer.
  51105. */
  51106. readonly camera: Nullable<Camera>;
  51107. /**
  51108. * Gets the rendering group id the layer should render in.
  51109. */
  51110. renderingGroupId: number;
  51111. /**
  51112. * An event triggered when the effect layer has been disposed.
  51113. */
  51114. onDisposeObservable: Observable<EffectLayer>;
  51115. /**
  51116. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51117. */
  51118. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51119. /**
  51120. * An event triggered when the generated texture is being merged in the scene.
  51121. */
  51122. onBeforeComposeObservable: Observable<EffectLayer>;
  51123. /**
  51124. * An event triggered when the generated texture has been merged in the scene.
  51125. */
  51126. onAfterComposeObservable: Observable<EffectLayer>;
  51127. /**
  51128. * An event triggered when the efffect layer changes its size.
  51129. */
  51130. onSizeChangedObservable: Observable<EffectLayer>;
  51131. /** @hidden */
  51132. static _SceneComponentInitialization: (scene: Scene) => void;
  51133. /**
  51134. * Instantiates a new effect Layer and references it in the scene.
  51135. * @param name The name of the layer
  51136. * @param scene The scene to use the layer in
  51137. */
  51138. constructor(
  51139. /** The Friendly of the effect in the scene */
  51140. name: string, scene: Scene);
  51141. /**
  51142. * Get the effect name of the layer.
  51143. * @return The effect name
  51144. */
  51145. abstract getEffectName(): string;
  51146. /**
  51147. * Checks for the readiness of the element composing the layer.
  51148. * @param subMesh the mesh to check for
  51149. * @param useInstances specify wether or not to use instances to render the mesh
  51150. * @return true if ready otherwise, false
  51151. */
  51152. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51153. /**
  51154. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51155. * @returns true if the effect requires stencil during the main canvas render pass.
  51156. */
  51157. abstract needStencil(): boolean;
  51158. /**
  51159. * Create the merge effect. This is the shader use to blit the information back
  51160. * to the main canvas at the end of the scene rendering.
  51161. * @returns The effect containing the shader used to merge the effect on the main canvas
  51162. */
  51163. protected abstract _createMergeEffect(): Effect;
  51164. /**
  51165. * Creates the render target textures and post processes used in the effect layer.
  51166. */
  51167. protected abstract _createTextureAndPostProcesses(): void;
  51168. /**
  51169. * Implementation specific of rendering the generating effect on the main canvas.
  51170. * @param effect The effect used to render through
  51171. */
  51172. protected abstract _internalRender(effect: Effect): void;
  51173. /**
  51174. * Sets the required values for both the emissive texture and and the main color.
  51175. */
  51176. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51177. /**
  51178. * Free any resources and references associated to a mesh.
  51179. * Internal use
  51180. * @param mesh The mesh to free.
  51181. */
  51182. abstract _disposeMesh(mesh: Mesh): void;
  51183. /**
  51184. * Serializes this layer (Glow or Highlight for example)
  51185. * @returns a serialized layer object
  51186. */
  51187. abstract serialize?(): any;
  51188. /**
  51189. * Initializes the effect layer with the required options.
  51190. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51191. */
  51192. protected _init(options: Partial<IEffectLayerOptions>): void;
  51193. /**
  51194. * Generates the index buffer of the full screen quad blending to the main canvas.
  51195. */
  51196. private _generateIndexBuffer;
  51197. /**
  51198. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51199. */
  51200. private _generateVertexBuffer;
  51201. /**
  51202. * Sets the main texture desired size which is the closest power of two
  51203. * of the engine canvas size.
  51204. */
  51205. private _setMainTextureSize;
  51206. /**
  51207. * Creates the main texture for the effect layer.
  51208. */
  51209. protected _createMainTexture(): void;
  51210. /**
  51211. * Adds specific effects defines.
  51212. * @param defines The defines to add specifics to.
  51213. */
  51214. protected _addCustomEffectDefines(defines: string[]): void;
  51215. /**
  51216. * Checks for the readiness of the element composing the layer.
  51217. * @param subMesh the mesh to check for
  51218. * @param useInstances specify wether or not to use instances to render the mesh
  51219. * @param emissiveTexture the associated emissive texture used to generate the glow
  51220. * @return true if ready otherwise, false
  51221. */
  51222. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51223. /**
  51224. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51225. */
  51226. render(): void;
  51227. /**
  51228. * Determine if a given mesh will be used in the current effect.
  51229. * @param mesh mesh to test
  51230. * @returns true if the mesh will be used
  51231. */
  51232. hasMesh(mesh: AbstractMesh): boolean;
  51233. /**
  51234. * Returns true if the layer contains information to display, otherwise false.
  51235. * @returns true if the glow layer should be rendered
  51236. */
  51237. shouldRender(): boolean;
  51238. /**
  51239. * Returns true if the mesh should render, otherwise false.
  51240. * @param mesh The mesh to render
  51241. * @returns true if it should render otherwise false
  51242. */
  51243. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51244. /**
  51245. * Returns true if the mesh can be rendered, otherwise false.
  51246. * @param mesh The mesh to render
  51247. * @param material The material used on the mesh
  51248. * @returns true if it can be rendered otherwise false
  51249. */
  51250. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51251. /**
  51252. * Returns true if the mesh should render, otherwise false.
  51253. * @param mesh The mesh to render
  51254. * @returns true if it should render otherwise false
  51255. */
  51256. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51257. /**
  51258. * Renders the submesh passed in parameter to the generation map.
  51259. */
  51260. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51261. /**
  51262. * Rebuild the required buffers.
  51263. * @hidden Internal use only.
  51264. */
  51265. _rebuild(): void;
  51266. /**
  51267. * Dispose only the render target textures and post process.
  51268. */
  51269. private _disposeTextureAndPostProcesses;
  51270. /**
  51271. * Dispose the highlight layer and free resources.
  51272. */
  51273. dispose(): void;
  51274. /**
  51275. * Gets the class name of the effect layer
  51276. * @returns the string with the class name of the effect layer
  51277. */
  51278. getClassName(): string;
  51279. /**
  51280. * Creates an effect layer from parsed effect layer data
  51281. * @param parsedEffectLayer defines effect layer data
  51282. * @param scene defines the current scene
  51283. * @param rootUrl defines the root URL containing the effect layer information
  51284. * @returns a parsed effect Layer
  51285. */
  51286. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51287. }
  51288. }
  51289. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51290. import { Scene } from "babylonjs/scene";
  51291. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51292. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51293. import { AbstractScene } from "babylonjs/abstractScene";
  51294. module "babylonjs/abstractScene" {
  51295. interface AbstractScene {
  51296. /**
  51297. * The list of effect layers (highlights/glow) added to the scene
  51298. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51299. * @see http://doc.babylonjs.com/how_to/glow_layer
  51300. */
  51301. effectLayers: Array<EffectLayer>;
  51302. /**
  51303. * Removes the given effect layer from this scene.
  51304. * @param toRemove defines the effect layer to remove
  51305. * @returns the index of the removed effect layer
  51306. */
  51307. removeEffectLayer(toRemove: EffectLayer): number;
  51308. /**
  51309. * Adds the given effect layer to this scene
  51310. * @param newEffectLayer defines the effect layer to add
  51311. */
  51312. addEffectLayer(newEffectLayer: EffectLayer): void;
  51313. }
  51314. }
  51315. /**
  51316. * Defines the layer scene component responsible to manage any effect layers
  51317. * in a given scene.
  51318. */
  51319. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51320. /**
  51321. * The component name helpfull to identify the component in the list of scene components.
  51322. */
  51323. readonly name: string;
  51324. /**
  51325. * The scene the component belongs to.
  51326. */
  51327. scene: Scene;
  51328. private _engine;
  51329. private _renderEffects;
  51330. private _needStencil;
  51331. private _previousStencilState;
  51332. /**
  51333. * Creates a new instance of the component for the given scene
  51334. * @param scene Defines the scene to register the component in
  51335. */
  51336. constructor(scene: Scene);
  51337. /**
  51338. * Registers the component in a given scene
  51339. */
  51340. register(): void;
  51341. /**
  51342. * Rebuilds the elements related to this component in case of
  51343. * context lost for instance.
  51344. */
  51345. rebuild(): void;
  51346. /**
  51347. * Serializes the component data to the specified json object
  51348. * @param serializationObject The object to serialize to
  51349. */
  51350. serialize(serializationObject: any): void;
  51351. /**
  51352. * Adds all the elements from the container to the scene
  51353. * @param container the container holding the elements
  51354. */
  51355. addFromContainer(container: AbstractScene): void;
  51356. /**
  51357. * Removes all the elements in the container from the scene
  51358. * @param container contains the elements to remove
  51359. * @param dispose if the removed element should be disposed (default: false)
  51360. */
  51361. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51362. /**
  51363. * Disposes the component and the associated ressources.
  51364. */
  51365. dispose(): void;
  51366. private _isReadyForMesh;
  51367. private _renderMainTexture;
  51368. private _setStencil;
  51369. private _setStencilBack;
  51370. private _draw;
  51371. private _drawCamera;
  51372. private _drawRenderingGroup;
  51373. }
  51374. }
  51375. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51376. /** @hidden */
  51377. export var glowMapMergePixelShader: {
  51378. name: string;
  51379. shader: string;
  51380. };
  51381. }
  51382. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51383. /** @hidden */
  51384. export var glowMapMergeVertexShader: {
  51385. name: string;
  51386. shader: string;
  51387. };
  51388. }
  51389. declare module "babylonjs/Layers/glowLayer" {
  51390. import { Nullable } from "babylonjs/types";
  51391. import { Camera } from "babylonjs/Cameras/camera";
  51392. import { Scene } from "babylonjs/scene";
  51393. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51395. import { Mesh } from "babylonjs/Meshes/mesh";
  51396. import { Texture } from "babylonjs/Materials/Textures/texture";
  51397. import { Effect } from "babylonjs/Materials/effect";
  51398. import { Material } from "babylonjs/Materials/material";
  51399. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51400. import { Color4 } from "babylonjs/Maths/math.color";
  51401. import "babylonjs/Shaders/glowMapMerge.fragment";
  51402. import "babylonjs/Shaders/glowMapMerge.vertex";
  51403. import "babylonjs/Layers/effectLayerSceneComponent";
  51404. module "babylonjs/abstractScene" {
  51405. interface AbstractScene {
  51406. /**
  51407. * Return a the first highlight layer of the scene with a given name.
  51408. * @param name The name of the highlight layer to look for.
  51409. * @return The highlight layer if found otherwise null.
  51410. */
  51411. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51412. }
  51413. }
  51414. /**
  51415. * Glow layer options. This helps customizing the behaviour
  51416. * of the glow layer.
  51417. */
  51418. export interface IGlowLayerOptions {
  51419. /**
  51420. * Multiplication factor apply to the canvas size to compute the render target size
  51421. * used to generated the glowing objects (the smaller the faster).
  51422. */
  51423. mainTextureRatio: number;
  51424. /**
  51425. * Enforces a fixed size texture to ensure resize independant blur.
  51426. */
  51427. mainTextureFixedSize?: number;
  51428. /**
  51429. * How big is the kernel of the blur texture.
  51430. */
  51431. blurKernelSize: number;
  51432. /**
  51433. * The camera attached to the layer.
  51434. */
  51435. camera: Nullable<Camera>;
  51436. /**
  51437. * Enable MSAA by chosing the number of samples.
  51438. */
  51439. mainTextureSamples?: number;
  51440. /**
  51441. * The rendering group to draw the layer in.
  51442. */
  51443. renderingGroupId: number;
  51444. }
  51445. /**
  51446. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51447. *
  51448. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51449. * glowy meshes to your scene.
  51450. *
  51451. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51452. */
  51453. export class GlowLayer extends EffectLayer {
  51454. /**
  51455. * Effect Name of the layer.
  51456. */
  51457. static readonly EffectName: string;
  51458. /**
  51459. * The default blur kernel size used for the glow.
  51460. */
  51461. static DefaultBlurKernelSize: number;
  51462. /**
  51463. * The default texture size ratio used for the glow.
  51464. */
  51465. static DefaultTextureRatio: number;
  51466. /**
  51467. * Sets the kernel size of the blur.
  51468. */
  51469. /**
  51470. * Gets the kernel size of the blur.
  51471. */
  51472. blurKernelSize: number;
  51473. /**
  51474. * Sets the glow intensity.
  51475. */
  51476. /**
  51477. * Gets the glow intensity.
  51478. */
  51479. intensity: number;
  51480. private _options;
  51481. private _intensity;
  51482. private _horizontalBlurPostprocess1;
  51483. private _verticalBlurPostprocess1;
  51484. private _horizontalBlurPostprocess2;
  51485. private _verticalBlurPostprocess2;
  51486. private _blurTexture1;
  51487. private _blurTexture2;
  51488. private _postProcesses1;
  51489. private _postProcesses2;
  51490. private _includedOnlyMeshes;
  51491. private _excludedMeshes;
  51492. /**
  51493. * Callback used to let the user override the color selection on a per mesh basis
  51494. */
  51495. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51496. /**
  51497. * Callback used to let the user override the texture selection on a per mesh basis
  51498. */
  51499. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51500. /**
  51501. * Instantiates a new glow Layer and references it to the scene.
  51502. * @param name The name of the layer
  51503. * @param scene The scene to use the layer in
  51504. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51505. */
  51506. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51507. /**
  51508. * Get the effect name of the layer.
  51509. * @return The effect name
  51510. */
  51511. getEffectName(): string;
  51512. /**
  51513. * Create the merge effect. This is the shader use to blit the information back
  51514. * to the main canvas at the end of the scene rendering.
  51515. */
  51516. protected _createMergeEffect(): Effect;
  51517. /**
  51518. * Creates the render target textures and post processes used in the glow layer.
  51519. */
  51520. protected _createTextureAndPostProcesses(): void;
  51521. /**
  51522. * Checks for the readiness of the element composing the layer.
  51523. * @param subMesh the mesh to check for
  51524. * @param useInstances specify wether or not to use instances to render the mesh
  51525. * @param emissiveTexture the associated emissive texture used to generate the glow
  51526. * @return true if ready otherwise, false
  51527. */
  51528. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51529. /**
  51530. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51531. */
  51532. needStencil(): boolean;
  51533. /**
  51534. * Returns true if the mesh can be rendered, otherwise false.
  51535. * @param mesh The mesh to render
  51536. * @param material The material used on the mesh
  51537. * @returns true if it can be rendered otherwise false
  51538. */
  51539. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51540. /**
  51541. * Implementation specific of rendering the generating effect on the main canvas.
  51542. * @param effect The effect used to render through
  51543. */
  51544. protected _internalRender(effect: Effect): void;
  51545. /**
  51546. * Sets the required values for both the emissive texture and and the main color.
  51547. */
  51548. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51549. /**
  51550. * Returns true if the mesh should render, otherwise false.
  51551. * @param mesh The mesh to render
  51552. * @returns true if it should render otherwise false
  51553. */
  51554. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51555. /**
  51556. * Adds specific effects defines.
  51557. * @param defines The defines to add specifics to.
  51558. */
  51559. protected _addCustomEffectDefines(defines: string[]): void;
  51560. /**
  51561. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51562. * @param mesh The mesh to exclude from the glow layer
  51563. */
  51564. addExcludedMesh(mesh: Mesh): void;
  51565. /**
  51566. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51567. * @param mesh The mesh to remove
  51568. */
  51569. removeExcludedMesh(mesh: Mesh): void;
  51570. /**
  51571. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51572. * @param mesh The mesh to include in the glow layer
  51573. */
  51574. addIncludedOnlyMesh(mesh: Mesh): void;
  51575. /**
  51576. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51577. * @param mesh The mesh to remove
  51578. */
  51579. removeIncludedOnlyMesh(mesh: Mesh): void;
  51580. /**
  51581. * Determine if a given mesh will be used in the glow layer
  51582. * @param mesh The mesh to test
  51583. * @returns true if the mesh will be highlighted by the current glow layer
  51584. */
  51585. hasMesh(mesh: AbstractMesh): boolean;
  51586. /**
  51587. * Free any resources and references associated to a mesh.
  51588. * Internal use
  51589. * @param mesh The mesh to free.
  51590. * @hidden
  51591. */
  51592. _disposeMesh(mesh: Mesh): void;
  51593. /**
  51594. * Gets the class name of the effect layer
  51595. * @returns the string with the class name of the effect layer
  51596. */
  51597. getClassName(): string;
  51598. /**
  51599. * Serializes this glow layer
  51600. * @returns a serialized glow layer object
  51601. */
  51602. serialize(): any;
  51603. /**
  51604. * Creates a Glow Layer from parsed glow layer data
  51605. * @param parsedGlowLayer defines glow layer data
  51606. * @param scene defines the current scene
  51607. * @param rootUrl defines the root URL containing the glow layer information
  51608. * @returns a parsed Glow Layer
  51609. */
  51610. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51611. }
  51612. }
  51613. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51614. /** @hidden */
  51615. export var glowBlurPostProcessPixelShader: {
  51616. name: string;
  51617. shader: string;
  51618. };
  51619. }
  51620. declare module "babylonjs/Layers/highlightLayer" {
  51621. import { Observable } from "babylonjs/Misc/observable";
  51622. import { Nullable } from "babylonjs/types";
  51623. import { Camera } from "babylonjs/Cameras/camera";
  51624. import { Scene } from "babylonjs/scene";
  51625. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51627. import { Mesh } from "babylonjs/Meshes/mesh";
  51628. import { Effect } from "babylonjs/Materials/effect";
  51629. import { Material } from "babylonjs/Materials/material";
  51630. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51631. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51632. import "babylonjs/Shaders/glowMapMerge.fragment";
  51633. import "babylonjs/Shaders/glowMapMerge.vertex";
  51634. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51635. module "babylonjs/abstractScene" {
  51636. interface AbstractScene {
  51637. /**
  51638. * Return a the first highlight layer of the scene with a given name.
  51639. * @param name The name of the highlight layer to look for.
  51640. * @return The highlight layer if found otherwise null.
  51641. */
  51642. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51643. }
  51644. }
  51645. /**
  51646. * Highlight layer options. This helps customizing the behaviour
  51647. * of the highlight layer.
  51648. */
  51649. export interface IHighlightLayerOptions {
  51650. /**
  51651. * Multiplication factor apply to the canvas size to compute the render target size
  51652. * used to generated the glowing objects (the smaller the faster).
  51653. */
  51654. mainTextureRatio: number;
  51655. /**
  51656. * Enforces a fixed size texture to ensure resize independant blur.
  51657. */
  51658. mainTextureFixedSize?: number;
  51659. /**
  51660. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51661. * of the picture to blur (the smaller the faster).
  51662. */
  51663. blurTextureSizeRatio: number;
  51664. /**
  51665. * How big in texel of the blur texture is the vertical blur.
  51666. */
  51667. blurVerticalSize: number;
  51668. /**
  51669. * How big in texel of the blur texture is the horizontal blur.
  51670. */
  51671. blurHorizontalSize: number;
  51672. /**
  51673. * Alpha blending mode used to apply the blur. Default is combine.
  51674. */
  51675. alphaBlendingMode: number;
  51676. /**
  51677. * The camera attached to the layer.
  51678. */
  51679. camera: Nullable<Camera>;
  51680. /**
  51681. * Should we display highlight as a solid stroke?
  51682. */
  51683. isStroke?: boolean;
  51684. /**
  51685. * The rendering group to draw the layer in.
  51686. */
  51687. renderingGroupId: number;
  51688. }
  51689. /**
  51690. * The highlight layer Helps adding a glow effect around a mesh.
  51691. *
  51692. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51693. * glowy meshes to your scene.
  51694. *
  51695. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51696. */
  51697. export class HighlightLayer extends EffectLayer {
  51698. name: string;
  51699. /**
  51700. * Effect Name of the highlight layer.
  51701. */
  51702. static readonly EffectName: string;
  51703. /**
  51704. * The neutral color used during the preparation of the glow effect.
  51705. * This is black by default as the blend operation is a blend operation.
  51706. */
  51707. static NeutralColor: Color4;
  51708. /**
  51709. * Stencil value used for glowing meshes.
  51710. */
  51711. static GlowingMeshStencilReference: number;
  51712. /**
  51713. * Stencil value used for the other meshes in the scene.
  51714. */
  51715. static NormalMeshStencilReference: number;
  51716. /**
  51717. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51718. */
  51719. innerGlow: boolean;
  51720. /**
  51721. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51722. */
  51723. outerGlow: boolean;
  51724. /**
  51725. * Specifies the horizontal size of the blur.
  51726. */
  51727. /**
  51728. * Gets the horizontal size of the blur.
  51729. */
  51730. blurHorizontalSize: number;
  51731. /**
  51732. * Specifies the vertical size of the blur.
  51733. */
  51734. /**
  51735. * Gets the vertical size of the blur.
  51736. */
  51737. blurVerticalSize: number;
  51738. /**
  51739. * An event triggered when the highlight layer is being blurred.
  51740. */
  51741. onBeforeBlurObservable: Observable<HighlightLayer>;
  51742. /**
  51743. * An event triggered when the highlight layer has been blurred.
  51744. */
  51745. onAfterBlurObservable: Observable<HighlightLayer>;
  51746. private _instanceGlowingMeshStencilReference;
  51747. private _options;
  51748. private _downSamplePostprocess;
  51749. private _horizontalBlurPostprocess;
  51750. private _verticalBlurPostprocess;
  51751. private _blurTexture;
  51752. private _meshes;
  51753. private _excludedMeshes;
  51754. /**
  51755. * Instantiates a new highlight Layer and references it to the scene..
  51756. * @param name The name of the layer
  51757. * @param scene The scene to use the layer in
  51758. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51759. */
  51760. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51761. /**
  51762. * Get the effect name of the layer.
  51763. * @return The effect name
  51764. */
  51765. getEffectName(): string;
  51766. /**
  51767. * Create the merge effect. This is the shader use to blit the information back
  51768. * to the main canvas at the end of the scene rendering.
  51769. */
  51770. protected _createMergeEffect(): Effect;
  51771. /**
  51772. * Creates the render target textures and post processes used in the highlight layer.
  51773. */
  51774. protected _createTextureAndPostProcesses(): void;
  51775. /**
  51776. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51777. */
  51778. needStencil(): boolean;
  51779. /**
  51780. * Checks for the readiness of the element composing the layer.
  51781. * @param subMesh the mesh to check for
  51782. * @param useInstances specify wether or not to use instances to render the mesh
  51783. * @param emissiveTexture the associated emissive texture used to generate the glow
  51784. * @return true if ready otherwise, false
  51785. */
  51786. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51787. /**
  51788. * Implementation specific of rendering the generating effect on the main canvas.
  51789. * @param effect The effect used to render through
  51790. */
  51791. protected _internalRender(effect: Effect): void;
  51792. /**
  51793. * Returns true if the layer contains information to display, otherwise false.
  51794. */
  51795. shouldRender(): boolean;
  51796. /**
  51797. * Returns true if the mesh should render, otherwise false.
  51798. * @param mesh The mesh to render
  51799. * @returns true if it should render otherwise false
  51800. */
  51801. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51802. /**
  51803. * Sets the required values for both the emissive texture and and the main color.
  51804. */
  51805. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51806. /**
  51807. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51808. * @param mesh The mesh to exclude from the highlight layer
  51809. */
  51810. addExcludedMesh(mesh: Mesh): void;
  51811. /**
  51812. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51813. * @param mesh The mesh to highlight
  51814. */
  51815. removeExcludedMesh(mesh: Mesh): void;
  51816. /**
  51817. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51818. * @param mesh mesh to test
  51819. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51820. */
  51821. hasMesh(mesh: AbstractMesh): boolean;
  51822. /**
  51823. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51824. * @param mesh The mesh to highlight
  51825. * @param color The color of the highlight
  51826. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51827. */
  51828. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51829. /**
  51830. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51831. * @param mesh The mesh to highlight
  51832. */
  51833. removeMesh(mesh: Mesh): void;
  51834. /**
  51835. * Force the stencil to the normal expected value for none glowing parts
  51836. */
  51837. private _defaultStencilReference;
  51838. /**
  51839. * Free any resources and references associated to a mesh.
  51840. * Internal use
  51841. * @param mesh The mesh to free.
  51842. * @hidden
  51843. */
  51844. _disposeMesh(mesh: Mesh): void;
  51845. /**
  51846. * Dispose the highlight layer and free resources.
  51847. */
  51848. dispose(): void;
  51849. /**
  51850. * Gets the class name of the effect layer
  51851. * @returns the string with the class name of the effect layer
  51852. */
  51853. getClassName(): string;
  51854. /**
  51855. * Serializes this Highlight layer
  51856. * @returns a serialized Highlight layer object
  51857. */
  51858. serialize(): any;
  51859. /**
  51860. * Creates a Highlight layer from parsed Highlight layer data
  51861. * @param parsedHightlightLayer defines the Highlight layer data
  51862. * @param scene defines the current scene
  51863. * @param rootUrl defines the root URL containing the Highlight layer information
  51864. * @returns a parsed Highlight layer
  51865. */
  51866. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51867. }
  51868. }
  51869. declare module "babylonjs/Layers/layerSceneComponent" {
  51870. import { Scene } from "babylonjs/scene";
  51871. import { ISceneComponent } from "babylonjs/sceneComponent";
  51872. import { Layer } from "babylonjs/Layers/layer";
  51873. import { AbstractScene } from "babylonjs/abstractScene";
  51874. module "babylonjs/abstractScene" {
  51875. interface AbstractScene {
  51876. /**
  51877. * The list of layers (background and foreground) of the scene
  51878. */
  51879. layers: Array<Layer>;
  51880. }
  51881. }
  51882. /**
  51883. * Defines the layer scene component responsible to manage any layers
  51884. * in a given scene.
  51885. */
  51886. export class LayerSceneComponent implements ISceneComponent {
  51887. /**
  51888. * The component name helpfull to identify the component in the list of scene components.
  51889. */
  51890. readonly name: string;
  51891. /**
  51892. * The scene the component belongs to.
  51893. */
  51894. scene: Scene;
  51895. private _engine;
  51896. /**
  51897. * Creates a new instance of the component for the given scene
  51898. * @param scene Defines the scene to register the component in
  51899. */
  51900. constructor(scene: Scene);
  51901. /**
  51902. * Registers the component in a given scene
  51903. */
  51904. register(): void;
  51905. /**
  51906. * Rebuilds the elements related to this component in case of
  51907. * context lost for instance.
  51908. */
  51909. rebuild(): void;
  51910. /**
  51911. * Disposes the component and the associated ressources.
  51912. */
  51913. dispose(): void;
  51914. private _draw;
  51915. private _drawCameraPredicate;
  51916. private _drawCameraBackground;
  51917. private _drawCameraForeground;
  51918. private _drawRenderTargetPredicate;
  51919. private _drawRenderTargetBackground;
  51920. private _drawRenderTargetForeground;
  51921. /**
  51922. * Adds all the elements from the container to the scene
  51923. * @param container the container holding the elements
  51924. */
  51925. addFromContainer(container: AbstractScene): void;
  51926. /**
  51927. * Removes all the elements in the container from the scene
  51928. * @param container contains the elements to remove
  51929. * @param dispose if the removed element should be disposed (default: false)
  51930. */
  51931. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51932. }
  51933. }
  51934. declare module "babylonjs/Shaders/layer.fragment" {
  51935. /** @hidden */
  51936. export var layerPixelShader: {
  51937. name: string;
  51938. shader: string;
  51939. };
  51940. }
  51941. declare module "babylonjs/Shaders/layer.vertex" {
  51942. /** @hidden */
  51943. export var layerVertexShader: {
  51944. name: string;
  51945. shader: string;
  51946. };
  51947. }
  51948. declare module "babylonjs/Layers/layer" {
  51949. import { Observable } from "babylonjs/Misc/observable";
  51950. import { Nullable } from "babylonjs/types";
  51951. import { Scene } from "babylonjs/scene";
  51952. import { Vector2 } from "babylonjs/Maths/math.vector";
  51953. import { Color4 } from "babylonjs/Maths/math.color";
  51954. import { Texture } from "babylonjs/Materials/Textures/texture";
  51955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51956. import "babylonjs/Shaders/layer.fragment";
  51957. import "babylonjs/Shaders/layer.vertex";
  51958. /**
  51959. * This represents a full screen 2d layer.
  51960. * This can be useful to display a picture in the background of your scene for instance.
  51961. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51962. */
  51963. export class Layer {
  51964. /**
  51965. * Define the name of the layer.
  51966. */
  51967. name: string;
  51968. /**
  51969. * Define the texture the layer should display.
  51970. */
  51971. texture: Nullable<Texture>;
  51972. /**
  51973. * Is the layer in background or foreground.
  51974. */
  51975. isBackground: boolean;
  51976. /**
  51977. * Define the color of the layer (instead of texture).
  51978. */
  51979. color: Color4;
  51980. /**
  51981. * Define the scale of the layer in order to zoom in out of the texture.
  51982. */
  51983. scale: Vector2;
  51984. /**
  51985. * Define an offset for the layer in order to shift the texture.
  51986. */
  51987. offset: Vector2;
  51988. /**
  51989. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51990. */
  51991. alphaBlendingMode: number;
  51992. /**
  51993. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51994. * Alpha test will not mix with the background color in case of transparency.
  51995. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51996. */
  51997. alphaTest: boolean;
  51998. /**
  51999. * Define a mask to restrict the layer to only some of the scene cameras.
  52000. */
  52001. layerMask: number;
  52002. /**
  52003. * Define the list of render target the layer is visible into.
  52004. */
  52005. renderTargetTextures: RenderTargetTexture[];
  52006. /**
  52007. * Define if the layer is only used in renderTarget or if it also
  52008. * renders in the main frame buffer of the canvas.
  52009. */
  52010. renderOnlyInRenderTargetTextures: boolean;
  52011. private _scene;
  52012. private _vertexBuffers;
  52013. private _indexBuffer;
  52014. private _effect;
  52015. private _alphaTestEffect;
  52016. /**
  52017. * An event triggered when the layer is disposed.
  52018. */
  52019. onDisposeObservable: Observable<Layer>;
  52020. private _onDisposeObserver;
  52021. /**
  52022. * Back compatibility with callback before the onDisposeObservable existed.
  52023. * The set callback will be triggered when the layer has been disposed.
  52024. */
  52025. onDispose: () => void;
  52026. /**
  52027. * An event triggered before rendering the scene
  52028. */
  52029. onBeforeRenderObservable: Observable<Layer>;
  52030. private _onBeforeRenderObserver;
  52031. /**
  52032. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52033. * The set callback will be triggered just before rendering the layer.
  52034. */
  52035. onBeforeRender: () => void;
  52036. /**
  52037. * An event triggered after rendering the scene
  52038. */
  52039. onAfterRenderObservable: Observable<Layer>;
  52040. private _onAfterRenderObserver;
  52041. /**
  52042. * Back compatibility with callback before the onAfterRenderObservable existed.
  52043. * The set callback will be triggered just after rendering the layer.
  52044. */
  52045. onAfterRender: () => void;
  52046. /**
  52047. * Instantiates a new layer.
  52048. * This represents a full screen 2d layer.
  52049. * This can be useful to display a picture in the background of your scene for instance.
  52050. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52051. * @param name Define the name of the layer in the scene
  52052. * @param imgUrl Define the url of the texture to display in the layer
  52053. * @param scene Define the scene the layer belongs to
  52054. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52055. * @param color Defines a color for the layer
  52056. */
  52057. constructor(
  52058. /**
  52059. * Define the name of the layer.
  52060. */
  52061. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52062. private _createIndexBuffer;
  52063. /** @hidden */
  52064. _rebuild(): void;
  52065. /**
  52066. * Renders the layer in the scene.
  52067. */
  52068. render(): void;
  52069. /**
  52070. * Disposes and releases the associated ressources.
  52071. */
  52072. dispose(): void;
  52073. }
  52074. }
  52075. declare module "babylonjs/Layers/index" {
  52076. export * from "babylonjs/Layers/effectLayer";
  52077. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52078. export * from "babylonjs/Layers/glowLayer";
  52079. export * from "babylonjs/Layers/highlightLayer";
  52080. export * from "babylonjs/Layers/layer";
  52081. export * from "babylonjs/Layers/layerSceneComponent";
  52082. }
  52083. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52084. /** @hidden */
  52085. export var lensFlarePixelShader: {
  52086. name: string;
  52087. shader: string;
  52088. };
  52089. }
  52090. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52091. /** @hidden */
  52092. export var lensFlareVertexShader: {
  52093. name: string;
  52094. shader: string;
  52095. };
  52096. }
  52097. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52098. import { Scene } from "babylonjs/scene";
  52099. import { Vector3 } from "babylonjs/Maths/math.vector";
  52100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52101. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52102. import "babylonjs/Shaders/lensFlare.fragment";
  52103. import "babylonjs/Shaders/lensFlare.vertex";
  52104. import { Viewport } from "babylonjs/Maths/math.viewport";
  52105. /**
  52106. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52107. * It is usually composed of several `lensFlare`.
  52108. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52109. */
  52110. export class LensFlareSystem {
  52111. /**
  52112. * Define the name of the lens flare system
  52113. */
  52114. name: string;
  52115. /**
  52116. * List of lens flares used in this system.
  52117. */
  52118. lensFlares: LensFlare[];
  52119. /**
  52120. * Define a limit from the border the lens flare can be visible.
  52121. */
  52122. borderLimit: number;
  52123. /**
  52124. * Define a viewport border we do not want to see the lens flare in.
  52125. */
  52126. viewportBorder: number;
  52127. /**
  52128. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52129. */
  52130. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52131. /**
  52132. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52133. */
  52134. layerMask: number;
  52135. /**
  52136. * Define the id of the lens flare system in the scene.
  52137. * (equal to name by default)
  52138. */
  52139. id: string;
  52140. private _scene;
  52141. private _emitter;
  52142. private _vertexBuffers;
  52143. private _indexBuffer;
  52144. private _effect;
  52145. private _positionX;
  52146. private _positionY;
  52147. private _isEnabled;
  52148. /** @hidden */
  52149. static _SceneComponentInitialization: (scene: Scene) => void;
  52150. /**
  52151. * Instantiates a lens flare system.
  52152. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52153. * It is usually composed of several `lensFlare`.
  52154. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52155. * @param name Define the name of the lens flare system in the scene
  52156. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52157. * @param scene Define the scene the lens flare system belongs to
  52158. */
  52159. constructor(
  52160. /**
  52161. * Define the name of the lens flare system
  52162. */
  52163. name: string, emitter: any, scene: Scene);
  52164. /**
  52165. * Define if the lens flare system is enabled.
  52166. */
  52167. isEnabled: boolean;
  52168. /**
  52169. * Get the scene the effects belongs to.
  52170. * @returns the scene holding the lens flare system
  52171. */
  52172. getScene(): Scene;
  52173. /**
  52174. * Get the emitter of the lens flare system.
  52175. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52176. * @returns the emitter of the lens flare system
  52177. */
  52178. getEmitter(): any;
  52179. /**
  52180. * Set the emitter of the lens flare system.
  52181. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52182. * @param newEmitter Define the new emitter of the system
  52183. */
  52184. setEmitter(newEmitter: any): void;
  52185. /**
  52186. * Get the lens flare system emitter position.
  52187. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52188. * @returns the position
  52189. */
  52190. getEmitterPosition(): Vector3;
  52191. /**
  52192. * @hidden
  52193. */
  52194. computeEffectivePosition(globalViewport: Viewport): boolean;
  52195. /** @hidden */
  52196. _isVisible(): boolean;
  52197. /**
  52198. * @hidden
  52199. */
  52200. render(): boolean;
  52201. /**
  52202. * Dispose and release the lens flare with its associated resources.
  52203. */
  52204. dispose(): void;
  52205. /**
  52206. * Parse a lens flare system from a JSON repressentation
  52207. * @param parsedLensFlareSystem Define the JSON to parse
  52208. * @param scene Define the scene the parsed system should be instantiated in
  52209. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52210. * @returns the parsed system
  52211. */
  52212. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52213. /**
  52214. * Serialize the current Lens Flare System into a JSON representation.
  52215. * @returns the serialized JSON
  52216. */
  52217. serialize(): any;
  52218. }
  52219. }
  52220. declare module "babylonjs/LensFlares/lensFlare" {
  52221. import { Nullable } from "babylonjs/types";
  52222. import { Color3 } from "babylonjs/Maths/math.color";
  52223. import { Texture } from "babylonjs/Materials/Textures/texture";
  52224. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52225. /**
  52226. * This represents one of the lens effect in a `lensFlareSystem`.
  52227. * It controls one of the indiviual texture used in the effect.
  52228. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52229. */
  52230. export class LensFlare {
  52231. /**
  52232. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52233. */
  52234. size: number;
  52235. /**
  52236. * 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.
  52237. */
  52238. position: number;
  52239. /**
  52240. * Define the lens color.
  52241. */
  52242. color: Color3;
  52243. /**
  52244. * Define the lens texture.
  52245. */
  52246. texture: Nullable<Texture>;
  52247. /**
  52248. * Define the alpha mode to render this particular lens.
  52249. */
  52250. alphaMode: number;
  52251. private _system;
  52252. /**
  52253. * Creates a new Lens Flare.
  52254. * This represents one of the lens effect in a `lensFlareSystem`.
  52255. * It controls one of the indiviual texture used in the effect.
  52256. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52257. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52258. * @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.
  52259. * @param color Define the lens color
  52260. * @param imgUrl Define the lens texture url
  52261. * @param system Define the `lensFlareSystem` this flare is part of
  52262. * @returns The newly created Lens Flare
  52263. */
  52264. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52265. /**
  52266. * Instantiates a new Lens Flare.
  52267. * This represents one of the lens effect in a `lensFlareSystem`.
  52268. * It controls one of the indiviual texture used in the effect.
  52269. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52270. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52271. * @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.
  52272. * @param color Define the lens color
  52273. * @param imgUrl Define the lens texture url
  52274. * @param system Define the `lensFlareSystem` this flare is part of
  52275. */
  52276. constructor(
  52277. /**
  52278. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52279. */
  52280. size: number,
  52281. /**
  52282. * 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.
  52283. */
  52284. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52285. /**
  52286. * Dispose and release the lens flare with its associated resources.
  52287. */
  52288. dispose(): void;
  52289. }
  52290. }
  52291. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52292. import { Nullable } from "babylonjs/types";
  52293. import { Scene } from "babylonjs/scene";
  52294. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52295. import { AbstractScene } from "babylonjs/abstractScene";
  52296. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52297. module "babylonjs/abstractScene" {
  52298. interface AbstractScene {
  52299. /**
  52300. * The list of lens flare system added to the scene
  52301. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52302. */
  52303. lensFlareSystems: Array<LensFlareSystem>;
  52304. /**
  52305. * Removes the given lens flare system from this scene.
  52306. * @param toRemove The lens flare system to remove
  52307. * @returns The index of the removed lens flare system
  52308. */
  52309. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52310. /**
  52311. * Adds the given lens flare system to this scene
  52312. * @param newLensFlareSystem The lens flare system to add
  52313. */
  52314. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52315. /**
  52316. * Gets a lens flare system using its name
  52317. * @param name defines the name to look for
  52318. * @returns the lens flare system or null if not found
  52319. */
  52320. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52321. /**
  52322. * Gets a lens flare system using its id
  52323. * @param id defines the id to look for
  52324. * @returns the lens flare system or null if not found
  52325. */
  52326. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52327. }
  52328. }
  52329. /**
  52330. * Defines the lens flare scene component responsible to manage any lens flares
  52331. * in a given scene.
  52332. */
  52333. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52334. /**
  52335. * The component name helpfull to identify the component in the list of scene components.
  52336. */
  52337. readonly name: string;
  52338. /**
  52339. * The scene the component belongs to.
  52340. */
  52341. scene: Scene;
  52342. /**
  52343. * Creates a new instance of the component for the given scene
  52344. * @param scene Defines the scene to register the component in
  52345. */
  52346. constructor(scene: Scene);
  52347. /**
  52348. * Registers the component in a given scene
  52349. */
  52350. register(): void;
  52351. /**
  52352. * Rebuilds the elements related to this component in case of
  52353. * context lost for instance.
  52354. */
  52355. rebuild(): void;
  52356. /**
  52357. * Adds all the elements from the container to the scene
  52358. * @param container the container holding the elements
  52359. */
  52360. addFromContainer(container: AbstractScene): void;
  52361. /**
  52362. * Removes all the elements in the container from the scene
  52363. * @param container contains the elements to remove
  52364. * @param dispose if the removed element should be disposed (default: false)
  52365. */
  52366. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52367. /**
  52368. * Serializes the component data to the specified json object
  52369. * @param serializationObject The object to serialize to
  52370. */
  52371. serialize(serializationObject: any): void;
  52372. /**
  52373. * Disposes the component and the associated ressources.
  52374. */
  52375. dispose(): void;
  52376. private _draw;
  52377. }
  52378. }
  52379. declare module "babylonjs/LensFlares/index" {
  52380. export * from "babylonjs/LensFlares/lensFlare";
  52381. export * from "babylonjs/LensFlares/lensFlareSystem";
  52382. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52383. }
  52384. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52385. import { Scene } from "babylonjs/scene";
  52386. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52387. import { AbstractScene } from "babylonjs/abstractScene";
  52388. /**
  52389. * Defines the shadow generator component responsible to manage any shadow generators
  52390. * in a given scene.
  52391. */
  52392. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52393. /**
  52394. * The component name helpfull to identify the component in the list of scene components.
  52395. */
  52396. readonly name: string;
  52397. /**
  52398. * The scene the component belongs to.
  52399. */
  52400. scene: Scene;
  52401. /**
  52402. * Creates a new instance of the component for the given scene
  52403. * @param scene Defines the scene to register the component in
  52404. */
  52405. constructor(scene: Scene);
  52406. /**
  52407. * Registers the component in a given scene
  52408. */
  52409. register(): void;
  52410. /**
  52411. * Rebuilds the elements related to this component in case of
  52412. * context lost for instance.
  52413. */
  52414. rebuild(): void;
  52415. /**
  52416. * Serializes the component data to the specified json object
  52417. * @param serializationObject The object to serialize to
  52418. */
  52419. serialize(serializationObject: any): void;
  52420. /**
  52421. * Adds all the elements from the container to the scene
  52422. * @param container the container holding the elements
  52423. */
  52424. addFromContainer(container: AbstractScene): void;
  52425. /**
  52426. * Removes all the elements in the container from the scene
  52427. * @param container contains the elements to remove
  52428. * @param dispose if the removed element should be disposed (default: false)
  52429. */
  52430. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52431. /**
  52432. * Rebuilds the elements related to this component in case of
  52433. * context lost for instance.
  52434. */
  52435. dispose(): void;
  52436. private _gatherRenderTargets;
  52437. }
  52438. }
  52439. declare module "babylonjs/Lights/Shadows/index" {
  52440. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52441. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52442. }
  52443. declare module "babylonjs/Lights/pointLight" {
  52444. import { Scene } from "babylonjs/scene";
  52445. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52447. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52448. import { Effect } from "babylonjs/Materials/effect";
  52449. /**
  52450. * A point light is a light defined by an unique point in world space.
  52451. * The light is emitted in every direction from this point.
  52452. * A good example of a point light is a standard light bulb.
  52453. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52454. */
  52455. export class PointLight extends ShadowLight {
  52456. private _shadowAngle;
  52457. /**
  52458. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52459. * This specifies what angle the shadow will use to be created.
  52460. *
  52461. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52462. */
  52463. /**
  52464. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52465. * This specifies what angle the shadow will use to be created.
  52466. *
  52467. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52468. */
  52469. shadowAngle: number;
  52470. /**
  52471. * Gets the direction if it has been set.
  52472. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52473. */
  52474. /**
  52475. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52476. */
  52477. direction: Vector3;
  52478. /**
  52479. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52480. * A PointLight emits the light in every direction.
  52481. * It can cast shadows.
  52482. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52483. * ```javascript
  52484. * var pointLight = new PointLight("pl", camera.position, scene);
  52485. * ```
  52486. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52487. * @param name The light friendly name
  52488. * @param position The position of the point light in the scene
  52489. * @param scene The scene the lights belongs to
  52490. */
  52491. constructor(name: string, position: Vector3, scene: Scene);
  52492. /**
  52493. * Returns the string "PointLight"
  52494. * @returns the class name
  52495. */
  52496. getClassName(): string;
  52497. /**
  52498. * Returns the integer 0.
  52499. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52500. */
  52501. getTypeID(): number;
  52502. /**
  52503. * Specifies wether or not the shadowmap should be a cube texture.
  52504. * @returns true if the shadowmap needs to be a cube texture.
  52505. */
  52506. needCube(): boolean;
  52507. /**
  52508. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52509. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52510. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52511. */
  52512. getShadowDirection(faceIndex?: number): Vector3;
  52513. /**
  52514. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52515. * - fov = PI / 2
  52516. * - aspect ratio : 1.0
  52517. * - z-near and far equal to the active camera minZ and maxZ.
  52518. * Returns the PointLight.
  52519. */
  52520. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52521. protected _buildUniformLayout(): void;
  52522. /**
  52523. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52524. * @param effect The effect to update
  52525. * @param lightIndex The index of the light in the effect to update
  52526. * @returns The point light
  52527. */
  52528. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52529. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52530. /**
  52531. * Prepares the list of defines specific to the light type.
  52532. * @param defines the list of defines
  52533. * @param lightIndex defines the index of the light for the effect
  52534. */
  52535. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52536. }
  52537. }
  52538. declare module "babylonjs/Lights/index" {
  52539. export * from "babylonjs/Lights/light";
  52540. export * from "babylonjs/Lights/shadowLight";
  52541. export * from "babylonjs/Lights/Shadows/index";
  52542. export * from "babylonjs/Lights/directionalLight";
  52543. export * from "babylonjs/Lights/hemisphericLight";
  52544. export * from "babylonjs/Lights/pointLight";
  52545. export * from "babylonjs/Lights/spotLight";
  52546. }
  52547. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52548. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52549. /**
  52550. * Header information of HDR texture files.
  52551. */
  52552. export interface HDRInfo {
  52553. /**
  52554. * The height of the texture in pixels.
  52555. */
  52556. height: number;
  52557. /**
  52558. * The width of the texture in pixels.
  52559. */
  52560. width: number;
  52561. /**
  52562. * The index of the beginning of the data in the binary file.
  52563. */
  52564. dataPosition: number;
  52565. }
  52566. /**
  52567. * This groups tools to convert HDR texture to native colors array.
  52568. */
  52569. export class HDRTools {
  52570. private static Ldexp;
  52571. private static Rgbe2float;
  52572. private static readStringLine;
  52573. /**
  52574. * Reads header information from an RGBE texture stored in a native array.
  52575. * More information on this format are available here:
  52576. * https://en.wikipedia.org/wiki/RGBE_image_format
  52577. *
  52578. * @param uint8array The binary file stored in native array.
  52579. * @return The header information.
  52580. */
  52581. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52582. /**
  52583. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52584. * This RGBE texture needs to store the information as a panorama.
  52585. *
  52586. * More information on this format are available here:
  52587. * https://en.wikipedia.org/wiki/RGBE_image_format
  52588. *
  52589. * @param buffer The binary file stored in an array buffer.
  52590. * @param size The expected size of the extracted cubemap.
  52591. * @return The Cube Map information.
  52592. */
  52593. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52594. /**
  52595. * Returns the pixels data extracted from an RGBE texture.
  52596. * This pixels will be stored left to right up to down in the R G B order in one array.
  52597. *
  52598. * More information on this format are available here:
  52599. * https://en.wikipedia.org/wiki/RGBE_image_format
  52600. *
  52601. * @param uint8array The binary file stored in an array buffer.
  52602. * @param hdrInfo The header information of the file.
  52603. * @return The pixels data in RGB right to left up to down order.
  52604. */
  52605. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52606. private static RGBE_ReadPixels_RLE;
  52607. }
  52608. }
  52609. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52610. import { Nullable } from "babylonjs/types";
  52611. import { Scene } from "babylonjs/scene";
  52612. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52614. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52615. /**
  52616. * This represents a texture coming from an HDR input.
  52617. *
  52618. * The only supported format is currently panorama picture stored in RGBE format.
  52619. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52620. */
  52621. export class HDRCubeTexture extends BaseTexture {
  52622. private static _facesMapping;
  52623. private _generateHarmonics;
  52624. private _noMipmap;
  52625. private _textureMatrix;
  52626. private _size;
  52627. private _onLoad;
  52628. private _onError;
  52629. /**
  52630. * The texture URL.
  52631. */
  52632. url: string;
  52633. /**
  52634. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52635. */
  52636. coordinatesMode: number;
  52637. protected _isBlocking: boolean;
  52638. /**
  52639. * Sets wether or not the texture is blocking during loading.
  52640. */
  52641. /**
  52642. * Gets wether or not the texture is blocking during loading.
  52643. */
  52644. isBlocking: boolean;
  52645. protected _rotationY: number;
  52646. /**
  52647. * Sets texture matrix rotation angle around Y axis in radians.
  52648. */
  52649. /**
  52650. * Gets texture matrix rotation angle around Y axis radians.
  52651. */
  52652. rotationY: number;
  52653. /**
  52654. * Gets or sets the center of the bounding box associated with the cube texture
  52655. * It must define where the camera used to render the texture was set
  52656. */
  52657. boundingBoxPosition: Vector3;
  52658. private _boundingBoxSize;
  52659. /**
  52660. * Gets or sets the size of the bounding box associated with the cube texture
  52661. * When defined, the cubemap will switch to local mode
  52662. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52663. * @example https://www.babylonjs-playground.com/#RNASML
  52664. */
  52665. boundingBoxSize: Vector3;
  52666. /**
  52667. * Instantiates an HDRTexture from the following parameters.
  52668. *
  52669. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52670. * @param scene The scene the texture will be used in
  52671. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52672. * @param noMipmap Forces to not generate the mipmap if true
  52673. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52674. * @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)
  52675. * @param reserved Reserved flag for internal use.
  52676. */
  52677. 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>);
  52678. /**
  52679. * Get the current class name of the texture useful for serialization or dynamic coding.
  52680. * @returns "HDRCubeTexture"
  52681. */
  52682. getClassName(): string;
  52683. /**
  52684. * Occurs when the file is raw .hdr file.
  52685. */
  52686. private loadTexture;
  52687. clone(): HDRCubeTexture;
  52688. delayLoad(): void;
  52689. /**
  52690. * Get the texture reflection matrix used to rotate/transform the reflection.
  52691. * @returns the reflection matrix
  52692. */
  52693. getReflectionTextureMatrix(): Matrix;
  52694. /**
  52695. * Set the texture reflection matrix used to rotate/transform the reflection.
  52696. * @param value Define the reflection matrix to set
  52697. */
  52698. setReflectionTextureMatrix(value: Matrix): void;
  52699. /**
  52700. * Parses a JSON representation of an HDR Texture in order to create the texture
  52701. * @param parsedTexture Define the JSON representation
  52702. * @param scene Define the scene the texture should be created in
  52703. * @param rootUrl Define the root url in case we need to load relative dependencies
  52704. * @returns the newly created texture after parsing
  52705. */
  52706. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52707. serialize(): any;
  52708. }
  52709. }
  52710. declare module "babylonjs/Physics/physicsEngine" {
  52711. import { Nullable } from "babylonjs/types";
  52712. import { Vector3 } from "babylonjs/Maths/math.vector";
  52713. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52714. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52715. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52716. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52717. /**
  52718. * Class used to control physics engine
  52719. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52720. */
  52721. export class PhysicsEngine implements IPhysicsEngine {
  52722. private _physicsPlugin;
  52723. /**
  52724. * Global value used to control the smallest number supported by the simulation
  52725. */
  52726. static Epsilon: number;
  52727. private _impostors;
  52728. private _joints;
  52729. /**
  52730. * Gets the gravity vector used by the simulation
  52731. */
  52732. gravity: Vector3;
  52733. /**
  52734. * Factory used to create the default physics plugin.
  52735. * @returns The default physics plugin
  52736. */
  52737. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52738. /**
  52739. * Creates a new Physics Engine
  52740. * @param gravity defines the gravity vector used by the simulation
  52741. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52742. */
  52743. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52744. /**
  52745. * Sets the gravity vector used by the simulation
  52746. * @param gravity defines the gravity vector to use
  52747. */
  52748. setGravity(gravity: Vector3): void;
  52749. /**
  52750. * Set the time step of the physics engine.
  52751. * Default is 1/60.
  52752. * To slow it down, enter 1/600 for example.
  52753. * To speed it up, 1/30
  52754. * @param newTimeStep defines the new timestep to apply to this world.
  52755. */
  52756. setTimeStep(newTimeStep?: number): void;
  52757. /**
  52758. * Get the time step of the physics engine.
  52759. * @returns the current time step
  52760. */
  52761. getTimeStep(): number;
  52762. /**
  52763. * Release all resources
  52764. */
  52765. dispose(): void;
  52766. /**
  52767. * Gets the name of the current physics plugin
  52768. * @returns the name of the plugin
  52769. */
  52770. getPhysicsPluginName(): string;
  52771. /**
  52772. * Adding a new impostor for the impostor tracking.
  52773. * This will be done by the impostor itself.
  52774. * @param impostor the impostor to add
  52775. */
  52776. addImpostor(impostor: PhysicsImpostor): void;
  52777. /**
  52778. * Remove an impostor from the engine.
  52779. * This impostor and its mesh will not longer be updated by the physics engine.
  52780. * @param impostor the impostor to remove
  52781. */
  52782. removeImpostor(impostor: PhysicsImpostor): void;
  52783. /**
  52784. * Add a joint to the physics engine
  52785. * @param mainImpostor defines the main impostor to which the joint is added.
  52786. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52787. * @param joint defines the joint that will connect both impostors.
  52788. */
  52789. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52790. /**
  52791. * Removes a joint from the simulation
  52792. * @param mainImpostor defines the impostor used with the joint
  52793. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52794. * @param joint defines the joint to remove
  52795. */
  52796. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52797. /**
  52798. * Called by the scene. No need to call it.
  52799. * @param delta defines the timespam between frames
  52800. */
  52801. _step(delta: number): void;
  52802. /**
  52803. * Gets the current plugin used to run the simulation
  52804. * @returns current plugin
  52805. */
  52806. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52807. /**
  52808. * Gets the list of physic impostors
  52809. * @returns an array of PhysicsImpostor
  52810. */
  52811. getImpostors(): Array<PhysicsImpostor>;
  52812. /**
  52813. * Gets the impostor for a physics enabled object
  52814. * @param object defines the object impersonated by the impostor
  52815. * @returns the PhysicsImpostor or null if not found
  52816. */
  52817. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52818. /**
  52819. * Gets the impostor for a physics body object
  52820. * @param body defines physics body used by the impostor
  52821. * @returns the PhysicsImpostor or null if not found
  52822. */
  52823. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52824. /**
  52825. * Does a raycast in the physics world
  52826. * @param from when should the ray start?
  52827. * @param to when should the ray end?
  52828. * @returns PhysicsRaycastResult
  52829. */
  52830. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52831. }
  52832. }
  52833. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52834. import { Nullable } from "babylonjs/types";
  52835. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52837. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52838. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52839. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52840. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52841. /** @hidden */
  52842. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52843. private _useDeltaForWorldStep;
  52844. world: any;
  52845. name: string;
  52846. private _physicsMaterials;
  52847. private _fixedTimeStep;
  52848. private _cannonRaycastResult;
  52849. private _raycastResult;
  52850. private _physicsBodysToRemoveAfterStep;
  52851. BJSCANNON: any;
  52852. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52853. setGravity(gravity: Vector3): void;
  52854. setTimeStep(timeStep: number): void;
  52855. getTimeStep(): number;
  52856. executeStep(delta: number): void;
  52857. private _removeMarkedPhysicsBodiesFromWorld;
  52858. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52859. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52860. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52861. private _processChildMeshes;
  52862. removePhysicsBody(impostor: PhysicsImpostor): void;
  52863. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52864. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52865. private _addMaterial;
  52866. private _checkWithEpsilon;
  52867. private _createShape;
  52868. private _createHeightmap;
  52869. private _minus90X;
  52870. private _plus90X;
  52871. private _tmpPosition;
  52872. private _tmpDeltaPosition;
  52873. private _tmpUnityRotation;
  52874. private _updatePhysicsBodyTransformation;
  52875. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52876. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52877. isSupported(): boolean;
  52878. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52879. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52880. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52881. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52882. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52883. getBodyMass(impostor: PhysicsImpostor): number;
  52884. getBodyFriction(impostor: PhysicsImpostor): number;
  52885. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52886. getBodyRestitution(impostor: PhysicsImpostor): number;
  52887. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52888. sleepBody(impostor: PhysicsImpostor): void;
  52889. wakeUpBody(impostor: PhysicsImpostor): void;
  52890. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52891. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52892. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52893. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52894. getRadius(impostor: PhysicsImpostor): number;
  52895. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52896. dispose(): void;
  52897. private _extendNamespace;
  52898. /**
  52899. * Does a raycast in the physics world
  52900. * @param from when should the ray start?
  52901. * @param to when should the ray end?
  52902. * @returns PhysicsRaycastResult
  52903. */
  52904. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52905. }
  52906. }
  52907. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52908. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52909. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52910. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52912. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52913. import { Nullable } from "babylonjs/types";
  52914. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52915. /** @hidden */
  52916. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52917. world: any;
  52918. name: string;
  52919. BJSOIMO: any;
  52920. private _raycastResult;
  52921. constructor(iterations?: number, oimoInjection?: any);
  52922. setGravity(gravity: Vector3): void;
  52923. setTimeStep(timeStep: number): void;
  52924. getTimeStep(): number;
  52925. private _tmpImpostorsArray;
  52926. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52927. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52928. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52929. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52930. private _tmpPositionVector;
  52931. removePhysicsBody(impostor: PhysicsImpostor): void;
  52932. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52933. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52934. isSupported(): boolean;
  52935. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52936. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52937. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52938. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52939. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52940. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52941. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52942. getBodyMass(impostor: PhysicsImpostor): number;
  52943. getBodyFriction(impostor: PhysicsImpostor): number;
  52944. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52945. getBodyRestitution(impostor: PhysicsImpostor): number;
  52946. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52947. sleepBody(impostor: PhysicsImpostor): void;
  52948. wakeUpBody(impostor: PhysicsImpostor): void;
  52949. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52950. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52951. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52952. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52953. getRadius(impostor: PhysicsImpostor): number;
  52954. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52955. dispose(): void;
  52956. /**
  52957. * Does a raycast in the physics world
  52958. * @param from when should the ray start?
  52959. * @param to when should the ray end?
  52960. * @returns PhysicsRaycastResult
  52961. */
  52962. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52963. }
  52964. }
  52965. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52966. import { Nullable } from "babylonjs/types";
  52967. import { Scene } from "babylonjs/scene";
  52968. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52969. import { Color4 } from "babylonjs/Maths/math.color";
  52970. import { Mesh } from "babylonjs/Meshes/mesh";
  52971. /**
  52972. * Class containing static functions to help procedurally build meshes
  52973. */
  52974. export class RibbonBuilder {
  52975. /**
  52976. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52977. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52978. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52979. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52980. * * 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
  52981. * * 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
  52982. * * 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
  52983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52985. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52986. * * 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
  52987. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52988. * * 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
  52989. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52991. * @param name defines the name of the mesh
  52992. * @param options defines the options used to create the mesh
  52993. * @param scene defines the hosting scene
  52994. * @returns the ribbon mesh
  52995. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52996. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52997. */
  52998. static CreateRibbon(name: string, options: {
  52999. pathArray: Vector3[][];
  53000. closeArray?: boolean;
  53001. closePath?: boolean;
  53002. offset?: number;
  53003. updatable?: boolean;
  53004. sideOrientation?: number;
  53005. frontUVs?: Vector4;
  53006. backUVs?: Vector4;
  53007. instance?: Mesh;
  53008. invertUV?: boolean;
  53009. uvs?: Vector2[];
  53010. colors?: Color4[];
  53011. }, scene?: Nullable<Scene>): Mesh;
  53012. }
  53013. }
  53014. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53015. import { Nullable } from "babylonjs/types";
  53016. import { Scene } from "babylonjs/scene";
  53017. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53018. import { Mesh } from "babylonjs/Meshes/mesh";
  53019. /**
  53020. * Class containing static functions to help procedurally build meshes
  53021. */
  53022. export class ShapeBuilder {
  53023. /**
  53024. * 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.
  53025. * * 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.
  53026. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53027. * * 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.
  53028. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53029. * * 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
  53030. * * 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
  53031. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53036. * @param name defines the name of the mesh
  53037. * @param options defines the options used to create the mesh
  53038. * @param scene defines the hosting scene
  53039. * @returns the extruded shape mesh
  53040. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53042. */
  53043. static ExtrudeShape(name: string, options: {
  53044. shape: Vector3[];
  53045. path: Vector3[];
  53046. scale?: number;
  53047. rotation?: number;
  53048. cap?: number;
  53049. updatable?: boolean;
  53050. sideOrientation?: number;
  53051. frontUVs?: Vector4;
  53052. backUVs?: Vector4;
  53053. instance?: Mesh;
  53054. invertUV?: boolean;
  53055. }, scene?: Nullable<Scene>): Mesh;
  53056. /**
  53057. * Creates an custom extruded shape mesh.
  53058. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53059. * * 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.
  53060. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53061. * * 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
  53062. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53063. * * 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
  53064. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53065. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53066. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53067. * * 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
  53068. * * 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
  53069. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53072. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53074. * @param name defines the name of the mesh
  53075. * @param options defines the options used to create the mesh
  53076. * @param scene defines the hosting scene
  53077. * @returns the custom extruded shape mesh
  53078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53081. */
  53082. static ExtrudeShapeCustom(name: string, options: {
  53083. shape: Vector3[];
  53084. path: Vector3[];
  53085. scaleFunction?: any;
  53086. rotationFunction?: any;
  53087. ribbonCloseArray?: boolean;
  53088. ribbonClosePath?: boolean;
  53089. cap?: number;
  53090. updatable?: boolean;
  53091. sideOrientation?: number;
  53092. frontUVs?: Vector4;
  53093. backUVs?: Vector4;
  53094. instance?: Mesh;
  53095. invertUV?: boolean;
  53096. }, scene?: Nullable<Scene>): Mesh;
  53097. private static _ExtrudeShapeGeneric;
  53098. }
  53099. }
  53100. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53101. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53102. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53103. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53104. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53105. import { Nullable } from "babylonjs/types";
  53106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53107. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53108. /**
  53109. * AmmoJS Physics plugin
  53110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53111. * @see https://github.com/kripken/ammo.js/
  53112. */
  53113. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53114. private _useDeltaForWorldStep;
  53115. /**
  53116. * Reference to the Ammo library
  53117. */
  53118. bjsAMMO: any;
  53119. /**
  53120. * Created ammoJS world which physics bodies are added to
  53121. */
  53122. world: any;
  53123. /**
  53124. * Name of the plugin
  53125. */
  53126. name: string;
  53127. private _timeStep;
  53128. private _fixedTimeStep;
  53129. private _maxSteps;
  53130. private _tmpQuaternion;
  53131. private _tmpAmmoTransform;
  53132. private _tmpAmmoQuaternion;
  53133. private _tmpAmmoConcreteContactResultCallback;
  53134. private _collisionConfiguration;
  53135. private _dispatcher;
  53136. private _overlappingPairCache;
  53137. private _solver;
  53138. private _softBodySolver;
  53139. private _tmpAmmoVectorA;
  53140. private _tmpAmmoVectorB;
  53141. private _tmpAmmoVectorC;
  53142. private _tmpAmmoVectorD;
  53143. private _tmpContactCallbackResult;
  53144. private _tmpAmmoVectorRCA;
  53145. private _tmpAmmoVectorRCB;
  53146. private _raycastResult;
  53147. private static readonly DISABLE_COLLISION_FLAG;
  53148. private static readonly KINEMATIC_FLAG;
  53149. private static readonly DISABLE_DEACTIVATION_FLAG;
  53150. /**
  53151. * Initializes the ammoJS plugin
  53152. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53153. * @param ammoInjection can be used to inject your own ammo reference
  53154. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53155. */
  53156. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53157. /**
  53158. * Sets the gravity of the physics world (m/(s^2))
  53159. * @param gravity Gravity to set
  53160. */
  53161. setGravity(gravity: Vector3): void;
  53162. /**
  53163. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53164. * @param timeStep timestep to use in seconds
  53165. */
  53166. setTimeStep(timeStep: number): void;
  53167. /**
  53168. * 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)
  53169. * @param fixedTimeStep fixedTimeStep to use in seconds
  53170. */
  53171. setFixedTimeStep(fixedTimeStep: number): void;
  53172. /**
  53173. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53174. * @param maxSteps the maximum number of steps by the physics engine per frame
  53175. */
  53176. setMaxSteps(maxSteps: number): void;
  53177. /**
  53178. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53179. * @returns the current timestep in seconds
  53180. */
  53181. getTimeStep(): number;
  53182. private _isImpostorInContact;
  53183. private _isImpostorPairInContact;
  53184. private _stepSimulation;
  53185. /**
  53186. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53187. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53188. * After the step the babylon meshes are set to the position of the physics imposters
  53189. * @param delta amount of time to step forward
  53190. * @param impostors array of imposters to update before/after the step
  53191. */
  53192. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53193. /**
  53194. * Update babylon mesh to match physics world object
  53195. * @param impostor imposter to match
  53196. */
  53197. private _afterSoftStep;
  53198. /**
  53199. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53200. * @param impostor imposter to match
  53201. */
  53202. private _ropeStep;
  53203. /**
  53204. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53205. * @param impostor imposter to match
  53206. */
  53207. private _softbodyOrClothStep;
  53208. private _tmpVector;
  53209. private _tmpMatrix;
  53210. /**
  53211. * Applies an impulse on the imposter
  53212. * @param impostor imposter to apply impulse to
  53213. * @param force amount of force to be applied to the imposter
  53214. * @param contactPoint the location to apply the impulse on the imposter
  53215. */
  53216. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53217. /**
  53218. * Applies a force on the imposter
  53219. * @param impostor imposter to apply force
  53220. * @param force amount of force to be applied to the imposter
  53221. * @param contactPoint the location to apply the force on the imposter
  53222. */
  53223. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53224. /**
  53225. * Creates a physics body using the plugin
  53226. * @param impostor the imposter to create the physics body on
  53227. */
  53228. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53229. /**
  53230. * Removes the physics body from the imposter and disposes of the body's memory
  53231. * @param impostor imposter to remove the physics body from
  53232. */
  53233. removePhysicsBody(impostor: PhysicsImpostor): void;
  53234. /**
  53235. * Generates a joint
  53236. * @param impostorJoint the imposter joint to create the joint with
  53237. */
  53238. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53239. /**
  53240. * Removes a joint
  53241. * @param impostorJoint the imposter joint to remove the joint from
  53242. */
  53243. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53244. private _addMeshVerts;
  53245. /**
  53246. * Initialise the soft body vertices to match its object's (mesh) vertices
  53247. * Softbody vertices (nodes) are in world space and to match this
  53248. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53249. * @param impostor to create the softbody for
  53250. */
  53251. private _softVertexData;
  53252. /**
  53253. * Create an impostor's soft body
  53254. * @param impostor to create the softbody for
  53255. */
  53256. private _createSoftbody;
  53257. /**
  53258. * Create cloth for an impostor
  53259. * @param impostor to create the softbody for
  53260. */
  53261. private _createCloth;
  53262. /**
  53263. * Create rope for an impostor
  53264. * @param impostor to create the softbody for
  53265. */
  53266. private _createRope;
  53267. private _addHullVerts;
  53268. private _createShape;
  53269. /**
  53270. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53271. * @param impostor imposter containing the physics body and babylon object
  53272. */
  53273. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53274. /**
  53275. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53276. * @param impostor imposter containing the physics body and babylon object
  53277. * @param newPosition new position
  53278. * @param newRotation new rotation
  53279. */
  53280. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53281. /**
  53282. * If this plugin is supported
  53283. * @returns true if its supported
  53284. */
  53285. isSupported(): boolean;
  53286. /**
  53287. * Sets the linear velocity of the physics body
  53288. * @param impostor imposter to set the velocity on
  53289. * @param velocity velocity to set
  53290. */
  53291. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53292. /**
  53293. * Sets the angular velocity of the physics body
  53294. * @param impostor imposter to set the velocity on
  53295. * @param velocity velocity to set
  53296. */
  53297. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53298. /**
  53299. * gets the linear velocity
  53300. * @param impostor imposter to get linear velocity from
  53301. * @returns linear velocity
  53302. */
  53303. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53304. /**
  53305. * gets the angular velocity
  53306. * @param impostor imposter to get angular velocity from
  53307. * @returns angular velocity
  53308. */
  53309. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53310. /**
  53311. * Sets the mass of physics body
  53312. * @param impostor imposter to set the mass on
  53313. * @param mass mass to set
  53314. */
  53315. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53316. /**
  53317. * Gets the mass of the physics body
  53318. * @param impostor imposter to get the mass from
  53319. * @returns mass
  53320. */
  53321. getBodyMass(impostor: PhysicsImpostor): number;
  53322. /**
  53323. * Gets friction of the impostor
  53324. * @param impostor impostor to get friction from
  53325. * @returns friction value
  53326. */
  53327. getBodyFriction(impostor: PhysicsImpostor): number;
  53328. /**
  53329. * Sets friction of the impostor
  53330. * @param impostor impostor to set friction on
  53331. * @param friction friction value
  53332. */
  53333. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53334. /**
  53335. * Gets restitution of the impostor
  53336. * @param impostor impostor to get restitution from
  53337. * @returns restitution value
  53338. */
  53339. getBodyRestitution(impostor: PhysicsImpostor): number;
  53340. /**
  53341. * Sets resitution of the impostor
  53342. * @param impostor impostor to set resitution on
  53343. * @param restitution resitution value
  53344. */
  53345. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53346. /**
  53347. * Gets pressure inside the impostor
  53348. * @param impostor impostor to get pressure from
  53349. * @returns pressure value
  53350. */
  53351. getBodyPressure(impostor: PhysicsImpostor): number;
  53352. /**
  53353. * Sets pressure inside a soft body impostor
  53354. * Cloth and rope must remain 0 pressure
  53355. * @param impostor impostor to set pressure on
  53356. * @param pressure pressure value
  53357. */
  53358. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53359. /**
  53360. * Gets stiffness of the impostor
  53361. * @param impostor impostor to get stiffness from
  53362. * @returns pressure value
  53363. */
  53364. getBodyStiffness(impostor: PhysicsImpostor): number;
  53365. /**
  53366. * Sets stiffness of the impostor
  53367. * @param impostor impostor to set stiffness on
  53368. * @param stiffness stiffness value from 0 to 1
  53369. */
  53370. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53371. /**
  53372. * Gets velocityIterations of the impostor
  53373. * @param impostor impostor to get velocity iterations from
  53374. * @returns velocityIterations value
  53375. */
  53376. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53377. /**
  53378. * Sets velocityIterations of the impostor
  53379. * @param impostor impostor to set velocity iterations on
  53380. * @param velocityIterations velocityIterations value
  53381. */
  53382. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53383. /**
  53384. * Gets positionIterations of the impostor
  53385. * @param impostor impostor to get position iterations from
  53386. * @returns positionIterations value
  53387. */
  53388. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53389. /**
  53390. * Sets positionIterations of the impostor
  53391. * @param impostor impostor to set position on
  53392. * @param positionIterations positionIterations value
  53393. */
  53394. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53395. /**
  53396. * Append an anchor to a cloth object
  53397. * @param impostor is the cloth impostor to add anchor to
  53398. * @param otherImpostor is the rigid impostor to anchor to
  53399. * @param width ratio across width from 0 to 1
  53400. * @param height ratio up height from 0 to 1
  53401. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53402. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53403. */
  53404. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53405. /**
  53406. * Append an hook to a rope object
  53407. * @param impostor is the rope impostor to add hook to
  53408. * @param otherImpostor is the rigid impostor to hook to
  53409. * @param length ratio along the rope from 0 to 1
  53410. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53411. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53412. */
  53413. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53414. /**
  53415. * Sleeps the physics body and stops it from being active
  53416. * @param impostor impostor to sleep
  53417. */
  53418. sleepBody(impostor: PhysicsImpostor): void;
  53419. /**
  53420. * Activates the physics body
  53421. * @param impostor impostor to activate
  53422. */
  53423. wakeUpBody(impostor: PhysicsImpostor): void;
  53424. /**
  53425. * Updates the distance parameters of the joint
  53426. * @param joint joint to update
  53427. * @param maxDistance maximum distance of the joint
  53428. * @param minDistance minimum distance of the joint
  53429. */
  53430. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53431. /**
  53432. * Sets a motor on the joint
  53433. * @param joint joint to set motor on
  53434. * @param speed speed of the motor
  53435. * @param maxForce maximum force of the motor
  53436. * @param motorIndex index of the motor
  53437. */
  53438. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53439. /**
  53440. * Sets the motors limit
  53441. * @param joint joint to set limit on
  53442. * @param upperLimit upper limit
  53443. * @param lowerLimit lower limit
  53444. */
  53445. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53446. /**
  53447. * Syncs the position and rotation of a mesh with the impostor
  53448. * @param mesh mesh to sync
  53449. * @param impostor impostor to update the mesh with
  53450. */
  53451. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53452. /**
  53453. * Gets the radius of the impostor
  53454. * @param impostor impostor to get radius from
  53455. * @returns the radius
  53456. */
  53457. getRadius(impostor: PhysicsImpostor): number;
  53458. /**
  53459. * Gets the box size of the impostor
  53460. * @param impostor impostor to get box size from
  53461. * @param result the resulting box size
  53462. */
  53463. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53464. /**
  53465. * Disposes of the impostor
  53466. */
  53467. dispose(): void;
  53468. /**
  53469. * Does a raycast in the physics world
  53470. * @param from when should the ray start?
  53471. * @param to when should the ray end?
  53472. * @returns PhysicsRaycastResult
  53473. */
  53474. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53475. }
  53476. }
  53477. declare module "babylonjs/Probes/reflectionProbe" {
  53478. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53479. import { Vector3 } from "babylonjs/Maths/math.vector";
  53480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53481. import { Nullable } from "babylonjs/types";
  53482. import { Scene } from "babylonjs/scene";
  53483. module "babylonjs/abstractScene" {
  53484. interface AbstractScene {
  53485. /**
  53486. * The list of reflection probes added to the scene
  53487. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53488. */
  53489. reflectionProbes: Array<ReflectionProbe>;
  53490. /**
  53491. * Removes the given reflection probe from this scene.
  53492. * @param toRemove The reflection probe to remove
  53493. * @returns The index of the removed reflection probe
  53494. */
  53495. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53496. /**
  53497. * Adds the given reflection probe to this scene.
  53498. * @param newReflectionProbe The reflection probe to add
  53499. */
  53500. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53501. }
  53502. }
  53503. /**
  53504. * Class used to generate realtime reflection / refraction cube textures
  53505. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53506. */
  53507. export class ReflectionProbe {
  53508. /** defines the name of the probe */
  53509. name: string;
  53510. private _scene;
  53511. private _renderTargetTexture;
  53512. private _projectionMatrix;
  53513. private _viewMatrix;
  53514. private _target;
  53515. private _add;
  53516. private _attachedMesh;
  53517. private _invertYAxis;
  53518. /** Gets or sets probe position (center of the cube map) */
  53519. position: Vector3;
  53520. /**
  53521. * Creates a new reflection probe
  53522. * @param name defines the name of the probe
  53523. * @param size defines the texture resolution (for each face)
  53524. * @param scene defines the hosting scene
  53525. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53526. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53527. */
  53528. constructor(
  53529. /** defines the name of the probe */
  53530. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53531. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53532. samples: number;
  53533. /** Gets or sets the refresh rate to use (on every frame by default) */
  53534. refreshRate: number;
  53535. /**
  53536. * Gets the hosting scene
  53537. * @returns a Scene
  53538. */
  53539. getScene(): Scene;
  53540. /** Gets the internal CubeTexture used to render to */
  53541. readonly cubeTexture: RenderTargetTexture;
  53542. /** Gets the list of meshes to render */
  53543. readonly renderList: Nullable<AbstractMesh[]>;
  53544. /**
  53545. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53546. * @param mesh defines the mesh to attach to
  53547. */
  53548. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53549. /**
  53550. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53551. * @param renderingGroupId The rendering group id corresponding to its index
  53552. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53553. */
  53554. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53555. /**
  53556. * Clean all associated resources
  53557. */
  53558. dispose(): void;
  53559. /**
  53560. * Converts the reflection probe information to a readable string for debug purpose.
  53561. * @param fullDetails Supports for multiple levels of logging within scene loading
  53562. * @returns the human readable reflection probe info
  53563. */
  53564. toString(fullDetails?: boolean): string;
  53565. /**
  53566. * Get the class name of the relfection probe.
  53567. * @returns "ReflectionProbe"
  53568. */
  53569. getClassName(): string;
  53570. /**
  53571. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53572. * @returns The JSON representation of the texture
  53573. */
  53574. serialize(): any;
  53575. /**
  53576. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53577. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53578. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53579. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53580. * @returns The parsed reflection probe if successful
  53581. */
  53582. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53583. }
  53584. }
  53585. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53586. /** @hidden */
  53587. export var _BabylonLoaderRegistered: boolean;
  53588. }
  53589. declare module "babylonjs/Loading/Plugins/index" {
  53590. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53591. }
  53592. declare module "babylonjs/Loading/index" {
  53593. export * from "babylonjs/Loading/loadingScreen";
  53594. export * from "babylonjs/Loading/Plugins/index";
  53595. export * from "babylonjs/Loading/sceneLoader";
  53596. export * from "babylonjs/Loading/sceneLoaderFlags";
  53597. }
  53598. declare module "babylonjs/Materials/Background/index" {
  53599. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53600. }
  53601. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53602. import { Scene } from "babylonjs/scene";
  53603. import { Color3 } from "babylonjs/Maths/math.color";
  53604. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53606. /**
  53607. * The Physically based simple base material of BJS.
  53608. *
  53609. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53610. * It is used as the base class for both the specGloss and metalRough conventions.
  53611. */
  53612. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53613. /**
  53614. * Number of Simultaneous lights allowed on the material.
  53615. */
  53616. maxSimultaneousLights: number;
  53617. /**
  53618. * If sets to true, disables all the lights affecting the material.
  53619. */
  53620. disableLighting: boolean;
  53621. /**
  53622. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53623. */
  53624. environmentTexture: BaseTexture;
  53625. /**
  53626. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53627. */
  53628. invertNormalMapX: boolean;
  53629. /**
  53630. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53631. */
  53632. invertNormalMapY: boolean;
  53633. /**
  53634. * Normal map used in the model.
  53635. */
  53636. normalTexture: BaseTexture;
  53637. /**
  53638. * Emissivie color used to self-illuminate the model.
  53639. */
  53640. emissiveColor: Color3;
  53641. /**
  53642. * Emissivie texture used to self-illuminate the model.
  53643. */
  53644. emissiveTexture: BaseTexture;
  53645. /**
  53646. * Occlusion Channel Strenght.
  53647. */
  53648. occlusionStrength: number;
  53649. /**
  53650. * Occlusion Texture of the material (adding extra occlusion effects).
  53651. */
  53652. occlusionTexture: BaseTexture;
  53653. /**
  53654. * Defines the alpha limits in alpha test mode.
  53655. */
  53656. alphaCutOff: number;
  53657. /**
  53658. * Gets the current double sided mode.
  53659. */
  53660. /**
  53661. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53662. */
  53663. doubleSided: boolean;
  53664. /**
  53665. * Stores the pre-calculated light information of a mesh in a texture.
  53666. */
  53667. lightmapTexture: BaseTexture;
  53668. /**
  53669. * If true, the light map contains occlusion information instead of lighting info.
  53670. */
  53671. useLightmapAsShadowmap: boolean;
  53672. /**
  53673. * Instantiates a new PBRMaterial instance.
  53674. *
  53675. * @param name The material name
  53676. * @param scene The scene the material will be use in.
  53677. */
  53678. constructor(name: string, scene: Scene);
  53679. getClassName(): string;
  53680. }
  53681. }
  53682. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53683. import { Scene } from "babylonjs/scene";
  53684. import { Color3 } from "babylonjs/Maths/math.color";
  53685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53686. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53687. /**
  53688. * The PBR material of BJS following the metal roughness convention.
  53689. *
  53690. * This fits to the PBR convention in the GLTF definition:
  53691. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53692. */
  53693. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53694. /**
  53695. * The base color has two different interpretations depending on the value of metalness.
  53696. * When the material is a metal, the base color is the specific measured reflectance value
  53697. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53698. * of the material.
  53699. */
  53700. baseColor: Color3;
  53701. /**
  53702. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53703. * well as opacity information in the alpha channel.
  53704. */
  53705. baseTexture: BaseTexture;
  53706. /**
  53707. * Specifies the metallic scalar value of the material.
  53708. * Can also be used to scale the metalness values of the metallic texture.
  53709. */
  53710. metallic: number;
  53711. /**
  53712. * Specifies the roughness scalar value of the material.
  53713. * Can also be used to scale the roughness values of the metallic texture.
  53714. */
  53715. roughness: number;
  53716. /**
  53717. * Texture containing both the metallic value in the B channel and the
  53718. * roughness value in the G channel to keep better precision.
  53719. */
  53720. metallicRoughnessTexture: BaseTexture;
  53721. /**
  53722. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53723. *
  53724. * @param name The material name
  53725. * @param scene The scene the material will be use in.
  53726. */
  53727. constructor(name: string, scene: Scene);
  53728. /**
  53729. * Return the currrent class name of the material.
  53730. */
  53731. getClassName(): string;
  53732. /**
  53733. * Makes a duplicate of the current material.
  53734. * @param name - name to use for the new material.
  53735. */
  53736. clone(name: string): PBRMetallicRoughnessMaterial;
  53737. /**
  53738. * Serialize the material to a parsable JSON object.
  53739. */
  53740. serialize(): any;
  53741. /**
  53742. * Parses a JSON object correponding to the serialize function.
  53743. */
  53744. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53745. }
  53746. }
  53747. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53748. import { Scene } from "babylonjs/scene";
  53749. import { Color3 } from "babylonjs/Maths/math.color";
  53750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53751. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53752. /**
  53753. * The PBR material of BJS following the specular glossiness convention.
  53754. *
  53755. * This fits to the PBR convention in the GLTF definition:
  53756. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53757. */
  53758. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53759. /**
  53760. * Specifies the diffuse color of the material.
  53761. */
  53762. diffuseColor: Color3;
  53763. /**
  53764. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53765. * channel.
  53766. */
  53767. diffuseTexture: BaseTexture;
  53768. /**
  53769. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53770. */
  53771. specularColor: Color3;
  53772. /**
  53773. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53774. */
  53775. glossiness: number;
  53776. /**
  53777. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53778. */
  53779. specularGlossinessTexture: BaseTexture;
  53780. /**
  53781. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53782. *
  53783. * @param name The material name
  53784. * @param scene The scene the material will be use in.
  53785. */
  53786. constructor(name: string, scene: Scene);
  53787. /**
  53788. * Return the currrent class name of the material.
  53789. */
  53790. getClassName(): string;
  53791. /**
  53792. * Makes a duplicate of the current material.
  53793. * @param name - name to use for the new material.
  53794. */
  53795. clone(name: string): PBRSpecularGlossinessMaterial;
  53796. /**
  53797. * Serialize the material to a parsable JSON object.
  53798. */
  53799. serialize(): any;
  53800. /**
  53801. * Parses a JSON object correponding to the serialize function.
  53802. */
  53803. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53804. }
  53805. }
  53806. declare module "babylonjs/Materials/PBR/index" {
  53807. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53808. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53809. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53810. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53811. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53812. }
  53813. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53814. import { Nullable } from "babylonjs/types";
  53815. import { Scene } from "babylonjs/scene";
  53816. import { Matrix } from "babylonjs/Maths/math.vector";
  53817. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53818. /**
  53819. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53820. * It can help converting any input color in a desired output one. This can then be used to create effects
  53821. * from sepia, black and white to sixties or futuristic rendering...
  53822. *
  53823. * The only supported format is currently 3dl.
  53824. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53825. */
  53826. export class ColorGradingTexture extends BaseTexture {
  53827. /**
  53828. * The current texture matrix. (will always be identity in color grading texture)
  53829. */
  53830. private _textureMatrix;
  53831. /**
  53832. * The texture URL.
  53833. */
  53834. url: string;
  53835. /**
  53836. * Empty line regex stored for GC.
  53837. */
  53838. private static _noneEmptyLineRegex;
  53839. private _engine;
  53840. /**
  53841. * Instantiates a ColorGradingTexture from the following parameters.
  53842. *
  53843. * @param url The location of the color gradind data (currently only supporting 3dl)
  53844. * @param scene The scene the texture will be used in
  53845. */
  53846. constructor(url: string, scene: Scene);
  53847. /**
  53848. * Returns the texture matrix used in most of the material.
  53849. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53850. */
  53851. getTextureMatrix(): Matrix;
  53852. /**
  53853. * Occurs when the file being loaded is a .3dl LUT file.
  53854. */
  53855. private load3dlTexture;
  53856. /**
  53857. * Starts the loading process of the texture.
  53858. */
  53859. private loadTexture;
  53860. /**
  53861. * Clones the color gradind texture.
  53862. */
  53863. clone(): ColorGradingTexture;
  53864. /**
  53865. * Called during delayed load for textures.
  53866. */
  53867. delayLoad(): void;
  53868. /**
  53869. * Parses a color grading texture serialized by Babylon.
  53870. * @param parsedTexture The texture information being parsedTexture
  53871. * @param scene The scene to load the texture in
  53872. * @param rootUrl The root url of the data assets to load
  53873. * @return A color gradind texture
  53874. */
  53875. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53876. /**
  53877. * Serializes the LUT texture to json format.
  53878. */
  53879. serialize(): any;
  53880. }
  53881. }
  53882. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53883. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53884. import { Scene } from "babylonjs/scene";
  53885. import { Nullable } from "babylonjs/types";
  53886. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53887. /**
  53888. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53889. */
  53890. export class EquiRectangularCubeTexture extends BaseTexture {
  53891. /** The six faces of the cube. */
  53892. private static _FacesMapping;
  53893. private _noMipmap;
  53894. private _onLoad;
  53895. private _onError;
  53896. /** The size of the cubemap. */
  53897. private _size;
  53898. /** The buffer of the image. */
  53899. private _buffer;
  53900. /** The width of the input image. */
  53901. private _width;
  53902. /** The height of the input image. */
  53903. private _height;
  53904. /** The URL to the image. */
  53905. url: string;
  53906. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53907. coordinatesMode: number;
  53908. /**
  53909. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53910. * @param url The location of the image
  53911. * @param scene The scene the texture will be used in
  53912. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53913. * @param noMipmap Forces to not generate the mipmap if true
  53914. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53915. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53916. * @param onLoad — defines a callback called when texture is loaded
  53917. * @param onError — defines a callback called if there is an error
  53918. */
  53919. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53920. /**
  53921. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53922. */
  53923. private loadImage;
  53924. /**
  53925. * Convert the image buffer into a cubemap and create a CubeTexture.
  53926. */
  53927. private loadTexture;
  53928. /**
  53929. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53930. * @param buffer The ArrayBuffer that should be converted.
  53931. * @returns The buffer as Float32Array.
  53932. */
  53933. private getFloat32ArrayFromArrayBuffer;
  53934. /**
  53935. * Get the current class name of the texture useful for serialization or dynamic coding.
  53936. * @returns "EquiRectangularCubeTexture"
  53937. */
  53938. getClassName(): string;
  53939. /**
  53940. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53941. * @returns A clone of the current EquiRectangularCubeTexture.
  53942. */
  53943. clone(): EquiRectangularCubeTexture;
  53944. }
  53945. }
  53946. declare module "babylonjs/Misc/tga" {
  53947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53948. /**
  53949. * Based on jsTGALoader - Javascript loader for TGA file
  53950. * By Vincent Thibault
  53951. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53952. */
  53953. export class TGATools {
  53954. private static _TYPE_INDEXED;
  53955. private static _TYPE_RGB;
  53956. private static _TYPE_GREY;
  53957. private static _TYPE_RLE_INDEXED;
  53958. private static _TYPE_RLE_RGB;
  53959. private static _TYPE_RLE_GREY;
  53960. private static _ORIGIN_MASK;
  53961. private static _ORIGIN_SHIFT;
  53962. private static _ORIGIN_BL;
  53963. private static _ORIGIN_BR;
  53964. private static _ORIGIN_UL;
  53965. private static _ORIGIN_UR;
  53966. /**
  53967. * Gets the header of a TGA file
  53968. * @param data defines the TGA data
  53969. * @returns the header
  53970. */
  53971. static GetTGAHeader(data: Uint8Array): any;
  53972. /**
  53973. * Uploads TGA content to a Babylon Texture
  53974. * @hidden
  53975. */
  53976. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53977. /** @hidden */
  53978. 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;
  53979. /** @hidden */
  53980. 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;
  53981. /** @hidden */
  53982. 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;
  53983. /** @hidden */
  53984. 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;
  53985. /** @hidden */
  53986. 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;
  53987. /** @hidden */
  53988. 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;
  53989. }
  53990. }
  53991. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53992. import { Nullable } from "babylonjs/types";
  53993. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53994. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53995. /**
  53996. * Implementation of the TGA Texture Loader.
  53997. * @hidden
  53998. */
  53999. export class _TGATextureLoader implements IInternalTextureLoader {
  54000. /**
  54001. * Defines wether the loader supports cascade loading the different faces.
  54002. */
  54003. readonly supportCascades: boolean;
  54004. /**
  54005. * This returns if the loader support the current file information.
  54006. * @param extension defines the file extension of the file being loaded
  54007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54008. * @param fallback defines the fallback internal texture if any
  54009. * @param isBase64 defines whether the texture is encoded as a base64
  54010. * @param isBuffer defines whether the texture data are stored as a buffer
  54011. * @returns true if the loader can load the specified file
  54012. */
  54013. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54014. /**
  54015. * Transform the url before loading if required.
  54016. * @param rootUrl the url of the texture
  54017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54018. * @returns the transformed texture
  54019. */
  54020. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54021. /**
  54022. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54023. * @param rootUrl the url of the texture
  54024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54025. * @returns the fallback texture
  54026. */
  54027. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54028. /**
  54029. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54030. * @param data contains the texture data
  54031. * @param texture defines the BabylonJS internal texture
  54032. * @param createPolynomials will be true if polynomials have been requested
  54033. * @param onLoad defines the callback to trigger once the texture is ready
  54034. * @param onError defines the callback to trigger in case of error
  54035. */
  54036. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54037. /**
  54038. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54039. * @param data contains the texture data
  54040. * @param texture defines the BabylonJS internal texture
  54041. * @param callback defines the method to call once ready to upload
  54042. */
  54043. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54044. }
  54045. }
  54046. declare module "babylonjs/Misc/basis" {
  54047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54048. /**
  54049. * Info about the .basis files
  54050. */
  54051. class BasisFileInfo {
  54052. /**
  54053. * If the file has alpha
  54054. */
  54055. hasAlpha: boolean;
  54056. /**
  54057. * Info about each image of the basis file
  54058. */
  54059. images: Array<{
  54060. levels: Array<{
  54061. width: number;
  54062. height: number;
  54063. transcodedPixels: ArrayBufferView;
  54064. }>;
  54065. }>;
  54066. }
  54067. /**
  54068. * Result of transcoding a basis file
  54069. */
  54070. class TranscodeResult {
  54071. /**
  54072. * Info about the .basis file
  54073. */
  54074. fileInfo: BasisFileInfo;
  54075. /**
  54076. * Format to use when loading the file
  54077. */
  54078. format: number;
  54079. }
  54080. /**
  54081. * Configuration options for the Basis transcoder
  54082. */
  54083. export class BasisTranscodeConfiguration {
  54084. /**
  54085. * Supported compression formats used to determine the supported output format of the transcoder
  54086. */
  54087. supportedCompressionFormats?: {
  54088. /**
  54089. * etc1 compression format
  54090. */
  54091. etc1?: boolean;
  54092. /**
  54093. * s3tc compression format
  54094. */
  54095. s3tc?: boolean;
  54096. /**
  54097. * pvrtc compression format
  54098. */
  54099. pvrtc?: boolean;
  54100. /**
  54101. * etc2 compression format
  54102. */
  54103. etc2?: boolean;
  54104. };
  54105. /**
  54106. * If mipmap levels should be loaded for transcoded images (Default: true)
  54107. */
  54108. loadMipmapLevels?: boolean;
  54109. /**
  54110. * Index of a single image to load (Default: all images)
  54111. */
  54112. loadSingleImage?: number;
  54113. }
  54114. /**
  54115. * Used to load .Basis files
  54116. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54117. */
  54118. export class BasisTools {
  54119. private static _IgnoreSupportedFormats;
  54120. /**
  54121. * URL to use when loading the basis transcoder
  54122. */
  54123. static JSModuleURL: string;
  54124. /**
  54125. * URL to use when loading the wasm module for the transcoder
  54126. */
  54127. static WasmModuleURL: string;
  54128. /**
  54129. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54130. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54131. * @returns internal format corresponding to the Basis format
  54132. */
  54133. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54134. private static _WorkerPromise;
  54135. private static _Worker;
  54136. private static _actionId;
  54137. private static _CreateWorkerAsync;
  54138. /**
  54139. * Transcodes a loaded image file to compressed pixel data
  54140. * @param imageData image data to transcode
  54141. * @param config configuration options for the transcoding
  54142. * @returns a promise resulting in the transcoded image
  54143. */
  54144. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54145. /**
  54146. * Loads a texture from the transcode result
  54147. * @param texture texture load to
  54148. * @param transcodeResult the result of transcoding the basis file to load from
  54149. */
  54150. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54151. }
  54152. }
  54153. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54154. import { Nullable } from "babylonjs/types";
  54155. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54156. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54157. /**
  54158. * Loader for .basis file format
  54159. */
  54160. export class _BasisTextureLoader implements IInternalTextureLoader {
  54161. /**
  54162. * Defines whether the loader supports cascade loading the different faces.
  54163. */
  54164. readonly supportCascades: boolean;
  54165. /**
  54166. * This returns if the loader support the current file information.
  54167. * @param extension defines the file extension of the file being loaded
  54168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54169. * @param fallback defines the fallback internal texture if any
  54170. * @param isBase64 defines whether the texture is encoded as a base64
  54171. * @param isBuffer defines whether the texture data are stored as a buffer
  54172. * @returns true if the loader can load the specified file
  54173. */
  54174. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54175. /**
  54176. * Transform the url before loading if required.
  54177. * @param rootUrl the url of the texture
  54178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54179. * @returns the transformed texture
  54180. */
  54181. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54182. /**
  54183. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54184. * @param rootUrl the url of the texture
  54185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54186. * @returns the fallback texture
  54187. */
  54188. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54189. /**
  54190. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54191. * @param data contains the texture data
  54192. * @param texture defines the BabylonJS internal texture
  54193. * @param createPolynomials will be true if polynomials have been requested
  54194. * @param onLoad defines the callback to trigger once the texture is ready
  54195. * @param onError defines the callback to trigger in case of error
  54196. */
  54197. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54198. /**
  54199. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54200. * @param data contains the texture data
  54201. * @param texture defines the BabylonJS internal texture
  54202. * @param callback defines the method to call once ready to upload
  54203. */
  54204. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54205. }
  54206. }
  54207. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54208. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54209. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54210. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54211. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54212. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54213. }
  54214. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54215. import { Scene } from "babylonjs/scene";
  54216. import { Texture } from "babylonjs/Materials/Textures/texture";
  54217. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54218. /**
  54219. * 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.
  54220. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54221. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54222. */
  54223. export class CustomProceduralTexture extends ProceduralTexture {
  54224. private _animate;
  54225. private _time;
  54226. private _config;
  54227. private _texturePath;
  54228. /**
  54229. * Instantiates a new Custom Procedural Texture.
  54230. * 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.
  54231. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54232. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54233. * @param name Define the name of the texture
  54234. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54235. * @param size Define the size of the texture to create
  54236. * @param scene Define the scene the texture belongs to
  54237. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54238. * @param generateMipMaps Define if the texture should creates mip maps or not
  54239. */
  54240. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54241. private _loadJson;
  54242. /**
  54243. * Is the texture ready to be used ? (rendered at least once)
  54244. * @returns true if ready, otherwise, false.
  54245. */
  54246. isReady(): boolean;
  54247. /**
  54248. * Render the texture to its associated render target.
  54249. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54250. */
  54251. render(useCameraPostProcess?: boolean): void;
  54252. /**
  54253. * Update the list of dependant textures samplers in the shader.
  54254. */
  54255. updateTextures(): void;
  54256. /**
  54257. * Update the uniform values of the procedural texture in the shader.
  54258. */
  54259. updateShaderUniforms(): void;
  54260. /**
  54261. * Define if the texture animates or not.
  54262. */
  54263. animate: boolean;
  54264. }
  54265. }
  54266. declare module "babylonjs/Shaders/noise.fragment" {
  54267. /** @hidden */
  54268. export var noisePixelShader: {
  54269. name: string;
  54270. shader: string;
  54271. };
  54272. }
  54273. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54274. import { Nullable } from "babylonjs/types";
  54275. import { Scene } from "babylonjs/scene";
  54276. import { Texture } from "babylonjs/Materials/Textures/texture";
  54277. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54278. import "babylonjs/Shaders/noise.fragment";
  54279. /**
  54280. * Class used to generate noise procedural textures
  54281. */
  54282. export class NoiseProceduralTexture extends ProceduralTexture {
  54283. private _time;
  54284. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54285. brightness: number;
  54286. /** Defines the number of octaves to process */
  54287. octaves: number;
  54288. /** Defines the level of persistence (0.8 by default) */
  54289. persistence: number;
  54290. /** Gets or sets animation speed factor (default is 1) */
  54291. animationSpeedFactor: number;
  54292. /**
  54293. * Creates a new NoiseProceduralTexture
  54294. * @param name defines the name fo the texture
  54295. * @param size defines the size of the texture (default is 256)
  54296. * @param scene defines the hosting scene
  54297. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54298. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54299. */
  54300. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54301. private _updateShaderUniforms;
  54302. protected _getDefines(): string;
  54303. /** Generate the current state of the procedural texture */
  54304. render(useCameraPostProcess?: boolean): void;
  54305. /**
  54306. * Serializes this noise procedural texture
  54307. * @returns a serialized noise procedural texture object
  54308. */
  54309. serialize(): any;
  54310. /**
  54311. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54312. * @param parsedTexture defines parsed texture data
  54313. * @param scene defines the current scene
  54314. * @param rootUrl defines the root URL containing noise procedural texture information
  54315. * @returns a parsed NoiseProceduralTexture
  54316. */
  54317. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54318. }
  54319. }
  54320. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54321. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54322. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54323. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54324. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54325. }
  54326. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54327. import { Nullable } from "babylonjs/types";
  54328. import { Scene } from "babylonjs/scene";
  54329. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54330. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54331. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54332. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54333. /**
  54334. * Raw cube texture where the raw buffers are passed in
  54335. */
  54336. export class RawCubeTexture extends CubeTexture {
  54337. /**
  54338. * Creates a cube texture where the raw buffers are passed in.
  54339. * @param scene defines the scene the texture is attached to
  54340. * @param data defines the array of data to use to create each face
  54341. * @param size defines the size of the textures
  54342. * @param format defines the format of the data
  54343. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54344. * @param generateMipMaps defines if the engine should generate the mip levels
  54345. * @param invertY defines if data must be stored with Y axis inverted
  54346. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54347. * @param compression defines the compression used (null by default)
  54348. */
  54349. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54350. /**
  54351. * Updates the raw cube texture.
  54352. * @param data defines the data to store
  54353. * @param format defines the data format
  54354. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54355. * @param invertY defines if data must be stored with Y axis inverted
  54356. * @param compression defines the compression used (null by default)
  54357. * @param level defines which level of the texture to update
  54358. */
  54359. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54360. /**
  54361. * Updates a raw cube texture with RGBD encoded data.
  54362. * @param data defines the array of data [mipmap][face] to use to create each face
  54363. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54364. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54365. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54366. * @returns a promsie that resolves when the operation is complete
  54367. */
  54368. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54369. /**
  54370. * Clones the raw cube texture.
  54371. * @return a new cube texture
  54372. */
  54373. clone(): CubeTexture;
  54374. /** @hidden */
  54375. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54376. }
  54377. }
  54378. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54379. import { Scene } from "babylonjs/scene";
  54380. import { Texture } from "babylonjs/Materials/Textures/texture";
  54381. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54382. /**
  54383. * Class used to store 3D textures containing user data
  54384. */
  54385. export class RawTexture3D extends Texture {
  54386. /** Gets or sets the texture format to use */
  54387. format: number;
  54388. private _engine;
  54389. /**
  54390. * Create a new RawTexture3D
  54391. * @param data defines the data of the texture
  54392. * @param width defines the width of the texture
  54393. * @param height defines the height of the texture
  54394. * @param depth defines the depth of the texture
  54395. * @param format defines the texture format to use
  54396. * @param scene defines the hosting scene
  54397. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54398. * @param invertY defines if texture must be stored with Y axis inverted
  54399. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54400. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54401. */
  54402. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54403. /** Gets or sets the texture format to use */
  54404. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54405. /**
  54406. * Update the texture with new data
  54407. * @param data defines the data to store in the texture
  54408. */
  54409. update(data: ArrayBufferView): void;
  54410. }
  54411. }
  54412. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54413. import { Scene } from "babylonjs/scene";
  54414. import { Plane } from "babylonjs/Maths/math.plane";
  54415. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54416. /**
  54417. * Creates a refraction texture used by refraction channel of the standard material.
  54418. * It is like a mirror but to see through a material.
  54419. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54420. */
  54421. export class RefractionTexture extends RenderTargetTexture {
  54422. /**
  54423. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54424. * 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.
  54425. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54426. */
  54427. refractionPlane: Plane;
  54428. /**
  54429. * Define how deep under the surface we should see.
  54430. */
  54431. depth: number;
  54432. /**
  54433. * Creates a refraction texture used by refraction channel of the standard material.
  54434. * It is like a mirror but to see through a material.
  54435. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54436. * @param name Define the texture name
  54437. * @param size Define the size of the underlying texture
  54438. * @param scene Define the scene the refraction belongs to
  54439. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54440. */
  54441. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54442. /**
  54443. * Clone the refraction texture.
  54444. * @returns the cloned texture
  54445. */
  54446. clone(): RefractionTexture;
  54447. /**
  54448. * Serialize the texture to a JSON representation you could use in Parse later on
  54449. * @returns the serialized JSON representation
  54450. */
  54451. serialize(): any;
  54452. }
  54453. }
  54454. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54455. import { Nullable } from "babylonjs/types";
  54456. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54457. import { Matrix } from "babylonjs/Maths/math.vector";
  54458. import { Engine } from "babylonjs/Engines/engine";
  54459. import { Scene } from "babylonjs/scene";
  54460. /**
  54461. * Defines the options related to the creation of an HtmlElementTexture
  54462. */
  54463. export interface IHtmlElementTextureOptions {
  54464. /**
  54465. * Defines wether mip maps should be created or not.
  54466. */
  54467. generateMipMaps?: boolean;
  54468. /**
  54469. * Defines the sampling mode of the texture.
  54470. */
  54471. samplingMode?: number;
  54472. /**
  54473. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54474. */
  54475. engine: Nullable<Engine>;
  54476. /**
  54477. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54478. */
  54479. scene: Nullable<Scene>;
  54480. }
  54481. /**
  54482. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54483. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54484. * is automatically managed.
  54485. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54486. * in your application.
  54487. *
  54488. * As the update is not automatic, you need to call them manually.
  54489. */
  54490. export class HtmlElementTexture extends BaseTexture {
  54491. /**
  54492. * The texture URL.
  54493. */
  54494. element: HTMLVideoElement | HTMLCanvasElement;
  54495. private static readonly DefaultOptions;
  54496. private _textureMatrix;
  54497. private _engine;
  54498. private _isVideo;
  54499. private _generateMipMaps;
  54500. private _samplingMode;
  54501. /**
  54502. * Instantiates a HtmlElementTexture from the following parameters.
  54503. *
  54504. * @param name Defines the name of the texture
  54505. * @param element Defines the video or canvas the texture is filled with
  54506. * @param options Defines the other none mandatory texture creation options
  54507. */
  54508. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54509. private _createInternalTexture;
  54510. /**
  54511. * Returns the texture matrix used in most of the material.
  54512. */
  54513. getTextureMatrix(): Matrix;
  54514. /**
  54515. * Updates the content of the texture.
  54516. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54517. */
  54518. update(invertY?: Nullable<boolean>): void;
  54519. }
  54520. }
  54521. declare module "babylonjs/Materials/Textures/index" {
  54522. export * from "babylonjs/Materials/Textures/baseTexture";
  54523. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54524. export * from "babylonjs/Materials/Textures/cubeTexture";
  54525. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54526. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54527. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54528. export * from "babylonjs/Materials/Textures/internalTexture";
  54529. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54530. export * from "babylonjs/Materials/Textures/Loaders/index";
  54531. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54532. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54533. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54534. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54535. export * from "babylonjs/Materials/Textures/rawTexture";
  54536. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54537. export * from "babylonjs/Materials/Textures/refractionTexture";
  54538. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54539. export * from "babylonjs/Materials/Textures/texture";
  54540. export * from "babylonjs/Materials/Textures/videoTexture";
  54541. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54542. }
  54543. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54544. /**
  54545. * Enum used to define the target of a block
  54546. */
  54547. export enum NodeMaterialBlockTargets {
  54548. /** Vertex shader */
  54549. Vertex = 1,
  54550. /** Fragment shader */
  54551. Fragment = 2,
  54552. /** Neutral */
  54553. Neutral = 4,
  54554. /** Vertex and Fragment */
  54555. VertexAndFragment = 3
  54556. }
  54557. }
  54558. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54559. /**
  54560. * Defines the kind of connection point for node based material
  54561. */
  54562. export enum NodeMaterialBlockConnectionPointTypes {
  54563. /** Float */
  54564. Float = 1,
  54565. /** Int */
  54566. Int = 2,
  54567. /** Vector2 */
  54568. Vector2 = 4,
  54569. /** Vector3 */
  54570. Vector3 = 8,
  54571. /** Vector4 */
  54572. Vector4 = 16,
  54573. /** Color3 */
  54574. Color3 = 32,
  54575. /** Color4 */
  54576. Color4 = 64,
  54577. /** Matrix */
  54578. Matrix = 128,
  54579. /** Detect type based on connection */
  54580. AutoDetect = 1024,
  54581. /** Output type that will be defined by input type */
  54582. BasedOnInput = 2048
  54583. }
  54584. }
  54585. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54586. /**
  54587. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54588. */
  54589. export enum NodeMaterialBlockConnectionPointMode {
  54590. /** Value is an uniform */
  54591. Uniform = 0,
  54592. /** Value is a mesh attribute */
  54593. Attribute = 1,
  54594. /** Value is a varying between vertex and fragment shaders */
  54595. Varying = 2,
  54596. /** Mode is undefined */
  54597. Undefined = 3
  54598. }
  54599. }
  54600. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54601. /**
  54602. * Enum used to define system values e.g. values automatically provided by the system
  54603. */
  54604. export enum NodeMaterialSystemValues {
  54605. /** World */
  54606. World = 1,
  54607. /** View */
  54608. View = 2,
  54609. /** Projection */
  54610. Projection = 3,
  54611. /** ViewProjection */
  54612. ViewProjection = 4,
  54613. /** WorldView */
  54614. WorldView = 5,
  54615. /** WorldViewProjection */
  54616. WorldViewProjection = 6,
  54617. /** CameraPosition */
  54618. CameraPosition = 7,
  54619. /** Fog Color */
  54620. FogColor = 8
  54621. }
  54622. }
  54623. declare module "babylonjs/Materials/Node/Enums/index" {
  54624. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54625. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54626. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  54627. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  54628. }
  54629. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54631. /**
  54632. * Root class for all node material optimizers
  54633. */
  54634. export class NodeMaterialOptimizer {
  54635. /**
  54636. * Function used to optimize a NodeMaterial graph
  54637. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54638. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54639. */
  54640. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54641. }
  54642. }
  54643. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54647. import { Scene } from "babylonjs/scene";
  54648. /**
  54649. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54650. */
  54651. export class TransformBlock extends NodeMaterialBlock {
  54652. /**
  54653. * Defines the value to use to complement W value to transform it to a Vector4
  54654. */
  54655. complementW: number;
  54656. /**
  54657. * Defines the value to use to complement z value to transform it to a Vector4
  54658. */
  54659. complementZ: number;
  54660. /**
  54661. * Creates a new TransformBlock
  54662. * @param name defines the block name
  54663. */
  54664. constructor(name: string);
  54665. /**
  54666. * Gets the current class name
  54667. * @returns the class name
  54668. */
  54669. getClassName(): string;
  54670. /**
  54671. * Gets the vector input
  54672. */
  54673. readonly vector: NodeMaterialConnectionPoint;
  54674. /**
  54675. * Gets the output component
  54676. */
  54677. readonly output: NodeMaterialConnectionPoint;
  54678. /**
  54679. * Gets the matrix transform input
  54680. */
  54681. readonly transform: NodeMaterialConnectionPoint;
  54682. protected _buildBlock(state: NodeMaterialBuildState): this;
  54683. serialize(): any;
  54684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54685. protected _dumpPropertiesCode(): string;
  54686. }
  54687. }
  54688. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54692. /**
  54693. * Block used to output the vertex position
  54694. */
  54695. export class VertexOutputBlock extends NodeMaterialBlock {
  54696. /**
  54697. * Creates a new VertexOutputBlock
  54698. * @param name defines the block name
  54699. */
  54700. constructor(name: string);
  54701. /**
  54702. * Gets the current class name
  54703. * @returns the class name
  54704. */
  54705. getClassName(): string;
  54706. /**
  54707. * Gets the vector input component
  54708. */
  54709. readonly vector: NodeMaterialConnectionPoint;
  54710. protected _buildBlock(state: NodeMaterialBuildState): this;
  54711. }
  54712. }
  54713. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54717. /**
  54718. * Block used to output the final color
  54719. */
  54720. export class FragmentOutputBlock extends NodeMaterialBlock {
  54721. /**
  54722. * Create a new FragmentOutputBlock
  54723. * @param name defines the block name
  54724. */
  54725. constructor(name: string);
  54726. /**
  54727. * Gets the current class name
  54728. * @returns the class name
  54729. */
  54730. getClassName(): string;
  54731. /**
  54732. * Gets the rgba input component
  54733. */
  54734. readonly rgba: NodeMaterialConnectionPoint;
  54735. /**
  54736. * Gets the rgb input component
  54737. */
  54738. readonly rgb: NodeMaterialConnectionPoint;
  54739. /**
  54740. * Gets the a input component
  54741. */
  54742. readonly a: NodeMaterialConnectionPoint;
  54743. protected _buildBlock(state: NodeMaterialBuildState): this;
  54744. }
  54745. }
  54746. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54752. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54753. import { Effect } from "babylonjs/Materials/effect";
  54754. import { Mesh } from "babylonjs/Meshes/mesh";
  54755. import { Nullable } from "babylonjs/types";
  54756. import { Scene } from "babylonjs/scene";
  54757. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54758. /**
  54759. * Block used to read a reflection texture from a sampler
  54760. */
  54761. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54762. private _define3DName;
  54763. private _defineCubicName;
  54764. private _defineExplicitName;
  54765. private _defineProjectionName;
  54766. private _defineLocalCubicName;
  54767. private _defineSphericalName;
  54768. private _definePlanarName;
  54769. private _defineEquirectangularName;
  54770. private _defineMirroredEquirectangularFixedName;
  54771. private _defineEquirectangularFixedName;
  54772. private _defineSkyboxName;
  54773. private _cubeSamplerName;
  54774. private _2DSamplerName;
  54775. private _positionUVWName;
  54776. private _directionWName;
  54777. private _reflectionCoordsName;
  54778. private _reflection2DCoordsName;
  54779. private _reflectionColorName;
  54780. private _reflectionMatrixName;
  54781. /**
  54782. * Gets or sets the texture associated with the node
  54783. */
  54784. texture: Nullable<BaseTexture>;
  54785. /**
  54786. * Create a new TextureBlock
  54787. * @param name defines the block name
  54788. */
  54789. constructor(name: string);
  54790. /**
  54791. * Gets the current class name
  54792. * @returns the class name
  54793. */
  54794. getClassName(): string;
  54795. /**
  54796. * Gets the world position input component
  54797. */
  54798. readonly position: NodeMaterialConnectionPoint;
  54799. /**
  54800. * Gets the world position input component
  54801. */
  54802. readonly worldPosition: NodeMaterialConnectionPoint;
  54803. /**
  54804. * Gets the world normal input component
  54805. */
  54806. readonly worldNormal: NodeMaterialConnectionPoint;
  54807. /**
  54808. * Gets the world input component
  54809. */
  54810. readonly world: NodeMaterialConnectionPoint;
  54811. /**
  54812. * Gets the camera (or eye) position component
  54813. */
  54814. readonly cameraPosition: NodeMaterialConnectionPoint;
  54815. /**
  54816. * Gets the view input component
  54817. */
  54818. readonly view: NodeMaterialConnectionPoint;
  54819. /**
  54820. * Gets the rgb output component
  54821. */
  54822. readonly rgb: NodeMaterialConnectionPoint;
  54823. /**
  54824. * Gets the r output component
  54825. */
  54826. readonly r: NodeMaterialConnectionPoint;
  54827. /**
  54828. * Gets the g output component
  54829. */
  54830. readonly g: NodeMaterialConnectionPoint;
  54831. /**
  54832. * Gets the b output component
  54833. */
  54834. readonly b: NodeMaterialConnectionPoint;
  54835. autoConfigure(material: NodeMaterial): void;
  54836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54837. isReady(): boolean;
  54838. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54839. private _injectVertexCode;
  54840. private _writeOutput;
  54841. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54842. serialize(): any;
  54843. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54844. }
  54845. }
  54846. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54848. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54849. import { Scene } from "babylonjs/scene";
  54850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54851. import { Matrix } from "babylonjs/Maths/math.vector";
  54852. import { Mesh } from "babylonjs/Meshes/mesh";
  54853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54854. import { Observable } from "babylonjs/Misc/observable";
  54855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54856. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54857. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54858. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54859. import { Nullable } from "babylonjs/types";
  54860. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54861. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54862. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54863. /**
  54864. * Interface used to configure the node material editor
  54865. */
  54866. export interface INodeMaterialEditorOptions {
  54867. /** Define the URl to load node editor script */
  54868. editorURL?: string;
  54869. }
  54870. /** @hidden */
  54871. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54872. /** BONES */
  54873. NUM_BONE_INFLUENCERS: number;
  54874. BonesPerMesh: number;
  54875. BONETEXTURE: boolean;
  54876. /** MORPH TARGETS */
  54877. MORPHTARGETS: boolean;
  54878. MORPHTARGETS_NORMAL: boolean;
  54879. MORPHTARGETS_TANGENT: boolean;
  54880. MORPHTARGETS_UV: boolean;
  54881. NUM_MORPH_INFLUENCERS: number;
  54882. /** IMAGE PROCESSING */
  54883. IMAGEPROCESSING: boolean;
  54884. VIGNETTE: boolean;
  54885. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54886. VIGNETTEBLENDMODEOPAQUE: boolean;
  54887. TONEMAPPING: boolean;
  54888. TONEMAPPING_ACES: boolean;
  54889. CONTRAST: boolean;
  54890. EXPOSURE: boolean;
  54891. COLORCURVES: boolean;
  54892. COLORGRADING: boolean;
  54893. COLORGRADING3D: boolean;
  54894. SAMPLER3DGREENDEPTH: boolean;
  54895. SAMPLER3DBGRMAP: boolean;
  54896. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54897. /** MISC. */
  54898. BUMPDIRECTUV: number;
  54899. constructor();
  54900. setValue(name: string, value: boolean): void;
  54901. }
  54902. /**
  54903. * Class used to configure NodeMaterial
  54904. */
  54905. export interface INodeMaterialOptions {
  54906. /**
  54907. * Defines if blocks should emit comments
  54908. */
  54909. emitComments: boolean;
  54910. }
  54911. /**
  54912. * Class used to create a node based material built by assembling shader blocks
  54913. */
  54914. export class NodeMaterial extends PushMaterial {
  54915. private static _BuildIdGenerator;
  54916. private _options;
  54917. private _vertexCompilationState;
  54918. private _fragmentCompilationState;
  54919. private _sharedData;
  54920. private _buildId;
  54921. private _buildWasSuccessful;
  54922. private _cachedWorldViewMatrix;
  54923. private _cachedWorldViewProjectionMatrix;
  54924. private _optimizers;
  54925. private _animationFrame;
  54926. /** Define the URl to load node editor script */
  54927. static EditorURL: string;
  54928. private BJSNODEMATERIALEDITOR;
  54929. /** Get the inspector from bundle or global */
  54930. private _getGlobalNodeMaterialEditor;
  54931. /**
  54932. * 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)
  54933. */
  54934. ignoreAlpha: boolean;
  54935. /**
  54936. * Defines the maximum number of lights that can be used in the material
  54937. */
  54938. maxSimultaneousLights: number;
  54939. /**
  54940. * Observable raised when the material is built
  54941. */
  54942. onBuildObservable: Observable<NodeMaterial>;
  54943. /**
  54944. * Gets or sets the root nodes of the material vertex shader
  54945. */
  54946. _vertexOutputNodes: NodeMaterialBlock[];
  54947. /**
  54948. * Gets or sets the root nodes of the material fragment (pixel) shader
  54949. */
  54950. _fragmentOutputNodes: NodeMaterialBlock[];
  54951. /** Gets or sets options to control the node material overall behavior */
  54952. options: INodeMaterialOptions;
  54953. /**
  54954. * Default configuration related to image processing available in the standard Material.
  54955. */
  54956. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54957. /**
  54958. * Gets the image processing configuration used either in this material.
  54959. */
  54960. /**
  54961. * Sets the Default image processing configuration used either in the this material.
  54962. *
  54963. * If sets to null, the scene one is in use.
  54964. */
  54965. imageProcessingConfiguration: ImageProcessingConfiguration;
  54966. /**
  54967. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54968. */
  54969. attachedBlocks: NodeMaterialBlock[];
  54970. /**
  54971. * Create a new node based material
  54972. * @param name defines the material name
  54973. * @param scene defines the hosting scene
  54974. * @param options defines creation option
  54975. */
  54976. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54977. /**
  54978. * Gets the current class name of the material e.g. "NodeMaterial"
  54979. * @returns the class name
  54980. */
  54981. getClassName(): string;
  54982. /**
  54983. * Keep track of the image processing observer to allow dispose and replace.
  54984. */
  54985. private _imageProcessingObserver;
  54986. /**
  54987. * Attaches a new image processing configuration to the Standard Material.
  54988. * @param configuration
  54989. */
  54990. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54991. /**
  54992. * Get a block by its name
  54993. * @param name defines the name of the block to retrieve
  54994. * @returns the required block or null if not found
  54995. */
  54996. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54997. /**
  54998. * Get a block by its name
  54999. * @param predicate defines the predicate used to find the good candidate
  55000. * @returns the required block or null if not found
  55001. */
  55002. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55003. /**
  55004. * Get an input block by its name
  55005. * @param predicate defines the predicate used to find the good candidate
  55006. * @returns the required input block or null if not found
  55007. */
  55008. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55009. /**
  55010. * Gets the list of input blocks attached to this material
  55011. * @returns an array of InputBlocks
  55012. */
  55013. getInputBlocks(): InputBlock[];
  55014. /**
  55015. * Adds a new optimizer to the list of optimizers
  55016. * @param optimizer defines the optimizers to add
  55017. * @returns the current material
  55018. */
  55019. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55020. /**
  55021. * Remove an optimizer from the list of optimizers
  55022. * @param optimizer defines the optimizers to remove
  55023. * @returns the current material
  55024. */
  55025. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55026. /**
  55027. * Add a new block to the list of output nodes
  55028. * @param node defines the node to add
  55029. * @returns the current material
  55030. */
  55031. addOutputNode(node: NodeMaterialBlock): this;
  55032. /**
  55033. * Remove a block from the list of root nodes
  55034. * @param node defines the node to remove
  55035. * @returns the current material
  55036. */
  55037. removeOutputNode(node: NodeMaterialBlock): this;
  55038. private _addVertexOutputNode;
  55039. private _removeVertexOutputNode;
  55040. private _addFragmentOutputNode;
  55041. private _removeFragmentOutputNode;
  55042. /**
  55043. * Specifies if the material will require alpha blending
  55044. * @returns a boolean specifying if alpha blending is needed
  55045. */
  55046. needAlphaBlending(): boolean;
  55047. /**
  55048. * Specifies if this material should be rendered in alpha test mode
  55049. * @returns a boolean specifying if an alpha test is needed.
  55050. */
  55051. needAlphaTesting(): boolean;
  55052. private _initializeBlock;
  55053. private _resetDualBlocks;
  55054. /**
  55055. * Build the material and generates the inner effect
  55056. * @param verbose defines if the build should log activity
  55057. */
  55058. build(verbose?: boolean): void;
  55059. /**
  55060. * Runs an otpimization phase to try to improve the shader code
  55061. */
  55062. optimize(): void;
  55063. private _prepareDefinesForAttributes;
  55064. /**
  55065. * Get if the submesh is ready to be used and all its information available.
  55066. * Child classes can use it to update shaders
  55067. * @param mesh defines the mesh to check
  55068. * @param subMesh defines which submesh to check
  55069. * @param useInstances specifies that instances should be used
  55070. * @returns a boolean indicating that the submesh is ready or not
  55071. */
  55072. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55073. /**
  55074. * Get a string representing the shaders built by the current node graph
  55075. */
  55076. readonly compiledShaders: string;
  55077. /**
  55078. * Binds the world matrix to the material
  55079. * @param world defines the world transformation matrix
  55080. */
  55081. bindOnlyWorldMatrix(world: Matrix): void;
  55082. /**
  55083. * Binds the submesh to this material by preparing the effect and shader to draw
  55084. * @param world defines the world transformation matrix
  55085. * @param mesh defines the mesh containing the submesh
  55086. * @param subMesh defines the submesh to bind the material to
  55087. */
  55088. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55089. /**
  55090. * Gets the active textures from the material
  55091. * @returns an array of textures
  55092. */
  55093. getActiveTextures(): BaseTexture[];
  55094. /**
  55095. * Gets the list of texture blocks
  55096. * @returns an array of texture blocks
  55097. */
  55098. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55099. /**
  55100. * Specifies if the material uses a texture
  55101. * @param texture defines the texture to check against the material
  55102. * @returns a boolean specifying if the material uses the texture
  55103. */
  55104. hasTexture(texture: BaseTexture): boolean;
  55105. /**
  55106. * Disposes the material
  55107. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55108. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55109. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55110. */
  55111. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55112. /** Creates the node editor window. */
  55113. private _createNodeEditor;
  55114. /**
  55115. * Launch the node material editor
  55116. * @param config Define the configuration of the editor
  55117. * @return a promise fulfilled when the node editor is visible
  55118. */
  55119. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55120. /**
  55121. * Clear the current material
  55122. */
  55123. clear(): void;
  55124. /**
  55125. * Clear the current material and set it to a default state
  55126. */
  55127. setToDefault(): void;
  55128. /**
  55129. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55130. * @param url defines the url to load from
  55131. * @returns a promise that will fullfil when the material is fully loaded
  55132. */
  55133. loadAsync(url: string): Promise<unknown>;
  55134. private _gatherBlocks;
  55135. /**
  55136. * Generate a string containing the code declaration required to create an equivalent of this material
  55137. * @returns a string
  55138. */
  55139. generateCode(): string;
  55140. /**
  55141. * Serializes this material in a JSON representation
  55142. * @returns the serialized material object
  55143. */
  55144. serialize(): any;
  55145. private _restoreConnections;
  55146. /**
  55147. * Clear the current graph and load a new one from a serialization object
  55148. * @param source defines the JSON representation of the material
  55149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55150. */
  55151. loadFromSerialization(source: any, rootUrl?: string): void;
  55152. /**
  55153. * Creates a node material from parsed material data
  55154. * @param source defines the JSON representation of the material
  55155. * @param scene defines the hosting scene
  55156. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55157. * @returns a new node material
  55158. */
  55159. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55160. /**
  55161. * Creates a new node material set to default basic configuration
  55162. * @param name defines the name of the material
  55163. * @param scene defines the hosting scene
  55164. * @returns a new NodeMaterial
  55165. */
  55166. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55167. }
  55168. }
  55169. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55172. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55173. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55175. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55176. import { Effect } from "babylonjs/Materials/effect";
  55177. import { Mesh } from "babylonjs/Meshes/mesh";
  55178. import { Nullable } from "babylonjs/types";
  55179. import { Texture } from "babylonjs/Materials/Textures/texture";
  55180. import { Scene } from "babylonjs/scene";
  55181. /**
  55182. * Block used to read a texture from a sampler
  55183. */
  55184. export class TextureBlock extends NodeMaterialBlock {
  55185. private _defineName;
  55186. private _samplerName;
  55187. private _transformedUVName;
  55188. private _textureTransformName;
  55189. private _textureInfoName;
  55190. private _mainUVName;
  55191. private _mainUVDefineName;
  55192. /**
  55193. * Gets or sets the texture associated with the node
  55194. */
  55195. texture: Nullable<Texture>;
  55196. /**
  55197. * Create a new TextureBlock
  55198. * @param name defines the block name
  55199. */
  55200. constructor(name: string);
  55201. /**
  55202. * Gets the current class name
  55203. * @returns the class name
  55204. */
  55205. getClassName(): string;
  55206. /**
  55207. * Gets the uv input component
  55208. */
  55209. readonly uv: NodeMaterialConnectionPoint;
  55210. /**
  55211. * Gets the rgba output component
  55212. */
  55213. readonly rgba: NodeMaterialConnectionPoint;
  55214. /**
  55215. * Gets the rgb output component
  55216. */
  55217. readonly rgb: NodeMaterialConnectionPoint;
  55218. /**
  55219. * Gets the r output component
  55220. */
  55221. readonly r: NodeMaterialConnectionPoint;
  55222. /**
  55223. * Gets the g output component
  55224. */
  55225. readonly g: NodeMaterialConnectionPoint;
  55226. /**
  55227. * Gets the b output component
  55228. */
  55229. readonly b: NodeMaterialConnectionPoint;
  55230. /**
  55231. * Gets the a output component
  55232. */
  55233. readonly a: NodeMaterialConnectionPoint;
  55234. readonly target: NodeMaterialBlockTargets;
  55235. autoConfigure(material: NodeMaterial): void;
  55236. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55237. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55238. isReady(): boolean;
  55239. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55240. private readonly _isMixed;
  55241. private _injectVertexCode;
  55242. private _writeOutput;
  55243. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55244. protected _dumpPropertiesCode(): string;
  55245. serialize(): any;
  55246. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55247. }
  55248. }
  55249. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55251. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55252. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55253. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55254. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55255. import { Scene } from "babylonjs/scene";
  55256. /**
  55257. * Class used to store shared data between 2 NodeMaterialBuildState
  55258. */
  55259. export class NodeMaterialBuildStateSharedData {
  55260. /**
  55261. * Gets the list of emitted varyings
  55262. */
  55263. temps: string[];
  55264. /**
  55265. * Gets the list of emitted varyings
  55266. */
  55267. varyings: string[];
  55268. /**
  55269. * Gets the varying declaration string
  55270. */
  55271. varyingDeclaration: string;
  55272. /**
  55273. * Input blocks
  55274. */
  55275. inputBlocks: InputBlock[];
  55276. /**
  55277. * Input blocks
  55278. */
  55279. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55280. /**
  55281. * Bindable blocks (Blocks that need to set data to the effect)
  55282. */
  55283. bindableBlocks: NodeMaterialBlock[];
  55284. /**
  55285. * List of blocks that can provide a compilation fallback
  55286. */
  55287. blocksWithFallbacks: NodeMaterialBlock[];
  55288. /**
  55289. * List of blocks that can provide a define update
  55290. */
  55291. blocksWithDefines: NodeMaterialBlock[];
  55292. /**
  55293. * List of blocks that can provide a repeatable content
  55294. */
  55295. repeatableContentBlocks: NodeMaterialBlock[];
  55296. /**
  55297. * List of blocks that can provide a dynamic list of uniforms
  55298. */
  55299. dynamicUniformBlocks: NodeMaterialBlock[];
  55300. /**
  55301. * List of blocks that can block the isReady function for the material
  55302. */
  55303. blockingBlocks: NodeMaterialBlock[];
  55304. /**
  55305. * Gets the list of animated inputs
  55306. */
  55307. animatedInputs: InputBlock[];
  55308. /**
  55309. * Build Id used to avoid multiple recompilations
  55310. */
  55311. buildId: number;
  55312. /** List of emitted variables */
  55313. variableNames: {
  55314. [key: string]: number;
  55315. };
  55316. /** List of emitted defines */
  55317. defineNames: {
  55318. [key: string]: number;
  55319. };
  55320. /** Should emit comments? */
  55321. emitComments: boolean;
  55322. /** Emit build activity */
  55323. verbose: boolean;
  55324. /** Gets or sets the hosting scene */
  55325. scene: Scene;
  55326. /**
  55327. * Gets the compilation hints emitted at compilation time
  55328. */
  55329. hints: {
  55330. needWorldViewMatrix: boolean;
  55331. needWorldViewProjectionMatrix: boolean;
  55332. needAlphaBlending: boolean;
  55333. needAlphaTesting: boolean;
  55334. };
  55335. /**
  55336. * List of compilation checks
  55337. */
  55338. checks: {
  55339. emitVertex: boolean;
  55340. emitFragment: boolean;
  55341. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55342. };
  55343. /** Creates a new shared data */
  55344. constructor();
  55345. /**
  55346. * Emits console errors and exceptions if there is a failing check
  55347. */
  55348. emitErrors(): void;
  55349. }
  55350. }
  55351. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55352. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55353. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55354. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55355. /**
  55356. * Class used to store node based material build state
  55357. */
  55358. export class NodeMaterialBuildState {
  55359. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55360. supportUniformBuffers: boolean;
  55361. /**
  55362. * Gets the list of emitted attributes
  55363. */
  55364. attributes: string[];
  55365. /**
  55366. * Gets the list of emitted uniforms
  55367. */
  55368. uniforms: string[];
  55369. /**
  55370. * Gets the list of emitted constants
  55371. */
  55372. constants: string[];
  55373. /**
  55374. * Gets the list of emitted uniform buffers
  55375. */
  55376. uniformBuffers: string[];
  55377. /**
  55378. * Gets the list of emitted samplers
  55379. */
  55380. samplers: string[];
  55381. /**
  55382. * Gets the list of emitted functions
  55383. */
  55384. functions: {
  55385. [key: string]: string;
  55386. };
  55387. /**
  55388. * Gets the list of emitted extensions
  55389. */
  55390. extensions: {
  55391. [key: string]: string;
  55392. };
  55393. /**
  55394. * Gets the target of the compilation state
  55395. */
  55396. target: NodeMaterialBlockTargets;
  55397. /**
  55398. * Gets the list of emitted counters
  55399. */
  55400. counters: {
  55401. [key: string]: number;
  55402. };
  55403. /**
  55404. * Shared data between multiple NodeMaterialBuildState instances
  55405. */
  55406. sharedData: NodeMaterialBuildStateSharedData;
  55407. /** @hidden */
  55408. _vertexState: NodeMaterialBuildState;
  55409. /** @hidden */
  55410. _attributeDeclaration: string;
  55411. /** @hidden */
  55412. _uniformDeclaration: string;
  55413. /** @hidden */
  55414. _constantDeclaration: string;
  55415. /** @hidden */
  55416. _samplerDeclaration: string;
  55417. /** @hidden */
  55418. _varyingTransfer: string;
  55419. private _repeatableContentAnchorIndex;
  55420. /** @hidden */
  55421. _builtCompilationString: string;
  55422. /**
  55423. * Gets the emitted compilation strings
  55424. */
  55425. compilationString: string;
  55426. /**
  55427. * Finalize the compilation strings
  55428. * @param state defines the current compilation state
  55429. */
  55430. finalize(state: NodeMaterialBuildState): void;
  55431. /** @hidden */
  55432. readonly _repeatableContentAnchor: string;
  55433. /** @hidden */
  55434. _getFreeVariableName(prefix: string): string;
  55435. /** @hidden */
  55436. _getFreeDefineName(prefix: string): string;
  55437. /** @hidden */
  55438. _excludeVariableName(name: string): void;
  55439. /** @hidden */
  55440. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55441. /** @hidden */
  55442. _emitExtension(name: string, extension: string): void;
  55443. /** @hidden */
  55444. _emitFunction(name: string, code: string, comments: string): void;
  55445. /** @hidden */
  55446. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55447. replaceStrings?: {
  55448. search: RegExp;
  55449. replace: string;
  55450. }[];
  55451. repeatKey?: string;
  55452. }): string;
  55453. /** @hidden */
  55454. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55455. repeatKey?: string;
  55456. removeAttributes?: boolean;
  55457. removeUniforms?: boolean;
  55458. removeVaryings?: boolean;
  55459. removeIfDef?: boolean;
  55460. replaceStrings?: {
  55461. search: RegExp;
  55462. replace: string;
  55463. }[];
  55464. }, storeKey?: string): void;
  55465. /** @hidden */
  55466. _registerTempVariable(name: string): boolean;
  55467. /** @hidden */
  55468. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55469. /** @hidden */
  55470. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55471. }
  55472. }
  55473. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55474. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55476. import { Nullable } from "babylonjs/types";
  55477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55478. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55479. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55481. import { Mesh } from "babylonjs/Meshes/mesh";
  55482. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55483. import { Scene } from "babylonjs/scene";
  55484. /**
  55485. * Defines a block that can be used inside a node based material
  55486. */
  55487. export class NodeMaterialBlock {
  55488. private _buildId;
  55489. private _buildTarget;
  55490. private _target;
  55491. private _isFinalMerger;
  55492. private _isInput;
  55493. /** @hidden */
  55494. _codeVariableName: string;
  55495. /** @hidden */
  55496. _inputs: NodeMaterialConnectionPoint[];
  55497. /** @hidden */
  55498. _outputs: NodeMaterialConnectionPoint[];
  55499. /** @hidden */
  55500. _preparationId: number;
  55501. /**
  55502. * Gets or sets the name of the block
  55503. */
  55504. name: string;
  55505. /**
  55506. * Gets or sets the unique id of the node
  55507. */
  55508. uniqueId: number;
  55509. /**
  55510. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55511. */
  55512. readonly isFinalMerger: boolean;
  55513. /**
  55514. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55515. */
  55516. readonly isInput: boolean;
  55517. /**
  55518. * Gets or sets the build Id
  55519. */
  55520. buildId: number;
  55521. /**
  55522. * Gets or sets the target of the block
  55523. */
  55524. target: NodeMaterialBlockTargets;
  55525. /**
  55526. * Gets the list of input points
  55527. */
  55528. readonly inputs: NodeMaterialConnectionPoint[];
  55529. /** Gets the list of output points */
  55530. readonly outputs: NodeMaterialConnectionPoint[];
  55531. /**
  55532. * Find an input by its name
  55533. * @param name defines the name of the input to look for
  55534. * @returns the input or null if not found
  55535. */
  55536. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55537. /**
  55538. * Find an output by its name
  55539. * @param name defines the name of the outputto look for
  55540. * @returns the output or null if not found
  55541. */
  55542. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55543. /**
  55544. * Creates a new NodeMaterialBlock
  55545. * @param name defines the block name
  55546. * @param target defines the target of that block (Vertex by default)
  55547. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55548. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55549. */
  55550. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55551. /**
  55552. * Initialize the block and prepare the context for build
  55553. * @param state defines the state that will be used for the build
  55554. */
  55555. initialize(state: NodeMaterialBuildState): void;
  55556. /**
  55557. * Bind data to effect. Will only be called for blocks with isBindable === true
  55558. * @param effect defines the effect to bind data to
  55559. * @param nodeMaterial defines the hosting NodeMaterial
  55560. * @param mesh defines the mesh that will be rendered
  55561. */
  55562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55563. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55564. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55565. protected _writeFloat(value: number): string;
  55566. /**
  55567. * Gets the current class name e.g. "NodeMaterialBlock"
  55568. * @returns the class name
  55569. */
  55570. getClassName(): string;
  55571. /**
  55572. * Register a new input. Must be called inside a block constructor
  55573. * @param name defines the connection point name
  55574. * @param type defines the connection point type
  55575. * @param isOptional defines a boolean indicating that this input can be omitted
  55576. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55577. * @returns the current block
  55578. */
  55579. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55580. /**
  55581. * Register a new output. Must be called inside a block constructor
  55582. * @param name defines the connection point name
  55583. * @param type defines the connection point type
  55584. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55585. * @returns the current block
  55586. */
  55587. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55588. /**
  55589. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55590. * @param forOutput defines an optional connection point to check compatibility with
  55591. * @returns the first available input or null
  55592. */
  55593. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55594. /**
  55595. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55596. * @param forBlock defines an optional block to check compatibility with
  55597. * @returns the first available input or null
  55598. */
  55599. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55600. /**
  55601. * Gets the sibling of the given output
  55602. * @param current defines the current output
  55603. * @returns the next output in the list or null
  55604. */
  55605. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55606. /**
  55607. * Connect current block with another block
  55608. * @param other defines the block to connect with
  55609. * @param options define the various options to help pick the right connections
  55610. * @returns the current block
  55611. */
  55612. connectTo(other: NodeMaterialBlock, options?: {
  55613. input?: string;
  55614. output?: string;
  55615. outputSwizzle?: string;
  55616. }): this | undefined;
  55617. protected _buildBlock(state: NodeMaterialBuildState): void;
  55618. /**
  55619. * Add uniforms, samplers and uniform buffers at compilation time
  55620. * @param state defines the state to update
  55621. * @param nodeMaterial defines the node material requesting the update
  55622. * @param defines defines the material defines to update
  55623. */
  55624. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55625. /**
  55626. * Add potential fallbacks if shader compilation fails
  55627. * @param mesh defines the mesh to be rendered
  55628. * @param fallbacks defines the current prioritized list of fallbacks
  55629. */
  55630. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55631. /**
  55632. * Initialize defines for shader compilation
  55633. * @param mesh defines the mesh to be rendered
  55634. * @param nodeMaterial defines the node material requesting the update
  55635. * @param defines defines the material defines to update
  55636. * @param useInstances specifies that instances should be used
  55637. */
  55638. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55639. /**
  55640. * Update defines for shader compilation
  55641. * @param mesh defines the mesh to be rendered
  55642. * @param nodeMaterial defines the node material requesting the update
  55643. * @param defines defines the material defines to update
  55644. * @param useInstances specifies that instances should be used
  55645. */
  55646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55647. /**
  55648. * Lets the block try to connect some inputs automatically
  55649. * @param material defines the hosting NodeMaterial
  55650. */
  55651. autoConfigure(material: NodeMaterial): void;
  55652. /**
  55653. * Function called when a block is declared as repeatable content generator
  55654. * @param vertexShaderState defines the current compilation state for the vertex shader
  55655. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55656. * @param mesh defines the mesh to be rendered
  55657. * @param defines defines the material defines to update
  55658. */
  55659. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55660. /**
  55661. * Checks if the block is ready
  55662. * @param mesh defines the mesh to be rendered
  55663. * @param nodeMaterial defines the node material requesting the update
  55664. * @param defines defines the material defines to update
  55665. * @param useInstances specifies that instances should be used
  55666. * @returns true if the block is ready
  55667. */
  55668. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55669. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55670. private _processBuild;
  55671. /**
  55672. * Compile the current node and generate the shader code
  55673. * @param state defines the current compilation state (uniforms, samplers, current string)
  55674. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55675. * @returns true if already built
  55676. */
  55677. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55678. protected _inputRename(name: string): string;
  55679. protected _outputRename(name: string): string;
  55680. protected _dumpPropertiesCode(): string;
  55681. /** @hidden */
  55682. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55683. /**
  55684. * Clone the current block to a new identical block
  55685. * @param scene defines the hosting scene
  55686. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55687. * @returns a copy of the current block
  55688. */
  55689. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55690. /**
  55691. * Serializes this block in a JSON representation
  55692. * @returns the serialized block object
  55693. */
  55694. serialize(): any;
  55695. /** @hidden */
  55696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55697. }
  55698. }
  55699. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55700. /**
  55701. * Enum defining the type of animations supported by InputBlock
  55702. */
  55703. export enum AnimatedInputBlockTypes {
  55704. /** No animation */
  55705. None = 0,
  55706. /** Time based animation. Will only work for floats */
  55707. Time = 1
  55708. }
  55709. }
  55710. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55712. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55713. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55714. import { Nullable } from "babylonjs/types";
  55715. import { Effect } from "babylonjs/Materials/effect";
  55716. import { Matrix } from "babylonjs/Maths/math.vector";
  55717. import { Scene } from "babylonjs/scene";
  55718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55720. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55721. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55722. /**
  55723. * Block used to expose an input value
  55724. */
  55725. export class InputBlock extends NodeMaterialBlock {
  55726. private _mode;
  55727. private _associatedVariableName;
  55728. private _storedValue;
  55729. private _valueCallback;
  55730. private _type;
  55731. private _animationType;
  55732. /** Gets or set a value used to limit the range of float values */
  55733. min: number;
  55734. /** Gets or set a value used to limit the range of float values */
  55735. max: number;
  55736. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55737. matrixMode: number;
  55738. /** @hidden */
  55739. _systemValue: Nullable<NodeMaterialSystemValues>;
  55740. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55741. visibleInInspector: boolean;
  55742. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55743. isConstant: boolean;
  55744. /**
  55745. * Gets or sets the connection point type (default is float)
  55746. */
  55747. readonly type: NodeMaterialBlockConnectionPointTypes;
  55748. /**
  55749. * Creates a new InputBlock
  55750. * @param name defines the block name
  55751. * @param target defines the target of that block (Vertex by default)
  55752. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55753. */
  55754. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55755. /**
  55756. * Gets the output component
  55757. */
  55758. readonly output: NodeMaterialConnectionPoint;
  55759. /**
  55760. * Set the source of this connection point to a vertex attribute
  55761. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55762. * @returns the current connection point
  55763. */
  55764. setAsAttribute(attributeName?: string): InputBlock;
  55765. /**
  55766. * Set the source of this connection point to a system value
  55767. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55768. * @returns the current connection point
  55769. */
  55770. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55771. /**
  55772. * Gets or sets the value of that point.
  55773. * Please note that this value will be ignored if valueCallback is defined
  55774. */
  55775. value: any;
  55776. /**
  55777. * Gets or sets a callback used to get the value of that point.
  55778. * Please note that setting this value will force the connection point to ignore the value property
  55779. */
  55780. valueCallback: () => any;
  55781. /**
  55782. * Gets or sets the associated variable name in the shader
  55783. */
  55784. associatedVariableName: string;
  55785. /** Gets or sets the type of animation applied to the input */
  55786. animationType: AnimatedInputBlockTypes;
  55787. /**
  55788. * Gets a boolean indicating that this connection point not defined yet
  55789. */
  55790. readonly isUndefined: boolean;
  55791. /**
  55792. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55793. * In this case the connection point name must be the name of the uniform to use.
  55794. * Can only be set on inputs
  55795. */
  55796. isUniform: boolean;
  55797. /**
  55798. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55799. * In this case the connection point name must be the name of the attribute to use
  55800. * Can only be set on inputs
  55801. */
  55802. isAttribute: boolean;
  55803. /**
  55804. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55805. * Can only be set on exit points
  55806. */
  55807. isVarying: boolean;
  55808. /**
  55809. * Gets a boolean indicating that the current connection point is a system value
  55810. */
  55811. readonly isSystemValue: boolean;
  55812. /**
  55813. * Gets or sets the current well known value or null if not defined as a system value
  55814. */
  55815. systemValue: Nullable<NodeMaterialSystemValues>;
  55816. /**
  55817. * Gets the current class name
  55818. * @returns the class name
  55819. */
  55820. getClassName(): string;
  55821. /**
  55822. * Animate the input if animationType !== None
  55823. * @param scene defines the rendering scene
  55824. */
  55825. animate(scene: Scene): void;
  55826. private _emitDefine;
  55827. initialize(state: NodeMaterialBuildState): void;
  55828. /**
  55829. * Set the input block to its default value (based on its type)
  55830. */
  55831. setDefaultValue(): void;
  55832. private _emitConstant;
  55833. private _emit;
  55834. /** @hidden */
  55835. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55836. /** @hidden */
  55837. _transmit(effect: Effect, scene: Scene): void;
  55838. protected _buildBlock(state: NodeMaterialBuildState): void;
  55839. protected _dumpPropertiesCode(): string;
  55840. serialize(): any;
  55841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55842. }
  55843. }
  55844. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55845. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55846. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55847. import { Nullable } from "babylonjs/types";
  55848. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55850. /**
  55851. * Defines a connection point for a block
  55852. */
  55853. export class NodeMaterialConnectionPoint {
  55854. /** @hidden */
  55855. _ownerBlock: NodeMaterialBlock;
  55856. /** @hidden */
  55857. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55858. private _endpoints;
  55859. private _associatedVariableName;
  55860. /** @hidden */
  55861. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55862. /** @hidden */
  55863. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55864. private _type;
  55865. /** @hidden */
  55866. _enforceAssociatedVariableName: boolean;
  55867. /**
  55868. * Gets or sets the additional types supported by this connection point
  55869. */
  55870. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55871. /**
  55872. * Gets or sets the additional types excluded by this connection point
  55873. */
  55874. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55875. /**
  55876. * Gets or sets the associated variable name in the shader
  55877. */
  55878. associatedVariableName: string;
  55879. /**
  55880. * Gets or sets the connection point type (default is float)
  55881. */
  55882. type: NodeMaterialBlockConnectionPointTypes;
  55883. /**
  55884. * Gets or sets the connection point name
  55885. */
  55886. name: string;
  55887. /**
  55888. * Gets or sets a boolean indicating that this connection point can be omitted
  55889. */
  55890. isOptional: boolean;
  55891. /**
  55892. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55893. */
  55894. define: string;
  55895. /** Gets or sets the target of that connection point */
  55896. target: NodeMaterialBlockTargets;
  55897. /**
  55898. * Gets a boolean indicating that the current point is connected
  55899. */
  55900. readonly isConnected: boolean;
  55901. /**
  55902. * Gets a boolean indicating that the current point is connected to an input block
  55903. */
  55904. readonly isConnectedToInputBlock: boolean;
  55905. /**
  55906. * Gets a the connected input block (if any)
  55907. */
  55908. readonly connectInputBlock: Nullable<InputBlock>;
  55909. /** Get the other side of the connection (if any) */
  55910. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55911. /** Get the block that owns this connection point */
  55912. readonly ownerBlock: NodeMaterialBlock;
  55913. /** Get the block connected on the other side of this connection (if any) */
  55914. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55915. /** Get the block connected on the endpoints of this connection (if any) */
  55916. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55917. /** Gets the list of connected endpoints */
  55918. readonly endpoints: NodeMaterialConnectionPoint[];
  55919. /** Gets a boolean indicating if that output point is connected to at least one input */
  55920. readonly hasEndpoints: boolean;
  55921. /**
  55922. * Creates a new connection point
  55923. * @param name defines the connection point name
  55924. * @param ownerBlock defines the block hosting this connection point
  55925. */
  55926. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55927. /**
  55928. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55929. * @returns the class name
  55930. */
  55931. getClassName(): string;
  55932. /**
  55933. * Gets an boolean indicating if the current point can be connected to another point
  55934. * @param connectionPoint defines the other connection point
  55935. * @returns true if the connection is possible
  55936. */
  55937. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55938. /**
  55939. * Connect this point to another connection point
  55940. * @param connectionPoint defines the other connection point
  55941. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55942. * @returns the current connection point
  55943. */
  55944. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55945. /**
  55946. * Disconnect this point from one of his endpoint
  55947. * @param endpoint defines the other connection point
  55948. * @returns the current connection point
  55949. */
  55950. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55951. /**
  55952. * Serializes this point in a JSON representation
  55953. * @returns the serialized point object
  55954. */
  55955. serialize(): any;
  55956. }
  55957. }
  55958. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55962. import { Mesh } from "babylonjs/Meshes/mesh";
  55963. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55965. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55966. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55967. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55968. /**
  55969. * Block used to add support for vertex skinning (bones)
  55970. */
  55971. export class BonesBlock extends NodeMaterialBlock {
  55972. /**
  55973. * Creates a new BonesBlock
  55974. * @param name defines the block name
  55975. */
  55976. constructor(name: string);
  55977. /**
  55978. * Initialize the block and prepare the context for build
  55979. * @param state defines the state that will be used for the build
  55980. */
  55981. initialize(state: NodeMaterialBuildState): void;
  55982. /**
  55983. * Gets the current class name
  55984. * @returns the class name
  55985. */
  55986. getClassName(): string;
  55987. /**
  55988. * Gets the matrix indices input component
  55989. */
  55990. readonly matricesIndices: NodeMaterialConnectionPoint;
  55991. /**
  55992. * Gets the matrix weights input component
  55993. */
  55994. readonly matricesWeights: NodeMaterialConnectionPoint;
  55995. /**
  55996. * Gets the extra matrix indices input component
  55997. */
  55998. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55999. /**
  56000. * Gets the extra matrix weights input component
  56001. */
  56002. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56003. /**
  56004. * Gets the world input component
  56005. */
  56006. readonly world: NodeMaterialConnectionPoint;
  56007. /**
  56008. * Gets the output component
  56009. */
  56010. readonly output: NodeMaterialConnectionPoint;
  56011. autoConfigure(material: NodeMaterial): void;
  56012. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56013. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56015. protected _buildBlock(state: NodeMaterialBuildState): this;
  56016. }
  56017. }
  56018. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56023. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56024. /**
  56025. * Block used to add support for instances
  56026. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56027. */
  56028. export class InstancesBlock extends NodeMaterialBlock {
  56029. /**
  56030. * Creates a new InstancesBlock
  56031. * @param name defines the block name
  56032. */
  56033. constructor(name: string);
  56034. /**
  56035. * Gets the current class name
  56036. * @returns the class name
  56037. */
  56038. getClassName(): string;
  56039. /**
  56040. * Gets the first world row input component
  56041. */
  56042. readonly world0: NodeMaterialConnectionPoint;
  56043. /**
  56044. * Gets the second world row input component
  56045. */
  56046. readonly world1: NodeMaterialConnectionPoint;
  56047. /**
  56048. * Gets the third world row input component
  56049. */
  56050. readonly world2: NodeMaterialConnectionPoint;
  56051. /**
  56052. * Gets the forth world row input component
  56053. */
  56054. readonly world3: NodeMaterialConnectionPoint;
  56055. /**
  56056. * Gets the world input component
  56057. */
  56058. readonly world: NodeMaterialConnectionPoint;
  56059. /**
  56060. * Gets the output component
  56061. */
  56062. readonly output: NodeMaterialConnectionPoint;
  56063. autoConfigure(material: NodeMaterial): void;
  56064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56065. protected _buildBlock(state: NodeMaterialBuildState): this;
  56066. }
  56067. }
  56068. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56073. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56074. import { Effect } from "babylonjs/Materials/effect";
  56075. import { Mesh } from "babylonjs/Meshes/mesh";
  56076. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56077. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56078. /**
  56079. * Block used to add morph targets support to vertex shader
  56080. */
  56081. export class MorphTargetsBlock extends NodeMaterialBlock {
  56082. private _repeatableContentAnchor;
  56083. private _repeatebleContentGenerated;
  56084. /**
  56085. * Create a new MorphTargetsBlock
  56086. * @param name defines the block name
  56087. */
  56088. constructor(name: string);
  56089. /**
  56090. * Gets the current class name
  56091. * @returns the class name
  56092. */
  56093. getClassName(): string;
  56094. /**
  56095. * Gets the position input component
  56096. */
  56097. readonly position: NodeMaterialConnectionPoint;
  56098. /**
  56099. * Gets the normal input component
  56100. */
  56101. readonly normal: NodeMaterialConnectionPoint;
  56102. /**
  56103. * Gets the tangent input component
  56104. */
  56105. readonly tangent: NodeMaterialConnectionPoint;
  56106. /**
  56107. * Gets the tangent input component
  56108. */
  56109. readonly uv: NodeMaterialConnectionPoint;
  56110. /**
  56111. * Gets the position output component
  56112. */
  56113. readonly positionOutput: NodeMaterialConnectionPoint;
  56114. /**
  56115. * Gets the normal output component
  56116. */
  56117. readonly normalOutput: NodeMaterialConnectionPoint;
  56118. /**
  56119. * Gets the tangent output component
  56120. */
  56121. readonly tangentOutput: NodeMaterialConnectionPoint;
  56122. /**
  56123. * Gets the tangent output component
  56124. */
  56125. readonly uvOutput: NodeMaterialConnectionPoint;
  56126. initialize(state: NodeMaterialBuildState): void;
  56127. autoConfigure(material: NodeMaterial): void;
  56128. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56129. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56130. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56131. protected _buildBlock(state: NodeMaterialBuildState): this;
  56132. }
  56133. }
  56134. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56138. import { Nullable } from "babylonjs/types";
  56139. import { Scene } from "babylonjs/scene";
  56140. import { Effect } from "babylonjs/Materials/effect";
  56141. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56142. import { Mesh } from "babylonjs/Meshes/mesh";
  56143. import { Light } from "babylonjs/Lights/light";
  56144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56145. /**
  56146. * Block used to get data information from a light
  56147. */
  56148. export class LightInformationBlock extends NodeMaterialBlock {
  56149. private _lightDataUniformName;
  56150. private _lightColorUniformName;
  56151. private _lightTypeDefineName;
  56152. /**
  56153. * Gets or sets the light associated with this block
  56154. */
  56155. light: Nullable<Light>;
  56156. /**
  56157. * Creates a new LightInformationBlock
  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 world position input component
  56168. */
  56169. readonly worldPosition: NodeMaterialConnectionPoint;
  56170. /**
  56171. * Gets the direction output component
  56172. */
  56173. readonly direction: NodeMaterialConnectionPoint;
  56174. /**
  56175. * Gets the direction output component
  56176. */
  56177. readonly color: NodeMaterialConnectionPoint;
  56178. /**
  56179. * Gets the direction output component
  56180. */
  56181. readonly intensity: NodeMaterialConnectionPoint;
  56182. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56183. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56184. protected _buildBlock(state: NodeMaterialBuildState): this;
  56185. serialize(): any;
  56186. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56187. }
  56188. }
  56189. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56190. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56191. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56192. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56193. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56194. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56195. }
  56196. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56201. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56202. import { Effect } from "babylonjs/Materials/effect";
  56203. import { Mesh } from "babylonjs/Meshes/mesh";
  56204. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56205. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56206. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56207. /**
  56208. * Block used to add image processing support to fragment shader
  56209. */
  56210. export class ImageProcessingBlock extends NodeMaterialBlock {
  56211. /**
  56212. * Create a new ImageProcessingBlock
  56213. * @param name defines the block name
  56214. */
  56215. constructor(name: string);
  56216. /**
  56217. * Gets the current class name
  56218. * @returns the class name
  56219. */
  56220. getClassName(): string;
  56221. /**
  56222. * Gets the color input component
  56223. */
  56224. readonly color: NodeMaterialConnectionPoint;
  56225. /**
  56226. * Gets the output component
  56227. */
  56228. readonly output: NodeMaterialConnectionPoint;
  56229. /**
  56230. * Initialize the block and prepare the context for build
  56231. * @param state defines the state that will be used for the build
  56232. */
  56233. initialize(state: NodeMaterialBuildState): void;
  56234. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56235. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56236. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56237. protected _buildBlock(state: NodeMaterialBuildState): this;
  56238. }
  56239. }
  56240. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56244. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56246. import { Effect } from "babylonjs/Materials/effect";
  56247. import { Mesh } from "babylonjs/Meshes/mesh";
  56248. import { Scene } from "babylonjs/scene";
  56249. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56250. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56251. /**
  56252. * Block used to pertub normals based on a normal map
  56253. */
  56254. export class PerturbNormalBlock extends NodeMaterialBlock {
  56255. private _tangentSpaceParameterName;
  56256. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56257. invertX: boolean;
  56258. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56259. invertY: boolean;
  56260. /**
  56261. * Create a new PerturbNormalBlock
  56262. * @param name defines the block name
  56263. */
  56264. constructor(name: string);
  56265. /**
  56266. * Gets the current class name
  56267. * @returns the class name
  56268. */
  56269. getClassName(): string;
  56270. /**
  56271. * Gets the world position input component
  56272. */
  56273. readonly worldPosition: NodeMaterialConnectionPoint;
  56274. /**
  56275. * Gets the world normal input component
  56276. */
  56277. readonly worldNormal: NodeMaterialConnectionPoint;
  56278. /**
  56279. * Gets the uv input component
  56280. */
  56281. readonly uv: NodeMaterialConnectionPoint;
  56282. /**
  56283. * Gets the normal map color input component
  56284. */
  56285. readonly normalMapColor: NodeMaterialConnectionPoint;
  56286. /**
  56287. * Gets the strength input component
  56288. */
  56289. readonly strength: NodeMaterialConnectionPoint;
  56290. /**
  56291. * Gets the output component
  56292. */
  56293. readonly output: NodeMaterialConnectionPoint;
  56294. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56295. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56296. autoConfigure(material: NodeMaterial): void;
  56297. protected _buildBlock(state: NodeMaterialBuildState): this;
  56298. protected _dumpPropertiesCode(): string;
  56299. serialize(): any;
  56300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56301. }
  56302. }
  56303. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56307. /**
  56308. * Block used to discard a pixel if a value is smaller than a cutoff
  56309. */
  56310. export class DiscardBlock extends NodeMaterialBlock {
  56311. /**
  56312. * Create a new DiscardBlock
  56313. * @param name defines the block name
  56314. */
  56315. constructor(name: string);
  56316. /**
  56317. * Gets the current class name
  56318. * @returns the class name
  56319. */
  56320. getClassName(): string;
  56321. /**
  56322. * Gets the color input component
  56323. */
  56324. readonly value: NodeMaterialConnectionPoint;
  56325. /**
  56326. * Gets the cutoff input component
  56327. */
  56328. readonly cutoff: NodeMaterialConnectionPoint;
  56329. protected _buildBlock(state: NodeMaterialBuildState): this;
  56330. }
  56331. }
  56332. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56333. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56334. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56335. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56336. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56337. }
  56338. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56339. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56340. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56341. import { Mesh } from "babylonjs/Meshes/mesh";
  56342. import { Effect } from "babylonjs/Materials/effect";
  56343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56345. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56346. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56347. /**
  56348. * Block used to add support for scene fog
  56349. */
  56350. export class FogBlock extends NodeMaterialBlock {
  56351. private _fogDistanceName;
  56352. private _fogParameters;
  56353. /**
  56354. * Create a new FogBlock
  56355. * @param name defines the block name
  56356. */
  56357. constructor(name: string);
  56358. /**
  56359. * Gets the current class name
  56360. * @returns the class name
  56361. */
  56362. getClassName(): string;
  56363. /**
  56364. * Gets the world position input component
  56365. */
  56366. readonly worldPosition: NodeMaterialConnectionPoint;
  56367. /**
  56368. * Gets the view input component
  56369. */
  56370. readonly view: NodeMaterialConnectionPoint;
  56371. /**
  56372. * Gets the color input component
  56373. */
  56374. readonly input: NodeMaterialConnectionPoint;
  56375. /**
  56376. * Gets the fog color input component
  56377. */
  56378. readonly fogColor: NodeMaterialConnectionPoint;
  56379. /**
  56380. * Gets the output component
  56381. */
  56382. readonly output: NodeMaterialConnectionPoint;
  56383. autoConfigure(material: NodeMaterial): void;
  56384. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56385. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56386. protected _buildBlock(state: NodeMaterialBuildState): this;
  56387. }
  56388. }
  56389. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56394. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56395. import { Effect } from "babylonjs/Materials/effect";
  56396. import { Mesh } from "babylonjs/Meshes/mesh";
  56397. import { Light } from "babylonjs/Lights/light";
  56398. import { Nullable } from "babylonjs/types";
  56399. import { Scene } from "babylonjs/scene";
  56400. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56401. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56402. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56403. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56404. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56405. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56406. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56407. /**
  56408. * Block used to add light in the fragment shader
  56409. */
  56410. export class LightBlock extends NodeMaterialBlock {
  56411. private _lightId;
  56412. /**
  56413. * Gets or sets the light associated with this block
  56414. */
  56415. light: Nullable<Light>;
  56416. /**
  56417. * Create a new LightBlock
  56418. * @param name defines the block name
  56419. */
  56420. constructor(name: string);
  56421. /**
  56422. * Gets the current class name
  56423. * @returns the class name
  56424. */
  56425. getClassName(): string;
  56426. /**
  56427. * Gets the world position input component
  56428. */
  56429. readonly worldPosition: NodeMaterialConnectionPoint;
  56430. /**
  56431. * Gets the world normal input component
  56432. */
  56433. readonly worldNormal: NodeMaterialConnectionPoint;
  56434. /**
  56435. * Gets the camera (or eye) position component
  56436. */
  56437. readonly cameraPosition: NodeMaterialConnectionPoint;
  56438. /**
  56439. * Gets the diffuse output component
  56440. */
  56441. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56442. /**
  56443. * Gets the specular output component
  56444. */
  56445. readonly specularOutput: NodeMaterialConnectionPoint;
  56446. autoConfigure(material: NodeMaterial): void;
  56447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56448. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56450. private _injectVertexCode;
  56451. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56452. serialize(): any;
  56453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56454. }
  56455. }
  56456. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56457. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56458. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56459. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56460. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56461. }
  56462. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56463. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56464. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56465. }
  56466. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56470. /**
  56471. * Block used to multiply 2 values
  56472. */
  56473. export class MultiplyBlock extends NodeMaterialBlock {
  56474. /**
  56475. * Creates a new MultiplyBlock
  56476. * @param name defines the block name
  56477. */
  56478. constructor(name: string);
  56479. /**
  56480. * Gets the current class name
  56481. * @returns the class name
  56482. */
  56483. getClassName(): string;
  56484. /**
  56485. * Gets the left operand input component
  56486. */
  56487. readonly left: NodeMaterialConnectionPoint;
  56488. /**
  56489. * Gets the right operand input component
  56490. */
  56491. readonly right: NodeMaterialConnectionPoint;
  56492. /**
  56493. * Gets the output component
  56494. */
  56495. readonly output: NodeMaterialConnectionPoint;
  56496. protected _buildBlock(state: NodeMaterialBuildState): this;
  56497. }
  56498. }
  56499. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56503. /**
  56504. * Block used to add 2 vectors
  56505. */
  56506. export class AddBlock extends NodeMaterialBlock {
  56507. /**
  56508. * Creates a new AddBlock
  56509. * @param name defines the block name
  56510. */
  56511. constructor(name: string);
  56512. /**
  56513. * Gets the current class name
  56514. * @returns the class name
  56515. */
  56516. getClassName(): string;
  56517. /**
  56518. * Gets the left operand input component
  56519. */
  56520. readonly left: NodeMaterialConnectionPoint;
  56521. /**
  56522. * Gets the right operand input component
  56523. */
  56524. readonly right: NodeMaterialConnectionPoint;
  56525. /**
  56526. * Gets the output component
  56527. */
  56528. readonly output: NodeMaterialConnectionPoint;
  56529. protected _buildBlock(state: NodeMaterialBuildState): this;
  56530. }
  56531. }
  56532. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56536. /**
  56537. * Block used to scale a vector by a float
  56538. */
  56539. export class ScaleBlock extends NodeMaterialBlock {
  56540. /**
  56541. * Creates a new ScaleBlock
  56542. * @param name defines the block name
  56543. */
  56544. constructor(name: string);
  56545. /**
  56546. * Gets the current class name
  56547. * @returns the class name
  56548. */
  56549. getClassName(): string;
  56550. /**
  56551. * Gets the input component
  56552. */
  56553. readonly input: NodeMaterialConnectionPoint;
  56554. /**
  56555. * Gets the factor input component
  56556. */
  56557. readonly factor: NodeMaterialConnectionPoint;
  56558. /**
  56559. * Gets the output component
  56560. */
  56561. readonly output: NodeMaterialConnectionPoint;
  56562. protected _buildBlock(state: NodeMaterialBuildState): this;
  56563. }
  56564. }
  56565. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56569. import { Scene } from "babylonjs/scene";
  56570. /**
  56571. * Block used to clamp a float
  56572. */
  56573. export class ClampBlock extends NodeMaterialBlock {
  56574. /** Gets or sets the minimum range */
  56575. minimum: number;
  56576. /** Gets or sets the maximum range */
  56577. maximum: number;
  56578. /**
  56579. * Creates a new ClampBlock
  56580. * @param name defines the block name
  56581. */
  56582. constructor(name: string);
  56583. /**
  56584. * Gets the current class name
  56585. * @returns the class name
  56586. */
  56587. getClassName(): string;
  56588. /**
  56589. * Gets the value input component
  56590. */
  56591. readonly value: NodeMaterialConnectionPoint;
  56592. /**
  56593. * Gets the output component
  56594. */
  56595. readonly output: NodeMaterialConnectionPoint;
  56596. protected _buildBlock(state: NodeMaterialBuildState): this;
  56597. protected _dumpPropertiesCode(): string;
  56598. serialize(): any;
  56599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56600. }
  56601. }
  56602. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56606. /**
  56607. * Block used to apply a cross product between 2 vectors
  56608. */
  56609. export class CrossBlock extends NodeMaterialBlock {
  56610. /**
  56611. * Creates a new CrossBlock
  56612. * @param name defines the block name
  56613. */
  56614. constructor(name: string);
  56615. /**
  56616. * Gets the current class name
  56617. * @returns the class name
  56618. */
  56619. getClassName(): string;
  56620. /**
  56621. * Gets the left operand input component
  56622. */
  56623. readonly left: NodeMaterialConnectionPoint;
  56624. /**
  56625. * Gets the right operand input component
  56626. */
  56627. readonly right: NodeMaterialConnectionPoint;
  56628. /**
  56629. * Gets the output component
  56630. */
  56631. readonly output: NodeMaterialConnectionPoint;
  56632. protected _buildBlock(state: NodeMaterialBuildState): this;
  56633. }
  56634. }
  56635. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56639. /**
  56640. * Block used to apply a dot product between 2 vectors
  56641. */
  56642. export class DotBlock extends NodeMaterialBlock {
  56643. /**
  56644. * Creates a new DotBlock
  56645. * @param name defines the block name
  56646. */
  56647. constructor(name: string);
  56648. /**
  56649. * Gets the current class name
  56650. * @returns the class name
  56651. */
  56652. getClassName(): string;
  56653. /**
  56654. * Gets the left operand input component
  56655. */
  56656. readonly left: NodeMaterialConnectionPoint;
  56657. /**
  56658. * Gets the right operand input component
  56659. */
  56660. readonly right: NodeMaterialConnectionPoint;
  56661. /**
  56662. * Gets the output component
  56663. */
  56664. readonly output: NodeMaterialConnectionPoint;
  56665. protected _buildBlock(state: NodeMaterialBuildState): this;
  56666. }
  56667. }
  56668. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56672. import { Vector2 } from "babylonjs/Maths/math.vector";
  56673. import { Scene } from "babylonjs/scene";
  56674. /**
  56675. * Block used to remap a float from a range to a new one
  56676. */
  56677. export class RemapBlock extends NodeMaterialBlock {
  56678. /**
  56679. * Gets or sets the source range
  56680. */
  56681. sourceRange: Vector2;
  56682. /**
  56683. * Gets or sets the target range
  56684. */
  56685. targetRange: Vector2;
  56686. /**
  56687. * Creates a new RemapBlock
  56688. * @param name defines the block name
  56689. */
  56690. constructor(name: string);
  56691. /**
  56692. * Gets the current class name
  56693. * @returns the class name
  56694. */
  56695. getClassName(): string;
  56696. /**
  56697. * Gets the input component
  56698. */
  56699. readonly input: NodeMaterialConnectionPoint;
  56700. /**
  56701. * Gets the source min input component
  56702. */
  56703. readonly sourceMin: NodeMaterialConnectionPoint;
  56704. /**
  56705. * Gets the source max input component
  56706. */
  56707. readonly sourceMax: NodeMaterialConnectionPoint;
  56708. /**
  56709. * Gets the target min input component
  56710. */
  56711. readonly targetMin: NodeMaterialConnectionPoint;
  56712. /**
  56713. * Gets the target max input component
  56714. */
  56715. readonly targetMax: NodeMaterialConnectionPoint;
  56716. /**
  56717. * Gets the output component
  56718. */
  56719. readonly output: NodeMaterialConnectionPoint;
  56720. protected _buildBlock(state: NodeMaterialBuildState): this;
  56721. protected _dumpPropertiesCode(): string;
  56722. serialize(): any;
  56723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56724. }
  56725. }
  56726. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56728. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56729. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56730. /**
  56731. * Block used to normalize a vector
  56732. */
  56733. export class NormalizeBlock extends NodeMaterialBlock {
  56734. /**
  56735. * Creates a new NormalizeBlock
  56736. * @param name defines the block name
  56737. */
  56738. constructor(name: string);
  56739. /**
  56740. * Gets the current class name
  56741. * @returns the class name
  56742. */
  56743. getClassName(): string;
  56744. /**
  56745. * Gets the input component
  56746. */
  56747. readonly input: NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the output component
  56750. */
  56751. readonly output: NodeMaterialConnectionPoint;
  56752. protected _buildBlock(state: NodeMaterialBuildState): this;
  56753. }
  56754. }
  56755. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56759. import { Scene } from "babylonjs/scene";
  56760. /**
  56761. * Operations supported by the Trigonometry block
  56762. */
  56763. export enum TrigonometryBlockOperations {
  56764. /** Cos */
  56765. Cos = 0,
  56766. /** Sin */
  56767. Sin = 1,
  56768. /** Abs */
  56769. Abs = 2,
  56770. /** Exp */
  56771. Exp = 3,
  56772. /** Exp2 */
  56773. Exp2 = 4,
  56774. /** Round */
  56775. Round = 5,
  56776. /** Floor */
  56777. Floor = 6,
  56778. /** Ceiling */
  56779. Ceiling = 7,
  56780. /** Square root */
  56781. Sqrt = 8
  56782. }
  56783. /**
  56784. * Block used to apply trigonometry operation to floats
  56785. */
  56786. export class TrigonometryBlock extends NodeMaterialBlock {
  56787. /**
  56788. * Gets or sets the operation applied by the block
  56789. */
  56790. operation: TrigonometryBlockOperations;
  56791. /**
  56792. * Creates a new TrigonometryBlock
  56793. * @param name defines the block name
  56794. */
  56795. constructor(name: string);
  56796. /**
  56797. * Gets the current class name
  56798. * @returns the class name
  56799. */
  56800. getClassName(): string;
  56801. /**
  56802. * Gets the input component
  56803. */
  56804. readonly input: NodeMaterialConnectionPoint;
  56805. /**
  56806. * Gets the output component
  56807. */
  56808. readonly output: NodeMaterialConnectionPoint;
  56809. protected _buildBlock(state: NodeMaterialBuildState): this;
  56810. serialize(): any;
  56811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56812. }
  56813. }
  56814. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56818. /**
  56819. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56820. */
  56821. export class ColorMergerBlock extends NodeMaterialBlock {
  56822. /**
  56823. * Create a new ColorMergerBlock
  56824. * @param name defines the block name
  56825. */
  56826. constructor(name: string);
  56827. /**
  56828. * Gets the current class name
  56829. * @returns the class name
  56830. */
  56831. getClassName(): string;
  56832. /**
  56833. * Gets the r component (input)
  56834. */
  56835. readonly r: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the g component (input)
  56838. */
  56839. readonly g: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the b component (input)
  56842. */
  56843. readonly b: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the a component (input)
  56846. */
  56847. readonly a: NodeMaterialConnectionPoint;
  56848. /**
  56849. * Gets the rgba component (output)
  56850. */
  56851. readonly rgba: NodeMaterialConnectionPoint;
  56852. /**
  56853. * Gets the rgb component (output)
  56854. */
  56855. readonly rgb: NodeMaterialConnectionPoint;
  56856. protected _buildBlock(state: NodeMaterialBuildState): this;
  56857. }
  56858. }
  56859. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56863. /**
  56864. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56865. */
  56866. export class VectorMergerBlock extends NodeMaterialBlock {
  56867. /**
  56868. * Create a new VectorMergerBlock
  56869. * @param name defines the block name
  56870. */
  56871. constructor(name: string);
  56872. /**
  56873. * Gets the current class name
  56874. * @returns the class name
  56875. */
  56876. getClassName(): string;
  56877. /**
  56878. * Gets the x component (input)
  56879. */
  56880. readonly x: NodeMaterialConnectionPoint;
  56881. /**
  56882. * Gets the y component (input)
  56883. */
  56884. readonly y: NodeMaterialConnectionPoint;
  56885. /**
  56886. * Gets the z component (input)
  56887. */
  56888. readonly z: NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the w component (input)
  56891. */
  56892. readonly w: NodeMaterialConnectionPoint;
  56893. /**
  56894. * Gets the xyzw component (output)
  56895. */
  56896. readonly xyzw: NodeMaterialConnectionPoint;
  56897. /**
  56898. * Gets the xyz component (output)
  56899. */
  56900. readonly xyz: NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the xy component (output)
  56903. */
  56904. readonly xy: NodeMaterialConnectionPoint;
  56905. protected _buildBlock(state: NodeMaterialBuildState): this;
  56906. }
  56907. }
  56908. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56912. /**
  56913. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56914. */
  56915. export class ColorSplitterBlock extends NodeMaterialBlock {
  56916. /**
  56917. * Create a new ColorSplitterBlock
  56918. * @param name defines the block name
  56919. */
  56920. constructor(name: string);
  56921. /**
  56922. * Gets the current class name
  56923. * @returns the class name
  56924. */
  56925. getClassName(): string;
  56926. /**
  56927. * Gets the rgba component (input)
  56928. */
  56929. readonly rgba: NodeMaterialConnectionPoint;
  56930. /**
  56931. * Gets the rgb component (input)
  56932. */
  56933. readonly rgbIn: NodeMaterialConnectionPoint;
  56934. /**
  56935. * Gets the rgb component (output)
  56936. */
  56937. readonly rgbOut: NodeMaterialConnectionPoint;
  56938. /**
  56939. * Gets the r component (output)
  56940. */
  56941. readonly r: NodeMaterialConnectionPoint;
  56942. /**
  56943. * Gets the g component (output)
  56944. */
  56945. readonly g: NodeMaterialConnectionPoint;
  56946. /**
  56947. * Gets the b component (output)
  56948. */
  56949. readonly b: NodeMaterialConnectionPoint;
  56950. /**
  56951. * Gets the a component (output)
  56952. */
  56953. readonly a: NodeMaterialConnectionPoint;
  56954. protected _inputRename(name: string): string;
  56955. protected _outputRename(name: string): string;
  56956. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56957. }
  56958. }
  56959. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56960. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56962. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56963. /**
  56964. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56965. */
  56966. export class VectorSplitterBlock extends NodeMaterialBlock {
  56967. /**
  56968. * Create a new VectorSplitterBlock
  56969. * @param name defines the block name
  56970. */
  56971. constructor(name: string);
  56972. /**
  56973. * Gets the current class name
  56974. * @returns the class name
  56975. */
  56976. getClassName(): string;
  56977. /**
  56978. * Gets the xyzw component (input)
  56979. */
  56980. readonly xyzw: NodeMaterialConnectionPoint;
  56981. /**
  56982. * Gets the xyz component (input)
  56983. */
  56984. readonly xyzIn: NodeMaterialConnectionPoint;
  56985. /**
  56986. * Gets the xy component (input)
  56987. */
  56988. readonly xyIn: NodeMaterialConnectionPoint;
  56989. /**
  56990. * Gets the xyz component (output)
  56991. */
  56992. readonly xyzOut: NodeMaterialConnectionPoint;
  56993. /**
  56994. * Gets the xy component (output)
  56995. */
  56996. readonly xyOut: NodeMaterialConnectionPoint;
  56997. /**
  56998. * Gets the x component (output)
  56999. */
  57000. readonly x: NodeMaterialConnectionPoint;
  57001. /**
  57002. * Gets the y component (output)
  57003. */
  57004. readonly y: NodeMaterialConnectionPoint;
  57005. /**
  57006. * Gets the z component (output)
  57007. */
  57008. readonly z: NodeMaterialConnectionPoint;
  57009. /**
  57010. * Gets the w component (output)
  57011. */
  57012. readonly w: NodeMaterialConnectionPoint;
  57013. protected _inputRename(name: string): string;
  57014. protected _outputRename(name: string): string;
  57015. protected _buildBlock(state: NodeMaterialBuildState): this;
  57016. }
  57017. }
  57018. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57022. /**
  57023. * Block used to lerp 2 values
  57024. */
  57025. export class LerpBlock extends NodeMaterialBlock {
  57026. /**
  57027. * Creates a new LerpBlock
  57028. * @param name defines the block name
  57029. */
  57030. constructor(name: string);
  57031. /**
  57032. * Gets the current class name
  57033. * @returns the class name
  57034. */
  57035. getClassName(): string;
  57036. /**
  57037. * Gets the left operand input component
  57038. */
  57039. readonly left: NodeMaterialConnectionPoint;
  57040. /**
  57041. * Gets the right operand input component
  57042. */
  57043. readonly right: NodeMaterialConnectionPoint;
  57044. /**
  57045. * Gets the gradient operand input component
  57046. */
  57047. readonly gradient: NodeMaterialConnectionPoint;
  57048. /**
  57049. * Gets the output component
  57050. */
  57051. readonly output: NodeMaterialConnectionPoint;
  57052. protected _buildBlock(state: NodeMaterialBuildState): this;
  57053. }
  57054. }
  57055. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57059. /**
  57060. * Block used to divide 2 vectors
  57061. */
  57062. export class DivideBlock extends NodeMaterialBlock {
  57063. /**
  57064. * Creates a new DivideBlock
  57065. * @param name defines the block name
  57066. */
  57067. constructor(name: string);
  57068. /**
  57069. * Gets the current class name
  57070. * @returns the class name
  57071. */
  57072. getClassName(): string;
  57073. /**
  57074. * Gets the left operand input component
  57075. */
  57076. readonly left: NodeMaterialConnectionPoint;
  57077. /**
  57078. * Gets the right operand input component
  57079. */
  57080. readonly right: NodeMaterialConnectionPoint;
  57081. /**
  57082. * Gets the output component
  57083. */
  57084. readonly output: NodeMaterialConnectionPoint;
  57085. protected _buildBlock(state: NodeMaterialBuildState): this;
  57086. }
  57087. }
  57088. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57092. /**
  57093. * Block used to subtract 2 vectors
  57094. */
  57095. export class SubtractBlock extends NodeMaterialBlock {
  57096. /**
  57097. * Creates a new SubtractBlock
  57098. * @param name defines the block name
  57099. */
  57100. constructor(name: string);
  57101. /**
  57102. * Gets the current class name
  57103. * @returns the class name
  57104. */
  57105. getClassName(): string;
  57106. /**
  57107. * Gets the left operand input component
  57108. */
  57109. readonly left: NodeMaterialConnectionPoint;
  57110. /**
  57111. * Gets the right operand input component
  57112. */
  57113. readonly right: NodeMaterialConnectionPoint;
  57114. /**
  57115. * Gets the output component
  57116. */
  57117. readonly output: NodeMaterialConnectionPoint;
  57118. protected _buildBlock(state: NodeMaterialBuildState): this;
  57119. }
  57120. }
  57121. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57125. /**
  57126. * Block used to step a value
  57127. */
  57128. export class StepBlock extends NodeMaterialBlock {
  57129. /**
  57130. * Creates a new AddBlock
  57131. * @param name defines the block name
  57132. */
  57133. constructor(name: string);
  57134. /**
  57135. * Gets the current class name
  57136. * @returns the class name
  57137. */
  57138. getClassName(): string;
  57139. /**
  57140. * Gets the value operand input component
  57141. */
  57142. readonly value: NodeMaterialConnectionPoint;
  57143. /**
  57144. * Gets the edge operand input component
  57145. */
  57146. readonly edge: NodeMaterialConnectionPoint;
  57147. /**
  57148. * Gets the output component
  57149. */
  57150. readonly output: NodeMaterialConnectionPoint;
  57151. protected _buildBlock(state: NodeMaterialBuildState): this;
  57152. }
  57153. }
  57154. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57158. /**
  57159. * Block used to get the opposite (1 - x) of a value
  57160. */
  57161. export class OneMinusBlock extends NodeMaterialBlock {
  57162. /**
  57163. * Creates a new OneMinusBlock
  57164. * @param name defines the block name
  57165. */
  57166. constructor(name: string);
  57167. /**
  57168. * Gets the current class name
  57169. * @returns the class name
  57170. */
  57171. getClassName(): string;
  57172. /**
  57173. * Gets the input component
  57174. */
  57175. readonly input: NodeMaterialConnectionPoint;
  57176. /**
  57177. * Gets the output component
  57178. */
  57179. readonly output: NodeMaterialConnectionPoint;
  57180. protected _buildBlock(state: NodeMaterialBuildState): this;
  57181. }
  57182. }
  57183. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57187. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57188. /**
  57189. * Block used to get the view direction
  57190. */
  57191. export class ViewDirectionBlock extends NodeMaterialBlock {
  57192. /**
  57193. * Creates a new ViewDirectionBlock
  57194. * @param name defines the block name
  57195. */
  57196. constructor(name: string);
  57197. /**
  57198. * Gets the current class name
  57199. * @returns the class name
  57200. */
  57201. getClassName(): string;
  57202. /**
  57203. * Gets the world position component
  57204. */
  57205. readonly worldPosition: NodeMaterialConnectionPoint;
  57206. /**
  57207. * Gets the camera position component
  57208. */
  57209. readonly cameraPosition: NodeMaterialConnectionPoint;
  57210. /**
  57211. * Gets the output component
  57212. */
  57213. readonly output: NodeMaterialConnectionPoint;
  57214. autoConfigure(material: NodeMaterial): void;
  57215. protected _buildBlock(state: NodeMaterialBuildState): this;
  57216. }
  57217. }
  57218. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57222. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57223. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57224. /**
  57225. * Block used to compute fresnel value
  57226. */
  57227. export class FresnelBlock extends NodeMaterialBlock {
  57228. /**
  57229. * Create a new FresnelBlock
  57230. * @param name defines the block name
  57231. */
  57232. constructor(name: string);
  57233. /**
  57234. * Gets the current class name
  57235. * @returns the class name
  57236. */
  57237. getClassName(): string;
  57238. /**
  57239. * Gets the world normal input component
  57240. */
  57241. readonly worldNormal: NodeMaterialConnectionPoint;
  57242. /**
  57243. * Gets the view direction input component
  57244. */
  57245. readonly viewDirection: NodeMaterialConnectionPoint;
  57246. /**
  57247. * Gets the bias input component
  57248. */
  57249. readonly bias: NodeMaterialConnectionPoint;
  57250. /**
  57251. * Gets the camera (or eye) position component
  57252. */
  57253. readonly power: NodeMaterialConnectionPoint;
  57254. /**
  57255. * Gets the fresnel output component
  57256. */
  57257. readonly fresnel: NodeMaterialConnectionPoint;
  57258. autoConfigure(material: NodeMaterial): void;
  57259. protected _buildBlock(state: NodeMaterialBuildState): this;
  57260. }
  57261. }
  57262. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57263. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57264. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57265. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57266. /**
  57267. * Block used to get the max of 2 values
  57268. */
  57269. export class MaxBlock extends NodeMaterialBlock {
  57270. /**
  57271. * Creates a new MaxBlock
  57272. * @param name defines the block name
  57273. */
  57274. constructor(name: string);
  57275. /**
  57276. * Gets the current class name
  57277. * @returns the class name
  57278. */
  57279. getClassName(): string;
  57280. /**
  57281. * Gets the left operand input component
  57282. */
  57283. readonly left: NodeMaterialConnectionPoint;
  57284. /**
  57285. * Gets the right operand input component
  57286. */
  57287. readonly right: NodeMaterialConnectionPoint;
  57288. /**
  57289. * Gets the output component
  57290. */
  57291. readonly output: NodeMaterialConnectionPoint;
  57292. protected _buildBlock(state: NodeMaterialBuildState): this;
  57293. }
  57294. }
  57295. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57296. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57297. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57298. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57299. /**
  57300. * Block used to get the min of 2 values
  57301. */
  57302. export class MinBlock extends NodeMaterialBlock {
  57303. /**
  57304. * Creates a new MinBlock
  57305. * @param name defines the block name
  57306. */
  57307. constructor(name: string);
  57308. /**
  57309. * Gets the current class name
  57310. * @returns the class name
  57311. */
  57312. getClassName(): string;
  57313. /**
  57314. * Gets the left operand input component
  57315. */
  57316. readonly left: NodeMaterialConnectionPoint;
  57317. /**
  57318. * Gets the right operand input component
  57319. */
  57320. readonly right: NodeMaterialConnectionPoint;
  57321. /**
  57322. * Gets the output component
  57323. */
  57324. readonly output: NodeMaterialConnectionPoint;
  57325. protected _buildBlock(state: NodeMaterialBuildState): this;
  57326. }
  57327. }
  57328. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57329. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57330. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57331. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57332. /**
  57333. * Block used to get the distance between 2 values
  57334. */
  57335. export class DistanceBlock extends NodeMaterialBlock {
  57336. /**
  57337. * Creates a new DistanceBlock
  57338. * @param name defines the block name
  57339. */
  57340. constructor(name: string);
  57341. /**
  57342. * Gets the current class name
  57343. * @returns the class name
  57344. */
  57345. getClassName(): string;
  57346. /**
  57347. * Gets the left operand input component
  57348. */
  57349. readonly left: NodeMaterialConnectionPoint;
  57350. /**
  57351. * Gets the right operand input component
  57352. */
  57353. readonly right: NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the output component
  57356. */
  57357. readonly output: NodeMaterialConnectionPoint;
  57358. protected _buildBlock(state: NodeMaterialBuildState): this;
  57359. }
  57360. }
  57361. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57362. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57363. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57364. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57365. /**
  57366. * Block used to get the length of a vector
  57367. */
  57368. export class LengthBlock extends NodeMaterialBlock {
  57369. /**
  57370. * Creates a new LengthBlock
  57371. * @param name defines the block name
  57372. */
  57373. constructor(name: string);
  57374. /**
  57375. * Gets the current class name
  57376. * @returns the class name
  57377. */
  57378. getClassName(): string;
  57379. /**
  57380. * Gets the value input component
  57381. */
  57382. readonly value: NodeMaterialConnectionPoint;
  57383. /**
  57384. * Gets the output component
  57385. */
  57386. readonly output: NodeMaterialConnectionPoint;
  57387. protected _buildBlock(state: NodeMaterialBuildState): this;
  57388. }
  57389. }
  57390. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57394. /**
  57395. * Block used to get negative version of a value (i.e. x * -1)
  57396. */
  57397. export class NegateBlock extends NodeMaterialBlock {
  57398. /**
  57399. * Creates a new NegateBlock
  57400. * @param name defines the block name
  57401. */
  57402. constructor(name: string);
  57403. /**
  57404. * Gets the current class name
  57405. * @returns the class name
  57406. */
  57407. getClassName(): string;
  57408. /**
  57409. * Gets the value input component
  57410. */
  57411. readonly value: NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the output component
  57414. */
  57415. readonly output: NodeMaterialConnectionPoint;
  57416. protected _buildBlock(state: NodeMaterialBuildState): this;
  57417. }
  57418. }
  57419. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57423. /**
  57424. * Block used to get the value of the first parameter raised to the power of the second
  57425. */
  57426. export class PowBlock extends NodeMaterialBlock {
  57427. /**
  57428. * Creates a new PowBlock
  57429. * @param name defines the block name
  57430. */
  57431. constructor(name: string);
  57432. /**
  57433. * Gets the current class name
  57434. * @returns the class name
  57435. */
  57436. getClassName(): string;
  57437. /**
  57438. * Gets the value operand input component
  57439. */
  57440. readonly value: NodeMaterialConnectionPoint;
  57441. /**
  57442. * Gets the power operand input component
  57443. */
  57444. readonly power: NodeMaterialConnectionPoint;
  57445. /**
  57446. * Gets the output component
  57447. */
  57448. readonly output: NodeMaterialConnectionPoint;
  57449. protected _buildBlock(state: NodeMaterialBuildState): this;
  57450. }
  57451. }
  57452. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57456. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57457. /**
  57458. * Block used to get a random number
  57459. */
  57460. export class RandomNumberBlock extends NodeMaterialBlock {
  57461. /**
  57462. * Creates a new RandomNumberBlock
  57463. * @param name defines the block name
  57464. */
  57465. constructor(name: string);
  57466. /**
  57467. * Gets the current class name
  57468. * @returns the class name
  57469. */
  57470. getClassName(): string;
  57471. /**
  57472. * Gets the seed input component
  57473. */
  57474. readonly seed: NodeMaterialConnectionPoint;
  57475. /**
  57476. * Gets the output component
  57477. */
  57478. readonly output: NodeMaterialConnectionPoint;
  57479. protected _buildBlock(state: NodeMaterialBuildState): this;
  57480. }
  57481. }
  57482. declare module "babylonjs/Materials/Node/Blocks/index" {
  57483. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57484. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57485. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57486. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57487. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57488. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57489. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57490. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57491. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57492. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57493. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57494. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57495. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57496. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57497. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57498. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57499. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57500. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57501. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57502. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57503. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57504. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57505. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57506. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57507. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57508. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57509. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57510. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57511. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57512. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57513. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57514. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  57515. }
  57516. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57517. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57518. }
  57519. declare module "babylonjs/Materials/Node/index" {
  57520. export * from "babylonjs/Materials/Node/Enums/index";
  57521. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57522. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57523. export * from "babylonjs/Materials/Node/nodeMaterial";
  57524. export * from "babylonjs/Materials/Node/Blocks/index";
  57525. export * from "babylonjs/Materials/Node/Optimizers/index";
  57526. }
  57527. declare module "babylonjs/Materials/effectRenderer" {
  57528. import { Nullable } from "babylonjs/types";
  57529. import { Texture } from "babylonjs/Materials/Textures/texture";
  57530. import { Engine } from "babylonjs/Engines/engine";
  57531. import { Viewport } from "babylonjs/Maths/math.viewport";
  57532. import { Observable } from "babylonjs/Misc/observable";
  57533. import { Effect } from "babylonjs/Materials/effect";
  57534. import "babylonjs/Shaders/postprocess.vertex";
  57535. /**
  57536. * Effect Render Options
  57537. */
  57538. export interface IEffectRendererOptions {
  57539. /**
  57540. * Defines the vertices positions.
  57541. */
  57542. positions?: number[];
  57543. /**
  57544. * Defines the indices.
  57545. */
  57546. indices?: number[];
  57547. }
  57548. /**
  57549. * Helper class to render one or more effects
  57550. */
  57551. export class EffectRenderer {
  57552. private engine;
  57553. private static _DefaultOptions;
  57554. private _vertexBuffers;
  57555. private _indexBuffer;
  57556. private _ringBufferIndex;
  57557. private _ringScreenBuffer;
  57558. private _fullscreenViewport;
  57559. private _getNextFrameBuffer;
  57560. /**
  57561. * Creates an effect renderer
  57562. * @param engine the engine to use for rendering
  57563. * @param options defines the options of the effect renderer
  57564. */
  57565. constructor(engine: Engine, options?: IEffectRendererOptions);
  57566. /**
  57567. * Sets the current viewport in normalized coordinates 0-1
  57568. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57569. */
  57570. setViewport(viewport?: Viewport): void;
  57571. /**
  57572. * Binds the embedded attributes buffer to the effect.
  57573. * @param effect Defines the effect to bind the attributes for
  57574. */
  57575. bindBuffers(effect: Effect): void;
  57576. /**
  57577. * Sets the current effect wrapper to use during draw.
  57578. * The effect needs to be ready before calling this api.
  57579. * This also sets the default full screen position attribute.
  57580. * @param effectWrapper Defines the effect to draw with
  57581. */
  57582. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57583. /**
  57584. * Draws a full screen quad.
  57585. */
  57586. draw(): void;
  57587. /**
  57588. * renders one or more effects to a specified texture
  57589. * @param effectWrappers list of effects to renderer
  57590. * @param outputTexture texture to draw to, if null it will render to the screen
  57591. */
  57592. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57593. /**
  57594. * Disposes of the effect renderer
  57595. */
  57596. dispose(): void;
  57597. }
  57598. /**
  57599. * Options to create an EffectWrapper
  57600. */
  57601. interface EffectWrapperCreationOptions {
  57602. /**
  57603. * Engine to use to create the effect
  57604. */
  57605. engine: Engine;
  57606. /**
  57607. * Fragment shader for the effect
  57608. */
  57609. fragmentShader: string;
  57610. /**
  57611. * Vertex shader for the effect
  57612. */
  57613. vertexShader?: string;
  57614. /**
  57615. * Attributes to use in the shader
  57616. */
  57617. attributeNames?: Array<string>;
  57618. /**
  57619. * Uniforms to use in the shader
  57620. */
  57621. uniformNames?: Array<string>;
  57622. /**
  57623. * Texture sampler names to use in the shader
  57624. */
  57625. samplerNames?: Array<string>;
  57626. /**
  57627. * The friendly name of the effect displayed in Spector.
  57628. */
  57629. name?: string;
  57630. }
  57631. /**
  57632. * Wraps an effect to be used for rendering
  57633. */
  57634. export class EffectWrapper {
  57635. /**
  57636. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57637. */
  57638. onApplyObservable: Observable<{}>;
  57639. /**
  57640. * The underlying effect
  57641. */
  57642. effect: Effect;
  57643. /**
  57644. * Creates an effect to be renderer
  57645. * @param creationOptions options to create the effect
  57646. */
  57647. constructor(creationOptions: EffectWrapperCreationOptions);
  57648. /**
  57649. * Disposes of the effect wrapper
  57650. */
  57651. dispose(): void;
  57652. }
  57653. }
  57654. declare module "babylonjs/Materials/index" {
  57655. export * from "babylonjs/Materials/Background/index";
  57656. export * from "babylonjs/Materials/colorCurves";
  57657. export * from "babylonjs/Materials/effect";
  57658. export * from "babylonjs/Materials/fresnelParameters";
  57659. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57660. export * from "babylonjs/Materials/material";
  57661. export * from "babylonjs/Materials/materialDefines";
  57662. export * from "babylonjs/Materials/materialHelper";
  57663. export * from "babylonjs/Materials/multiMaterial";
  57664. export * from "babylonjs/Materials/PBR/index";
  57665. export * from "babylonjs/Materials/pushMaterial";
  57666. export * from "babylonjs/Materials/shaderMaterial";
  57667. export * from "babylonjs/Materials/standardMaterial";
  57668. export * from "babylonjs/Materials/Textures/index";
  57669. export * from "babylonjs/Materials/uniformBuffer";
  57670. export * from "babylonjs/Materials/materialFlags";
  57671. export * from "babylonjs/Materials/Node/index";
  57672. export * from "babylonjs/Materials/effectRenderer";
  57673. }
  57674. declare module "babylonjs/Maths/index" {
  57675. export * from "babylonjs/Maths/math.scalar";
  57676. export * from "babylonjs/Maths/math";
  57677. export * from "babylonjs/Maths/sphericalPolynomial";
  57678. }
  57679. declare module "babylonjs/Misc/workerPool" {
  57680. import { IDisposable } from "babylonjs/scene";
  57681. /**
  57682. * Helper class to push actions to a pool of workers.
  57683. */
  57684. export class WorkerPool implements IDisposable {
  57685. private _workerInfos;
  57686. private _pendingActions;
  57687. /**
  57688. * Constructor
  57689. * @param workers Array of workers to use for actions
  57690. */
  57691. constructor(workers: Array<Worker>);
  57692. /**
  57693. * Terminates all workers and clears any pending actions.
  57694. */
  57695. dispose(): void;
  57696. /**
  57697. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57698. * pended until a worker has completed its action.
  57699. * @param action The action to perform. Call onComplete when the action is complete.
  57700. */
  57701. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57702. private _execute;
  57703. }
  57704. }
  57705. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57706. import { IDisposable } from "babylonjs/scene";
  57707. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57708. /**
  57709. * Configuration for Draco compression
  57710. */
  57711. export interface IDracoCompressionConfiguration {
  57712. /**
  57713. * Configuration for the decoder.
  57714. */
  57715. decoder: {
  57716. /**
  57717. * The url to the WebAssembly module.
  57718. */
  57719. wasmUrl?: string;
  57720. /**
  57721. * The url to the WebAssembly binary.
  57722. */
  57723. wasmBinaryUrl?: string;
  57724. /**
  57725. * The url to the fallback JavaScript module.
  57726. */
  57727. fallbackUrl?: string;
  57728. };
  57729. }
  57730. /**
  57731. * Draco compression (https://google.github.io/draco/)
  57732. *
  57733. * This class wraps the Draco module.
  57734. *
  57735. * **Encoder**
  57736. *
  57737. * The encoder is not currently implemented.
  57738. *
  57739. * **Decoder**
  57740. *
  57741. * 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.
  57742. *
  57743. * To update the configuration, use the following code:
  57744. * ```javascript
  57745. * DracoCompression.Configuration = {
  57746. * decoder: {
  57747. * wasmUrl: "<url to the WebAssembly library>",
  57748. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57749. * fallbackUrl: "<url to the fallback JavaScript library>",
  57750. * }
  57751. * };
  57752. * ```
  57753. *
  57754. * 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.
  57755. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57756. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57757. *
  57758. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57759. * ```javascript
  57760. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57761. * ```
  57762. *
  57763. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57764. */
  57765. export class DracoCompression implements IDisposable {
  57766. private _workerPoolPromise?;
  57767. private _decoderModulePromise?;
  57768. /**
  57769. * The configuration. Defaults to the following urls:
  57770. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57771. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57772. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57773. */
  57774. static Configuration: IDracoCompressionConfiguration;
  57775. /**
  57776. * Returns true if the decoder configuration is available.
  57777. */
  57778. static readonly DecoderAvailable: boolean;
  57779. /**
  57780. * Default number of workers to create when creating the draco compression object.
  57781. */
  57782. static DefaultNumWorkers: number;
  57783. private static GetDefaultNumWorkers;
  57784. private static _Default;
  57785. /**
  57786. * Default instance for the draco compression object.
  57787. */
  57788. static readonly Default: DracoCompression;
  57789. /**
  57790. * Constructor
  57791. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57792. */
  57793. constructor(numWorkers?: number);
  57794. /**
  57795. * Stop all async operations and release resources.
  57796. */
  57797. dispose(): void;
  57798. /**
  57799. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57800. * @returns a promise that resolves when ready
  57801. */
  57802. whenReadyAsync(): Promise<void>;
  57803. /**
  57804. * Decode Draco compressed mesh data to vertex data.
  57805. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57806. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57807. * @returns A promise that resolves with the decoded vertex data
  57808. */
  57809. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57810. [kind: string]: number;
  57811. }): Promise<VertexData>;
  57812. }
  57813. }
  57814. declare module "babylonjs/Meshes/Compression/index" {
  57815. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57816. }
  57817. declare module "babylonjs/Meshes/csg" {
  57818. import { Nullable } from "babylonjs/types";
  57819. import { Scene } from "babylonjs/scene";
  57820. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57821. import { Mesh } from "babylonjs/Meshes/mesh";
  57822. import { Material } from "babylonjs/Materials/material";
  57823. /**
  57824. * Class for building Constructive Solid Geometry
  57825. */
  57826. export class CSG {
  57827. private polygons;
  57828. /**
  57829. * The world matrix
  57830. */
  57831. matrix: Matrix;
  57832. /**
  57833. * Stores the position
  57834. */
  57835. position: Vector3;
  57836. /**
  57837. * Stores the rotation
  57838. */
  57839. rotation: Vector3;
  57840. /**
  57841. * Stores the rotation quaternion
  57842. */
  57843. rotationQuaternion: Nullable<Quaternion>;
  57844. /**
  57845. * Stores the scaling vector
  57846. */
  57847. scaling: Vector3;
  57848. /**
  57849. * Convert the Mesh to CSG
  57850. * @param mesh The Mesh to convert to CSG
  57851. * @returns A new CSG from the Mesh
  57852. */
  57853. static FromMesh(mesh: Mesh): CSG;
  57854. /**
  57855. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57856. * @param polygons Polygons used to construct a CSG solid
  57857. */
  57858. private static FromPolygons;
  57859. /**
  57860. * Clones, or makes a deep copy, of the CSG
  57861. * @returns A new CSG
  57862. */
  57863. clone(): CSG;
  57864. /**
  57865. * Unions this CSG with another CSG
  57866. * @param csg The CSG to union against this CSG
  57867. * @returns The unioned CSG
  57868. */
  57869. union(csg: CSG): CSG;
  57870. /**
  57871. * Unions this CSG with another CSG in place
  57872. * @param csg The CSG to union against this CSG
  57873. */
  57874. unionInPlace(csg: CSG): void;
  57875. /**
  57876. * Subtracts this CSG with another CSG
  57877. * @param csg The CSG to subtract against this CSG
  57878. * @returns A new CSG
  57879. */
  57880. subtract(csg: CSG): CSG;
  57881. /**
  57882. * Subtracts this CSG with another CSG in place
  57883. * @param csg The CSG to subtact against this CSG
  57884. */
  57885. subtractInPlace(csg: CSG): void;
  57886. /**
  57887. * Intersect this CSG with another CSG
  57888. * @param csg The CSG to intersect against this CSG
  57889. * @returns A new CSG
  57890. */
  57891. intersect(csg: CSG): CSG;
  57892. /**
  57893. * Intersects this CSG with another CSG in place
  57894. * @param csg The CSG to intersect against this CSG
  57895. */
  57896. intersectInPlace(csg: CSG): void;
  57897. /**
  57898. * Return a new CSG solid with solid and empty space switched. This solid is
  57899. * not modified.
  57900. * @returns A new CSG solid with solid and empty space switched
  57901. */
  57902. inverse(): CSG;
  57903. /**
  57904. * Inverses the CSG in place
  57905. */
  57906. inverseInPlace(): void;
  57907. /**
  57908. * This is used to keep meshes transformations so they can be restored
  57909. * when we build back a Babylon Mesh
  57910. * NB : All CSG operations are performed in world coordinates
  57911. * @param csg The CSG to copy the transform attributes from
  57912. * @returns This CSG
  57913. */
  57914. copyTransformAttributes(csg: CSG): CSG;
  57915. /**
  57916. * Build Raw mesh from CSG
  57917. * Coordinates here are in world space
  57918. * @param name The name of the mesh geometry
  57919. * @param scene The Scene
  57920. * @param keepSubMeshes Specifies if the submeshes should be kept
  57921. * @returns A new Mesh
  57922. */
  57923. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57924. /**
  57925. * Build Mesh from CSG taking material and transforms into account
  57926. * @param name The name of the Mesh
  57927. * @param material The material of the Mesh
  57928. * @param scene The Scene
  57929. * @param keepSubMeshes Specifies if submeshes should be kept
  57930. * @returns The new Mesh
  57931. */
  57932. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57933. }
  57934. }
  57935. declare module "babylonjs/Meshes/trailMesh" {
  57936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57937. import { Mesh } from "babylonjs/Meshes/mesh";
  57938. import { Scene } from "babylonjs/scene";
  57939. /**
  57940. * Class used to create a trail following a mesh
  57941. */
  57942. export class TrailMesh extends Mesh {
  57943. private _generator;
  57944. private _autoStart;
  57945. private _running;
  57946. private _diameter;
  57947. private _length;
  57948. private _sectionPolygonPointsCount;
  57949. private _sectionVectors;
  57950. private _sectionNormalVectors;
  57951. private _beforeRenderObserver;
  57952. /**
  57953. * @constructor
  57954. * @param name The value used by scene.getMeshByName() to do a lookup.
  57955. * @param generator The mesh to generate a trail.
  57956. * @param scene The scene to add this mesh to.
  57957. * @param diameter Diameter of trailing mesh. Default is 1.
  57958. * @param length Length of trailing mesh. Default is 60.
  57959. * @param autoStart Automatically start trailing mesh. Default true.
  57960. */
  57961. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57962. /**
  57963. * "TrailMesh"
  57964. * @returns "TrailMesh"
  57965. */
  57966. getClassName(): string;
  57967. private _createMesh;
  57968. /**
  57969. * Start trailing mesh.
  57970. */
  57971. start(): void;
  57972. /**
  57973. * Stop trailing mesh.
  57974. */
  57975. stop(): void;
  57976. /**
  57977. * Update trailing mesh geometry.
  57978. */
  57979. update(): void;
  57980. /**
  57981. * Returns a new TrailMesh object.
  57982. * @param name is a string, the name given to the new mesh
  57983. * @param newGenerator use new generator object for cloned trail mesh
  57984. * @returns a new mesh
  57985. */
  57986. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57987. /**
  57988. * Serializes this trail mesh
  57989. * @param serializationObject object to write serialization to
  57990. */
  57991. serialize(serializationObject: any): void;
  57992. /**
  57993. * Parses a serialized trail mesh
  57994. * @param parsedMesh the serialized mesh
  57995. * @param scene the scene to create the trail mesh in
  57996. * @returns the created trail mesh
  57997. */
  57998. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57999. }
  58000. }
  58001. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58002. import { Nullable } from "babylonjs/types";
  58003. import { Scene } from "babylonjs/scene";
  58004. import { Vector4 } from "babylonjs/Maths/math.vector";
  58005. import { Color4 } from "babylonjs/Maths/math.color";
  58006. import { Mesh } from "babylonjs/Meshes/mesh";
  58007. /**
  58008. * Class containing static functions to help procedurally build meshes
  58009. */
  58010. export class TiledBoxBuilder {
  58011. /**
  58012. * Creates a box mesh
  58013. * 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)
  58014. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58018. * @param name defines the name of the mesh
  58019. * @param options defines the options used to create the mesh
  58020. * @param scene defines the hosting scene
  58021. * @returns the box mesh
  58022. */
  58023. static CreateTiledBox(name: string, options: {
  58024. pattern?: number;
  58025. width?: number;
  58026. height?: number;
  58027. depth?: number;
  58028. tileSize?: number;
  58029. tileWidth?: number;
  58030. tileHeight?: number;
  58031. alignHorizontal?: number;
  58032. alignVertical?: number;
  58033. faceUV?: Vector4[];
  58034. faceColors?: Color4[];
  58035. sideOrientation?: number;
  58036. updatable?: boolean;
  58037. }, scene?: Nullable<Scene>): Mesh;
  58038. }
  58039. }
  58040. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58041. import { Vector4 } from "babylonjs/Maths/math.vector";
  58042. import { Mesh } from "babylonjs/Meshes/mesh";
  58043. /**
  58044. * Class containing static functions to help procedurally build meshes
  58045. */
  58046. export class TorusKnotBuilder {
  58047. /**
  58048. * Creates a torus knot mesh
  58049. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58050. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58051. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58052. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58056. * @param name defines the name of the mesh
  58057. * @param options defines the options used to create the mesh
  58058. * @param scene defines the hosting scene
  58059. * @returns the torus knot mesh
  58060. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58061. */
  58062. static CreateTorusKnot(name: string, options: {
  58063. radius?: number;
  58064. tube?: number;
  58065. radialSegments?: number;
  58066. tubularSegments?: number;
  58067. p?: number;
  58068. q?: number;
  58069. updatable?: boolean;
  58070. sideOrientation?: number;
  58071. frontUVs?: Vector4;
  58072. backUVs?: Vector4;
  58073. }, scene: any): Mesh;
  58074. }
  58075. }
  58076. declare module "babylonjs/Meshes/polygonMesh" {
  58077. import { Scene } from "babylonjs/scene";
  58078. import { Vector2 } from "babylonjs/Maths/math.vector";
  58079. import { Mesh } from "babylonjs/Meshes/mesh";
  58080. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58081. import { Path2 } from "babylonjs/Maths/math.path";
  58082. /**
  58083. * Polygon
  58084. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58085. */
  58086. export class Polygon {
  58087. /**
  58088. * Creates a rectangle
  58089. * @param xmin bottom X coord
  58090. * @param ymin bottom Y coord
  58091. * @param xmax top X coord
  58092. * @param ymax top Y coord
  58093. * @returns points that make the resulting rectation
  58094. */
  58095. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58096. /**
  58097. * Creates a circle
  58098. * @param radius radius of circle
  58099. * @param cx scale in x
  58100. * @param cy scale in y
  58101. * @param numberOfSides number of sides that make up the circle
  58102. * @returns points that make the resulting circle
  58103. */
  58104. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58105. /**
  58106. * Creates a polygon from input string
  58107. * @param input Input polygon data
  58108. * @returns the parsed points
  58109. */
  58110. static Parse(input: string): Vector2[];
  58111. /**
  58112. * Starts building a polygon from x and y coordinates
  58113. * @param x x coordinate
  58114. * @param y y coordinate
  58115. * @returns the started path2
  58116. */
  58117. static StartingAt(x: number, y: number): Path2;
  58118. }
  58119. /**
  58120. * Builds a polygon
  58121. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58122. */
  58123. export class PolygonMeshBuilder {
  58124. private _points;
  58125. private _outlinepoints;
  58126. private _holes;
  58127. private _name;
  58128. private _scene;
  58129. private _epoints;
  58130. private _eholes;
  58131. private _addToepoint;
  58132. /**
  58133. * Babylon reference to the earcut plugin.
  58134. */
  58135. bjsEarcut: any;
  58136. /**
  58137. * Creates a PolygonMeshBuilder
  58138. * @param name name of the builder
  58139. * @param contours Path of the polygon
  58140. * @param scene scene to add to when creating the mesh
  58141. * @param earcutInjection can be used to inject your own earcut reference
  58142. */
  58143. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58144. /**
  58145. * Adds a whole within the polygon
  58146. * @param hole Array of points defining the hole
  58147. * @returns this
  58148. */
  58149. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58150. /**
  58151. * Creates the polygon
  58152. * @param updatable If the mesh should be updatable
  58153. * @param depth The depth of the mesh created
  58154. * @returns the created mesh
  58155. */
  58156. build(updatable?: boolean, depth?: number): Mesh;
  58157. /**
  58158. * Creates the polygon
  58159. * @param depth The depth of the mesh created
  58160. * @returns the created VertexData
  58161. */
  58162. buildVertexData(depth?: number): VertexData;
  58163. /**
  58164. * Adds a side to the polygon
  58165. * @param positions points that make the polygon
  58166. * @param normals normals of the polygon
  58167. * @param uvs uvs of the polygon
  58168. * @param indices indices of the polygon
  58169. * @param bounds bounds of the polygon
  58170. * @param points points of the polygon
  58171. * @param depth depth of the polygon
  58172. * @param flip flip of the polygon
  58173. */
  58174. private addSide;
  58175. }
  58176. }
  58177. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58178. import { Scene } from "babylonjs/scene";
  58179. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58180. import { Color4 } from "babylonjs/Maths/math.color";
  58181. import { Mesh } from "babylonjs/Meshes/mesh";
  58182. import { Nullable } from "babylonjs/types";
  58183. /**
  58184. * Class containing static functions to help procedurally build meshes
  58185. */
  58186. export class PolygonBuilder {
  58187. /**
  58188. * Creates a polygon mesh
  58189. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58190. * * 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
  58191. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58194. * * Remember you can only change the shape positions, not their number when updating a polygon
  58195. * @param name defines the name of the mesh
  58196. * @param options defines the options used to create the mesh
  58197. * @param scene defines the hosting scene
  58198. * @param earcutInjection can be used to inject your own earcut reference
  58199. * @returns the polygon mesh
  58200. */
  58201. static CreatePolygon(name: string, options: {
  58202. shape: Vector3[];
  58203. holes?: Vector3[][];
  58204. depth?: number;
  58205. faceUV?: Vector4[];
  58206. faceColors?: Color4[];
  58207. updatable?: boolean;
  58208. sideOrientation?: number;
  58209. frontUVs?: Vector4;
  58210. backUVs?: Vector4;
  58211. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58212. /**
  58213. * Creates an extruded polygon mesh, with depth in the Y direction.
  58214. * * 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)
  58215. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58216. * @param name defines the name of the mesh
  58217. * @param options defines the options used to create the mesh
  58218. * @param scene defines the hosting scene
  58219. * @param earcutInjection can be used to inject your own earcut reference
  58220. * @returns the polygon mesh
  58221. */
  58222. static ExtrudePolygon(name: string, options: {
  58223. shape: Vector3[];
  58224. holes?: Vector3[][];
  58225. depth?: number;
  58226. faceUV?: Vector4[];
  58227. faceColors?: Color4[];
  58228. updatable?: boolean;
  58229. sideOrientation?: number;
  58230. frontUVs?: Vector4;
  58231. backUVs?: Vector4;
  58232. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58233. }
  58234. }
  58235. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58236. import { Scene } from "babylonjs/scene";
  58237. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58238. import { Mesh } from "babylonjs/Meshes/mesh";
  58239. import { Nullable } from "babylonjs/types";
  58240. /**
  58241. * Class containing static functions to help procedurally build meshes
  58242. */
  58243. export class LatheBuilder {
  58244. /**
  58245. * Creates lathe mesh.
  58246. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58247. * * 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
  58248. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58249. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58250. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58251. * * 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
  58252. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58253. * * 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
  58254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58258. * @param name defines the name of the mesh
  58259. * @param options defines the options used to create the mesh
  58260. * @param scene defines the hosting scene
  58261. * @returns the lathe mesh
  58262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58263. */
  58264. static CreateLathe(name: string, options: {
  58265. shape: Vector3[];
  58266. radius?: number;
  58267. tessellation?: number;
  58268. clip?: number;
  58269. arc?: number;
  58270. closed?: boolean;
  58271. updatable?: boolean;
  58272. sideOrientation?: number;
  58273. frontUVs?: Vector4;
  58274. backUVs?: Vector4;
  58275. cap?: number;
  58276. invertUV?: boolean;
  58277. }, scene?: Nullable<Scene>): Mesh;
  58278. }
  58279. }
  58280. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58281. import { Nullable } from "babylonjs/types";
  58282. import { Scene } from "babylonjs/scene";
  58283. import { Vector4 } from "babylonjs/Maths/math.vector";
  58284. import { Mesh } from "babylonjs/Meshes/mesh";
  58285. /**
  58286. * Class containing static functions to help procedurally build meshes
  58287. */
  58288. export class TiledPlaneBuilder {
  58289. /**
  58290. * Creates a tiled plane mesh
  58291. * * The parameter `pattern` will, depending on value, do nothing or
  58292. * * * flip (reflect about central vertical) alternate tiles across and up
  58293. * * * flip every tile on alternate rows
  58294. * * * rotate (180 degs) alternate tiles across and up
  58295. * * * rotate every tile on alternate rows
  58296. * * * flip and rotate alternate tiles across and up
  58297. * * * flip and rotate every tile on alternate rows
  58298. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58299. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58302. * * 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)
  58303. * * 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)
  58304. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58305. * @param name defines the name of the mesh
  58306. * @param options defines the options used to create the mesh
  58307. * @param scene defines the hosting scene
  58308. * @returns the box mesh
  58309. */
  58310. static CreateTiledPlane(name: string, options: {
  58311. pattern?: number;
  58312. tileSize?: number;
  58313. tileWidth?: number;
  58314. tileHeight?: number;
  58315. size?: number;
  58316. width?: number;
  58317. height?: number;
  58318. alignHorizontal?: number;
  58319. alignVertical?: number;
  58320. sideOrientation?: number;
  58321. frontUVs?: Vector4;
  58322. backUVs?: Vector4;
  58323. updatable?: boolean;
  58324. }, scene?: Nullable<Scene>): Mesh;
  58325. }
  58326. }
  58327. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58328. import { Nullable } from "babylonjs/types";
  58329. import { Scene } from "babylonjs/scene";
  58330. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58331. import { Mesh } from "babylonjs/Meshes/mesh";
  58332. /**
  58333. * Class containing static functions to help procedurally build meshes
  58334. */
  58335. export class TubeBuilder {
  58336. /**
  58337. * Creates a tube mesh.
  58338. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58339. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58340. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58341. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58342. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58343. * * 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)
  58344. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58345. * * 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
  58346. * * 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
  58347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58349. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58351. * @param name defines the name of the mesh
  58352. * @param options defines the options used to create the mesh
  58353. * @param scene defines the hosting scene
  58354. * @returns the tube mesh
  58355. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58356. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58357. */
  58358. static CreateTube(name: string, options: {
  58359. path: Vector3[];
  58360. radius?: number;
  58361. tessellation?: number;
  58362. radiusFunction?: {
  58363. (i: number, distance: number): number;
  58364. };
  58365. cap?: number;
  58366. arc?: number;
  58367. updatable?: boolean;
  58368. sideOrientation?: number;
  58369. frontUVs?: Vector4;
  58370. backUVs?: Vector4;
  58371. instance?: Mesh;
  58372. invertUV?: boolean;
  58373. }, scene?: Nullable<Scene>): Mesh;
  58374. }
  58375. }
  58376. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58377. import { Scene } from "babylonjs/scene";
  58378. import { Vector4 } from "babylonjs/Maths/math.vector";
  58379. import { Mesh } from "babylonjs/Meshes/mesh";
  58380. import { Nullable } from "babylonjs/types";
  58381. /**
  58382. * Class containing static functions to help procedurally build meshes
  58383. */
  58384. export class IcoSphereBuilder {
  58385. /**
  58386. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58387. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58388. * * 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`)
  58389. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58390. * * 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
  58391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58394. * @param name defines the name of the mesh
  58395. * @param options defines the options used to create the mesh
  58396. * @param scene defines the hosting scene
  58397. * @returns the icosahedron mesh
  58398. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58399. */
  58400. static CreateIcoSphere(name: string, options: {
  58401. radius?: number;
  58402. radiusX?: number;
  58403. radiusY?: number;
  58404. radiusZ?: number;
  58405. flat?: boolean;
  58406. subdivisions?: number;
  58407. sideOrientation?: number;
  58408. frontUVs?: Vector4;
  58409. backUVs?: Vector4;
  58410. updatable?: boolean;
  58411. }, scene?: Nullable<Scene>): Mesh;
  58412. }
  58413. }
  58414. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58415. import { Vector3 } from "babylonjs/Maths/math.vector";
  58416. import { Mesh } from "babylonjs/Meshes/mesh";
  58417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58418. /**
  58419. * Class containing static functions to help procedurally build meshes
  58420. */
  58421. export class DecalBuilder {
  58422. /**
  58423. * Creates a decal mesh.
  58424. * 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
  58425. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58426. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58427. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58428. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58429. * @param name defines the name of the mesh
  58430. * @param sourceMesh defines the mesh where the decal must be applied
  58431. * @param options defines the options used to create the mesh
  58432. * @param scene defines the hosting scene
  58433. * @returns the decal mesh
  58434. * @see https://doc.babylonjs.com/how_to/decals
  58435. */
  58436. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58437. position?: Vector3;
  58438. normal?: Vector3;
  58439. size?: Vector3;
  58440. angle?: number;
  58441. }): Mesh;
  58442. }
  58443. }
  58444. declare module "babylonjs/Meshes/meshBuilder" {
  58445. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58446. import { Nullable } from "babylonjs/types";
  58447. import { Scene } from "babylonjs/scene";
  58448. import { Mesh } from "babylonjs/Meshes/mesh";
  58449. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58450. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58452. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58453. import { Plane } from "babylonjs/Maths/math.plane";
  58454. /**
  58455. * Class containing static functions to help procedurally build meshes
  58456. */
  58457. export class MeshBuilder {
  58458. /**
  58459. * Creates a box mesh
  58460. * * The parameter `size` sets the size (float) of each box side (default 1)
  58461. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58462. * * 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)
  58463. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58467. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58468. * @param name defines the name of the mesh
  58469. * @param options defines the options used to create the mesh
  58470. * @param scene defines the hosting scene
  58471. * @returns the box mesh
  58472. */
  58473. static CreateBox(name: string, options: {
  58474. size?: number;
  58475. width?: number;
  58476. height?: number;
  58477. depth?: number;
  58478. faceUV?: Vector4[];
  58479. faceColors?: Color4[];
  58480. sideOrientation?: number;
  58481. frontUVs?: Vector4;
  58482. backUVs?: Vector4;
  58483. updatable?: boolean;
  58484. }, scene?: Nullable<Scene>): Mesh;
  58485. /**
  58486. * Creates a tiled box mesh
  58487. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58489. * @param name defines the name of the mesh
  58490. * @param options defines the options used to create the mesh
  58491. * @param scene defines the hosting scene
  58492. * @returns the tiled box mesh
  58493. */
  58494. static CreateTiledBox(name: string, options: {
  58495. pattern?: number;
  58496. size?: number;
  58497. width?: number;
  58498. height?: number;
  58499. depth: number;
  58500. tileSize?: number;
  58501. tileWidth?: number;
  58502. tileHeight?: number;
  58503. faceUV?: Vector4[];
  58504. faceColors?: Color4[];
  58505. alignHorizontal?: number;
  58506. alignVertical?: number;
  58507. sideOrientation?: number;
  58508. updatable?: boolean;
  58509. }, scene?: Nullable<Scene>): Mesh;
  58510. /**
  58511. * Creates a sphere mesh
  58512. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58513. * * 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`)
  58514. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58515. * * 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
  58516. * * 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)
  58517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58520. * @param name defines the name of the mesh
  58521. * @param options defines the options used to create the mesh
  58522. * @param scene defines the hosting scene
  58523. * @returns the sphere mesh
  58524. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58525. */
  58526. static CreateSphere(name: string, options: {
  58527. segments?: number;
  58528. diameter?: number;
  58529. diameterX?: number;
  58530. diameterY?: number;
  58531. diameterZ?: number;
  58532. arc?: number;
  58533. slice?: number;
  58534. sideOrientation?: number;
  58535. frontUVs?: Vector4;
  58536. backUVs?: Vector4;
  58537. updatable?: boolean;
  58538. }, scene?: Nullable<Scene>): Mesh;
  58539. /**
  58540. * Creates a plane polygonal mesh. By default, this is a disc
  58541. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58542. * * 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
  58543. * * 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
  58544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @param name defines the name of the mesh
  58548. * @param options defines the options used to create the mesh
  58549. * @param scene defines the hosting scene
  58550. * @returns the plane polygonal mesh
  58551. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58552. */
  58553. static CreateDisc(name: string, options: {
  58554. radius?: number;
  58555. tessellation?: number;
  58556. arc?: number;
  58557. updatable?: boolean;
  58558. sideOrientation?: number;
  58559. frontUVs?: Vector4;
  58560. backUVs?: Vector4;
  58561. }, scene?: Nullable<Scene>): Mesh;
  58562. /**
  58563. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58564. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58565. * * 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`)
  58566. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58567. * * 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
  58568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58571. * @param name defines the name of the mesh
  58572. * @param options defines the options used to create the mesh
  58573. * @param scene defines the hosting scene
  58574. * @returns the icosahedron mesh
  58575. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58576. */
  58577. static CreateIcoSphere(name: string, options: {
  58578. radius?: number;
  58579. radiusX?: number;
  58580. radiusY?: number;
  58581. radiusZ?: number;
  58582. flat?: boolean;
  58583. subdivisions?: number;
  58584. sideOrientation?: number;
  58585. frontUVs?: Vector4;
  58586. backUVs?: Vector4;
  58587. updatable?: boolean;
  58588. }, scene?: Nullable<Scene>): Mesh;
  58589. /**
  58590. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58591. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58592. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58593. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58594. * * 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
  58595. * * 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
  58596. * * 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
  58597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58599. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58600. * * 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
  58601. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58602. * * 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
  58603. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58605. * @param name defines the name of the mesh
  58606. * @param options defines the options used to create the mesh
  58607. * @param scene defines the hosting scene
  58608. * @returns the ribbon mesh
  58609. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58610. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58611. */
  58612. static CreateRibbon(name: string, options: {
  58613. pathArray: Vector3[][];
  58614. closeArray?: boolean;
  58615. closePath?: boolean;
  58616. offset?: number;
  58617. updatable?: boolean;
  58618. sideOrientation?: number;
  58619. frontUVs?: Vector4;
  58620. backUVs?: Vector4;
  58621. instance?: Mesh;
  58622. invertUV?: boolean;
  58623. uvs?: Vector2[];
  58624. colors?: Color4[];
  58625. }, scene?: Nullable<Scene>): Mesh;
  58626. /**
  58627. * Creates a cylinder or a cone mesh
  58628. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58629. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58630. * * 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.
  58631. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58632. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58633. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58634. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58635. * * 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).
  58636. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58637. * * 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).
  58638. * * 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
  58639. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58640. * * 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
  58641. * * 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.
  58642. * * If `enclose` is false, a ring surface is one element.
  58643. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58644. * * 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
  58645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58648. * @param name defines the name of the mesh
  58649. * @param options defines the options used to create the mesh
  58650. * @param scene defines the hosting scene
  58651. * @returns the cylinder mesh
  58652. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58653. */
  58654. static CreateCylinder(name: string, options: {
  58655. height?: number;
  58656. diameterTop?: number;
  58657. diameterBottom?: number;
  58658. diameter?: number;
  58659. tessellation?: number;
  58660. subdivisions?: number;
  58661. arc?: number;
  58662. faceColors?: Color4[];
  58663. faceUV?: Vector4[];
  58664. updatable?: boolean;
  58665. hasRings?: boolean;
  58666. enclose?: boolean;
  58667. cap?: number;
  58668. sideOrientation?: number;
  58669. frontUVs?: Vector4;
  58670. backUVs?: Vector4;
  58671. }, scene?: Nullable<Scene>): Mesh;
  58672. /**
  58673. * Creates a torus mesh
  58674. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58675. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58676. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58680. * @param name defines the name of the mesh
  58681. * @param options defines the options used to create the mesh
  58682. * @param scene defines the hosting scene
  58683. * @returns the torus mesh
  58684. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58685. */
  58686. static CreateTorus(name: string, options: {
  58687. diameter?: number;
  58688. thickness?: number;
  58689. tessellation?: number;
  58690. updatable?: boolean;
  58691. sideOrientation?: number;
  58692. frontUVs?: Vector4;
  58693. backUVs?: Vector4;
  58694. }, scene?: Nullable<Scene>): Mesh;
  58695. /**
  58696. * Creates a torus knot mesh
  58697. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58698. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58699. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58700. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58704. * @param name defines the name of the mesh
  58705. * @param options defines the options used to create the mesh
  58706. * @param scene defines the hosting scene
  58707. * @returns the torus knot mesh
  58708. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58709. */
  58710. static CreateTorusKnot(name: string, options: {
  58711. radius?: number;
  58712. tube?: number;
  58713. radialSegments?: number;
  58714. tubularSegments?: number;
  58715. p?: number;
  58716. q?: number;
  58717. updatable?: boolean;
  58718. sideOrientation?: number;
  58719. frontUVs?: Vector4;
  58720. backUVs?: Vector4;
  58721. }, scene?: Nullable<Scene>): Mesh;
  58722. /**
  58723. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58724. * * 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
  58725. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58726. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58727. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58728. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58729. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58730. * * 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
  58731. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58734. * @param name defines the name of the new line system
  58735. * @param options defines the options used to create the line system
  58736. * @param scene defines the hosting scene
  58737. * @returns a new line system mesh
  58738. */
  58739. static CreateLineSystem(name: string, options: {
  58740. lines: Vector3[][];
  58741. updatable?: boolean;
  58742. instance?: Nullable<LinesMesh>;
  58743. colors?: Nullable<Color4[][]>;
  58744. useVertexAlpha?: boolean;
  58745. }, scene: Nullable<Scene>): LinesMesh;
  58746. /**
  58747. * Creates a line mesh
  58748. * 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
  58749. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58750. * * The parameter `points` is an array successive Vector3
  58751. * * 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
  58752. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58753. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58754. * * When updating an instance, remember that only point positions can change, not the number of points
  58755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58757. * @param name defines the name of the new line system
  58758. * @param options defines the options used to create the line system
  58759. * @param scene defines the hosting scene
  58760. * @returns a new line mesh
  58761. */
  58762. static CreateLines(name: string, options: {
  58763. points: Vector3[];
  58764. updatable?: boolean;
  58765. instance?: Nullable<LinesMesh>;
  58766. colors?: Color4[];
  58767. useVertexAlpha?: boolean;
  58768. }, scene?: Nullable<Scene>): LinesMesh;
  58769. /**
  58770. * Creates a dashed line mesh
  58771. * * 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
  58772. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58773. * * The parameter `points` is an array successive Vector3
  58774. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58775. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58776. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58777. * * 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
  58778. * * When updating an instance, remember that only point positions can change, not the number of points
  58779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58780. * @param name defines the name of the mesh
  58781. * @param options defines the options used to create the mesh
  58782. * @param scene defines the hosting scene
  58783. * @returns the dashed line mesh
  58784. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58785. */
  58786. static CreateDashedLines(name: string, options: {
  58787. points: Vector3[];
  58788. dashSize?: number;
  58789. gapSize?: number;
  58790. dashNb?: number;
  58791. updatable?: boolean;
  58792. instance?: LinesMesh;
  58793. }, scene?: Nullable<Scene>): LinesMesh;
  58794. /**
  58795. * 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.
  58796. * * 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.
  58797. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58798. * * 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.
  58799. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58800. * * 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
  58801. * * 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
  58802. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58805. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58807. * @param name defines the name of the mesh
  58808. * @param options defines the options used to create the mesh
  58809. * @param scene defines the hosting scene
  58810. * @returns the extruded shape mesh
  58811. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58813. */
  58814. static ExtrudeShape(name: string, options: {
  58815. shape: Vector3[];
  58816. path: Vector3[];
  58817. scale?: number;
  58818. rotation?: number;
  58819. cap?: number;
  58820. updatable?: boolean;
  58821. sideOrientation?: number;
  58822. frontUVs?: Vector4;
  58823. backUVs?: Vector4;
  58824. instance?: Mesh;
  58825. invertUV?: boolean;
  58826. }, scene?: Nullable<Scene>): Mesh;
  58827. /**
  58828. * Creates an custom extruded shape mesh.
  58829. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58830. * * 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.
  58831. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58832. * * 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
  58833. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58834. * * 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
  58835. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58836. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58837. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58838. * * 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
  58839. * * 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
  58840. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58845. * @param name defines the name of the mesh
  58846. * @param options defines the options used to create the mesh
  58847. * @param scene defines the hosting scene
  58848. * @returns the custom extruded shape mesh
  58849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58850. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58852. */
  58853. static ExtrudeShapeCustom(name: string, options: {
  58854. shape: Vector3[];
  58855. path: Vector3[];
  58856. scaleFunction?: any;
  58857. rotationFunction?: any;
  58858. ribbonCloseArray?: boolean;
  58859. ribbonClosePath?: boolean;
  58860. cap?: number;
  58861. updatable?: boolean;
  58862. sideOrientation?: number;
  58863. frontUVs?: Vector4;
  58864. backUVs?: Vector4;
  58865. instance?: Mesh;
  58866. invertUV?: boolean;
  58867. }, scene?: Nullable<Scene>): Mesh;
  58868. /**
  58869. * Creates lathe mesh.
  58870. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58871. * * 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
  58872. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58873. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58874. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58875. * * 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
  58876. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58877. * * 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
  58878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58880. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58882. * @param name defines the name of the mesh
  58883. * @param options defines the options used to create the mesh
  58884. * @param scene defines the hosting scene
  58885. * @returns the lathe mesh
  58886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58887. */
  58888. static CreateLathe(name: string, options: {
  58889. shape: Vector3[];
  58890. radius?: number;
  58891. tessellation?: number;
  58892. clip?: number;
  58893. arc?: number;
  58894. closed?: boolean;
  58895. updatable?: boolean;
  58896. sideOrientation?: number;
  58897. frontUVs?: Vector4;
  58898. backUVs?: Vector4;
  58899. cap?: number;
  58900. invertUV?: boolean;
  58901. }, scene?: Nullable<Scene>): Mesh;
  58902. /**
  58903. * Creates a tiled plane mesh
  58904. * * You can set a limited pattern arrangement with the tiles
  58905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58908. * @param name defines the name of the mesh
  58909. * @param options defines the options used to create the mesh
  58910. * @param scene defines the hosting scene
  58911. * @returns the plane mesh
  58912. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58913. */
  58914. static CreateTiledPlane(name: string, options: {
  58915. pattern?: number;
  58916. tileSize?: number;
  58917. tileWidth?: number;
  58918. tileHeight?: number;
  58919. size?: number;
  58920. width?: number;
  58921. height?: number;
  58922. alignHorizontal?: number;
  58923. alignVertical?: number;
  58924. sideOrientation?: number;
  58925. frontUVs?: Vector4;
  58926. backUVs?: Vector4;
  58927. updatable?: boolean;
  58928. }, scene?: Nullable<Scene>): Mesh;
  58929. /**
  58930. * Creates a plane mesh
  58931. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58932. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58933. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58937. * @param name defines the name of the mesh
  58938. * @param options defines the options used to create the mesh
  58939. * @param scene defines the hosting scene
  58940. * @returns the plane mesh
  58941. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58942. */
  58943. static CreatePlane(name: string, options: {
  58944. size?: number;
  58945. width?: number;
  58946. height?: number;
  58947. sideOrientation?: number;
  58948. frontUVs?: Vector4;
  58949. backUVs?: Vector4;
  58950. updatable?: boolean;
  58951. sourcePlane?: Plane;
  58952. }, scene?: Nullable<Scene>): Mesh;
  58953. /**
  58954. * Creates a ground mesh
  58955. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58956. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58958. * @param name defines the name of the mesh
  58959. * @param options defines the options used to create the mesh
  58960. * @param scene defines the hosting scene
  58961. * @returns the ground mesh
  58962. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58963. */
  58964. static CreateGround(name: string, options: {
  58965. width?: number;
  58966. height?: number;
  58967. subdivisions?: number;
  58968. subdivisionsX?: number;
  58969. subdivisionsY?: number;
  58970. updatable?: boolean;
  58971. }, scene?: Nullable<Scene>): Mesh;
  58972. /**
  58973. * Creates a tiled ground mesh
  58974. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58975. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58976. * * 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
  58977. * * 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
  58978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58979. * @param name defines the name of the mesh
  58980. * @param options defines the options used to create the mesh
  58981. * @param scene defines the hosting scene
  58982. * @returns the tiled ground mesh
  58983. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58984. */
  58985. static CreateTiledGround(name: string, options: {
  58986. xmin: number;
  58987. zmin: number;
  58988. xmax: number;
  58989. zmax: number;
  58990. subdivisions?: {
  58991. w: number;
  58992. h: number;
  58993. };
  58994. precision?: {
  58995. w: number;
  58996. h: number;
  58997. };
  58998. updatable?: boolean;
  58999. }, scene?: Nullable<Scene>): Mesh;
  59000. /**
  59001. * Creates a ground mesh from a height map
  59002. * * The parameter `url` sets the URL of the height map image resource.
  59003. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59004. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59005. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59006. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59007. * * 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.
  59008. * * 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).
  59009. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59011. * @param name defines the name of the mesh
  59012. * @param url defines the url to the height map
  59013. * @param options defines the options used to create the mesh
  59014. * @param scene defines the hosting scene
  59015. * @returns the ground mesh
  59016. * @see https://doc.babylonjs.com/babylon101/height_map
  59017. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59018. */
  59019. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59020. width?: number;
  59021. height?: number;
  59022. subdivisions?: number;
  59023. minHeight?: number;
  59024. maxHeight?: number;
  59025. colorFilter?: Color3;
  59026. alphaFilter?: number;
  59027. updatable?: boolean;
  59028. onReady?: (mesh: GroundMesh) => void;
  59029. }, scene?: Nullable<Scene>): GroundMesh;
  59030. /**
  59031. * Creates a polygon mesh
  59032. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59033. * * 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
  59034. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59037. * * Remember you can only change the shape positions, not their number when updating a polygon
  59038. * @param name defines the name of the mesh
  59039. * @param options defines the options used to create the mesh
  59040. * @param scene defines the hosting scene
  59041. * @param earcutInjection can be used to inject your own earcut reference
  59042. * @returns the polygon mesh
  59043. */
  59044. static CreatePolygon(name: string, options: {
  59045. shape: Vector3[];
  59046. holes?: Vector3[][];
  59047. depth?: number;
  59048. faceUV?: Vector4[];
  59049. faceColors?: Color4[];
  59050. updatable?: boolean;
  59051. sideOrientation?: number;
  59052. frontUVs?: Vector4;
  59053. backUVs?: Vector4;
  59054. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59055. /**
  59056. * Creates an extruded polygon mesh, with depth in the Y direction.
  59057. * * 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)
  59058. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59059. * @param name defines the name of the mesh
  59060. * @param options defines the options used to create the mesh
  59061. * @param scene defines the hosting scene
  59062. * @param earcutInjection can be used to inject your own earcut reference
  59063. * @returns the polygon mesh
  59064. */
  59065. static ExtrudePolygon(name: string, options: {
  59066. shape: Vector3[];
  59067. holes?: Vector3[][];
  59068. depth?: number;
  59069. faceUV?: Vector4[];
  59070. faceColors?: Color4[];
  59071. updatable?: boolean;
  59072. sideOrientation?: number;
  59073. frontUVs?: Vector4;
  59074. backUVs?: Vector4;
  59075. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59076. /**
  59077. * Creates a tube mesh.
  59078. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59079. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59080. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59081. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59082. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59083. * * 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)
  59084. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59085. * * 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
  59086. * * 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
  59087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59091. * @param name defines the name of the mesh
  59092. * @param options defines the options used to create the mesh
  59093. * @param scene defines the hosting scene
  59094. * @returns the tube mesh
  59095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59096. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59097. */
  59098. static CreateTube(name: string, options: {
  59099. path: Vector3[];
  59100. radius?: number;
  59101. tessellation?: number;
  59102. radiusFunction?: {
  59103. (i: number, distance: number): number;
  59104. };
  59105. cap?: number;
  59106. arc?: number;
  59107. updatable?: boolean;
  59108. sideOrientation?: number;
  59109. frontUVs?: Vector4;
  59110. backUVs?: Vector4;
  59111. instance?: Mesh;
  59112. invertUV?: boolean;
  59113. }, scene?: Nullable<Scene>): Mesh;
  59114. /**
  59115. * Creates a polyhedron mesh
  59116. * * 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
  59117. * * The parameter `size` (positive float, default 1) sets the polygon size
  59118. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59119. * * 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`
  59120. * * 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
  59121. * * 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)`)
  59122. * * 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
  59123. * * 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
  59124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59127. * @param name defines the name of the mesh
  59128. * @param options defines the options used to create the mesh
  59129. * @param scene defines the hosting scene
  59130. * @returns the polyhedron mesh
  59131. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59132. */
  59133. static CreatePolyhedron(name: string, options: {
  59134. type?: number;
  59135. size?: number;
  59136. sizeX?: number;
  59137. sizeY?: number;
  59138. sizeZ?: number;
  59139. custom?: any;
  59140. faceUV?: Vector4[];
  59141. faceColors?: Color4[];
  59142. flat?: boolean;
  59143. updatable?: boolean;
  59144. sideOrientation?: number;
  59145. frontUVs?: Vector4;
  59146. backUVs?: Vector4;
  59147. }, scene?: Nullable<Scene>): Mesh;
  59148. /**
  59149. * Creates a decal mesh.
  59150. * 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
  59151. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59152. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59153. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59154. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59155. * @param name defines the name of the mesh
  59156. * @param sourceMesh defines the mesh where the decal must be applied
  59157. * @param options defines the options used to create the mesh
  59158. * @param scene defines the hosting scene
  59159. * @returns the decal mesh
  59160. * @see https://doc.babylonjs.com/how_to/decals
  59161. */
  59162. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59163. position?: Vector3;
  59164. normal?: Vector3;
  59165. size?: Vector3;
  59166. angle?: number;
  59167. }): Mesh;
  59168. }
  59169. }
  59170. declare module "babylonjs/Meshes/meshSimplification" {
  59171. import { Mesh } from "babylonjs/Meshes/mesh";
  59172. /**
  59173. * A simplifier interface for future simplification implementations
  59174. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59175. */
  59176. export interface ISimplifier {
  59177. /**
  59178. * Simplification of a given mesh according to the given settings.
  59179. * Since this requires computation, it is assumed that the function runs async.
  59180. * @param settings The settings of the simplification, including quality and distance
  59181. * @param successCallback A callback that will be called after the mesh was simplified.
  59182. * @param errorCallback in case of an error, this callback will be called. optional.
  59183. */
  59184. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59185. }
  59186. /**
  59187. * Expected simplification settings.
  59188. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59189. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59190. */
  59191. export interface ISimplificationSettings {
  59192. /**
  59193. * Gets or sets the expected quality
  59194. */
  59195. quality: number;
  59196. /**
  59197. * Gets or sets the distance when this optimized version should be used
  59198. */
  59199. distance: number;
  59200. /**
  59201. * Gets an already optimized mesh
  59202. */
  59203. optimizeMesh?: boolean;
  59204. }
  59205. /**
  59206. * Class used to specify simplification options
  59207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59208. */
  59209. export class SimplificationSettings implements ISimplificationSettings {
  59210. /** expected quality */
  59211. quality: number;
  59212. /** distance when this optimized version should be used */
  59213. distance: number;
  59214. /** already optimized mesh */
  59215. optimizeMesh?: boolean | undefined;
  59216. /**
  59217. * Creates a SimplificationSettings
  59218. * @param quality expected quality
  59219. * @param distance distance when this optimized version should be used
  59220. * @param optimizeMesh already optimized mesh
  59221. */
  59222. constructor(
  59223. /** expected quality */
  59224. quality: number,
  59225. /** distance when this optimized version should be used */
  59226. distance: number,
  59227. /** already optimized mesh */
  59228. optimizeMesh?: boolean | undefined);
  59229. }
  59230. /**
  59231. * Interface used to define a simplification task
  59232. */
  59233. export interface ISimplificationTask {
  59234. /**
  59235. * Array of settings
  59236. */
  59237. settings: Array<ISimplificationSettings>;
  59238. /**
  59239. * Simplification type
  59240. */
  59241. simplificationType: SimplificationType;
  59242. /**
  59243. * Mesh to simplify
  59244. */
  59245. mesh: Mesh;
  59246. /**
  59247. * Callback called on success
  59248. */
  59249. successCallback?: () => void;
  59250. /**
  59251. * Defines if parallel processing can be used
  59252. */
  59253. parallelProcessing: boolean;
  59254. }
  59255. /**
  59256. * Queue used to order the simplification tasks
  59257. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59258. */
  59259. export class SimplificationQueue {
  59260. private _simplificationArray;
  59261. /**
  59262. * Gets a boolean indicating that the process is still running
  59263. */
  59264. running: boolean;
  59265. /**
  59266. * Creates a new queue
  59267. */
  59268. constructor();
  59269. /**
  59270. * Adds a new simplification task
  59271. * @param task defines a task to add
  59272. */
  59273. addTask(task: ISimplificationTask): void;
  59274. /**
  59275. * Execute next task
  59276. */
  59277. executeNext(): void;
  59278. /**
  59279. * Execute a simplification task
  59280. * @param task defines the task to run
  59281. */
  59282. runSimplification(task: ISimplificationTask): void;
  59283. private getSimplifier;
  59284. }
  59285. /**
  59286. * The implemented types of simplification
  59287. * At the moment only Quadratic Error Decimation is implemented
  59288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59289. */
  59290. export enum SimplificationType {
  59291. /** Quadratic error decimation */
  59292. QUADRATIC = 0
  59293. }
  59294. }
  59295. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59296. import { Scene } from "babylonjs/scene";
  59297. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59298. import { ISceneComponent } from "babylonjs/sceneComponent";
  59299. module "babylonjs/scene" {
  59300. interface Scene {
  59301. /** @hidden (Backing field) */
  59302. _simplificationQueue: SimplificationQueue;
  59303. /**
  59304. * Gets or sets the simplification queue attached to the scene
  59305. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59306. */
  59307. simplificationQueue: SimplificationQueue;
  59308. }
  59309. }
  59310. module "babylonjs/Meshes/mesh" {
  59311. interface Mesh {
  59312. /**
  59313. * Simplify the mesh according to the given array of settings.
  59314. * Function will return immediately and will simplify async
  59315. * @param settings a collection of simplification settings
  59316. * @param parallelProcessing should all levels calculate parallel or one after the other
  59317. * @param simplificationType the type of simplification to run
  59318. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59319. * @returns the current mesh
  59320. */
  59321. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59322. }
  59323. }
  59324. /**
  59325. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59326. * created in a scene
  59327. */
  59328. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59329. /**
  59330. * The component name helpfull to identify the component in the list of scene components.
  59331. */
  59332. readonly name: string;
  59333. /**
  59334. * The scene the component belongs to.
  59335. */
  59336. scene: Scene;
  59337. /**
  59338. * Creates a new instance of the component for the given scene
  59339. * @param scene Defines the scene to register the component in
  59340. */
  59341. constructor(scene: Scene);
  59342. /**
  59343. * Registers the component in a given scene
  59344. */
  59345. register(): void;
  59346. /**
  59347. * Rebuilds the elements related to this component in case of
  59348. * context lost for instance.
  59349. */
  59350. rebuild(): void;
  59351. /**
  59352. * Disposes the component and the associated ressources
  59353. */
  59354. dispose(): void;
  59355. private _beforeCameraUpdate;
  59356. }
  59357. }
  59358. declare module "babylonjs/Meshes/Builders/index" {
  59359. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59360. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59361. export * from "babylonjs/Meshes/Builders/discBuilder";
  59362. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59363. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59364. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59365. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59366. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59367. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59368. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59369. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59370. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59371. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59372. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59373. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59374. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59375. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59376. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59377. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59378. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59379. }
  59380. declare module "babylonjs/Meshes/index" {
  59381. export * from "babylonjs/Meshes/abstractMesh";
  59382. export * from "babylonjs/Meshes/buffer";
  59383. export * from "babylonjs/Meshes/Compression/index";
  59384. export * from "babylonjs/Meshes/csg";
  59385. export * from "babylonjs/Meshes/geometry";
  59386. export * from "babylonjs/Meshes/groundMesh";
  59387. export * from "babylonjs/Meshes/trailMesh";
  59388. export * from "babylonjs/Meshes/instancedMesh";
  59389. export * from "babylonjs/Meshes/linesMesh";
  59390. export * from "babylonjs/Meshes/mesh";
  59391. export * from "babylonjs/Meshes/mesh.vertexData";
  59392. export * from "babylonjs/Meshes/meshBuilder";
  59393. export * from "babylonjs/Meshes/meshSimplification";
  59394. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59395. export * from "babylonjs/Meshes/polygonMesh";
  59396. export * from "babylonjs/Meshes/subMesh";
  59397. export * from "babylonjs/Meshes/meshLODLevel";
  59398. export * from "babylonjs/Meshes/transformNode";
  59399. export * from "babylonjs/Meshes/Builders/index";
  59400. export * from "babylonjs/Meshes/dataBuffer";
  59401. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59402. }
  59403. declare module "babylonjs/Morph/index" {
  59404. export * from "babylonjs/Morph/morphTarget";
  59405. export * from "babylonjs/Morph/morphTargetManager";
  59406. }
  59407. declare module "babylonjs/Navigation/INavigationEngine" {
  59408. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59409. import { Vector3 } from "babylonjs/Maths/math";
  59410. import { Mesh } from "babylonjs/Meshes/mesh";
  59411. import { Scene } from "babylonjs/scene";
  59412. /**
  59413. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59414. */
  59415. export interface INavigationEnginePlugin {
  59416. /**
  59417. * plugin name
  59418. */
  59419. name: string;
  59420. /**
  59421. * Creates a navigation mesh
  59422. * @param meshes array of all the geometry used to compute the navigatio mesh
  59423. * @param parameters bunch of parameters used to filter geometry
  59424. */
  59425. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59426. /**
  59427. * Create a navigation mesh debug mesh
  59428. * @param scene is where the mesh will be added
  59429. * @returns debug display mesh
  59430. */
  59431. createDebugNavMesh(scene: Scene): Mesh;
  59432. /**
  59433. * Get a navigation mesh constrained position, closest to the parameter position
  59434. * @param position world position
  59435. * @returns the closest point to position constrained by the navigation mesh
  59436. */
  59437. getClosestPoint(position: Vector3): Vector3;
  59438. /**
  59439. * Get a navigation mesh constrained position, within a particular radius
  59440. * @param position world position
  59441. * @param maxRadius the maximum distance to the constrained world position
  59442. * @returns the closest point to position constrained by the navigation mesh
  59443. */
  59444. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59445. /**
  59446. * Compute the final position from a segment made of destination-position
  59447. * @param position world position
  59448. * @param destination world position
  59449. * @returns the resulting point along the navmesh
  59450. */
  59451. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59452. /**
  59453. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59454. * @param start world position
  59455. * @param end world position
  59456. * @returns array containing world position composing the path
  59457. */
  59458. computePath(start: Vector3, end: Vector3): Vector3[];
  59459. /**
  59460. * If this plugin is supported
  59461. * @returns true if plugin is supported
  59462. */
  59463. isSupported(): boolean;
  59464. /**
  59465. * Create a new Crowd so you can add agents
  59466. * @param maxAgents the maximum agent count in the crowd
  59467. * @param maxAgentRadius the maximum radius an agent can have
  59468. * @param scene to attach the crowd to
  59469. * @returns the crowd you can add agents to
  59470. */
  59471. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59472. /**
  59473. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59474. * The queries will try to find a solution within those bounds
  59475. * default is (1,1,1)
  59476. * @param extent x,y,z value that define the extent around the queries point of reference
  59477. */
  59478. setDefaultQueryExtent(extent: Vector3): void;
  59479. /**
  59480. * Get the Bounding box extent specified by setDefaultQueryExtent
  59481. * @returns the box extent values
  59482. */
  59483. getDefaultQueryExtent(): Vector3;
  59484. /**
  59485. * Release all resources
  59486. */
  59487. dispose(): void;
  59488. }
  59489. /**
  59490. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59491. */
  59492. export interface ICrowd {
  59493. /**
  59494. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59495. * You can attach anything to that node. The node position is updated in the scene update tick.
  59496. * @param pos world position that will be constrained by the navigation mesh
  59497. * @param parameters agent parameters
  59498. * @param transform hooked to the agent that will be update by the scene
  59499. * @returns agent index
  59500. */
  59501. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59502. /**
  59503. * Returns the agent position in world space
  59504. * @param index agent index returned by addAgent
  59505. * @returns world space position
  59506. */
  59507. getAgentPosition(index: number): Vector3;
  59508. /**
  59509. * Gets the agent velocity in world space
  59510. * @param index agent index returned by addAgent
  59511. * @returns world space velocity
  59512. */
  59513. getAgentVelocity(index: number): Vector3;
  59514. /**
  59515. * remove a particular agent previously created
  59516. * @param index agent index returned by addAgent
  59517. */
  59518. removeAgent(index: number): void;
  59519. /**
  59520. * get the list of all agents attached to this crowd
  59521. * @returns list of agent indices
  59522. */
  59523. getAgents(): number[];
  59524. /**
  59525. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59526. * @param deltaTime in seconds
  59527. */
  59528. update(deltaTime: number): void;
  59529. /**
  59530. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59531. * @param index agent index returned by addAgent
  59532. * @param destination targeted world position
  59533. */
  59534. agentGoto(index: number, destination: Vector3): void;
  59535. /**
  59536. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59537. * The queries will try to find a solution within those bounds
  59538. * default is (1,1,1)
  59539. * @param extent x,y,z value that define the extent around the queries point of reference
  59540. */
  59541. setDefaultQueryExtent(extent: Vector3): void;
  59542. /**
  59543. * Get the Bounding box extent specified by setDefaultQueryExtent
  59544. * @returns the box extent values
  59545. */
  59546. getDefaultQueryExtent(): Vector3;
  59547. /**
  59548. * Release all resources
  59549. */
  59550. dispose(): void;
  59551. }
  59552. /**
  59553. * Configures an agent
  59554. */
  59555. export interface IAgentParameters {
  59556. /**
  59557. * Agent radius. [Limit: >= 0]
  59558. */
  59559. radius: number;
  59560. /**
  59561. * Agent height. [Limit: > 0]
  59562. */
  59563. height: number;
  59564. /**
  59565. * Maximum allowed acceleration. [Limit: >= 0]
  59566. */
  59567. maxAcceleration: number;
  59568. /**
  59569. * Maximum allowed speed. [Limit: >= 0]
  59570. */
  59571. maxSpeed: number;
  59572. /**
  59573. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59574. */
  59575. collisionQueryRange: number;
  59576. /**
  59577. * The path visibility optimization range. [Limit: > 0]
  59578. */
  59579. pathOptimizationRange: number;
  59580. /**
  59581. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59582. */
  59583. separationWeight: number;
  59584. }
  59585. /**
  59586. * Configures the navigation mesh creation
  59587. */
  59588. export interface INavMeshParameters {
  59589. /**
  59590. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59591. */
  59592. cs: number;
  59593. /**
  59594. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59595. */
  59596. ch: number;
  59597. /**
  59598. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59599. */
  59600. walkableSlopeAngle: number;
  59601. /**
  59602. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59603. * be considered walkable. [Limit: >= 3] [Units: vx]
  59604. */
  59605. walkableHeight: number;
  59606. /**
  59607. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59608. */
  59609. walkableClimb: number;
  59610. /**
  59611. * The distance to erode/shrink the walkable area of the heightfield away from
  59612. * obstructions. [Limit: >=0] [Units: vx]
  59613. */
  59614. walkableRadius: number;
  59615. /**
  59616. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59617. */
  59618. maxEdgeLen: number;
  59619. /**
  59620. * The maximum distance a simplfied contour's border edges should deviate
  59621. * the original raw contour. [Limit: >=0] [Units: vx]
  59622. */
  59623. maxSimplificationError: number;
  59624. /**
  59625. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59626. */
  59627. minRegionArea: number;
  59628. /**
  59629. * Any regions with a span count smaller than this value will, if possible,
  59630. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59631. */
  59632. mergeRegionArea: number;
  59633. /**
  59634. * The maximum number of vertices allowed for polygons generated during the
  59635. * contour to polygon conversion process. [Limit: >= 3]
  59636. */
  59637. maxVertsPerPoly: number;
  59638. /**
  59639. * Sets the sampling distance to use when generating the detail mesh.
  59640. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59641. */
  59642. detailSampleDist: number;
  59643. /**
  59644. * The maximum distance the detail mesh surface should deviate from heightfield
  59645. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59646. */
  59647. detailSampleMaxError: number;
  59648. }
  59649. }
  59650. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59651. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59652. import { Mesh } from "babylonjs/Meshes/mesh";
  59653. import { Scene } from "babylonjs/scene";
  59654. import { Vector3 } from "babylonjs/Maths/math";
  59655. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59656. /**
  59657. * RecastJS navigation plugin
  59658. */
  59659. export class RecastJSPlugin implements INavigationEnginePlugin {
  59660. /**
  59661. * Reference to the Recast library
  59662. */
  59663. bjsRECAST: any;
  59664. /**
  59665. * plugin name
  59666. */
  59667. name: string;
  59668. /**
  59669. * the first navmesh created. We might extend this to support multiple navmeshes
  59670. */
  59671. navMesh: any;
  59672. /**
  59673. * Initializes the recastJS plugin
  59674. * @param recastInjection can be used to inject your own recast reference
  59675. */
  59676. constructor(recastInjection?: any);
  59677. /**
  59678. * Creates a navigation mesh
  59679. * @param meshes array of all the geometry used to compute the navigatio mesh
  59680. * @param parameters bunch of parameters used to filter geometry
  59681. */
  59682. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59683. /**
  59684. * Create a navigation mesh debug mesh
  59685. * @param scene is where the mesh will be added
  59686. * @returns debug display mesh
  59687. */
  59688. createDebugNavMesh(scene: Scene): Mesh;
  59689. /**
  59690. * Get a navigation mesh constrained position, closest to the parameter position
  59691. * @param position world position
  59692. * @returns the closest point to position constrained by the navigation mesh
  59693. */
  59694. getClosestPoint(position: Vector3): Vector3;
  59695. /**
  59696. * Get a navigation mesh constrained position, within a particular radius
  59697. * @param position world position
  59698. * @param maxRadius the maximum distance to the constrained world position
  59699. * @returns the closest point to position constrained by the navigation mesh
  59700. */
  59701. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59702. /**
  59703. * Compute the final position from a segment made of destination-position
  59704. * @param position world position
  59705. * @param destination world position
  59706. * @returns the resulting point along the navmesh
  59707. */
  59708. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59709. /**
  59710. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59711. * @param start world position
  59712. * @param end world position
  59713. * @returns array containing world position composing the path
  59714. */
  59715. computePath(start: Vector3, end: Vector3): Vector3[];
  59716. /**
  59717. * Create a new Crowd so you can add agents
  59718. * @param maxAgents the maximum agent count in the crowd
  59719. * @param maxAgentRadius the maximum radius an agent can have
  59720. * @param scene to attach the crowd to
  59721. * @returns the crowd you can add agents to
  59722. */
  59723. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59724. /**
  59725. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59726. * The queries will try to find a solution within those bounds
  59727. * default is (1,1,1)
  59728. * @param extent x,y,z value that define the extent around the queries point of reference
  59729. */
  59730. setDefaultQueryExtent(extent: Vector3): void;
  59731. /**
  59732. * Get the Bounding box extent specified by setDefaultQueryExtent
  59733. * @returns the box extent values
  59734. */
  59735. getDefaultQueryExtent(): Vector3;
  59736. /**
  59737. * Disposes
  59738. */
  59739. dispose(): void;
  59740. /**
  59741. * If this plugin is supported
  59742. * @returns true if plugin is supported
  59743. */
  59744. isSupported(): boolean;
  59745. }
  59746. /**
  59747. * Recast detour crowd implementation
  59748. */
  59749. export class RecastJSCrowd implements ICrowd {
  59750. /**
  59751. * Recast/detour plugin
  59752. */
  59753. bjsRECASTPlugin: RecastJSPlugin;
  59754. /**
  59755. * Link to the detour crowd
  59756. */
  59757. recastCrowd: any;
  59758. /**
  59759. * One transform per agent
  59760. */
  59761. transforms: TransformNode[];
  59762. /**
  59763. * All agents created
  59764. */
  59765. agents: number[];
  59766. /**
  59767. * Link to the scene is kept to unregister the crowd from the scene
  59768. */
  59769. private _scene;
  59770. /**
  59771. * Observer for crowd updates
  59772. */
  59773. private _onBeforeAnimationsObserver;
  59774. /**
  59775. * Constructor
  59776. * @param plugin recastJS plugin
  59777. * @param maxAgents the maximum agent count in the crowd
  59778. * @param maxAgentRadius the maximum radius an agent can have
  59779. * @param scene to attach the crowd to
  59780. * @returns the crowd you can add agents to
  59781. */
  59782. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59783. /**
  59784. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59785. * You can attach anything to that node. The node position is updated in the scene update tick.
  59786. * @param pos world position that will be constrained by the navigation mesh
  59787. * @param parameters agent parameters
  59788. * @param transform hooked to the agent that will be update by the scene
  59789. * @returns agent index
  59790. */
  59791. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59792. /**
  59793. * Returns the agent position in world space
  59794. * @param index agent index returned by addAgent
  59795. * @returns world space position
  59796. */
  59797. getAgentPosition(index: number): Vector3;
  59798. /**
  59799. * Returns the agent velocity in world space
  59800. * @param index agent index returned by addAgent
  59801. * @returns world space velocity
  59802. */
  59803. getAgentVelocity(index: number): Vector3;
  59804. /**
  59805. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59806. * @param index agent index returned by addAgent
  59807. * @param destination targeted world position
  59808. */
  59809. agentGoto(index: number, destination: Vector3): void;
  59810. /**
  59811. * remove a particular agent previously created
  59812. * @param index agent index returned by addAgent
  59813. */
  59814. removeAgent(index: number): void;
  59815. /**
  59816. * get the list of all agents attached to this crowd
  59817. * @returns list of agent indices
  59818. */
  59819. getAgents(): number[];
  59820. /**
  59821. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59822. * @param deltaTime in seconds
  59823. */
  59824. update(deltaTime: number): void;
  59825. /**
  59826. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59827. * The queries will try to find a solution within those bounds
  59828. * default is (1,1,1)
  59829. * @param extent x,y,z value that define the extent around the queries point of reference
  59830. */
  59831. setDefaultQueryExtent(extent: Vector3): void;
  59832. /**
  59833. * Get the Bounding box extent specified by setDefaultQueryExtent
  59834. * @returns the box extent values
  59835. */
  59836. getDefaultQueryExtent(): Vector3;
  59837. /**
  59838. * Release all resources
  59839. */
  59840. dispose(): void;
  59841. }
  59842. }
  59843. declare module "babylonjs/Navigation/Plugins/index" {
  59844. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59845. }
  59846. declare module "babylonjs/Navigation/index" {
  59847. export * from "babylonjs/Navigation/INavigationEngine";
  59848. export * from "babylonjs/Navigation/Plugins/index";
  59849. }
  59850. declare module "babylonjs/Offline/database" {
  59851. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59852. /**
  59853. * Class used to enable access to IndexedDB
  59854. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59855. */
  59856. export class Database implements IOfflineProvider {
  59857. private _callbackManifestChecked;
  59858. private _currentSceneUrl;
  59859. private _db;
  59860. private _enableSceneOffline;
  59861. private _enableTexturesOffline;
  59862. private _manifestVersionFound;
  59863. private _mustUpdateRessources;
  59864. private _hasReachedQuota;
  59865. private _isSupported;
  59866. private _idbFactory;
  59867. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59868. private static IsUASupportingBlobStorage;
  59869. /**
  59870. * Gets a boolean indicating if Database storate is enabled (off by default)
  59871. */
  59872. static IDBStorageEnabled: boolean;
  59873. /**
  59874. * Gets a boolean indicating if scene must be saved in the database
  59875. */
  59876. readonly enableSceneOffline: boolean;
  59877. /**
  59878. * Gets a boolean indicating if textures must be saved in the database
  59879. */
  59880. readonly enableTexturesOffline: boolean;
  59881. /**
  59882. * Creates a new Database
  59883. * @param urlToScene defines the url to load the scene
  59884. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59885. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59886. */
  59887. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59888. private static _ParseURL;
  59889. private static _ReturnFullUrlLocation;
  59890. private _checkManifestFile;
  59891. /**
  59892. * Open the database and make it available
  59893. * @param successCallback defines the callback to call on success
  59894. * @param errorCallback defines the callback to call on error
  59895. */
  59896. open(successCallback: () => void, errorCallback: () => void): void;
  59897. /**
  59898. * Loads an image from the database
  59899. * @param url defines the url to load from
  59900. * @param image defines the target DOM image
  59901. */
  59902. loadImage(url: string, image: HTMLImageElement): void;
  59903. private _loadImageFromDBAsync;
  59904. private _saveImageIntoDBAsync;
  59905. private _checkVersionFromDB;
  59906. private _loadVersionFromDBAsync;
  59907. private _saveVersionIntoDBAsync;
  59908. /**
  59909. * Loads a file from database
  59910. * @param url defines the URL to load from
  59911. * @param sceneLoaded defines a callback to call on success
  59912. * @param progressCallBack defines a callback to call when progress changed
  59913. * @param errorCallback defines a callback to call on error
  59914. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59915. */
  59916. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59917. private _loadFileAsync;
  59918. private _saveFileAsync;
  59919. /**
  59920. * Validates if xhr data is correct
  59921. * @param xhr defines the request to validate
  59922. * @param dataType defines the expected data type
  59923. * @returns true if data is correct
  59924. */
  59925. private static _ValidateXHRData;
  59926. }
  59927. }
  59928. declare module "babylonjs/Offline/index" {
  59929. export * from "babylonjs/Offline/database";
  59930. export * from "babylonjs/Offline/IOfflineProvider";
  59931. }
  59932. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59933. /** @hidden */
  59934. export var gpuUpdateParticlesPixelShader: {
  59935. name: string;
  59936. shader: string;
  59937. };
  59938. }
  59939. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59940. /** @hidden */
  59941. export var gpuUpdateParticlesVertexShader: {
  59942. name: string;
  59943. shader: string;
  59944. };
  59945. }
  59946. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59947. /** @hidden */
  59948. export var clipPlaneFragmentDeclaration2: {
  59949. name: string;
  59950. shader: string;
  59951. };
  59952. }
  59953. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59954. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59955. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59956. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59957. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59958. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59959. /** @hidden */
  59960. export var gpuRenderParticlesPixelShader: {
  59961. name: string;
  59962. shader: string;
  59963. };
  59964. }
  59965. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59966. /** @hidden */
  59967. export var clipPlaneVertexDeclaration2: {
  59968. name: string;
  59969. shader: string;
  59970. };
  59971. }
  59972. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59973. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59974. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59975. /** @hidden */
  59976. export var gpuRenderParticlesVertexShader: {
  59977. name: string;
  59978. shader: string;
  59979. };
  59980. }
  59981. declare module "babylonjs/Particles/gpuParticleSystem" {
  59982. import { Nullable } from "babylonjs/types";
  59983. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59984. import { Observable } from "babylonjs/Misc/observable";
  59985. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59986. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59987. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59988. import { Scene, IDisposable } from "babylonjs/scene";
  59989. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59991. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59992. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59993. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59994. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59995. /**
  59996. * This represents a GPU particle system in Babylon
  59997. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59998. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59999. */
  60000. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60001. /**
  60002. * The layer mask we are rendering the particles through.
  60003. */
  60004. layerMask: number;
  60005. private _capacity;
  60006. private _activeCount;
  60007. private _currentActiveCount;
  60008. private _accumulatedCount;
  60009. private _renderEffect;
  60010. private _updateEffect;
  60011. private _buffer0;
  60012. private _buffer1;
  60013. private _spriteBuffer;
  60014. private _updateVAO;
  60015. private _renderVAO;
  60016. private _targetIndex;
  60017. private _sourceBuffer;
  60018. private _targetBuffer;
  60019. private _engine;
  60020. private _currentRenderId;
  60021. private _started;
  60022. private _stopped;
  60023. private _timeDelta;
  60024. private _randomTexture;
  60025. private _randomTexture2;
  60026. private _attributesStrideSize;
  60027. private _updateEffectOptions;
  60028. private _randomTextureSize;
  60029. private _actualFrame;
  60030. private readonly _rawTextureWidth;
  60031. /**
  60032. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60033. */
  60034. static readonly IsSupported: boolean;
  60035. /**
  60036. * An event triggered when the system is disposed.
  60037. */
  60038. onDisposeObservable: Observable<GPUParticleSystem>;
  60039. /**
  60040. * Gets the maximum number of particles active at the same time.
  60041. * @returns The max number of active particles.
  60042. */
  60043. getCapacity(): number;
  60044. /**
  60045. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60046. * to override the particles.
  60047. */
  60048. forceDepthWrite: boolean;
  60049. /**
  60050. * Gets or set the number of active particles
  60051. */
  60052. activeParticleCount: number;
  60053. private _preWarmDone;
  60054. /**
  60055. * Is this system ready to be used/rendered
  60056. * @return true if the system is ready
  60057. */
  60058. isReady(): boolean;
  60059. /**
  60060. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60061. * @returns True if it has been started, otherwise false.
  60062. */
  60063. isStarted(): boolean;
  60064. /**
  60065. * Starts the particle system and begins to emit
  60066. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60067. */
  60068. start(delay?: number): void;
  60069. /**
  60070. * Stops the particle system.
  60071. */
  60072. stop(): void;
  60073. /**
  60074. * Remove all active particles
  60075. */
  60076. reset(): void;
  60077. /**
  60078. * Returns the string "GPUParticleSystem"
  60079. * @returns a string containing the class name
  60080. */
  60081. getClassName(): string;
  60082. private _colorGradientsTexture;
  60083. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60084. /**
  60085. * Adds a new color gradient
  60086. * @param gradient defines the gradient to use (between 0 and 1)
  60087. * @param color1 defines the color to affect to the specified gradient
  60088. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60089. * @returns the current particle system
  60090. */
  60091. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60092. /**
  60093. * Remove a specific color gradient
  60094. * @param gradient defines the gradient to remove
  60095. * @returns the current particle system
  60096. */
  60097. removeColorGradient(gradient: number): GPUParticleSystem;
  60098. private _angularSpeedGradientsTexture;
  60099. private _sizeGradientsTexture;
  60100. private _velocityGradientsTexture;
  60101. private _limitVelocityGradientsTexture;
  60102. private _dragGradientsTexture;
  60103. private _addFactorGradient;
  60104. /**
  60105. * Adds a new size gradient
  60106. * @param gradient defines the gradient to use (between 0 and 1)
  60107. * @param factor defines the size factor to affect to the specified gradient
  60108. * @returns the current particle system
  60109. */
  60110. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60111. /**
  60112. * Remove a specific size gradient
  60113. * @param gradient defines the gradient to remove
  60114. * @returns the current particle system
  60115. */
  60116. removeSizeGradient(gradient: number): GPUParticleSystem;
  60117. /**
  60118. * Adds a new angular speed gradient
  60119. * @param gradient defines the gradient to use (between 0 and 1)
  60120. * @param factor defines the angular speed to affect to the specified gradient
  60121. * @returns the current particle system
  60122. */
  60123. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60124. /**
  60125. * Remove a specific angular speed gradient
  60126. * @param gradient defines the gradient to remove
  60127. * @returns the current particle system
  60128. */
  60129. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60130. /**
  60131. * Adds a new velocity gradient
  60132. * @param gradient defines the gradient to use (between 0 and 1)
  60133. * @param factor defines the velocity to affect to the specified gradient
  60134. * @returns the current particle system
  60135. */
  60136. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60137. /**
  60138. * Remove a specific velocity gradient
  60139. * @param gradient defines the gradient to remove
  60140. * @returns the current particle system
  60141. */
  60142. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60143. /**
  60144. * Adds a new limit velocity gradient
  60145. * @param gradient defines the gradient to use (between 0 and 1)
  60146. * @param factor defines the limit velocity value to affect to the specified gradient
  60147. * @returns the current particle system
  60148. */
  60149. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60150. /**
  60151. * Remove a specific limit velocity gradient
  60152. * @param gradient defines the gradient to remove
  60153. * @returns the current particle system
  60154. */
  60155. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60156. /**
  60157. * Adds a new drag gradient
  60158. * @param gradient defines the gradient to use (between 0 and 1)
  60159. * @param factor defines the drag value to affect to the specified gradient
  60160. * @returns the current particle system
  60161. */
  60162. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60163. /**
  60164. * Remove a specific drag gradient
  60165. * @param gradient defines the gradient to remove
  60166. * @returns the current particle system
  60167. */
  60168. removeDragGradient(gradient: number): GPUParticleSystem;
  60169. /**
  60170. * Not supported by GPUParticleSystem
  60171. * @param gradient defines the gradient to use (between 0 and 1)
  60172. * @param factor defines the emit rate value to affect to the specified gradient
  60173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60174. * @returns the current particle system
  60175. */
  60176. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60177. /**
  60178. * Not supported by GPUParticleSystem
  60179. * @param gradient defines the gradient to remove
  60180. * @returns the current particle system
  60181. */
  60182. removeEmitRateGradient(gradient: number): IParticleSystem;
  60183. /**
  60184. * Not supported by GPUParticleSystem
  60185. * @param gradient defines the gradient to use (between 0 and 1)
  60186. * @param factor defines the start size value to affect to the specified gradient
  60187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60188. * @returns the current particle system
  60189. */
  60190. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60191. /**
  60192. * Not supported by GPUParticleSystem
  60193. * @param gradient defines the gradient to remove
  60194. * @returns the current particle system
  60195. */
  60196. removeStartSizeGradient(gradient: number): IParticleSystem;
  60197. /**
  60198. * Not supported by GPUParticleSystem
  60199. * @param gradient defines the gradient to use (between 0 and 1)
  60200. * @param min defines the color remap minimal range
  60201. * @param max defines the color remap maximal range
  60202. * @returns the current particle system
  60203. */
  60204. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60205. /**
  60206. * Not supported by GPUParticleSystem
  60207. * @param gradient defines the gradient to remove
  60208. * @returns the current particle system
  60209. */
  60210. removeColorRemapGradient(): IParticleSystem;
  60211. /**
  60212. * Not supported by GPUParticleSystem
  60213. * @param gradient defines the gradient to use (between 0 and 1)
  60214. * @param min defines the alpha remap minimal range
  60215. * @param max defines the alpha remap maximal range
  60216. * @returns the current particle system
  60217. */
  60218. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60219. /**
  60220. * Not supported by GPUParticleSystem
  60221. * @param gradient defines the gradient to remove
  60222. * @returns the current particle system
  60223. */
  60224. removeAlphaRemapGradient(): IParticleSystem;
  60225. /**
  60226. * Not supported by GPUParticleSystem
  60227. * @param gradient defines the gradient to use (between 0 and 1)
  60228. * @param color defines the color to affect to the specified gradient
  60229. * @returns the current particle system
  60230. */
  60231. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60232. /**
  60233. * Not supported by GPUParticleSystem
  60234. * @param gradient defines the gradient to remove
  60235. * @returns the current particle system
  60236. */
  60237. removeRampGradient(): IParticleSystem;
  60238. /**
  60239. * Not supported by GPUParticleSystem
  60240. * @returns the list of ramp gradients
  60241. */
  60242. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60243. /**
  60244. * Not supported by GPUParticleSystem
  60245. * Gets or sets a boolean indicating that ramp gradients must be used
  60246. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60247. */
  60248. useRampGradients: boolean;
  60249. /**
  60250. * Not supported by GPUParticleSystem
  60251. * @param gradient defines the gradient to use (between 0 and 1)
  60252. * @param factor defines the life time factor to affect to the specified gradient
  60253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60254. * @returns the current particle system
  60255. */
  60256. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60257. /**
  60258. * Not supported by GPUParticleSystem
  60259. * @param gradient defines the gradient to remove
  60260. * @returns the current particle system
  60261. */
  60262. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60263. /**
  60264. * Instantiates a GPU particle system.
  60265. * 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.
  60266. * @param name The name of the particle system
  60267. * @param options The options used to create the system
  60268. * @param scene The scene the particle system belongs to
  60269. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60270. */
  60271. constructor(name: string, options: Partial<{
  60272. capacity: number;
  60273. randomTextureSize: number;
  60274. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60275. protected _reset(): void;
  60276. private _createUpdateVAO;
  60277. private _createRenderVAO;
  60278. private _initialize;
  60279. /** @hidden */
  60280. _recreateUpdateEffect(): void;
  60281. /** @hidden */
  60282. _recreateRenderEffect(): void;
  60283. /**
  60284. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60285. * @param preWarm defines if we are in the pre-warmimg phase
  60286. */
  60287. animate(preWarm?: boolean): void;
  60288. private _createFactorGradientTexture;
  60289. private _createSizeGradientTexture;
  60290. private _createAngularSpeedGradientTexture;
  60291. private _createVelocityGradientTexture;
  60292. private _createLimitVelocityGradientTexture;
  60293. private _createDragGradientTexture;
  60294. private _createColorGradientTexture;
  60295. /**
  60296. * Renders the particle system in its current state
  60297. * @param preWarm defines if the system should only update the particles but not render them
  60298. * @returns the current number of particles
  60299. */
  60300. render(preWarm?: boolean): number;
  60301. /**
  60302. * Rebuilds the particle system
  60303. */
  60304. rebuild(): void;
  60305. private _releaseBuffers;
  60306. private _releaseVAOs;
  60307. /**
  60308. * Disposes the particle system and free the associated resources
  60309. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60310. */
  60311. dispose(disposeTexture?: boolean): void;
  60312. /**
  60313. * Clones the particle system.
  60314. * @param name The name of the cloned object
  60315. * @param newEmitter The new emitter to use
  60316. * @returns the cloned particle system
  60317. */
  60318. clone(name: string, newEmitter: any): GPUParticleSystem;
  60319. /**
  60320. * Serializes the particle system to a JSON object.
  60321. * @returns the JSON object
  60322. */
  60323. serialize(): any;
  60324. /**
  60325. * Parses a JSON object to create a GPU particle system.
  60326. * @param parsedParticleSystem The JSON object to parse
  60327. * @param scene The scene to create the particle system in
  60328. * @param rootUrl The root url to use to load external dependencies like texture
  60329. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60330. * @returns the parsed GPU particle system
  60331. */
  60332. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60333. }
  60334. }
  60335. declare module "babylonjs/Particles/particleSystemSet" {
  60336. import { Nullable } from "babylonjs/types";
  60337. import { Color3 } from "babylonjs/Maths/math.color";
  60338. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60340. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60341. import { Scene, IDisposable } from "babylonjs/scene";
  60342. /**
  60343. * Represents a set of particle systems working together to create a specific effect
  60344. */
  60345. export class ParticleSystemSet implements IDisposable {
  60346. private _emitterCreationOptions;
  60347. private _emitterNode;
  60348. /**
  60349. * Gets the particle system list
  60350. */
  60351. systems: IParticleSystem[];
  60352. /**
  60353. * Gets the emitter node used with this set
  60354. */
  60355. readonly emitterNode: Nullable<TransformNode>;
  60356. /**
  60357. * Creates a new emitter mesh as a sphere
  60358. * @param options defines the options used to create the sphere
  60359. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60360. * @param scene defines the hosting scene
  60361. */
  60362. setEmitterAsSphere(options: {
  60363. diameter: number;
  60364. segments: number;
  60365. color: Color3;
  60366. }, renderingGroupId: number, scene: Scene): void;
  60367. /**
  60368. * Starts all particle systems of the set
  60369. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60370. */
  60371. start(emitter?: AbstractMesh): void;
  60372. /**
  60373. * Release all associated resources
  60374. */
  60375. dispose(): void;
  60376. /**
  60377. * Serialize the set into a JSON compatible object
  60378. * @returns a JSON compatible representation of the set
  60379. */
  60380. serialize(): any;
  60381. /**
  60382. * Parse a new ParticleSystemSet from a serialized source
  60383. * @param data defines a JSON compatible representation of the set
  60384. * @param scene defines the hosting scene
  60385. * @param gpu defines if we want GPU particles or CPU particles
  60386. * @returns a new ParticleSystemSet
  60387. */
  60388. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60389. }
  60390. }
  60391. declare module "babylonjs/Particles/particleHelper" {
  60392. import { Nullable } from "babylonjs/types";
  60393. import { Scene } from "babylonjs/scene";
  60394. import { Vector3 } from "babylonjs/Maths/math.vector";
  60395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60396. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60397. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60398. /**
  60399. * This class is made for on one-liner static method to help creating particle system set.
  60400. */
  60401. export class ParticleHelper {
  60402. /**
  60403. * Gets or sets base Assets URL
  60404. */
  60405. static BaseAssetsUrl: string;
  60406. /**
  60407. * Create a default particle system that you can tweak
  60408. * @param emitter defines the emitter to use
  60409. * @param capacity defines the system capacity (default is 500 particles)
  60410. * @param scene defines the hosting scene
  60411. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60412. * @returns the new Particle system
  60413. */
  60414. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60415. /**
  60416. * This is the main static method (one-liner) of this helper to create different particle systems
  60417. * @param type This string represents the type to the particle system to create
  60418. * @param scene The scene where the particle system should live
  60419. * @param gpu If the system will use gpu
  60420. * @returns the ParticleSystemSet created
  60421. */
  60422. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60423. /**
  60424. * Static function used to export a particle system to a ParticleSystemSet variable.
  60425. * Please note that the emitter shape is not exported
  60426. * @param systems defines the particle systems to export
  60427. * @returns the created particle system set
  60428. */
  60429. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60430. }
  60431. }
  60432. declare module "babylonjs/Particles/particleSystemComponent" {
  60433. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60434. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60435. import "babylonjs/Shaders/particles.vertex";
  60436. module "babylonjs/Engines/engine" {
  60437. interface Engine {
  60438. /**
  60439. * Create an effect to use with particle systems.
  60440. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60441. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60442. * @param uniformsNames defines a list of attribute names
  60443. * @param samplers defines an array of string used to represent textures
  60444. * @param defines defines the string containing the defines to use to compile the shaders
  60445. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60446. * @param onCompiled defines a function to call when the effect creation is successful
  60447. * @param onError defines a function to call when the effect creation has failed
  60448. * @returns the new Effect
  60449. */
  60450. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60451. }
  60452. }
  60453. module "babylonjs/Meshes/mesh" {
  60454. interface Mesh {
  60455. /**
  60456. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60457. * @returns an array of IParticleSystem
  60458. */
  60459. getEmittedParticleSystems(): IParticleSystem[];
  60460. /**
  60461. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60462. * @returns an array of IParticleSystem
  60463. */
  60464. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60465. }
  60466. }
  60467. /**
  60468. * @hidden
  60469. */
  60470. export var _IDoNeedToBeInTheBuild: number;
  60471. }
  60472. declare module "babylonjs/Particles/index" {
  60473. export * from "babylonjs/Particles/baseParticleSystem";
  60474. export * from "babylonjs/Particles/EmitterTypes/index";
  60475. export * from "babylonjs/Particles/gpuParticleSystem";
  60476. export * from "babylonjs/Particles/IParticleSystem";
  60477. export * from "babylonjs/Particles/particle";
  60478. export * from "babylonjs/Particles/particleHelper";
  60479. export * from "babylonjs/Particles/particleSystem";
  60480. export * from "babylonjs/Particles/particleSystemComponent";
  60481. export * from "babylonjs/Particles/particleSystemSet";
  60482. export * from "babylonjs/Particles/solidParticle";
  60483. export * from "babylonjs/Particles/solidParticleSystem";
  60484. export * from "babylonjs/Particles/subEmitter";
  60485. }
  60486. declare module "babylonjs/Physics/physicsEngineComponent" {
  60487. import { Nullable } from "babylonjs/types";
  60488. import { Observable, Observer } from "babylonjs/Misc/observable";
  60489. import { Vector3 } from "babylonjs/Maths/math.vector";
  60490. import { Mesh } from "babylonjs/Meshes/mesh";
  60491. import { ISceneComponent } from "babylonjs/sceneComponent";
  60492. import { Scene } from "babylonjs/scene";
  60493. import { Node } from "babylonjs/node";
  60494. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60495. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60496. module "babylonjs/scene" {
  60497. interface Scene {
  60498. /** @hidden (Backing field) */
  60499. _physicsEngine: Nullable<IPhysicsEngine>;
  60500. /**
  60501. * Gets the current physics engine
  60502. * @returns a IPhysicsEngine or null if none attached
  60503. */
  60504. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60505. /**
  60506. * Enables physics to the current scene
  60507. * @param gravity defines the scene's gravity for the physics engine
  60508. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60509. * @return a boolean indicating if the physics engine was initialized
  60510. */
  60511. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60512. /**
  60513. * Disables and disposes the physics engine associated with the scene
  60514. */
  60515. disablePhysicsEngine(): void;
  60516. /**
  60517. * Gets a boolean indicating if there is an active physics engine
  60518. * @returns a boolean indicating if there is an active physics engine
  60519. */
  60520. isPhysicsEnabled(): boolean;
  60521. /**
  60522. * Deletes a physics compound impostor
  60523. * @param compound defines the compound to delete
  60524. */
  60525. deleteCompoundImpostor(compound: any): void;
  60526. /**
  60527. * An event triggered when physic simulation is about to be run
  60528. */
  60529. onBeforePhysicsObservable: Observable<Scene>;
  60530. /**
  60531. * An event triggered when physic simulation has been done
  60532. */
  60533. onAfterPhysicsObservable: Observable<Scene>;
  60534. }
  60535. }
  60536. module "babylonjs/Meshes/abstractMesh" {
  60537. interface AbstractMesh {
  60538. /** @hidden */
  60539. _physicsImpostor: Nullable<PhysicsImpostor>;
  60540. /**
  60541. * Gets or sets impostor used for physic simulation
  60542. * @see http://doc.babylonjs.com/features/physics_engine
  60543. */
  60544. physicsImpostor: Nullable<PhysicsImpostor>;
  60545. /**
  60546. * Gets the current physics impostor
  60547. * @see http://doc.babylonjs.com/features/physics_engine
  60548. * @returns a physics impostor or null
  60549. */
  60550. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60551. /** Apply a physic impulse to the mesh
  60552. * @param force defines the force to apply
  60553. * @param contactPoint defines where to apply the force
  60554. * @returns the current mesh
  60555. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60556. */
  60557. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60558. /**
  60559. * Creates a physic joint between two meshes
  60560. * @param otherMesh defines the other mesh to use
  60561. * @param pivot1 defines the pivot to use on this mesh
  60562. * @param pivot2 defines the pivot to use on the other mesh
  60563. * @param options defines additional options (can be plugin dependent)
  60564. * @returns the current mesh
  60565. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60566. */
  60567. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60568. /** @hidden */
  60569. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60570. }
  60571. }
  60572. /**
  60573. * Defines the physics engine scene component responsible to manage a physics engine
  60574. */
  60575. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60576. /**
  60577. * The component name helpful to identify the component in the list of scene components.
  60578. */
  60579. readonly name: string;
  60580. /**
  60581. * The scene the component belongs to.
  60582. */
  60583. scene: Scene;
  60584. /**
  60585. * Creates a new instance of the component for the given scene
  60586. * @param scene Defines the scene to register the component in
  60587. */
  60588. constructor(scene: Scene);
  60589. /**
  60590. * Registers the component in a given scene
  60591. */
  60592. register(): void;
  60593. /**
  60594. * Rebuilds the elements related to this component in case of
  60595. * context lost for instance.
  60596. */
  60597. rebuild(): void;
  60598. /**
  60599. * Disposes the component and the associated ressources
  60600. */
  60601. dispose(): void;
  60602. }
  60603. }
  60604. declare module "babylonjs/Physics/physicsHelper" {
  60605. import { Nullable } from "babylonjs/types";
  60606. import { Vector3 } from "babylonjs/Maths/math.vector";
  60607. import { Mesh } from "babylonjs/Meshes/mesh";
  60608. import { Scene } from "babylonjs/scene";
  60609. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60610. /**
  60611. * A helper for physics simulations
  60612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60613. */
  60614. export class PhysicsHelper {
  60615. private _scene;
  60616. private _physicsEngine;
  60617. /**
  60618. * Initializes the Physics helper
  60619. * @param scene Babylon.js scene
  60620. */
  60621. constructor(scene: Scene);
  60622. /**
  60623. * Applies a radial explosion impulse
  60624. * @param origin the origin of the explosion
  60625. * @param radiusOrEventOptions the radius or the options of radial explosion
  60626. * @param strength the explosion strength
  60627. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60628. * @returns A physics radial explosion event, or null
  60629. */
  60630. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60631. /**
  60632. * Applies a radial explosion force
  60633. * @param origin the origin of the explosion
  60634. * @param radiusOrEventOptions the radius or the options of radial explosion
  60635. * @param strength the explosion strength
  60636. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60637. * @returns A physics radial explosion event, or null
  60638. */
  60639. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60640. /**
  60641. * Creates a gravitational field
  60642. * @param origin the origin of the explosion
  60643. * @param radiusOrEventOptions the radius or the options of radial explosion
  60644. * @param strength the explosion strength
  60645. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60646. * @returns A physics gravitational field event, or null
  60647. */
  60648. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60649. /**
  60650. * Creates a physics updraft event
  60651. * @param origin the origin of the updraft
  60652. * @param radiusOrEventOptions the radius or the options of the updraft
  60653. * @param strength the strength of the updraft
  60654. * @param height the height of the updraft
  60655. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60656. * @returns A physics updraft event, or null
  60657. */
  60658. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60659. /**
  60660. * Creates a physics vortex event
  60661. * @param origin the of the vortex
  60662. * @param radiusOrEventOptions the radius or the options of the vortex
  60663. * @param strength the strength of the vortex
  60664. * @param height the height of the vortex
  60665. * @returns a Physics vortex event, or null
  60666. * A physics vortex event or null
  60667. */
  60668. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60669. }
  60670. /**
  60671. * Represents a physics radial explosion event
  60672. */
  60673. class PhysicsRadialExplosionEvent {
  60674. private _scene;
  60675. private _options;
  60676. private _sphere;
  60677. private _dataFetched;
  60678. /**
  60679. * Initializes a radial explosioin event
  60680. * @param _scene BabylonJS scene
  60681. * @param _options The options for the vortex event
  60682. */
  60683. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60684. /**
  60685. * Returns the data related to the radial explosion event (sphere).
  60686. * @returns The radial explosion event data
  60687. */
  60688. getData(): PhysicsRadialExplosionEventData;
  60689. /**
  60690. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60691. * @param impostor A physics imposter
  60692. * @param origin the origin of the explosion
  60693. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60694. */
  60695. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60696. /**
  60697. * Triggers affecterd impostors callbacks
  60698. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60699. */
  60700. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60701. /**
  60702. * Disposes the sphere.
  60703. * @param force Specifies if the sphere should be disposed by force
  60704. */
  60705. dispose(force?: boolean): void;
  60706. /*** Helpers ***/
  60707. private _prepareSphere;
  60708. private _intersectsWithSphere;
  60709. }
  60710. /**
  60711. * Represents a gravitational field event
  60712. */
  60713. class PhysicsGravitationalFieldEvent {
  60714. private _physicsHelper;
  60715. private _scene;
  60716. private _origin;
  60717. private _options;
  60718. private _tickCallback;
  60719. private _sphere;
  60720. private _dataFetched;
  60721. /**
  60722. * Initializes the physics gravitational field event
  60723. * @param _physicsHelper A physics helper
  60724. * @param _scene BabylonJS scene
  60725. * @param _origin The origin position of the gravitational field event
  60726. * @param _options The options for the vortex event
  60727. */
  60728. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60729. /**
  60730. * Returns the data related to the gravitational field event (sphere).
  60731. * @returns A gravitational field event
  60732. */
  60733. getData(): PhysicsGravitationalFieldEventData;
  60734. /**
  60735. * Enables the gravitational field.
  60736. */
  60737. enable(): void;
  60738. /**
  60739. * Disables the gravitational field.
  60740. */
  60741. disable(): void;
  60742. /**
  60743. * Disposes the sphere.
  60744. * @param force The force to dispose from the gravitational field event
  60745. */
  60746. dispose(force?: boolean): void;
  60747. private _tick;
  60748. }
  60749. /**
  60750. * Represents a physics updraft event
  60751. */
  60752. class PhysicsUpdraftEvent {
  60753. private _scene;
  60754. private _origin;
  60755. private _options;
  60756. private _physicsEngine;
  60757. private _originTop;
  60758. private _originDirection;
  60759. private _tickCallback;
  60760. private _cylinder;
  60761. private _cylinderPosition;
  60762. private _dataFetched;
  60763. /**
  60764. * Initializes the physics updraft event
  60765. * @param _scene BabylonJS scene
  60766. * @param _origin The origin position of the updraft
  60767. * @param _options The options for the updraft event
  60768. */
  60769. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60770. /**
  60771. * Returns the data related to the updraft event (cylinder).
  60772. * @returns A physics updraft event
  60773. */
  60774. getData(): PhysicsUpdraftEventData;
  60775. /**
  60776. * Enables the updraft.
  60777. */
  60778. enable(): void;
  60779. /**
  60780. * Disables the updraft.
  60781. */
  60782. disable(): void;
  60783. /**
  60784. * Disposes the cylinder.
  60785. * @param force Specifies if the updraft should be disposed by force
  60786. */
  60787. dispose(force?: boolean): void;
  60788. private getImpostorHitData;
  60789. private _tick;
  60790. /*** Helpers ***/
  60791. private _prepareCylinder;
  60792. private _intersectsWithCylinder;
  60793. }
  60794. /**
  60795. * Represents a physics vortex event
  60796. */
  60797. class PhysicsVortexEvent {
  60798. private _scene;
  60799. private _origin;
  60800. private _options;
  60801. private _physicsEngine;
  60802. private _originTop;
  60803. private _tickCallback;
  60804. private _cylinder;
  60805. private _cylinderPosition;
  60806. private _dataFetched;
  60807. /**
  60808. * Initializes the physics vortex event
  60809. * @param _scene The BabylonJS scene
  60810. * @param _origin The origin position of the vortex
  60811. * @param _options The options for the vortex event
  60812. */
  60813. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60814. /**
  60815. * Returns the data related to the vortex event (cylinder).
  60816. * @returns The physics vortex event data
  60817. */
  60818. getData(): PhysicsVortexEventData;
  60819. /**
  60820. * Enables the vortex.
  60821. */
  60822. enable(): void;
  60823. /**
  60824. * Disables the cortex.
  60825. */
  60826. disable(): void;
  60827. /**
  60828. * Disposes the sphere.
  60829. * @param force
  60830. */
  60831. dispose(force?: boolean): void;
  60832. private getImpostorHitData;
  60833. private _tick;
  60834. /*** Helpers ***/
  60835. private _prepareCylinder;
  60836. private _intersectsWithCylinder;
  60837. }
  60838. /**
  60839. * Options fot the radial explosion event
  60840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60841. */
  60842. export class PhysicsRadialExplosionEventOptions {
  60843. /**
  60844. * The radius of the sphere for the radial explosion.
  60845. */
  60846. radius: number;
  60847. /**
  60848. * The strenth of the explosion.
  60849. */
  60850. strength: number;
  60851. /**
  60852. * The strenght of the force in correspondence to the distance of the affected object
  60853. */
  60854. falloff: PhysicsRadialImpulseFalloff;
  60855. /**
  60856. * Sphere options for the radial explosion.
  60857. */
  60858. sphere: {
  60859. segments: number;
  60860. diameter: number;
  60861. };
  60862. /**
  60863. * Sphere options for the radial explosion.
  60864. */
  60865. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60866. }
  60867. /**
  60868. * Options fot the updraft event
  60869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60870. */
  60871. export class PhysicsUpdraftEventOptions {
  60872. /**
  60873. * The radius of the cylinder for the vortex
  60874. */
  60875. radius: number;
  60876. /**
  60877. * The strenth of the updraft.
  60878. */
  60879. strength: number;
  60880. /**
  60881. * The height of the cylinder for the updraft.
  60882. */
  60883. height: number;
  60884. /**
  60885. * The mode for the the updraft.
  60886. */
  60887. updraftMode: PhysicsUpdraftMode;
  60888. }
  60889. /**
  60890. * Options fot the vortex event
  60891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60892. */
  60893. export class PhysicsVortexEventOptions {
  60894. /**
  60895. * The radius of the cylinder for the vortex
  60896. */
  60897. radius: number;
  60898. /**
  60899. * The strenth of the vortex.
  60900. */
  60901. strength: number;
  60902. /**
  60903. * The height of the cylinder for the vortex.
  60904. */
  60905. height: number;
  60906. /**
  60907. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60908. */
  60909. centripetalForceThreshold: number;
  60910. /**
  60911. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60912. */
  60913. centripetalForceMultiplier: number;
  60914. /**
  60915. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60916. */
  60917. centrifugalForceMultiplier: number;
  60918. /**
  60919. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60920. */
  60921. updraftForceMultiplier: number;
  60922. }
  60923. /**
  60924. * The strenght of the force in correspondence to the distance of the affected object
  60925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60926. */
  60927. export enum PhysicsRadialImpulseFalloff {
  60928. /** Defines that impulse is constant in strength across it's whole radius */
  60929. Constant = 0,
  60930. /** Defines that impulse gets weaker if it's further from the origin */
  60931. Linear = 1
  60932. }
  60933. /**
  60934. * The strength of the force in correspondence to the distance of the affected object
  60935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60936. */
  60937. export enum PhysicsUpdraftMode {
  60938. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60939. Center = 0,
  60940. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60941. Perpendicular = 1
  60942. }
  60943. /**
  60944. * Interface for a physics hit data
  60945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60946. */
  60947. export interface PhysicsHitData {
  60948. /**
  60949. * The force applied at the contact point
  60950. */
  60951. force: Vector3;
  60952. /**
  60953. * The contact point
  60954. */
  60955. contactPoint: Vector3;
  60956. /**
  60957. * The distance from the origin to the contact point
  60958. */
  60959. distanceFromOrigin: number;
  60960. }
  60961. /**
  60962. * Interface for radial explosion event data
  60963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60964. */
  60965. export interface PhysicsRadialExplosionEventData {
  60966. /**
  60967. * A sphere used for the radial explosion event
  60968. */
  60969. sphere: Mesh;
  60970. }
  60971. /**
  60972. * Interface for gravitational field event data
  60973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60974. */
  60975. export interface PhysicsGravitationalFieldEventData {
  60976. /**
  60977. * A sphere mesh used for the gravitational field event
  60978. */
  60979. sphere: Mesh;
  60980. }
  60981. /**
  60982. * Interface for updraft event data
  60983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60984. */
  60985. export interface PhysicsUpdraftEventData {
  60986. /**
  60987. * A cylinder used for the updraft event
  60988. */
  60989. cylinder: Mesh;
  60990. }
  60991. /**
  60992. * Interface for vortex event data
  60993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60994. */
  60995. export interface PhysicsVortexEventData {
  60996. /**
  60997. * A cylinder used for the vortex event
  60998. */
  60999. cylinder: Mesh;
  61000. }
  61001. /**
  61002. * Interface for an affected physics impostor
  61003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61004. */
  61005. export interface PhysicsAffectedImpostorWithData {
  61006. /**
  61007. * The impostor affected by the effect
  61008. */
  61009. impostor: PhysicsImpostor;
  61010. /**
  61011. * The data about the hit/horce from the explosion
  61012. */
  61013. hitData: PhysicsHitData;
  61014. }
  61015. }
  61016. declare module "babylonjs/Physics/Plugins/index" {
  61017. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61018. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61019. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61020. }
  61021. declare module "babylonjs/Physics/index" {
  61022. export * from "babylonjs/Physics/IPhysicsEngine";
  61023. export * from "babylonjs/Physics/physicsEngine";
  61024. export * from "babylonjs/Physics/physicsEngineComponent";
  61025. export * from "babylonjs/Physics/physicsHelper";
  61026. export * from "babylonjs/Physics/physicsImpostor";
  61027. export * from "babylonjs/Physics/physicsJoint";
  61028. export * from "babylonjs/Physics/Plugins/index";
  61029. }
  61030. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61031. /** @hidden */
  61032. export var blackAndWhitePixelShader: {
  61033. name: string;
  61034. shader: string;
  61035. };
  61036. }
  61037. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61038. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61039. import { Camera } from "babylonjs/Cameras/camera";
  61040. import { Engine } from "babylonjs/Engines/engine";
  61041. import "babylonjs/Shaders/blackAndWhite.fragment";
  61042. /**
  61043. * Post process used to render in black and white
  61044. */
  61045. export class BlackAndWhitePostProcess extends PostProcess {
  61046. /**
  61047. * Linear about to convert he result to black and white (default: 1)
  61048. */
  61049. degree: number;
  61050. /**
  61051. * Creates a black and white post process
  61052. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61053. * @param name The name of the effect.
  61054. * @param options The required width/height ratio to downsize to before computing the render pass.
  61055. * @param camera The camera to apply the render pass to.
  61056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61057. * @param engine The engine which the post process will be applied. (default: current engine)
  61058. * @param reusable If the post process can be reused on the same frame. (default: false)
  61059. */
  61060. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61061. }
  61062. }
  61063. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61064. import { Nullable } from "babylonjs/types";
  61065. import { Camera } from "babylonjs/Cameras/camera";
  61066. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61067. import { Engine } from "babylonjs/Engines/engine";
  61068. /**
  61069. * This represents a set of one or more post processes in Babylon.
  61070. * A post process can be used to apply a shader to a texture after it is rendered.
  61071. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61072. */
  61073. export class PostProcessRenderEffect {
  61074. private _postProcesses;
  61075. private _getPostProcesses;
  61076. private _singleInstance;
  61077. private _cameras;
  61078. private _indicesForCamera;
  61079. /**
  61080. * Name of the effect
  61081. * @hidden
  61082. */
  61083. _name: string;
  61084. /**
  61085. * Instantiates a post process render effect.
  61086. * A post process can be used to apply a shader to a texture after it is rendered.
  61087. * @param engine The engine the effect is tied to
  61088. * @param name The name of the effect
  61089. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61090. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61091. */
  61092. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61093. /**
  61094. * Checks if all the post processes in the effect are supported.
  61095. */
  61096. readonly isSupported: boolean;
  61097. /**
  61098. * Updates the current state of the effect
  61099. * @hidden
  61100. */
  61101. _update(): void;
  61102. /**
  61103. * Attaches the effect on cameras
  61104. * @param cameras The camera to attach to.
  61105. * @hidden
  61106. */
  61107. _attachCameras(cameras: Camera): void;
  61108. /**
  61109. * Attaches the effect on cameras
  61110. * @param cameras The camera to attach to.
  61111. * @hidden
  61112. */
  61113. _attachCameras(cameras: Camera[]): void;
  61114. /**
  61115. * Detaches the effect on cameras
  61116. * @param cameras The camera to detatch from.
  61117. * @hidden
  61118. */
  61119. _detachCameras(cameras: Camera): void;
  61120. /**
  61121. * Detatches the effect on cameras
  61122. * @param cameras The camera to detatch from.
  61123. * @hidden
  61124. */
  61125. _detachCameras(cameras: Camera[]): void;
  61126. /**
  61127. * Enables the effect on given cameras
  61128. * @param cameras The camera to enable.
  61129. * @hidden
  61130. */
  61131. _enable(cameras: Camera): void;
  61132. /**
  61133. * Enables the effect on given cameras
  61134. * @param cameras The camera to enable.
  61135. * @hidden
  61136. */
  61137. _enable(cameras: Nullable<Camera[]>): void;
  61138. /**
  61139. * Disables the effect on the given cameras
  61140. * @param cameras The camera to disable.
  61141. * @hidden
  61142. */
  61143. _disable(cameras: Camera): void;
  61144. /**
  61145. * Disables the effect on the given cameras
  61146. * @param cameras The camera to disable.
  61147. * @hidden
  61148. */
  61149. _disable(cameras: Nullable<Camera[]>): void;
  61150. /**
  61151. * Gets a list of the post processes contained in the effect.
  61152. * @param camera The camera to get the post processes on.
  61153. * @returns The list of the post processes in the effect.
  61154. */
  61155. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61156. }
  61157. }
  61158. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61159. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61160. /** @hidden */
  61161. export var extractHighlightsPixelShader: {
  61162. name: string;
  61163. shader: string;
  61164. };
  61165. }
  61166. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61167. import { Nullable } from "babylonjs/types";
  61168. import { Camera } from "babylonjs/Cameras/camera";
  61169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61170. import { Engine } from "babylonjs/Engines/engine";
  61171. import "babylonjs/Shaders/extractHighlights.fragment";
  61172. /**
  61173. * 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.
  61174. */
  61175. export class ExtractHighlightsPostProcess extends PostProcess {
  61176. /**
  61177. * The luminance threshold, pixels below this value will be set to black.
  61178. */
  61179. threshold: number;
  61180. /** @hidden */
  61181. _exposure: number;
  61182. /**
  61183. * Post process which has the input texture to be used when performing highlight extraction
  61184. * @hidden
  61185. */
  61186. _inputPostProcess: Nullable<PostProcess>;
  61187. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61188. }
  61189. }
  61190. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61191. /** @hidden */
  61192. export var bloomMergePixelShader: {
  61193. name: string;
  61194. shader: string;
  61195. };
  61196. }
  61197. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61198. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61199. import { Nullable } from "babylonjs/types";
  61200. import { Engine } from "babylonjs/Engines/engine";
  61201. import { Camera } from "babylonjs/Cameras/camera";
  61202. import "babylonjs/Shaders/bloomMerge.fragment";
  61203. /**
  61204. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61205. */
  61206. export class BloomMergePostProcess extends PostProcess {
  61207. /** Weight of the bloom to be added to the original input. */
  61208. weight: number;
  61209. /**
  61210. * Creates a new instance of @see BloomMergePostProcess
  61211. * @param name The name of the effect.
  61212. * @param originalFromInput Post process which's input will be used for the merge.
  61213. * @param blurred Blurred highlights post process which's output will be used.
  61214. * @param weight Weight of the bloom to be added to the original input.
  61215. * @param options The required width/height ratio to downsize to before computing the render pass.
  61216. * @param camera The camera to apply the render pass to.
  61217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61218. * @param engine The engine which the post process will be applied. (default: current engine)
  61219. * @param reusable If the post process can be reused on the same frame. (default: false)
  61220. * @param textureType Type of textures used when performing the post process. (default: 0)
  61221. * @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)
  61222. */
  61223. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61224. /** Weight of the bloom to be added to the original input. */
  61225. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61226. }
  61227. }
  61228. declare module "babylonjs/PostProcesses/bloomEffect" {
  61229. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61230. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61231. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61232. import { Camera } from "babylonjs/Cameras/camera";
  61233. import { Scene } from "babylonjs/scene";
  61234. /**
  61235. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61236. */
  61237. export class BloomEffect extends PostProcessRenderEffect {
  61238. private bloomScale;
  61239. /**
  61240. * @hidden Internal
  61241. */
  61242. _effects: Array<PostProcess>;
  61243. /**
  61244. * @hidden Internal
  61245. */
  61246. _downscale: ExtractHighlightsPostProcess;
  61247. private _blurX;
  61248. private _blurY;
  61249. private _merge;
  61250. /**
  61251. * The luminance threshold to find bright areas of the image to bloom.
  61252. */
  61253. threshold: number;
  61254. /**
  61255. * The strength of the bloom.
  61256. */
  61257. weight: number;
  61258. /**
  61259. * Specifies the size of the bloom blur kernel, relative to the final output size
  61260. */
  61261. kernel: number;
  61262. /**
  61263. * Creates a new instance of @see BloomEffect
  61264. * @param scene The scene the effect belongs to.
  61265. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61266. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61267. * @param bloomWeight The the strength of bloom.
  61268. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61269. * @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)
  61270. */
  61271. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61272. /**
  61273. * Disposes each of the internal effects for a given camera.
  61274. * @param camera The camera to dispose the effect on.
  61275. */
  61276. disposeEffects(camera: Camera): void;
  61277. /**
  61278. * @hidden Internal
  61279. */
  61280. _updateEffects(): void;
  61281. /**
  61282. * Internal
  61283. * @returns if all the contained post processes are ready.
  61284. * @hidden
  61285. */
  61286. _isReady(): boolean;
  61287. }
  61288. }
  61289. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61290. /** @hidden */
  61291. export var chromaticAberrationPixelShader: {
  61292. name: string;
  61293. shader: string;
  61294. };
  61295. }
  61296. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61297. import { Vector2 } from "babylonjs/Maths/math.vector";
  61298. import { Nullable } from "babylonjs/types";
  61299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61300. import { Camera } from "babylonjs/Cameras/camera";
  61301. import { Engine } from "babylonjs/Engines/engine";
  61302. import "babylonjs/Shaders/chromaticAberration.fragment";
  61303. /**
  61304. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61305. */
  61306. export class ChromaticAberrationPostProcess extends PostProcess {
  61307. /**
  61308. * The amount of seperation of rgb channels (default: 30)
  61309. */
  61310. aberrationAmount: number;
  61311. /**
  61312. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61313. */
  61314. radialIntensity: number;
  61315. /**
  61316. * 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))
  61317. */
  61318. direction: Vector2;
  61319. /**
  61320. * 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))
  61321. */
  61322. centerPosition: Vector2;
  61323. /**
  61324. * Creates a new instance ChromaticAberrationPostProcess
  61325. * @param name The name of the effect.
  61326. * @param screenWidth The width of the screen to apply the effect on.
  61327. * @param screenHeight The height of the screen to apply the effect on.
  61328. * @param options The required width/height ratio to downsize to before computing the render pass.
  61329. * @param camera The camera to apply the render pass to.
  61330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61331. * @param engine The engine which the post process will be applied. (default: current engine)
  61332. * @param reusable If the post process can be reused on the same frame. (default: false)
  61333. * @param textureType Type of textures used when performing the post process. (default: 0)
  61334. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  61335. */
  61336. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61337. }
  61338. }
  61339. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61340. /** @hidden */
  61341. export var circleOfConfusionPixelShader: {
  61342. name: string;
  61343. shader: string;
  61344. };
  61345. }
  61346. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61347. import { Nullable } from "babylonjs/types";
  61348. import { Engine } from "babylonjs/Engines/engine";
  61349. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61351. import { Camera } from "babylonjs/Cameras/camera";
  61352. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61353. /**
  61354. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61355. */
  61356. export class CircleOfConfusionPostProcess extends PostProcess {
  61357. /**
  61358. * 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.
  61359. */
  61360. lensSize: number;
  61361. /**
  61362. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61363. */
  61364. fStop: number;
  61365. /**
  61366. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61367. */
  61368. focusDistance: number;
  61369. /**
  61370. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61371. */
  61372. focalLength: number;
  61373. private _depthTexture;
  61374. /**
  61375. * Creates a new instance CircleOfConfusionPostProcess
  61376. * @param name The name of the effect.
  61377. * @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.
  61378. * @param options The required width/height ratio to downsize to before computing the render pass.
  61379. * @param camera The camera to apply the render pass to.
  61380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61381. * @param engine The engine which the post process will be applied. (default: current engine)
  61382. * @param reusable If the post process can be reused on the same frame. (default: false)
  61383. * @param textureType Type of textures used when performing the post process. (default: 0)
  61384. * @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)
  61385. */
  61386. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61387. /**
  61388. * 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.
  61389. */
  61390. depthTexture: RenderTargetTexture;
  61391. }
  61392. }
  61393. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61394. /** @hidden */
  61395. export var colorCorrectionPixelShader: {
  61396. name: string;
  61397. shader: string;
  61398. };
  61399. }
  61400. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61401. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61402. import { Engine } from "babylonjs/Engines/engine";
  61403. import { Camera } from "babylonjs/Cameras/camera";
  61404. import "babylonjs/Shaders/colorCorrection.fragment";
  61405. /**
  61406. *
  61407. * This post-process allows the modification of rendered colors by using
  61408. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61409. *
  61410. * The object needs to be provided an url to a texture containing the color
  61411. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61412. * Use an image editing software to tweak the LUT to match your needs.
  61413. *
  61414. * For an example of a color LUT, see here:
  61415. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61416. * For explanations on color grading, see here:
  61417. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61418. *
  61419. */
  61420. export class ColorCorrectionPostProcess extends PostProcess {
  61421. private _colorTableTexture;
  61422. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61423. }
  61424. }
  61425. declare module "babylonjs/Shaders/convolution.fragment" {
  61426. /** @hidden */
  61427. export var convolutionPixelShader: {
  61428. name: string;
  61429. shader: string;
  61430. };
  61431. }
  61432. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61433. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61434. import { Nullable } from "babylonjs/types";
  61435. import { Camera } from "babylonjs/Cameras/camera";
  61436. import { Engine } from "babylonjs/Engines/engine";
  61437. import "babylonjs/Shaders/convolution.fragment";
  61438. /**
  61439. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61440. * input texture to perform effects such as edge detection or sharpening
  61441. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61442. */
  61443. export class ConvolutionPostProcess extends PostProcess {
  61444. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61445. kernel: number[];
  61446. /**
  61447. * Creates a new instance ConvolutionPostProcess
  61448. * @param name The name of the effect.
  61449. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61450. * @param options The required width/height ratio to downsize to before computing the render pass.
  61451. * @param camera The camera to apply the render pass to.
  61452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61453. * @param engine The engine which the post process will be applied. (default: current engine)
  61454. * @param reusable If the post process can be reused on the same frame. (default: false)
  61455. * @param textureType Type of textures used when performing the post process. (default: 0)
  61456. */
  61457. constructor(name: string,
  61458. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61459. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61460. /**
  61461. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61462. */
  61463. static EdgeDetect0Kernel: number[];
  61464. /**
  61465. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61466. */
  61467. static EdgeDetect1Kernel: number[];
  61468. /**
  61469. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61470. */
  61471. static EdgeDetect2Kernel: number[];
  61472. /**
  61473. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61474. */
  61475. static SharpenKernel: number[];
  61476. /**
  61477. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61478. */
  61479. static EmbossKernel: number[];
  61480. /**
  61481. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61482. */
  61483. static GaussianKernel: number[];
  61484. }
  61485. }
  61486. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61487. import { Nullable } from "babylonjs/types";
  61488. import { Vector2 } from "babylonjs/Maths/math.vector";
  61489. import { Camera } from "babylonjs/Cameras/camera";
  61490. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61491. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61492. import { Engine } from "babylonjs/Engines/engine";
  61493. import { Scene } from "babylonjs/scene";
  61494. /**
  61495. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61496. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61497. * based on samples that have a large difference in distance than the center pixel.
  61498. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61499. */
  61500. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61501. direction: Vector2;
  61502. /**
  61503. * Creates a new instance CircleOfConfusionPostProcess
  61504. * @param name The name of the effect.
  61505. * @param scene The scene the effect belongs to.
  61506. * @param direction The direction the blur should be applied.
  61507. * @param kernel The size of the kernel used to blur.
  61508. * @param options The required width/height ratio to downsize to before computing the render pass.
  61509. * @param camera The camera to apply the render pass to.
  61510. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61511. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61513. * @param engine The engine which the post process will be applied. (default: current engine)
  61514. * @param reusable If the post process can be reused on the same frame. (default: false)
  61515. * @param textureType Type of textures used when performing the post process. (default: 0)
  61516. * @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)
  61517. */
  61518. 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);
  61519. }
  61520. }
  61521. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61522. /** @hidden */
  61523. export var depthOfFieldMergePixelShader: {
  61524. name: string;
  61525. shader: string;
  61526. };
  61527. }
  61528. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61529. import { Nullable } from "babylonjs/types";
  61530. import { Camera } from "babylonjs/Cameras/camera";
  61531. import { Effect } from "babylonjs/Materials/effect";
  61532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61533. import { Engine } from "babylonjs/Engines/engine";
  61534. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61535. /**
  61536. * Options to be set when merging outputs from the default pipeline.
  61537. */
  61538. export class DepthOfFieldMergePostProcessOptions {
  61539. /**
  61540. * The original image to merge on top of
  61541. */
  61542. originalFromInput: PostProcess;
  61543. /**
  61544. * Parameters to perform the merge of the depth of field effect
  61545. */
  61546. depthOfField?: {
  61547. circleOfConfusion: PostProcess;
  61548. blurSteps: Array<PostProcess>;
  61549. };
  61550. /**
  61551. * Parameters to perform the merge of bloom effect
  61552. */
  61553. bloom?: {
  61554. blurred: PostProcess;
  61555. weight: number;
  61556. };
  61557. }
  61558. /**
  61559. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61560. */
  61561. export class DepthOfFieldMergePostProcess extends PostProcess {
  61562. private blurSteps;
  61563. /**
  61564. * Creates a new instance of DepthOfFieldMergePostProcess
  61565. * @param name The name of the effect.
  61566. * @param originalFromInput Post process which's input will be used for the merge.
  61567. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61568. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61569. * @param options The required width/height ratio to downsize to before computing the render pass.
  61570. * @param camera The camera to apply the render pass to.
  61571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61572. * @param engine The engine which the post process will be applied. (default: current engine)
  61573. * @param reusable If the post process can be reused on the same frame. (default: false)
  61574. * @param textureType Type of textures used when performing the post process. (default: 0)
  61575. * @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)
  61576. */
  61577. 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);
  61578. /**
  61579. * Updates the effect with the current post process compile time values and recompiles the shader.
  61580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61583. * @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
  61584. * @param onCompiled Called when the shader has been compiled.
  61585. * @param onError Called if there is an error when compiling a shader.
  61586. */
  61587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61588. }
  61589. }
  61590. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61591. import { Nullable } from "babylonjs/types";
  61592. import { Camera } from "babylonjs/Cameras/camera";
  61593. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61594. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61595. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61596. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61597. import { Scene } from "babylonjs/scene";
  61598. /**
  61599. * Specifies the level of max blur that should be applied when using the depth of field effect
  61600. */
  61601. export enum DepthOfFieldEffectBlurLevel {
  61602. /**
  61603. * Subtle blur
  61604. */
  61605. Low = 0,
  61606. /**
  61607. * Medium blur
  61608. */
  61609. Medium = 1,
  61610. /**
  61611. * Large blur
  61612. */
  61613. High = 2
  61614. }
  61615. /**
  61616. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61617. */
  61618. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61619. private _circleOfConfusion;
  61620. /**
  61621. * @hidden Internal, blurs from high to low
  61622. */
  61623. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61624. private _depthOfFieldBlurY;
  61625. private _dofMerge;
  61626. /**
  61627. * @hidden Internal post processes in depth of field effect
  61628. */
  61629. _effects: Array<PostProcess>;
  61630. /**
  61631. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61632. */
  61633. focalLength: number;
  61634. /**
  61635. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61636. */
  61637. fStop: number;
  61638. /**
  61639. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61640. */
  61641. focusDistance: number;
  61642. /**
  61643. * 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.
  61644. */
  61645. lensSize: number;
  61646. /**
  61647. * Creates a new instance DepthOfFieldEffect
  61648. * @param scene The scene the effect belongs to.
  61649. * @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.
  61650. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61651. * @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)
  61652. */
  61653. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61654. /**
  61655. * Get the current class name of the current effet
  61656. * @returns "DepthOfFieldEffect"
  61657. */
  61658. getClassName(): string;
  61659. /**
  61660. * 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.
  61661. */
  61662. depthTexture: RenderTargetTexture;
  61663. /**
  61664. * Disposes each of the internal effects for a given camera.
  61665. * @param camera The camera to dispose the effect on.
  61666. */
  61667. disposeEffects(camera: Camera): void;
  61668. /**
  61669. * @hidden Internal
  61670. */
  61671. _updateEffects(): void;
  61672. /**
  61673. * Internal
  61674. * @returns if all the contained post processes are ready.
  61675. * @hidden
  61676. */
  61677. _isReady(): boolean;
  61678. }
  61679. }
  61680. declare module "babylonjs/Shaders/displayPass.fragment" {
  61681. /** @hidden */
  61682. export var displayPassPixelShader: {
  61683. name: string;
  61684. shader: string;
  61685. };
  61686. }
  61687. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61688. import { Nullable } from "babylonjs/types";
  61689. import { Camera } from "babylonjs/Cameras/camera";
  61690. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61691. import { Engine } from "babylonjs/Engines/engine";
  61692. import "babylonjs/Shaders/displayPass.fragment";
  61693. /**
  61694. * DisplayPassPostProcess which produces an output the same as it's input
  61695. */
  61696. export class DisplayPassPostProcess extends PostProcess {
  61697. /**
  61698. * Creates the DisplayPassPostProcess
  61699. * @param name The name of the effect.
  61700. * @param options The required width/height ratio to downsize to before computing the render pass.
  61701. * @param camera The camera to apply the render pass to.
  61702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61703. * @param engine The engine which the post process will be applied. (default: current engine)
  61704. * @param reusable If the post process can be reused on the same frame. (default: false)
  61705. */
  61706. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61707. }
  61708. }
  61709. declare module "babylonjs/Shaders/filter.fragment" {
  61710. /** @hidden */
  61711. export var filterPixelShader: {
  61712. name: string;
  61713. shader: string;
  61714. };
  61715. }
  61716. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61717. import { Nullable } from "babylonjs/types";
  61718. import { Matrix } from "babylonjs/Maths/math.vector";
  61719. import { Camera } from "babylonjs/Cameras/camera";
  61720. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61721. import { Engine } from "babylonjs/Engines/engine";
  61722. import "babylonjs/Shaders/filter.fragment";
  61723. /**
  61724. * Applies a kernel filter to the image
  61725. */
  61726. export class FilterPostProcess extends PostProcess {
  61727. /** The matrix to be applied to the image */
  61728. kernelMatrix: Matrix;
  61729. /**
  61730. *
  61731. * @param name The name of the effect.
  61732. * @param kernelMatrix The matrix to be applied to the image
  61733. * @param options The required width/height ratio to downsize to before computing the render pass.
  61734. * @param camera The camera to apply the render pass to.
  61735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61736. * @param engine The engine which the post process will be applied. (default: current engine)
  61737. * @param reusable If the post process can be reused on the same frame. (default: false)
  61738. */
  61739. constructor(name: string,
  61740. /** The matrix to be applied to the image */
  61741. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61742. }
  61743. }
  61744. declare module "babylonjs/Shaders/fxaa.fragment" {
  61745. /** @hidden */
  61746. export var fxaaPixelShader: {
  61747. name: string;
  61748. shader: string;
  61749. };
  61750. }
  61751. declare module "babylonjs/Shaders/fxaa.vertex" {
  61752. /** @hidden */
  61753. export var fxaaVertexShader: {
  61754. name: string;
  61755. shader: string;
  61756. };
  61757. }
  61758. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61759. import { Nullable } from "babylonjs/types";
  61760. import { Camera } from "babylonjs/Cameras/camera";
  61761. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61762. import { Engine } from "babylonjs/Engines/engine";
  61763. import "babylonjs/Shaders/fxaa.fragment";
  61764. import "babylonjs/Shaders/fxaa.vertex";
  61765. /**
  61766. * Fxaa post process
  61767. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61768. */
  61769. export class FxaaPostProcess extends PostProcess {
  61770. /** @hidden */
  61771. texelWidth: number;
  61772. /** @hidden */
  61773. texelHeight: number;
  61774. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61775. private _getDefines;
  61776. }
  61777. }
  61778. declare module "babylonjs/Shaders/grain.fragment" {
  61779. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61780. /** @hidden */
  61781. export var grainPixelShader: {
  61782. name: string;
  61783. shader: string;
  61784. };
  61785. }
  61786. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61787. import { Nullable } from "babylonjs/types";
  61788. import { Camera } from "babylonjs/Cameras/camera";
  61789. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61790. import { Engine } from "babylonjs/Engines/engine";
  61791. import "babylonjs/Shaders/grain.fragment";
  61792. /**
  61793. * The GrainPostProcess adds noise to the image at mid luminance levels
  61794. */
  61795. export class GrainPostProcess extends PostProcess {
  61796. /**
  61797. * The intensity of the grain added (default: 30)
  61798. */
  61799. intensity: number;
  61800. /**
  61801. * If the grain should be randomized on every frame
  61802. */
  61803. animated: boolean;
  61804. /**
  61805. * Creates a new instance of @see GrainPostProcess
  61806. * @param name The name of the effect.
  61807. * @param options The required width/height ratio to downsize to before computing the render pass.
  61808. * @param camera The camera to apply the render pass to.
  61809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61810. * @param engine The engine which the post process will be applied. (default: current engine)
  61811. * @param reusable If the post process can be reused on the same frame. (default: false)
  61812. * @param textureType Type of textures used when performing the post process. (default: 0)
  61813. * @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)
  61814. */
  61815. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61816. }
  61817. }
  61818. declare module "babylonjs/Shaders/highlights.fragment" {
  61819. /** @hidden */
  61820. export var highlightsPixelShader: {
  61821. name: string;
  61822. shader: string;
  61823. };
  61824. }
  61825. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61826. import { Nullable } from "babylonjs/types";
  61827. import { Camera } from "babylonjs/Cameras/camera";
  61828. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61829. import { Engine } from "babylonjs/Engines/engine";
  61830. import "babylonjs/Shaders/highlights.fragment";
  61831. /**
  61832. * Extracts highlights from the image
  61833. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61834. */
  61835. export class HighlightsPostProcess extends PostProcess {
  61836. /**
  61837. * Extracts highlights from the image
  61838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61839. * @param name The name of the effect.
  61840. * @param options The required width/height ratio to downsize to before computing the render pass.
  61841. * @param camera The camera to apply the render pass to.
  61842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61843. * @param engine The engine which the post process will be applied. (default: current engine)
  61844. * @param reusable If the post process can be reused on the same frame. (default: false)
  61845. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61846. */
  61847. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61848. }
  61849. }
  61850. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61851. /** @hidden */
  61852. export var mrtFragmentDeclaration: {
  61853. name: string;
  61854. shader: string;
  61855. };
  61856. }
  61857. declare module "babylonjs/Shaders/geometry.fragment" {
  61858. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61859. /** @hidden */
  61860. export var geometryPixelShader: {
  61861. name: string;
  61862. shader: string;
  61863. };
  61864. }
  61865. declare module "babylonjs/Shaders/geometry.vertex" {
  61866. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61868. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61869. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61870. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61871. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61872. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61873. /** @hidden */
  61874. export var geometryVertexShader: {
  61875. name: string;
  61876. shader: string;
  61877. };
  61878. }
  61879. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61880. import { Matrix } from "babylonjs/Maths/math.vector";
  61881. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61882. import { Mesh } from "babylonjs/Meshes/mesh";
  61883. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61884. import { Effect } from "babylonjs/Materials/effect";
  61885. import { Scene } from "babylonjs/scene";
  61886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61887. import "babylonjs/Shaders/geometry.fragment";
  61888. import "babylonjs/Shaders/geometry.vertex";
  61889. /** @hidden */
  61890. interface ISavedTransformationMatrix {
  61891. world: Matrix;
  61892. viewProjection: Matrix;
  61893. }
  61894. /**
  61895. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61896. */
  61897. export class GeometryBufferRenderer {
  61898. /**
  61899. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61900. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61901. */
  61902. static readonly POSITION_TEXTURE_TYPE: number;
  61903. /**
  61904. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61905. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61906. */
  61907. static readonly VELOCITY_TEXTURE_TYPE: number;
  61908. /**
  61909. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61910. * in order to compute objects velocities when enableVelocity is set to "true"
  61911. * @hidden
  61912. */
  61913. _previousTransformationMatrices: {
  61914. [index: number]: ISavedTransformationMatrix;
  61915. };
  61916. /**
  61917. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61918. * in order to compute objects velocities when enableVelocity is set to "true"
  61919. * @hidden
  61920. */
  61921. _previousBonesTransformationMatrices: {
  61922. [index: number]: Float32Array;
  61923. };
  61924. /**
  61925. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61926. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61927. */
  61928. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61929. private _scene;
  61930. private _multiRenderTarget;
  61931. private _ratio;
  61932. private _enablePosition;
  61933. private _enableVelocity;
  61934. private _positionIndex;
  61935. private _velocityIndex;
  61936. protected _effect: Effect;
  61937. protected _cachedDefines: string;
  61938. /**
  61939. * Set the render list (meshes to be rendered) used in the G buffer.
  61940. */
  61941. renderList: Mesh[];
  61942. /**
  61943. * Gets wether or not G buffer are supported by the running hardware.
  61944. * This requires draw buffer supports
  61945. */
  61946. readonly isSupported: boolean;
  61947. /**
  61948. * Returns the index of the given texture type in the G-Buffer textures array
  61949. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61950. * @returns the index of the given texture type in the G-Buffer textures array
  61951. */
  61952. getTextureIndex(textureType: number): number;
  61953. /**
  61954. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61955. */
  61956. /**
  61957. * Sets whether or not objects positions are enabled for the G buffer.
  61958. */
  61959. enablePosition: boolean;
  61960. /**
  61961. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61962. */
  61963. /**
  61964. * Sets wether or not objects velocities are enabled for the G buffer.
  61965. */
  61966. enableVelocity: boolean;
  61967. /**
  61968. * Gets the scene associated with the buffer.
  61969. */
  61970. readonly scene: Scene;
  61971. /**
  61972. * Gets the ratio used by the buffer during its creation.
  61973. * How big is the buffer related to the main canvas.
  61974. */
  61975. readonly ratio: number;
  61976. /** @hidden */
  61977. static _SceneComponentInitialization: (scene: Scene) => void;
  61978. /**
  61979. * Creates a new G Buffer for the scene
  61980. * @param scene The scene the buffer belongs to
  61981. * @param ratio How big is the buffer related to the main canvas.
  61982. */
  61983. constructor(scene: Scene, ratio?: number);
  61984. /**
  61985. * Checks wether everything is ready to render a submesh to the G buffer.
  61986. * @param subMesh the submesh to check readiness for
  61987. * @param useInstances is the mesh drawn using instance or not
  61988. * @returns true if ready otherwise false
  61989. */
  61990. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61991. /**
  61992. * Gets the current underlying G Buffer.
  61993. * @returns the buffer
  61994. */
  61995. getGBuffer(): MultiRenderTarget;
  61996. /**
  61997. * Gets the number of samples used to render the buffer (anti aliasing).
  61998. */
  61999. /**
  62000. * Sets the number of samples used to render the buffer (anti aliasing).
  62001. */
  62002. samples: number;
  62003. /**
  62004. * Disposes the renderer and frees up associated resources.
  62005. */
  62006. dispose(): void;
  62007. protected _createRenderTargets(): void;
  62008. private _copyBonesTransformationMatrices;
  62009. }
  62010. }
  62011. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62012. import { Nullable } from "babylonjs/types";
  62013. import { Scene } from "babylonjs/scene";
  62014. import { ISceneComponent } from "babylonjs/sceneComponent";
  62015. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62016. module "babylonjs/scene" {
  62017. interface Scene {
  62018. /** @hidden (Backing field) */
  62019. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62020. /**
  62021. * Gets or Sets the current geometry buffer associated to the scene.
  62022. */
  62023. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62024. /**
  62025. * Enables a GeometryBufferRender and associates it with the scene
  62026. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62027. * @returns the GeometryBufferRenderer
  62028. */
  62029. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62030. /**
  62031. * Disables the GeometryBufferRender associated with the scene
  62032. */
  62033. disableGeometryBufferRenderer(): void;
  62034. }
  62035. }
  62036. /**
  62037. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62038. * in several rendering techniques.
  62039. */
  62040. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62041. /**
  62042. * The component name helpful to identify the component in the list of scene components.
  62043. */
  62044. readonly name: string;
  62045. /**
  62046. * The scene the component belongs to.
  62047. */
  62048. scene: Scene;
  62049. /**
  62050. * Creates a new instance of the component for the given scene
  62051. * @param scene Defines the scene to register the component in
  62052. */
  62053. constructor(scene: Scene);
  62054. /**
  62055. * Registers the component in a given scene
  62056. */
  62057. register(): void;
  62058. /**
  62059. * Rebuilds the elements related to this component in case of
  62060. * context lost for instance.
  62061. */
  62062. rebuild(): void;
  62063. /**
  62064. * Disposes the component and the associated ressources
  62065. */
  62066. dispose(): void;
  62067. private _gatherRenderTargets;
  62068. }
  62069. }
  62070. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62071. /** @hidden */
  62072. export var motionBlurPixelShader: {
  62073. name: string;
  62074. shader: string;
  62075. };
  62076. }
  62077. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62078. import { Nullable } from "babylonjs/types";
  62079. import { Camera } from "babylonjs/Cameras/camera";
  62080. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62081. import { Scene } from "babylonjs/scene";
  62082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62083. import "babylonjs/Animations/animatable";
  62084. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62085. import "babylonjs/Shaders/motionBlur.fragment";
  62086. import { Engine } from "babylonjs/Engines/engine";
  62087. /**
  62088. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62089. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62090. * As an example, all you have to do is to create the post-process:
  62091. * var mb = new BABYLON.MotionBlurPostProcess(
  62092. * 'mb', // The name of the effect.
  62093. * scene, // The scene containing the objects to blur according to their velocity.
  62094. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62095. * camera // The camera to apply the render pass to.
  62096. * );
  62097. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62098. */
  62099. export class MotionBlurPostProcess extends PostProcess {
  62100. /**
  62101. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62102. */
  62103. motionStrength: number;
  62104. /**
  62105. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62106. */
  62107. /**
  62108. * Sets the number of iterations to be used for motion blur quality
  62109. */
  62110. motionBlurSamples: number;
  62111. private _motionBlurSamples;
  62112. private _geometryBufferRenderer;
  62113. /**
  62114. * Creates a new instance MotionBlurPostProcess
  62115. * @param name The name of the effect.
  62116. * @param scene The scene containing the objects to blur according to their velocity.
  62117. * @param options The required width/height ratio to downsize to before computing the render pass.
  62118. * @param camera The camera to apply the render pass to.
  62119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62120. * @param engine The engine which the post process will be applied. (default: current engine)
  62121. * @param reusable If the post process can be reused on the same frame. (default: false)
  62122. * @param textureType Type of textures used when performing the post process. (default: 0)
  62123. * @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)
  62124. */
  62125. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62126. /**
  62127. * Excludes the given skinned mesh from computing bones velocities.
  62128. * 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.
  62129. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62130. */
  62131. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62132. /**
  62133. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62134. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62135. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62136. */
  62137. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62138. /**
  62139. * Disposes the post process.
  62140. * @param camera The camera to dispose the post process on.
  62141. */
  62142. dispose(camera?: Camera): void;
  62143. }
  62144. }
  62145. declare module "babylonjs/Shaders/refraction.fragment" {
  62146. /** @hidden */
  62147. export var refractionPixelShader: {
  62148. name: string;
  62149. shader: string;
  62150. };
  62151. }
  62152. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62153. import { Color3 } from "babylonjs/Maths/math.color";
  62154. import { Camera } from "babylonjs/Cameras/camera";
  62155. import { Texture } from "babylonjs/Materials/Textures/texture";
  62156. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62157. import { Engine } from "babylonjs/Engines/engine";
  62158. import "babylonjs/Shaders/refraction.fragment";
  62159. /**
  62160. * Post process which applies a refractin texture
  62161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62162. */
  62163. export class RefractionPostProcess extends PostProcess {
  62164. /** the base color of the refraction (used to taint the rendering) */
  62165. color: Color3;
  62166. /** simulated refraction depth */
  62167. depth: number;
  62168. /** the coefficient of the base color (0 to remove base color tainting) */
  62169. colorLevel: number;
  62170. private _refTexture;
  62171. private _ownRefractionTexture;
  62172. /**
  62173. * Gets or sets the refraction texture
  62174. * Please note that you are responsible for disposing the texture if you set it manually
  62175. */
  62176. refractionTexture: Texture;
  62177. /**
  62178. * Initializes the RefractionPostProcess
  62179. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62180. * @param name The name of the effect.
  62181. * @param refractionTextureUrl Url of the refraction texture to use
  62182. * @param color the base color of the refraction (used to taint the rendering)
  62183. * @param depth simulated refraction depth
  62184. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62185. * @param camera The camera to apply the render pass to.
  62186. * @param options The required width/height ratio to downsize to before computing the render pass.
  62187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62188. * @param engine The engine which the post process will be applied. (default: current engine)
  62189. * @param reusable If the post process can be reused on the same frame. (default: false)
  62190. */
  62191. constructor(name: string, refractionTextureUrl: string,
  62192. /** the base color of the refraction (used to taint the rendering) */
  62193. color: Color3,
  62194. /** simulated refraction depth */
  62195. depth: number,
  62196. /** the coefficient of the base color (0 to remove base color tainting) */
  62197. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62198. /**
  62199. * Disposes of the post process
  62200. * @param camera Camera to dispose post process on
  62201. */
  62202. dispose(camera: Camera): void;
  62203. }
  62204. }
  62205. declare module "babylonjs/Shaders/sharpen.fragment" {
  62206. /** @hidden */
  62207. export var sharpenPixelShader: {
  62208. name: string;
  62209. shader: string;
  62210. };
  62211. }
  62212. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62213. import { Nullable } from "babylonjs/types";
  62214. import { Camera } from "babylonjs/Cameras/camera";
  62215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62216. import "babylonjs/Shaders/sharpen.fragment";
  62217. import { Engine } from "babylonjs/Engines/engine";
  62218. /**
  62219. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62220. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62221. */
  62222. export class SharpenPostProcess extends PostProcess {
  62223. /**
  62224. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62225. */
  62226. colorAmount: number;
  62227. /**
  62228. * How much sharpness should be applied (default: 0.3)
  62229. */
  62230. edgeAmount: number;
  62231. /**
  62232. * Creates a new instance ConvolutionPostProcess
  62233. * @param name The name of the effect.
  62234. * @param options The required width/height ratio to downsize to before computing the render pass.
  62235. * @param camera The camera to apply the render pass to.
  62236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62237. * @param engine The engine which the post process will be applied. (default: current engine)
  62238. * @param reusable If the post process can be reused on the same frame. (default: false)
  62239. * @param textureType Type of textures used when performing the post process. (default: 0)
  62240. * @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)
  62241. */
  62242. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62243. }
  62244. }
  62245. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62246. import { Nullable } from "babylonjs/types";
  62247. import { Camera } from "babylonjs/Cameras/camera";
  62248. import { Engine } from "babylonjs/Engines/engine";
  62249. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62250. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62251. /**
  62252. * PostProcessRenderPipeline
  62253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62254. */
  62255. export class PostProcessRenderPipeline {
  62256. private engine;
  62257. private _renderEffects;
  62258. private _renderEffectsForIsolatedPass;
  62259. /**
  62260. * List of inspectable custom properties (used by the Inspector)
  62261. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62262. */
  62263. inspectableCustomProperties: IInspectable[];
  62264. /**
  62265. * @hidden
  62266. */
  62267. protected _cameras: Camera[];
  62268. /** @hidden */
  62269. _name: string;
  62270. /**
  62271. * Gets pipeline name
  62272. */
  62273. readonly name: string;
  62274. /**
  62275. * Initializes a PostProcessRenderPipeline
  62276. * @param engine engine to add the pipeline to
  62277. * @param name name of the pipeline
  62278. */
  62279. constructor(engine: Engine, name: string);
  62280. /**
  62281. * Gets the class name
  62282. * @returns "PostProcessRenderPipeline"
  62283. */
  62284. getClassName(): string;
  62285. /**
  62286. * If all the render effects in the pipeline are supported
  62287. */
  62288. readonly isSupported: boolean;
  62289. /**
  62290. * Adds an effect to the pipeline
  62291. * @param renderEffect the effect to add
  62292. */
  62293. addEffect(renderEffect: PostProcessRenderEffect): void;
  62294. /** @hidden */
  62295. _rebuild(): void;
  62296. /** @hidden */
  62297. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62298. /** @hidden */
  62299. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62300. /** @hidden */
  62301. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62302. /** @hidden */
  62303. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62304. /** @hidden */
  62305. _attachCameras(cameras: Camera, unique: boolean): void;
  62306. /** @hidden */
  62307. _attachCameras(cameras: Camera[], unique: boolean): void;
  62308. /** @hidden */
  62309. _detachCameras(cameras: Camera): void;
  62310. /** @hidden */
  62311. _detachCameras(cameras: Nullable<Camera[]>): void;
  62312. /** @hidden */
  62313. _update(): void;
  62314. /** @hidden */
  62315. _reset(): void;
  62316. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62317. /**
  62318. * Disposes of the pipeline
  62319. */
  62320. dispose(): void;
  62321. }
  62322. }
  62323. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62324. import { Camera } from "babylonjs/Cameras/camera";
  62325. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62326. /**
  62327. * PostProcessRenderPipelineManager class
  62328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62329. */
  62330. export class PostProcessRenderPipelineManager {
  62331. private _renderPipelines;
  62332. /**
  62333. * Initializes a PostProcessRenderPipelineManager
  62334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62335. */
  62336. constructor();
  62337. /**
  62338. * Gets the list of supported render pipelines
  62339. */
  62340. readonly supportedPipelines: PostProcessRenderPipeline[];
  62341. /**
  62342. * Adds a pipeline to the manager
  62343. * @param renderPipeline The pipeline to add
  62344. */
  62345. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62346. /**
  62347. * Attaches a camera to the pipeline
  62348. * @param renderPipelineName The name of the pipeline to attach to
  62349. * @param cameras the camera to attach
  62350. * @param unique if the camera can be attached multiple times to the pipeline
  62351. */
  62352. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62353. /**
  62354. * Detaches a camera from the pipeline
  62355. * @param renderPipelineName The name of the pipeline to detach from
  62356. * @param cameras the camera to detach
  62357. */
  62358. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62359. /**
  62360. * Enables an effect by name on a pipeline
  62361. * @param renderPipelineName the name of the pipeline to enable the effect in
  62362. * @param renderEffectName the name of the effect to enable
  62363. * @param cameras the cameras that the effect should be enabled on
  62364. */
  62365. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62366. /**
  62367. * Disables an effect by name on a pipeline
  62368. * @param renderPipelineName the name of the pipeline to disable the effect in
  62369. * @param renderEffectName the name of the effect to disable
  62370. * @param cameras the cameras that the effect should be disabled on
  62371. */
  62372. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62373. /**
  62374. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62375. */
  62376. update(): void;
  62377. /** @hidden */
  62378. _rebuild(): void;
  62379. /**
  62380. * Disposes of the manager and pipelines
  62381. */
  62382. dispose(): void;
  62383. }
  62384. }
  62385. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62386. import { ISceneComponent } from "babylonjs/sceneComponent";
  62387. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62388. import { Scene } from "babylonjs/scene";
  62389. module "babylonjs/scene" {
  62390. interface Scene {
  62391. /** @hidden (Backing field) */
  62392. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62393. /**
  62394. * Gets the postprocess render pipeline manager
  62395. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62396. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62397. */
  62398. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62399. }
  62400. }
  62401. /**
  62402. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62403. */
  62404. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62405. /**
  62406. * The component name helpfull to identify the component in the list of scene components.
  62407. */
  62408. readonly name: string;
  62409. /**
  62410. * The scene the component belongs to.
  62411. */
  62412. scene: Scene;
  62413. /**
  62414. * Creates a new instance of the component for the given scene
  62415. * @param scene Defines the scene to register the component in
  62416. */
  62417. constructor(scene: Scene);
  62418. /**
  62419. * Registers the component in a given scene
  62420. */
  62421. register(): void;
  62422. /**
  62423. * Rebuilds the elements related to this component in case of
  62424. * context lost for instance.
  62425. */
  62426. rebuild(): void;
  62427. /**
  62428. * Disposes the component and the associated ressources
  62429. */
  62430. dispose(): void;
  62431. private _gatherRenderTargets;
  62432. }
  62433. }
  62434. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62435. import { Nullable } from "babylonjs/types";
  62436. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62437. import { Camera } from "babylonjs/Cameras/camera";
  62438. import { IDisposable } from "babylonjs/scene";
  62439. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62440. import { Scene } from "babylonjs/scene";
  62441. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62442. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62443. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62444. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62445. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62446. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62447. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62448. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62449. import { Animation } from "babylonjs/Animations/animation";
  62450. /**
  62451. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62452. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62453. */
  62454. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62455. private _scene;
  62456. private _camerasToBeAttached;
  62457. /**
  62458. * ID of the sharpen post process,
  62459. */
  62460. private readonly SharpenPostProcessId;
  62461. /**
  62462. * @ignore
  62463. * ID of the image processing post process;
  62464. */
  62465. readonly ImageProcessingPostProcessId: string;
  62466. /**
  62467. * @ignore
  62468. * ID of the Fast Approximate Anti-Aliasing post process;
  62469. */
  62470. readonly FxaaPostProcessId: string;
  62471. /**
  62472. * ID of the chromatic aberration post process,
  62473. */
  62474. private readonly ChromaticAberrationPostProcessId;
  62475. /**
  62476. * ID of the grain post process
  62477. */
  62478. private readonly GrainPostProcessId;
  62479. /**
  62480. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62481. */
  62482. sharpen: SharpenPostProcess;
  62483. private _sharpenEffect;
  62484. private bloom;
  62485. /**
  62486. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62487. */
  62488. depthOfField: DepthOfFieldEffect;
  62489. /**
  62490. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62491. */
  62492. fxaa: FxaaPostProcess;
  62493. /**
  62494. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62495. */
  62496. imageProcessing: ImageProcessingPostProcess;
  62497. /**
  62498. * Chromatic aberration post process which will shift rgb colors in the image
  62499. */
  62500. chromaticAberration: ChromaticAberrationPostProcess;
  62501. private _chromaticAberrationEffect;
  62502. /**
  62503. * Grain post process which add noise to the image
  62504. */
  62505. grain: GrainPostProcess;
  62506. private _grainEffect;
  62507. /**
  62508. * Glow post process which adds a glow to emissive areas of the image
  62509. */
  62510. private _glowLayer;
  62511. /**
  62512. * Animations which can be used to tweak settings over a period of time
  62513. */
  62514. animations: Animation[];
  62515. private _imageProcessingConfigurationObserver;
  62516. private _sharpenEnabled;
  62517. private _bloomEnabled;
  62518. private _depthOfFieldEnabled;
  62519. private _depthOfFieldBlurLevel;
  62520. private _fxaaEnabled;
  62521. private _imageProcessingEnabled;
  62522. private _defaultPipelineTextureType;
  62523. private _bloomScale;
  62524. private _chromaticAberrationEnabled;
  62525. private _grainEnabled;
  62526. private _buildAllowed;
  62527. /**
  62528. * Gets active scene
  62529. */
  62530. readonly scene: Scene;
  62531. /**
  62532. * Enable or disable the sharpen process from the pipeline
  62533. */
  62534. sharpenEnabled: boolean;
  62535. private _resizeObserver;
  62536. private _hardwareScaleLevel;
  62537. private _bloomKernel;
  62538. /**
  62539. * Specifies the size of the bloom blur kernel, relative to the final output size
  62540. */
  62541. bloomKernel: number;
  62542. /**
  62543. * Specifies the weight of the bloom in the final rendering
  62544. */
  62545. private _bloomWeight;
  62546. /**
  62547. * Specifies the luma threshold for the area that will be blurred by the bloom
  62548. */
  62549. private _bloomThreshold;
  62550. private _hdr;
  62551. /**
  62552. * The strength of the bloom.
  62553. */
  62554. bloomWeight: number;
  62555. /**
  62556. * The strength of the bloom.
  62557. */
  62558. bloomThreshold: number;
  62559. /**
  62560. * The scale of the bloom, lower value will provide better performance.
  62561. */
  62562. bloomScale: number;
  62563. /**
  62564. * Enable or disable the bloom from the pipeline
  62565. */
  62566. bloomEnabled: boolean;
  62567. private _rebuildBloom;
  62568. /**
  62569. * If the depth of field is enabled.
  62570. */
  62571. depthOfFieldEnabled: boolean;
  62572. /**
  62573. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62574. */
  62575. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62576. /**
  62577. * If the anti aliasing is enabled.
  62578. */
  62579. fxaaEnabled: boolean;
  62580. private _samples;
  62581. /**
  62582. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62583. */
  62584. samples: number;
  62585. /**
  62586. * If image processing is enabled.
  62587. */
  62588. imageProcessingEnabled: boolean;
  62589. /**
  62590. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62591. */
  62592. glowLayerEnabled: boolean;
  62593. /**
  62594. * Gets the glow layer (or null if not defined)
  62595. */
  62596. readonly glowLayer: Nullable<GlowLayer>;
  62597. /**
  62598. * Enable or disable the chromaticAberration process from the pipeline
  62599. */
  62600. chromaticAberrationEnabled: boolean;
  62601. /**
  62602. * Enable or disable the grain process from the pipeline
  62603. */
  62604. grainEnabled: boolean;
  62605. /**
  62606. * @constructor
  62607. * @param name - The rendering pipeline name (default: "")
  62608. * @param hdr - If high dynamic range textures should be used (default: true)
  62609. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62610. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62611. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62612. */
  62613. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62614. /**
  62615. * Get the class name
  62616. * @returns "DefaultRenderingPipeline"
  62617. */
  62618. getClassName(): string;
  62619. /**
  62620. * Force the compilation of the entire pipeline.
  62621. */
  62622. prepare(): void;
  62623. private _hasCleared;
  62624. private _prevPostProcess;
  62625. private _prevPrevPostProcess;
  62626. private _setAutoClearAndTextureSharing;
  62627. private _depthOfFieldSceneObserver;
  62628. private _buildPipeline;
  62629. private _disposePostProcesses;
  62630. /**
  62631. * Adds a camera to the pipeline
  62632. * @param camera the camera to be added
  62633. */
  62634. addCamera(camera: Camera): void;
  62635. /**
  62636. * Removes a camera from the pipeline
  62637. * @param camera the camera to remove
  62638. */
  62639. removeCamera(camera: Camera): void;
  62640. /**
  62641. * Dispose of the pipeline and stop all post processes
  62642. */
  62643. dispose(): void;
  62644. /**
  62645. * Serialize the rendering pipeline (Used when exporting)
  62646. * @returns the serialized object
  62647. */
  62648. serialize(): any;
  62649. /**
  62650. * Parse the serialized pipeline
  62651. * @param source Source pipeline.
  62652. * @param scene The scene to load the pipeline to.
  62653. * @param rootUrl The URL of the serialized pipeline.
  62654. * @returns An instantiated pipeline from the serialized object.
  62655. */
  62656. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62657. }
  62658. }
  62659. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62660. /** @hidden */
  62661. export var lensHighlightsPixelShader: {
  62662. name: string;
  62663. shader: string;
  62664. };
  62665. }
  62666. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62667. /** @hidden */
  62668. export var depthOfFieldPixelShader: {
  62669. name: string;
  62670. shader: string;
  62671. };
  62672. }
  62673. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62674. import { Camera } from "babylonjs/Cameras/camera";
  62675. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62676. import { Scene } from "babylonjs/scene";
  62677. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62678. import "babylonjs/Shaders/chromaticAberration.fragment";
  62679. import "babylonjs/Shaders/lensHighlights.fragment";
  62680. import "babylonjs/Shaders/depthOfField.fragment";
  62681. /**
  62682. * BABYLON.JS Chromatic Aberration GLSL Shader
  62683. * Author: Olivier Guyot
  62684. * Separates very slightly R, G and B colors on the edges of the screen
  62685. * Inspired by Francois Tarlier & Martins Upitis
  62686. */
  62687. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62688. /**
  62689. * @ignore
  62690. * The chromatic aberration PostProcess id in the pipeline
  62691. */
  62692. LensChromaticAberrationEffect: string;
  62693. /**
  62694. * @ignore
  62695. * The highlights enhancing PostProcess id in the pipeline
  62696. */
  62697. HighlightsEnhancingEffect: string;
  62698. /**
  62699. * @ignore
  62700. * The depth-of-field PostProcess id in the pipeline
  62701. */
  62702. LensDepthOfFieldEffect: string;
  62703. private _scene;
  62704. private _depthTexture;
  62705. private _grainTexture;
  62706. private _chromaticAberrationPostProcess;
  62707. private _highlightsPostProcess;
  62708. private _depthOfFieldPostProcess;
  62709. private _edgeBlur;
  62710. private _grainAmount;
  62711. private _chromaticAberration;
  62712. private _distortion;
  62713. private _highlightsGain;
  62714. private _highlightsThreshold;
  62715. private _dofDistance;
  62716. private _dofAperture;
  62717. private _dofDarken;
  62718. private _dofPentagon;
  62719. private _blurNoise;
  62720. /**
  62721. * @constructor
  62722. *
  62723. * Effect parameters are as follow:
  62724. * {
  62725. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62726. * edge_blur: number; // from 0 to x (1 for realism)
  62727. * distortion: number; // from 0 to x (1 for realism)
  62728. * grain_amount: number; // from 0 to 1
  62729. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62730. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62731. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62732. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62733. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62734. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62735. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62736. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62737. * }
  62738. * Note: if an effect parameter is unset, effect is disabled
  62739. *
  62740. * @param name The rendering pipeline name
  62741. * @param parameters - An object containing all parameters (see above)
  62742. * @param scene The scene linked to this pipeline
  62743. * @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)
  62744. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62745. */
  62746. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62747. /**
  62748. * Get the class name
  62749. * @returns "LensRenderingPipeline"
  62750. */
  62751. getClassName(): string;
  62752. /**
  62753. * Gets associated scene
  62754. */
  62755. readonly scene: Scene;
  62756. /**
  62757. * Gets or sets the edge blur
  62758. */
  62759. edgeBlur: number;
  62760. /**
  62761. * Gets or sets the grain amount
  62762. */
  62763. grainAmount: number;
  62764. /**
  62765. * Gets or sets the chromatic aberration amount
  62766. */
  62767. chromaticAberration: number;
  62768. /**
  62769. * Gets or sets the depth of field aperture
  62770. */
  62771. dofAperture: number;
  62772. /**
  62773. * Gets or sets the edge distortion
  62774. */
  62775. edgeDistortion: number;
  62776. /**
  62777. * Gets or sets the depth of field distortion
  62778. */
  62779. dofDistortion: number;
  62780. /**
  62781. * Gets or sets the darken out of focus amount
  62782. */
  62783. darkenOutOfFocus: number;
  62784. /**
  62785. * Gets or sets a boolean indicating if blur noise is enabled
  62786. */
  62787. blurNoise: boolean;
  62788. /**
  62789. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62790. */
  62791. pentagonBokeh: boolean;
  62792. /**
  62793. * Gets or sets the highlight grain amount
  62794. */
  62795. highlightsGain: number;
  62796. /**
  62797. * Gets or sets the highlight threshold
  62798. */
  62799. highlightsThreshold: number;
  62800. /**
  62801. * Sets the amount of blur at the edges
  62802. * @param amount blur amount
  62803. */
  62804. setEdgeBlur(amount: number): void;
  62805. /**
  62806. * Sets edge blur to 0
  62807. */
  62808. disableEdgeBlur(): void;
  62809. /**
  62810. * Sets the amout of grain
  62811. * @param amount Amount of grain
  62812. */
  62813. setGrainAmount(amount: number): void;
  62814. /**
  62815. * Set grain amount to 0
  62816. */
  62817. disableGrain(): void;
  62818. /**
  62819. * Sets the chromatic aberration amount
  62820. * @param amount amount of chromatic aberration
  62821. */
  62822. setChromaticAberration(amount: number): void;
  62823. /**
  62824. * Sets chromatic aberration amount to 0
  62825. */
  62826. disableChromaticAberration(): void;
  62827. /**
  62828. * Sets the EdgeDistortion amount
  62829. * @param amount amount of EdgeDistortion
  62830. */
  62831. setEdgeDistortion(amount: number): void;
  62832. /**
  62833. * Sets edge distortion to 0
  62834. */
  62835. disableEdgeDistortion(): void;
  62836. /**
  62837. * Sets the FocusDistance amount
  62838. * @param amount amount of FocusDistance
  62839. */
  62840. setFocusDistance(amount: number): void;
  62841. /**
  62842. * Disables depth of field
  62843. */
  62844. disableDepthOfField(): void;
  62845. /**
  62846. * Sets the Aperture amount
  62847. * @param amount amount of Aperture
  62848. */
  62849. setAperture(amount: number): void;
  62850. /**
  62851. * Sets the DarkenOutOfFocus amount
  62852. * @param amount amount of DarkenOutOfFocus
  62853. */
  62854. setDarkenOutOfFocus(amount: number): void;
  62855. private _pentagonBokehIsEnabled;
  62856. /**
  62857. * Creates a pentagon bokeh effect
  62858. */
  62859. enablePentagonBokeh(): void;
  62860. /**
  62861. * Disables the pentagon bokeh effect
  62862. */
  62863. disablePentagonBokeh(): void;
  62864. /**
  62865. * Enables noise blur
  62866. */
  62867. enableNoiseBlur(): void;
  62868. /**
  62869. * Disables noise blur
  62870. */
  62871. disableNoiseBlur(): void;
  62872. /**
  62873. * Sets the HighlightsGain amount
  62874. * @param amount amount of HighlightsGain
  62875. */
  62876. setHighlightsGain(amount: number): void;
  62877. /**
  62878. * Sets the HighlightsThreshold amount
  62879. * @param amount amount of HighlightsThreshold
  62880. */
  62881. setHighlightsThreshold(amount: number): void;
  62882. /**
  62883. * Disables highlights
  62884. */
  62885. disableHighlights(): void;
  62886. /**
  62887. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62888. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62889. */
  62890. dispose(disableDepthRender?: boolean): void;
  62891. private _createChromaticAberrationPostProcess;
  62892. private _createHighlightsPostProcess;
  62893. private _createDepthOfFieldPostProcess;
  62894. private _createGrainTexture;
  62895. }
  62896. }
  62897. declare module "babylonjs/Shaders/ssao2.fragment" {
  62898. /** @hidden */
  62899. export var ssao2PixelShader: {
  62900. name: string;
  62901. shader: string;
  62902. };
  62903. }
  62904. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62905. /** @hidden */
  62906. export var ssaoCombinePixelShader: {
  62907. name: string;
  62908. shader: string;
  62909. };
  62910. }
  62911. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62912. import { Camera } from "babylonjs/Cameras/camera";
  62913. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62914. import { Scene } from "babylonjs/scene";
  62915. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62916. import "babylonjs/Shaders/ssao2.fragment";
  62917. import "babylonjs/Shaders/ssaoCombine.fragment";
  62918. /**
  62919. * Render pipeline to produce ssao effect
  62920. */
  62921. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62922. /**
  62923. * @ignore
  62924. * The PassPostProcess id in the pipeline that contains the original scene color
  62925. */
  62926. SSAOOriginalSceneColorEffect: string;
  62927. /**
  62928. * @ignore
  62929. * The SSAO PostProcess id in the pipeline
  62930. */
  62931. SSAORenderEffect: string;
  62932. /**
  62933. * @ignore
  62934. * The horizontal blur PostProcess id in the pipeline
  62935. */
  62936. SSAOBlurHRenderEffect: string;
  62937. /**
  62938. * @ignore
  62939. * The vertical blur PostProcess id in the pipeline
  62940. */
  62941. SSAOBlurVRenderEffect: string;
  62942. /**
  62943. * @ignore
  62944. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62945. */
  62946. SSAOCombineRenderEffect: string;
  62947. /**
  62948. * The output strength of the SSAO post-process. Default value is 1.0.
  62949. */
  62950. totalStrength: number;
  62951. /**
  62952. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62953. */
  62954. maxZ: number;
  62955. /**
  62956. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62957. */
  62958. minZAspect: number;
  62959. private _samples;
  62960. /**
  62961. * Number of samples used for the SSAO calculations. Default value is 8
  62962. */
  62963. samples: number;
  62964. private _textureSamples;
  62965. /**
  62966. * Number of samples to use for antialiasing
  62967. */
  62968. textureSamples: number;
  62969. /**
  62970. * Ratio object used for SSAO ratio and blur ratio
  62971. */
  62972. private _ratio;
  62973. /**
  62974. * Dynamically generated sphere sampler.
  62975. */
  62976. private _sampleSphere;
  62977. /**
  62978. * Blur filter offsets
  62979. */
  62980. private _samplerOffsets;
  62981. private _expensiveBlur;
  62982. /**
  62983. * If bilateral blur should be used
  62984. */
  62985. expensiveBlur: boolean;
  62986. /**
  62987. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62988. */
  62989. radius: number;
  62990. /**
  62991. * The base color of the SSAO post-process
  62992. * The final result is "base + ssao" between [0, 1]
  62993. */
  62994. base: number;
  62995. /**
  62996. * Support test.
  62997. */
  62998. static readonly IsSupported: boolean;
  62999. private _scene;
  63000. private _depthTexture;
  63001. private _normalTexture;
  63002. private _randomTexture;
  63003. private _originalColorPostProcess;
  63004. private _ssaoPostProcess;
  63005. private _blurHPostProcess;
  63006. private _blurVPostProcess;
  63007. private _ssaoCombinePostProcess;
  63008. private _firstUpdate;
  63009. /**
  63010. * Gets active scene
  63011. */
  63012. readonly scene: Scene;
  63013. /**
  63014. * @constructor
  63015. * @param name The rendering pipeline name
  63016. * @param scene The scene linked to this pipeline
  63017. * @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 }
  63018. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63019. */
  63020. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63021. /**
  63022. * Get the class name
  63023. * @returns "SSAO2RenderingPipeline"
  63024. */
  63025. getClassName(): string;
  63026. /**
  63027. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63028. */
  63029. dispose(disableGeometryBufferRenderer?: boolean): void;
  63030. private _createBlurPostProcess;
  63031. /** @hidden */
  63032. _rebuild(): void;
  63033. private _bits;
  63034. private _radicalInverse_VdC;
  63035. private _hammersley;
  63036. private _hemisphereSample_uniform;
  63037. private _generateHemisphere;
  63038. private _createSSAOPostProcess;
  63039. private _createSSAOCombinePostProcess;
  63040. private _createRandomTexture;
  63041. /**
  63042. * Serialize the rendering pipeline (Used when exporting)
  63043. * @returns the serialized object
  63044. */
  63045. serialize(): any;
  63046. /**
  63047. * Parse the serialized pipeline
  63048. * @param source Source pipeline.
  63049. * @param scene The scene to load the pipeline to.
  63050. * @param rootUrl The URL of the serialized pipeline.
  63051. * @returns An instantiated pipeline from the serialized object.
  63052. */
  63053. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63054. }
  63055. }
  63056. declare module "babylonjs/Shaders/ssao.fragment" {
  63057. /** @hidden */
  63058. export var ssaoPixelShader: {
  63059. name: string;
  63060. shader: string;
  63061. };
  63062. }
  63063. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63064. import { Camera } from "babylonjs/Cameras/camera";
  63065. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63066. import { Scene } from "babylonjs/scene";
  63067. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63068. import "babylonjs/Shaders/ssao.fragment";
  63069. import "babylonjs/Shaders/ssaoCombine.fragment";
  63070. /**
  63071. * Render pipeline to produce ssao effect
  63072. */
  63073. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63074. /**
  63075. * @ignore
  63076. * The PassPostProcess id in the pipeline that contains the original scene color
  63077. */
  63078. SSAOOriginalSceneColorEffect: string;
  63079. /**
  63080. * @ignore
  63081. * The SSAO PostProcess id in the pipeline
  63082. */
  63083. SSAORenderEffect: string;
  63084. /**
  63085. * @ignore
  63086. * The horizontal blur PostProcess id in the pipeline
  63087. */
  63088. SSAOBlurHRenderEffect: string;
  63089. /**
  63090. * @ignore
  63091. * The vertical blur PostProcess id in the pipeline
  63092. */
  63093. SSAOBlurVRenderEffect: string;
  63094. /**
  63095. * @ignore
  63096. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63097. */
  63098. SSAOCombineRenderEffect: string;
  63099. /**
  63100. * The output strength of the SSAO post-process. Default value is 1.0.
  63101. */
  63102. totalStrength: number;
  63103. /**
  63104. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63105. */
  63106. radius: number;
  63107. /**
  63108. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63109. * Must not be equal to fallOff and superior to fallOff.
  63110. * Default value is 0.0075
  63111. */
  63112. area: number;
  63113. /**
  63114. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63115. * Must not be equal to area and inferior to area.
  63116. * Default value is 0.000001
  63117. */
  63118. fallOff: number;
  63119. /**
  63120. * The base color of the SSAO post-process
  63121. * The final result is "base + ssao" between [0, 1]
  63122. */
  63123. base: number;
  63124. private _scene;
  63125. private _depthTexture;
  63126. private _randomTexture;
  63127. private _originalColorPostProcess;
  63128. private _ssaoPostProcess;
  63129. private _blurHPostProcess;
  63130. private _blurVPostProcess;
  63131. private _ssaoCombinePostProcess;
  63132. private _firstUpdate;
  63133. /**
  63134. * Gets active scene
  63135. */
  63136. readonly scene: Scene;
  63137. /**
  63138. * @constructor
  63139. * @param name - The rendering pipeline name
  63140. * @param scene - The scene linked to this pipeline
  63141. * @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 }
  63142. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63143. */
  63144. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63145. /**
  63146. * Get the class name
  63147. * @returns "SSAORenderingPipeline"
  63148. */
  63149. getClassName(): string;
  63150. /**
  63151. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63152. */
  63153. dispose(disableDepthRender?: boolean): void;
  63154. private _createBlurPostProcess;
  63155. /** @hidden */
  63156. _rebuild(): void;
  63157. private _createSSAOPostProcess;
  63158. private _createSSAOCombinePostProcess;
  63159. private _createRandomTexture;
  63160. }
  63161. }
  63162. declare module "babylonjs/Shaders/standard.fragment" {
  63163. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63164. /** @hidden */
  63165. export var standardPixelShader: {
  63166. name: string;
  63167. shader: string;
  63168. };
  63169. }
  63170. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63171. import { Nullable } from "babylonjs/types";
  63172. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63173. import { Camera } from "babylonjs/Cameras/camera";
  63174. import { Texture } from "babylonjs/Materials/Textures/texture";
  63175. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63176. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63177. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63178. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63179. import { IDisposable } from "babylonjs/scene";
  63180. import { SpotLight } from "babylonjs/Lights/spotLight";
  63181. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63182. import { Scene } from "babylonjs/scene";
  63183. import { Animation } from "babylonjs/Animations/animation";
  63184. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63185. import "babylonjs/Shaders/standard.fragment";
  63186. /**
  63187. * Standard rendering pipeline
  63188. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63189. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63190. */
  63191. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63192. /**
  63193. * Public members
  63194. */
  63195. /**
  63196. * Post-process which contains the original scene color before the pipeline applies all the effects
  63197. */
  63198. originalPostProcess: Nullable<PostProcess>;
  63199. /**
  63200. * Post-process used to down scale an image x4
  63201. */
  63202. downSampleX4PostProcess: Nullable<PostProcess>;
  63203. /**
  63204. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63205. */
  63206. brightPassPostProcess: Nullable<PostProcess>;
  63207. /**
  63208. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63209. */
  63210. blurHPostProcesses: PostProcess[];
  63211. /**
  63212. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63213. */
  63214. blurVPostProcesses: PostProcess[];
  63215. /**
  63216. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63217. */
  63218. textureAdderPostProcess: Nullable<PostProcess>;
  63219. /**
  63220. * Post-process used to create volumetric lighting effect
  63221. */
  63222. volumetricLightPostProcess: Nullable<PostProcess>;
  63223. /**
  63224. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63225. */
  63226. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63227. /**
  63228. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63229. */
  63230. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63231. /**
  63232. * Post-process used to merge the volumetric light effect and the real scene color
  63233. */
  63234. volumetricLightMergePostProces: Nullable<PostProcess>;
  63235. /**
  63236. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63237. */
  63238. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63239. /**
  63240. * Base post-process used to calculate the average luminance of the final image for HDR
  63241. */
  63242. luminancePostProcess: Nullable<PostProcess>;
  63243. /**
  63244. * Post-processes used to create down sample post-processes in order to get
  63245. * the average luminance of the final image for HDR
  63246. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63247. */
  63248. luminanceDownSamplePostProcesses: PostProcess[];
  63249. /**
  63250. * Post-process used to create a HDR effect (light adaptation)
  63251. */
  63252. hdrPostProcess: Nullable<PostProcess>;
  63253. /**
  63254. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63255. */
  63256. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63257. /**
  63258. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63259. */
  63260. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63261. /**
  63262. * Post-process used to merge the final HDR post-process and the real scene color
  63263. */
  63264. hdrFinalPostProcess: Nullable<PostProcess>;
  63265. /**
  63266. * Post-process used to create a lens flare effect
  63267. */
  63268. lensFlarePostProcess: Nullable<PostProcess>;
  63269. /**
  63270. * Post-process that merges the result of the lens flare post-process and the real scene color
  63271. */
  63272. lensFlareComposePostProcess: Nullable<PostProcess>;
  63273. /**
  63274. * Post-process used to create a motion blur effect
  63275. */
  63276. motionBlurPostProcess: Nullable<PostProcess>;
  63277. /**
  63278. * Post-process used to create a depth of field effect
  63279. */
  63280. depthOfFieldPostProcess: Nullable<PostProcess>;
  63281. /**
  63282. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63283. */
  63284. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63285. /**
  63286. * Represents the brightness threshold in order to configure the illuminated surfaces
  63287. */
  63288. brightThreshold: number;
  63289. /**
  63290. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63291. */
  63292. blurWidth: number;
  63293. /**
  63294. * Sets if the blur for highlighted surfaces must be only horizontal
  63295. */
  63296. horizontalBlur: boolean;
  63297. /**
  63298. * Gets the overall exposure used by the pipeline
  63299. */
  63300. /**
  63301. * Sets the overall exposure used by the pipeline
  63302. */
  63303. exposure: number;
  63304. /**
  63305. * Texture used typically to simulate "dirty" on camera lens
  63306. */
  63307. lensTexture: Nullable<Texture>;
  63308. /**
  63309. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63310. */
  63311. volumetricLightCoefficient: number;
  63312. /**
  63313. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63314. */
  63315. volumetricLightPower: number;
  63316. /**
  63317. * Used the set the blur intensity to smooth the volumetric lights
  63318. */
  63319. volumetricLightBlurScale: number;
  63320. /**
  63321. * Light (spot or directional) used to generate the volumetric lights rays
  63322. * The source light must have a shadow generate so the pipeline can get its
  63323. * depth map
  63324. */
  63325. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63326. /**
  63327. * For eye adaptation, represents the minimum luminance the eye can see
  63328. */
  63329. hdrMinimumLuminance: number;
  63330. /**
  63331. * For eye adaptation, represents the decrease luminance speed
  63332. */
  63333. hdrDecreaseRate: number;
  63334. /**
  63335. * For eye adaptation, represents the increase luminance speed
  63336. */
  63337. hdrIncreaseRate: number;
  63338. /**
  63339. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63340. */
  63341. /**
  63342. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63343. */
  63344. hdrAutoExposure: boolean;
  63345. /**
  63346. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63347. */
  63348. lensColorTexture: Nullable<Texture>;
  63349. /**
  63350. * The overall strengh for the lens flare effect
  63351. */
  63352. lensFlareStrength: number;
  63353. /**
  63354. * Dispersion coefficient for lens flare ghosts
  63355. */
  63356. lensFlareGhostDispersal: number;
  63357. /**
  63358. * Main lens flare halo width
  63359. */
  63360. lensFlareHaloWidth: number;
  63361. /**
  63362. * Based on the lens distortion effect, defines how much the lens flare result
  63363. * is distorted
  63364. */
  63365. lensFlareDistortionStrength: number;
  63366. /**
  63367. * Configures the blur intensity used for for lens flare (halo)
  63368. */
  63369. lensFlareBlurWidth: number;
  63370. /**
  63371. * Lens star texture must be used to simulate rays on the flares and is available
  63372. * in the documentation
  63373. */
  63374. lensStarTexture: Nullable<Texture>;
  63375. /**
  63376. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63377. * flare effect by taking account of the dirt texture
  63378. */
  63379. lensFlareDirtTexture: Nullable<Texture>;
  63380. /**
  63381. * Represents the focal length for the depth of field effect
  63382. */
  63383. depthOfFieldDistance: number;
  63384. /**
  63385. * Represents the blur intensity for the blurred part of the depth of field effect
  63386. */
  63387. depthOfFieldBlurWidth: number;
  63388. /**
  63389. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63390. */
  63391. /**
  63392. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63393. */
  63394. motionStrength: number;
  63395. /**
  63396. * Gets wether or not the motion blur post-process is object based or screen based.
  63397. */
  63398. /**
  63399. * Sets wether or not the motion blur post-process should be object based or screen based
  63400. */
  63401. objectBasedMotionBlur: boolean;
  63402. /**
  63403. * List of animations for the pipeline (IAnimatable implementation)
  63404. */
  63405. animations: Animation[];
  63406. /**
  63407. * Private members
  63408. */
  63409. private _scene;
  63410. private _currentDepthOfFieldSource;
  63411. private _basePostProcess;
  63412. private _fixedExposure;
  63413. private _currentExposure;
  63414. private _hdrAutoExposure;
  63415. private _hdrCurrentLuminance;
  63416. private _motionStrength;
  63417. private _isObjectBasedMotionBlur;
  63418. private _floatTextureType;
  63419. private _camerasToBeAttached;
  63420. private _ratio;
  63421. private _bloomEnabled;
  63422. private _depthOfFieldEnabled;
  63423. private _vlsEnabled;
  63424. private _lensFlareEnabled;
  63425. private _hdrEnabled;
  63426. private _motionBlurEnabled;
  63427. private _fxaaEnabled;
  63428. private _motionBlurSamples;
  63429. private _volumetricLightStepsCount;
  63430. private _samples;
  63431. /**
  63432. * @ignore
  63433. * Specifies if the bloom pipeline is enabled
  63434. */
  63435. BloomEnabled: boolean;
  63436. /**
  63437. * @ignore
  63438. * Specifies if the depth of field pipeline is enabed
  63439. */
  63440. DepthOfFieldEnabled: boolean;
  63441. /**
  63442. * @ignore
  63443. * Specifies if the lens flare pipeline is enabed
  63444. */
  63445. LensFlareEnabled: boolean;
  63446. /**
  63447. * @ignore
  63448. * Specifies if the HDR pipeline is enabled
  63449. */
  63450. HDREnabled: boolean;
  63451. /**
  63452. * @ignore
  63453. * Specifies if the volumetric lights scattering effect is enabled
  63454. */
  63455. VLSEnabled: boolean;
  63456. /**
  63457. * @ignore
  63458. * Specifies if the motion blur effect is enabled
  63459. */
  63460. MotionBlurEnabled: boolean;
  63461. /**
  63462. * Specifies if anti-aliasing is enabled
  63463. */
  63464. fxaaEnabled: boolean;
  63465. /**
  63466. * Specifies the number of steps used to calculate the volumetric lights
  63467. * Typically in interval [50, 200]
  63468. */
  63469. volumetricLightStepsCount: number;
  63470. /**
  63471. * Specifies the number of samples used for the motion blur effect
  63472. * Typically in interval [16, 64]
  63473. */
  63474. motionBlurSamples: number;
  63475. /**
  63476. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63477. */
  63478. samples: number;
  63479. /**
  63480. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63481. * @constructor
  63482. * @param name The rendering pipeline name
  63483. * @param scene The scene linked to this pipeline
  63484. * @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)
  63485. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63486. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63487. */
  63488. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63489. private _buildPipeline;
  63490. private _createDownSampleX4PostProcess;
  63491. private _createBrightPassPostProcess;
  63492. private _createBlurPostProcesses;
  63493. private _createTextureAdderPostProcess;
  63494. private _createVolumetricLightPostProcess;
  63495. private _createLuminancePostProcesses;
  63496. private _createHdrPostProcess;
  63497. private _createLensFlarePostProcess;
  63498. private _createDepthOfFieldPostProcess;
  63499. private _createMotionBlurPostProcess;
  63500. private _getDepthTexture;
  63501. private _disposePostProcesses;
  63502. /**
  63503. * Dispose of the pipeline and stop all post processes
  63504. */
  63505. dispose(): void;
  63506. /**
  63507. * Serialize the rendering pipeline (Used when exporting)
  63508. * @returns the serialized object
  63509. */
  63510. serialize(): any;
  63511. /**
  63512. * Parse the serialized pipeline
  63513. * @param source Source pipeline.
  63514. * @param scene The scene to load the pipeline to.
  63515. * @param rootUrl The URL of the serialized pipeline.
  63516. * @returns An instantiated pipeline from the serialized object.
  63517. */
  63518. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63519. /**
  63520. * Luminance steps
  63521. */
  63522. static LuminanceSteps: number;
  63523. }
  63524. }
  63525. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63526. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63527. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63528. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63529. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63530. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63531. }
  63532. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63533. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63534. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63535. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63536. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63537. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63538. }
  63539. declare module "babylonjs/Shaders/tonemap.fragment" {
  63540. /** @hidden */
  63541. export var tonemapPixelShader: {
  63542. name: string;
  63543. shader: string;
  63544. };
  63545. }
  63546. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63547. import { Camera } from "babylonjs/Cameras/camera";
  63548. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63549. import "babylonjs/Shaders/tonemap.fragment";
  63550. import { Engine } from "babylonjs/Engines/engine";
  63551. /** Defines operator used for tonemapping */
  63552. export enum TonemappingOperator {
  63553. /** Hable */
  63554. Hable = 0,
  63555. /** Reinhard */
  63556. Reinhard = 1,
  63557. /** HejiDawson */
  63558. HejiDawson = 2,
  63559. /** Photographic */
  63560. Photographic = 3
  63561. }
  63562. /**
  63563. * Defines a post process to apply tone mapping
  63564. */
  63565. export class TonemapPostProcess extends PostProcess {
  63566. private _operator;
  63567. /** Defines the required exposure adjustement */
  63568. exposureAdjustment: number;
  63569. /**
  63570. * Creates a new TonemapPostProcess
  63571. * @param name defines the name of the postprocess
  63572. * @param _operator defines the operator to use
  63573. * @param exposureAdjustment defines the required exposure adjustement
  63574. * @param camera defines the camera to use (can be null)
  63575. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63576. * @param engine defines the hosting engine (can be ignore if camera is set)
  63577. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63578. */
  63579. constructor(name: string, _operator: TonemappingOperator,
  63580. /** Defines the required exposure adjustement */
  63581. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63582. }
  63583. }
  63584. declare module "babylonjs/Shaders/depth.vertex" {
  63585. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63586. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63588. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63589. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63590. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63591. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63592. /** @hidden */
  63593. export var depthVertexShader: {
  63594. name: string;
  63595. shader: string;
  63596. };
  63597. }
  63598. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63599. /** @hidden */
  63600. export var volumetricLightScatteringPixelShader: {
  63601. name: string;
  63602. shader: string;
  63603. };
  63604. }
  63605. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63606. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63608. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63609. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63610. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63611. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63612. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63613. /** @hidden */
  63614. export var volumetricLightScatteringPassVertexShader: {
  63615. name: string;
  63616. shader: string;
  63617. };
  63618. }
  63619. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63620. /** @hidden */
  63621. export var volumetricLightScatteringPassPixelShader: {
  63622. name: string;
  63623. shader: string;
  63624. };
  63625. }
  63626. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63627. import { Vector3 } from "babylonjs/Maths/math.vector";
  63628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63629. import { Mesh } from "babylonjs/Meshes/mesh";
  63630. import { Camera } from "babylonjs/Cameras/camera";
  63631. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63632. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63633. import { Scene } from "babylonjs/scene";
  63634. import "babylonjs/Meshes/Builders/planeBuilder";
  63635. import "babylonjs/Shaders/depth.vertex";
  63636. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63637. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63638. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63639. import { Engine } from "babylonjs/Engines/engine";
  63640. /**
  63641. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63642. */
  63643. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63644. private _volumetricLightScatteringPass;
  63645. private _volumetricLightScatteringRTT;
  63646. private _viewPort;
  63647. private _screenCoordinates;
  63648. private _cachedDefines;
  63649. /**
  63650. * If not undefined, the mesh position is computed from the attached node position
  63651. */
  63652. attachedNode: {
  63653. position: Vector3;
  63654. };
  63655. /**
  63656. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63657. */
  63658. customMeshPosition: Vector3;
  63659. /**
  63660. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63661. */
  63662. useCustomMeshPosition: boolean;
  63663. /**
  63664. * If the post-process should inverse the light scattering direction
  63665. */
  63666. invert: boolean;
  63667. /**
  63668. * The internal mesh used by the post-process
  63669. */
  63670. mesh: Mesh;
  63671. /**
  63672. * @hidden
  63673. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63674. */
  63675. useDiffuseColor: boolean;
  63676. /**
  63677. * Array containing the excluded meshes not rendered in the internal pass
  63678. */
  63679. excludedMeshes: AbstractMesh[];
  63680. /**
  63681. * Controls the overall intensity of the post-process
  63682. */
  63683. exposure: number;
  63684. /**
  63685. * Dissipates each sample's contribution in range [0, 1]
  63686. */
  63687. decay: number;
  63688. /**
  63689. * Controls the overall intensity of each sample
  63690. */
  63691. weight: number;
  63692. /**
  63693. * Controls the density of each sample
  63694. */
  63695. density: number;
  63696. /**
  63697. * @constructor
  63698. * @param name The post-process name
  63699. * @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)
  63700. * @param camera The camera that the post-process will be attached to
  63701. * @param mesh The mesh used to create the light scattering
  63702. * @param samples The post-process quality, default 100
  63703. * @param samplingModeThe post-process filtering mode
  63704. * @param engine The babylon engine
  63705. * @param reusable If the post-process is reusable
  63706. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63707. */
  63708. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63709. /**
  63710. * Returns the string "VolumetricLightScatteringPostProcess"
  63711. * @returns "VolumetricLightScatteringPostProcess"
  63712. */
  63713. getClassName(): string;
  63714. private _isReady;
  63715. /**
  63716. * Sets the new light position for light scattering effect
  63717. * @param position The new custom light position
  63718. */
  63719. setCustomMeshPosition(position: Vector3): void;
  63720. /**
  63721. * Returns the light position for light scattering effect
  63722. * @return Vector3 The custom light position
  63723. */
  63724. getCustomMeshPosition(): Vector3;
  63725. /**
  63726. * Disposes the internal assets and detaches the post-process from the camera
  63727. */
  63728. dispose(camera: Camera): void;
  63729. /**
  63730. * Returns the render target texture used by the post-process
  63731. * @return the render target texture used by the post-process
  63732. */
  63733. getPass(): RenderTargetTexture;
  63734. private _meshExcluded;
  63735. private _createPass;
  63736. private _updateMeshScreenCoordinates;
  63737. /**
  63738. * Creates a default mesh for the Volumeric Light Scattering post-process
  63739. * @param name The mesh name
  63740. * @param scene The scene where to create the mesh
  63741. * @return the default mesh
  63742. */
  63743. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63744. }
  63745. }
  63746. declare module "babylonjs/PostProcesses/index" {
  63747. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63748. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63749. export * from "babylonjs/PostProcesses/bloomEffect";
  63750. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63751. export * from "babylonjs/PostProcesses/blurPostProcess";
  63752. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63753. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63754. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63755. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63756. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63757. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63758. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63759. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63760. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63761. export * from "babylonjs/PostProcesses/filterPostProcess";
  63762. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63763. export * from "babylonjs/PostProcesses/grainPostProcess";
  63764. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63765. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63766. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63767. export * from "babylonjs/PostProcesses/passPostProcess";
  63768. export * from "babylonjs/PostProcesses/postProcess";
  63769. export * from "babylonjs/PostProcesses/postProcessManager";
  63770. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63771. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63772. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63773. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63774. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63775. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63776. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63777. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63778. }
  63779. declare module "babylonjs/Probes/index" {
  63780. export * from "babylonjs/Probes/reflectionProbe";
  63781. }
  63782. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63783. import { Scene } from "babylonjs/scene";
  63784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63785. import { SmartArray } from "babylonjs/Misc/smartArray";
  63786. import { ISceneComponent } from "babylonjs/sceneComponent";
  63787. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63788. import "babylonjs/Meshes/Builders/boxBuilder";
  63789. import "babylonjs/Shaders/color.fragment";
  63790. import "babylonjs/Shaders/color.vertex";
  63791. import { Color3 } from "babylonjs/Maths/math.color";
  63792. module "babylonjs/scene" {
  63793. interface Scene {
  63794. /** @hidden (Backing field) */
  63795. _boundingBoxRenderer: BoundingBoxRenderer;
  63796. /** @hidden (Backing field) */
  63797. _forceShowBoundingBoxes: boolean;
  63798. /**
  63799. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63800. */
  63801. forceShowBoundingBoxes: boolean;
  63802. /**
  63803. * Gets the bounding box renderer associated with the scene
  63804. * @returns a BoundingBoxRenderer
  63805. */
  63806. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63807. }
  63808. }
  63809. module "babylonjs/Meshes/abstractMesh" {
  63810. interface AbstractMesh {
  63811. /** @hidden (Backing field) */
  63812. _showBoundingBox: boolean;
  63813. /**
  63814. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63815. */
  63816. showBoundingBox: boolean;
  63817. }
  63818. }
  63819. /**
  63820. * Component responsible of rendering the bounding box of the meshes in a scene.
  63821. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63822. */
  63823. export class BoundingBoxRenderer implements ISceneComponent {
  63824. /**
  63825. * The component name helpfull to identify the component in the list of scene components.
  63826. */
  63827. readonly name: string;
  63828. /**
  63829. * The scene the component belongs to.
  63830. */
  63831. scene: Scene;
  63832. /**
  63833. * Color of the bounding box lines placed in front of an object
  63834. */
  63835. frontColor: Color3;
  63836. /**
  63837. * Color of the bounding box lines placed behind an object
  63838. */
  63839. backColor: Color3;
  63840. /**
  63841. * Defines if the renderer should show the back lines or not
  63842. */
  63843. showBackLines: boolean;
  63844. /**
  63845. * @hidden
  63846. */
  63847. renderList: SmartArray<BoundingBox>;
  63848. private _colorShader;
  63849. private _vertexBuffers;
  63850. private _indexBuffer;
  63851. private _fillIndexBuffer;
  63852. private _fillIndexData;
  63853. /**
  63854. * Instantiates a new bounding box renderer in a scene.
  63855. * @param scene the scene the renderer renders in
  63856. */
  63857. constructor(scene: Scene);
  63858. /**
  63859. * Registers the component in a given scene
  63860. */
  63861. register(): void;
  63862. private _evaluateSubMesh;
  63863. private _activeMesh;
  63864. private _prepareRessources;
  63865. private _createIndexBuffer;
  63866. /**
  63867. * Rebuilds the elements related to this component in case of
  63868. * context lost for instance.
  63869. */
  63870. rebuild(): void;
  63871. /**
  63872. * @hidden
  63873. */
  63874. reset(): void;
  63875. /**
  63876. * Render the bounding boxes of a specific rendering group
  63877. * @param renderingGroupId defines the rendering group to render
  63878. */
  63879. render(renderingGroupId: number): void;
  63880. /**
  63881. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63882. * @param mesh Define the mesh to render the occlusion bounding box for
  63883. */
  63884. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63885. /**
  63886. * Dispose and release the resources attached to this renderer.
  63887. */
  63888. dispose(): void;
  63889. }
  63890. }
  63891. declare module "babylonjs/Shaders/depth.fragment" {
  63892. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63893. /** @hidden */
  63894. export var depthPixelShader: {
  63895. name: string;
  63896. shader: string;
  63897. };
  63898. }
  63899. declare module "babylonjs/Rendering/depthRenderer" {
  63900. import { Nullable } from "babylonjs/types";
  63901. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63902. import { Scene } from "babylonjs/scene";
  63903. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63904. import { Camera } from "babylonjs/Cameras/camera";
  63905. import "babylonjs/Shaders/depth.fragment";
  63906. import "babylonjs/Shaders/depth.vertex";
  63907. /**
  63908. * This represents a depth renderer in Babylon.
  63909. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63910. */
  63911. export class DepthRenderer {
  63912. private _scene;
  63913. private _depthMap;
  63914. private _effect;
  63915. private readonly _storeNonLinearDepth;
  63916. private readonly _clearColor;
  63917. /** Get if the depth renderer is using packed depth or not */
  63918. readonly isPacked: boolean;
  63919. private _cachedDefines;
  63920. private _camera;
  63921. /**
  63922. * Specifiess that the depth renderer will only be used within
  63923. * the camera it is created for.
  63924. * This can help forcing its rendering during the camera processing.
  63925. */
  63926. useOnlyInActiveCamera: boolean;
  63927. /** @hidden */
  63928. static _SceneComponentInitialization: (scene: Scene) => void;
  63929. /**
  63930. * Instantiates a depth renderer
  63931. * @param scene The scene the renderer belongs to
  63932. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63933. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63934. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63935. */
  63936. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63937. /**
  63938. * Creates the depth rendering effect and checks if the effect is ready.
  63939. * @param subMesh The submesh to be used to render the depth map of
  63940. * @param useInstances If multiple world instances should be used
  63941. * @returns if the depth renderer is ready to render the depth map
  63942. */
  63943. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63944. /**
  63945. * Gets the texture which the depth map will be written to.
  63946. * @returns The depth map texture
  63947. */
  63948. getDepthMap(): RenderTargetTexture;
  63949. /**
  63950. * Disposes of the depth renderer.
  63951. */
  63952. dispose(): void;
  63953. }
  63954. }
  63955. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63956. import { Nullable } from "babylonjs/types";
  63957. import { Scene } from "babylonjs/scene";
  63958. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63959. import { Camera } from "babylonjs/Cameras/camera";
  63960. import { ISceneComponent } from "babylonjs/sceneComponent";
  63961. module "babylonjs/scene" {
  63962. interface Scene {
  63963. /** @hidden (Backing field) */
  63964. _depthRenderer: {
  63965. [id: string]: DepthRenderer;
  63966. };
  63967. /**
  63968. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63969. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63970. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63971. * @returns the created depth renderer
  63972. */
  63973. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63974. /**
  63975. * Disables a depth renderer for a given camera
  63976. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63977. */
  63978. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63979. }
  63980. }
  63981. /**
  63982. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63983. * in several rendering techniques.
  63984. */
  63985. export class DepthRendererSceneComponent implements ISceneComponent {
  63986. /**
  63987. * The component name helpfull to identify the component in the list of scene components.
  63988. */
  63989. readonly name: string;
  63990. /**
  63991. * The scene the component belongs to.
  63992. */
  63993. scene: Scene;
  63994. /**
  63995. * Creates a new instance of the component for the given scene
  63996. * @param scene Defines the scene to register the component in
  63997. */
  63998. constructor(scene: Scene);
  63999. /**
  64000. * Registers the component in a given scene
  64001. */
  64002. register(): void;
  64003. /**
  64004. * Rebuilds the elements related to this component in case of
  64005. * context lost for instance.
  64006. */
  64007. rebuild(): void;
  64008. /**
  64009. * Disposes the component and the associated ressources
  64010. */
  64011. dispose(): void;
  64012. private _gatherRenderTargets;
  64013. private _gatherActiveCameraRenderTargets;
  64014. }
  64015. }
  64016. declare module "babylonjs/Shaders/outline.fragment" {
  64017. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64018. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64019. /** @hidden */
  64020. export var outlinePixelShader: {
  64021. name: string;
  64022. shader: string;
  64023. };
  64024. }
  64025. declare module "babylonjs/Shaders/outline.vertex" {
  64026. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64027. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64028. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64029. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64030. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64031. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64032. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64033. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64034. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64035. /** @hidden */
  64036. export var outlineVertexShader: {
  64037. name: string;
  64038. shader: string;
  64039. };
  64040. }
  64041. declare module "babylonjs/Rendering/outlineRenderer" {
  64042. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64043. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64044. import { Scene } from "babylonjs/scene";
  64045. import { ISceneComponent } from "babylonjs/sceneComponent";
  64046. import "babylonjs/Shaders/outline.fragment";
  64047. import "babylonjs/Shaders/outline.vertex";
  64048. module "babylonjs/scene" {
  64049. interface Scene {
  64050. /** @hidden */
  64051. _outlineRenderer: OutlineRenderer;
  64052. /**
  64053. * Gets the outline renderer associated with the scene
  64054. * @returns a OutlineRenderer
  64055. */
  64056. getOutlineRenderer(): OutlineRenderer;
  64057. }
  64058. }
  64059. module "babylonjs/Meshes/abstractMesh" {
  64060. interface AbstractMesh {
  64061. /** @hidden (Backing field) */
  64062. _renderOutline: boolean;
  64063. /**
  64064. * Gets or sets a boolean indicating if the outline must be rendered as well
  64065. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64066. */
  64067. renderOutline: boolean;
  64068. /** @hidden (Backing field) */
  64069. _renderOverlay: boolean;
  64070. /**
  64071. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64072. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64073. */
  64074. renderOverlay: boolean;
  64075. }
  64076. }
  64077. /**
  64078. * This class is responsible to draw bothe outline/overlay of meshes.
  64079. * It should not be used directly but through the available method on mesh.
  64080. */
  64081. export class OutlineRenderer implements ISceneComponent {
  64082. /**
  64083. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64084. */
  64085. private static _StencilReference;
  64086. /**
  64087. * The name of the component. Each component must have a unique name.
  64088. */
  64089. name: string;
  64090. /**
  64091. * The scene the component belongs to.
  64092. */
  64093. scene: Scene;
  64094. /**
  64095. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64096. */
  64097. zOffset: number;
  64098. private _engine;
  64099. private _effect;
  64100. private _cachedDefines;
  64101. private _savedDepthWrite;
  64102. /**
  64103. * Instantiates a new outline renderer. (There could be only one per scene).
  64104. * @param scene Defines the scene it belongs to
  64105. */
  64106. constructor(scene: Scene);
  64107. /**
  64108. * Register the component to one instance of a scene.
  64109. */
  64110. register(): void;
  64111. /**
  64112. * Rebuilds the elements related to this component in case of
  64113. * context lost for instance.
  64114. */
  64115. rebuild(): void;
  64116. /**
  64117. * Disposes the component and the associated ressources.
  64118. */
  64119. dispose(): void;
  64120. /**
  64121. * Renders the outline in the canvas.
  64122. * @param subMesh Defines the sumesh to render
  64123. * @param batch Defines the batch of meshes in case of instances
  64124. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64125. */
  64126. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64127. /**
  64128. * Returns whether or not the outline renderer is ready for a given submesh.
  64129. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64130. * @param subMesh Defines the submesh to check readyness for
  64131. * @param useInstances Defines wheter wee are trying to render instances or not
  64132. * @returns true if ready otherwise false
  64133. */
  64134. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64135. private _beforeRenderingMesh;
  64136. private _afterRenderingMesh;
  64137. }
  64138. }
  64139. declare module "babylonjs/Rendering/index" {
  64140. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64141. export * from "babylonjs/Rendering/depthRenderer";
  64142. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64143. export * from "babylonjs/Rendering/edgesRenderer";
  64144. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64145. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64146. export * from "babylonjs/Rendering/outlineRenderer";
  64147. export * from "babylonjs/Rendering/renderingGroup";
  64148. export * from "babylonjs/Rendering/renderingManager";
  64149. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64150. }
  64151. declare module "babylonjs/Sprites/spritePackedManager" {
  64152. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64153. import { Scene } from "babylonjs/scene";
  64154. /**
  64155. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64156. * @see http://doc.babylonjs.com/babylon101/sprites
  64157. */
  64158. export class SpritePackedManager extends SpriteManager {
  64159. /** defines the packed manager's name */
  64160. name: string;
  64161. /**
  64162. * Creates a new sprite manager from a packed sprite sheet
  64163. * @param name defines the manager's name
  64164. * @param imgUrl defines the sprite sheet url
  64165. * @param capacity defines the maximum allowed number of sprites
  64166. * @param scene defines the hosting scene
  64167. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64168. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64169. * @param samplingMode defines the smapling mode to use with spritesheet
  64170. * @param fromPacked set to true; do not alter
  64171. */
  64172. constructor(
  64173. /** defines the packed manager's name */
  64174. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64175. }
  64176. }
  64177. declare module "babylonjs/Sprites/index" {
  64178. export * from "babylonjs/Sprites/sprite";
  64179. export * from "babylonjs/Sprites/spriteManager";
  64180. export * from "babylonjs/Sprites/spritePackedManager";
  64181. export * from "babylonjs/Sprites/spriteSceneComponent";
  64182. }
  64183. declare module "babylonjs/Misc/assetsManager" {
  64184. import { Scene } from "babylonjs/scene";
  64185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64186. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64187. import { Skeleton } from "babylonjs/Bones/skeleton";
  64188. import { Observable } from "babylonjs/Misc/observable";
  64189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64190. import { Texture } from "babylonjs/Materials/Textures/texture";
  64191. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64192. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64193. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64194. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64195. /**
  64196. * Defines the list of states available for a task inside a AssetsManager
  64197. */
  64198. export enum AssetTaskState {
  64199. /**
  64200. * Initialization
  64201. */
  64202. INIT = 0,
  64203. /**
  64204. * Running
  64205. */
  64206. RUNNING = 1,
  64207. /**
  64208. * Done
  64209. */
  64210. DONE = 2,
  64211. /**
  64212. * Error
  64213. */
  64214. ERROR = 3
  64215. }
  64216. /**
  64217. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64218. */
  64219. export abstract class AbstractAssetTask {
  64220. /**
  64221. * Task name
  64222. */ name: string;
  64223. /**
  64224. * Callback called when the task is successful
  64225. */
  64226. onSuccess: (task: any) => void;
  64227. /**
  64228. * Callback called when the task is not successful
  64229. */
  64230. onError: (task: any, message?: string, exception?: any) => void;
  64231. /**
  64232. * Creates a new AssetsManager
  64233. * @param name defines the name of the task
  64234. */
  64235. constructor(
  64236. /**
  64237. * Task name
  64238. */ name: string);
  64239. private _isCompleted;
  64240. private _taskState;
  64241. private _errorObject;
  64242. /**
  64243. * Get if the task is completed
  64244. */
  64245. readonly isCompleted: boolean;
  64246. /**
  64247. * Gets the current state of the task
  64248. */
  64249. readonly taskState: AssetTaskState;
  64250. /**
  64251. * Gets the current error object (if task is in error)
  64252. */
  64253. readonly errorObject: {
  64254. message?: string;
  64255. exception?: any;
  64256. };
  64257. /**
  64258. * Internal only
  64259. * @hidden
  64260. */
  64261. _setErrorObject(message?: string, exception?: any): void;
  64262. /**
  64263. * Execute the current task
  64264. * @param scene defines the scene where you want your assets to be loaded
  64265. * @param onSuccess is a callback called when the task is successfully executed
  64266. * @param onError is a callback called if an error occurs
  64267. */
  64268. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64269. /**
  64270. * Execute the current task
  64271. * @param scene defines the scene where you want your assets to be loaded
  64272. * @param onSuccess is a callback called when the task is successfully executed
  64273. * @param onError is a callback called if an error occurs
  64274. */
  64275. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64276. /**
  64277. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64278. * This can be used with failed tasks that have the reason for failure fixed.
  64279. */
  64280. reset(): void;
  64281. private onErrorCallback;
  64282. private onDoneCallback;
  64283. }
  64284. /**
  64285. * Define the interface used by progress events raised during assets loading
  64286. */
  64287. export interface IAssetsProgressEvent {
  64288. /**
  64289. * Defines the number of remaining tasks to process
  64290. */
  64291. remainingCount: number;
  64292. /**
  64293. * Defines the total number of tasks
  64294. */
  64295. totalCount: number;
  64296. /**
  64297. * Defines the task that was just processed
  64298. */
  64299. task: AbstractAssetTask;
  64300. }
  64301. /**
  64302. * Class used to share progress information about assets loading
  64303. */
  64304. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64305. /**
  64306. * Defines the number of remaining tasks to process
  64307. */
  64308. remainingCount: number;
  64309. /**
  64310. * Defines the total number of tasks
  64311. */
  64312. totalCount: number;
  64313. /**
  64314. * Defines the task that was just processed
  64315. */
  64316. task: AbstractAssetTask;
  64317. /**
  64318. * Creates a AssetsProgressEvent
  64319. * @param remainingCount defines the number of remaining tasks to process
  64320. * @param totalCount defines the total number of tasks
  64321. * @param task defines the task that was just processed
  64322. */
  64323. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64324. }
  64325. /**
  64326. * Define a task used by AssetsManager to load meshes
  64327. */
  64328. export class MeshAssetTask extends AbstractAssetTask {
  64329. /**
  64330. * Defines the name of the task
  64331. */
  64332. name: string;
  64333. /**
  64334. * Defines the list of mesh's names you want to load
  64335. */
  64336. meshesNames: any;
  64337. /**
  64338. * Defines the root url to use as a base to load your meshes and associated resources
  64339. */
  64340. rootUrl: string;
  64341. /**
  64342. * Defines the filename of the scene to load from
  64343. */
  64344. sceneFilename: string;
  64345. /**
  64346. * Gets the list of loaded meshes
  64347. */
  64348. loadedMeshes: Array<AbstractMesh>;
  64349. /**
  64350. * Gets the list of loaded particle systems
  64351. */
  64352. loadedParticleSystems: Array<IParticleSystem>;
  64353. /**
  64354. * Gets the list of loaded skeletons
  64355. */
  64356. loadedSkeletons: Array<Skeleton>;
  64357. /**
  64358. * Gets the list of loaded animation groups
  64359. */
  64360. loadedAnimationGroups: Array<AnimationGroup>;
  64361. /**
  64362. * Callback called when the task is successful
  64363. */
  64364. onSuccess: (task: MeshAssetTask) => void;
  64365. /**
  64366. * Callback called when the task is successful
  64367. */
  64368. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64369. /**
  64370. * Creates a new MeshAssetTask
  64371. * @param name defines the name of the task
  64372. * @param meshesNames defines the list of mesh's names you want to load
  64373. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64374. * @param sceneFilename defines the filename of the scene to load from
  64375. */
  64376. constructor(
  64377. /**
  64378. * Defines the name of the task
  64379. */
  64380. name: string,
  64381. /**
  64382. * Defines the list of mesh's names you want to load
  64383. */
  64384. meshesNames: any,
  64385. /**
  64386. * Defines the root url to use as a base to load your meshes and associated resources
  64387. */
  64388. rootUrl: string,
  64389. /**
  64390. * Defines the filename of the scene to load from
  64391. */
  64392. sceneFilename: string);
  64393. /**
  64394. * Execute the current task
  64395. * @param scene defines the scene where you want your assets to be loaded
  64396. * @param onSuccess is a callback called when the task is successfully executed
  64397. * @param onError is a callback called if an error occurs
  64398. */
  64399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64400. }
  64401. /**
  64402. * Define a task used by AssetsManager to load text content
  64403. */
  64404. export class TextFileAssetTask extends AbstractAssetTask {
  64405. /**
  64406. * Defines the name of the task
  64407. */
  64408. name: string;
  64409. /**
  64410. * Defines the location of the file to load
  64411. */
  64412. url: string;
  64413. /**
  64414. * Gets the loaded text string
  64415. */
  64416. text: string;
  64417. /**
  64418. * Callback called when the task is successful
  64419. */
  64420. onSuccess: (task: TextFileAssetTask) => void;
  64421. /**
  64422. * Callback called when the task is successful
  64423. */
  64424. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64425. /**
  64426. * Creates a new TextFileAssetTask object
  64427. * @param name defines the name of the task
  64428. * @param url defines the location of the file to load
  64429. */
  64430. constructor(
  64431. /**
  64432. * Defines the name of the task
  64433. */
  64434. name: string,
  64435. /**
  64436. * Defines the location of the file to load
  64437. */
  64438. url: string);
  64439. /**
  64440. * Execute the current task
  64441. * @param scene defines the scene where you want your assets to be loaded
  64442. * @param onSuccess is a callback called when the task is successfully executed
  64443. * @param onError is a callback called if an error occurs
  64444. */
  64445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64446. }
  64447. /**
  64448. * Define a task used by AssetsManager to load binary data
  64449. */
  64450. export class BinaryFileAssetTask extends AbstractAssetTask {
  64451. /**
  64452. * Defines the name of the task
  64453. */
  64454. name: string;
  64455. /**
  64456. * Defines the location of the file to load
  64457. */
  64458. url: string;
  64459. /**
  64460. * Gets the lodaded data (as an array buffer)
  64461. */
  64462. data: ArrayBuffer;
  64463. /**
  64464. * Callback called when the task is successful
  64465. */
  64466. onSuccess: (task: BinaryFileAssetTask) => void;
  64467. /**
  64468. * Callback called when the task is successful
  64469. */
  64470. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64471. /**
  64472. * Creates a new BinaryFileAssetTask object
  64473. * @param name defines the name of the new task
  64474. * @param url defines the location of the file to load
  64475. */
  64476. constructor(
  64477. /**
  64478. * Defines the name of the task
  64479. */
  64480. name: string,
  64481. /**
  64482. * Defines the location of the file to load
  64483. */
  64484. url: string);
  64485. /**
  64486. * Execute the current task
  64487. * @param scene defines the scene where you want your assets to be loaded
  64488. * @param onSuccess is a callback called when the task is successfully executed
  64489. * @param onError is a callback called if an error occurs
  64490. */
  64491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64492. }
  64493. /**
  64494. * Define a task used by AssetsManager to load images
  64495. */
  64496. export class ImageAssetTask extends AbstractAssetTask {
  64497. /**
  64498. * Defines the name of the task
  64499. */
  64500. name: string;
  64501. /**
  64502. * Defines the location of the image to load
  64503. */
  64504. url: string;
  64505. /**
  64506. * Gets the loaded images
  64507. */
  64508. image: HTMLImageElement;
  64509. /**
  64510. * Callback called when the task is successful
  64511. */
  64512. onSuccess: (task: ImageAssetTask) => void;
  64513. /**
  64514. * Callback called when the task is successful
  64515. */
  64516. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64517. /**
  64518. * Creates a new ImageAssetTask
  64519. * @param name defines the name of the task
  64520. * @param url defines the location of the image to load
  64521. */
  64522. constructor(
  64523. /**
  64524. * Defines the name of the task
  64525. */
  64526. name: string,
  64527. /**
  64528. * Defines the location of the image to load
  64529. */
  64530. url: string);
  64531. /**
  64532. * Execute the current task
  64533. * @param scene defines the scene where you want your assets to be loaded
  64534. * @param onSuccess is a callback called when the task is successfully executed
  64535. * @param onError is a callback called if an error occurs
  64536. */
  64537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64538. }
  64539. /**
  64540. * Defines the interface used by texture loading tasks
  64541. */
  64542. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64543. /**
  64544. * Gets the loaded texture
  64545. */
  64546. texture: TEX;
  64547. }
  64548. /**
  64549. * Define a task used by AssetsManager to load 2D textures
  64550. */
  64551. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64552. /**
  64553. * Defines the name of the task
  64554. */
  64555. name: string;
  64556. /**
  64557. * Defines the location of the file to load
  64558. */
  64559. url: string;
  64560. /**
  64561. * Defines if mipmap should not be generated (default is false)
  64562. */
  64563. noMipmap?: boolean | undefined;
  64564. /**
  64565. * Defines if texture must be inverted on Y axis (default is false)
  64566. */
  64567. invertY?: boolean | undefined;
  64568. /**
  64569. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64570. */
  64571. samplingMode: number;
  64572. /**
  64573. * Gets the loaded texture
  64574. */
  64575. texture: Texture;
  64576. /**
  64577. * Callback called when the task is successful
  64578. */
  64579. onSuccess: (task: TextureAssetTask) => void;
  64580. /**
  64581. * Callback called when the task is successful
  64582. */
  64583. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64584. /**
  64585. * Creates a new TextureAssetTask object
  64586. * @param name defines the name of the task
  64587. * @param url defines the location of the file to load
  64588. * @param noMipmap defines if mipmap should not be generated (default is false)
  64589. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64590. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64591. */
  64592. constructor(
  64593. /**
  64594. * Defines the name of the task
  64595. */
  64596. name: string,
  64597. /**
  64598. * Defines the location of the file to load
  64599. */
  64600. url: string,
  64601. /**
  64602. * Defines if mipmap should not be generated (default is false)
  64603. */
  64604. noMipmap?: boolean | undefined,
  64605. /**
  64606. * Defines if texture must be inverted on Y axis (default is false)
  64607. */
  64608. invertY?: boolean | undefined,
  64609. /**
  64610. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64611. */
  64612. samplingMode?: number);
  64613. /**
  64614. * Execute the current task
  64615. * @param scene defines the scene where you want your assets to be loaded
  64616. * @param onSuccess is a callback called when the task is successfully executed
  64617. * @param onError is a callback called if an error occurs
  64618. */
  64619. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64620. }
  64621. /**
  64622. * Define a task used by AssetsManager to load cube textures
  64623. */
  64624. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64625. /**
  64626. * Defines the name of the task
  64627. */
  64628. name: string;
  64629. /**
  64630. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64631. */
  64632. url: string;
  64633. /**
  64634. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64635. */
  64636. extensions?: string[] | undefined;
  64637. /**
  64638. * Defines if mipmaps should not be generated (default is false)
  64639. */
  64640. noMipmap?: boolean | undefined;
  64641. /**
  64642. * Defines the explicit list of files (undefined by default)
  64643. */
  64644. files?: string[] | undefined;
  64645. /**
  64646. * Gets the loaded texture
  64647. */
  64648. texture: CubeTexture;
  64649. /**
  64650. * Callback called when the task is successful
  64651. */
  64652. onSuccess: (task: CubeTextureAssetTask) => void;
  64653. /**
  64654. * Callback called when the task is successful
  64655. */
  64656. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64657. /**
  64658. * Creates a new CubeTextureAssetTask
  64659. * @param name defines the name of the task
  64660. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64661. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64662. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64663. * @param files defines the explicit list of files (undefined by default)
  64664. */
  64665. constructor(
  64666. /**
  64667. * Defines the name of the task
  64668. */
  64669. name: string,
  64670. /**
  64671. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64672. */
  64673. url: string,
  64674. /**
  64675. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64676. */
  64677. extensions?: string[] | undefined,
  64678. /**
  64679. * Defines if mipmaps should not be generated (default is false)
  64680. */
  64681. noMipmap?: boolean | undefined,
  64682. /**
  64683. * Defines the explicit list of files (undefined by default)
  64684. */
  64685. files?: string[] | undefined);
  64686. /**
  64687. * Execute the current task
  64688. * @param scene defines the scene where you want your assets to be loaded
  64689. * @param onSuccess is a callback called when the task is successfully executed
  64690. * @param onError is a callback called if an error occurs
  64691. */
  64692. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64693. }
  64694. /**
  64695. * Define a task used by AssetsManager to load HDR cube textures
  64696. */
  64697. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64698. /**
  64699. * Defines the name of the task
  64700. */
  64701. name: string;
  64702. /**
  64703. * Defines the location of the file to load
  64704. */
  64705. url: string;
  64706. /**
  64707. * Defines the desired size (the more it increases the longer the generation will be)
  64708. */
  64709. size: number;
  64710. /**
  64711. * Defines if mipmaps should not be generated (default is false)
  64712. */
  64713. noMipmap: boolean;
  64714. /**
  64715. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64716. */
  64717. generateHarmonics: boolean;
  64718. /**
  64719. * 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)
  64720. */
  64721. gammaSpace: boolean;
  64722. /**
  64723. * Internal Use Only
  64724. */
  64725. reserved: boolean;
  64726. /**
  64727. * Gets the loaded texture
  64728. */
  64729. texture: HDRCubeTexture;
  64730. /**
  64731. * Callback called when the task is successful
  64732. */
  64733. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64734. /**
  64735. * Callback called when the task is successful
  64736. */
  64737. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64738. /**
  64739. * Creates a new HDRCubeTextureAssetTask object
  64740. * @param name defines the name of the task
  64741. * @param url defines the location of the file to load
  64742. * @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.
  64743. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64744. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64745. * @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)
  64746. * @param reserved Internal use only
  64747. */
  64748. constructor(
  64749. /**
  64750. * Defines the name of the task
  64751. */
  64752. name: string,
  64753. /**
  64754. * Defines the location of the file to load
  64755. */
  64756. url: string,
  64757. /**
  64758. * Defines the desired size (the more it increases the longer the generation will be)
  64759. */
  64760. size: number,
  64761. /**
  64762. * Defines if mipmaps should not be generated (default is false)
  64763. */
  64764. noMipmap?: boolean,
  64765. /**
  64766. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64767. */
  64768. generateHarmonics?: boolean,
  64769. /**
  64770. * 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)
  64771. */
  64772. gammaSpace?: boolean,
  64773. /**
  64774. * Internal Use Only
  64775. */
  64776. reserved?: boolean);
  64777. /**
  64778. * Execute the current task
  64779. * @param scene defines the scene where you want your assets to be loaded
  64780. * @param onSuccess is a callback called when the task is successfully executed
  64781. * @param onError is a callback called if an error occurs
  64782. */
  64783. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64784. }
  64785. /**
  64786. * Define a task used by AssetsManager to load Equirectangular cube textures
  64787. */
  64788. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64789. /**
  64790. * Defines the name of the task
  64791. */
  64792. name: string;
  64793. /**
  64794. * Defines the location of the file to load
  64795. */
  64796. url: string;
  64797. /**
  64798. * Defines the desired size (the more it increases the longer the generation will be)
  64799. */
  64800. size: number;
  64801. /**
  64802. * Defines if mipmaps should not be generated (default is false)
  64803. */
  64804. noMipmap: boolean;
  64805. /**
  64806. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64807. * but the standard material would require them in Gamma space) (default is true)
  64808. */
  64809. gammaSpace: boolean;
  64810. /**
  64811. * Gets the loaded texture
  64812. */
  64813. texture: EquiRectangularCubeTexture;
  64814. /**
  64815. * Callback called when the task is successful
  64816. */
  64817. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64818. /**
  64819. * Callback called when the task is successful
  64820. */
  64821. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64822. /**
  64823. * Creates a new EquiRectangularCubeTextureAssetTask object
  64824. * @param name defines the name of the task
  64825. * @param url defines the location of the file to load
  64826. * @param size defines the desired size (the more it increases the longer the generation will be)
  64827. * If the size is omitted this implies you are using a preprocessed cubemap.
  64828. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64829. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64830. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64831. * (default is true)
  64832. */
  64833. constructor(
  64834. /**
  64835. * Defines the name of the task
  64836. */
  64837. name: string,
  64838. /**
  64839. * Defines the location of the file to load
  64840. */
  64841. url: string,
  64842. /**
  64843. * Defines the desired size (the more it increases the longer the generation will be)
  64844. */
  64845. size: number,
  64846. /**
  64847. * Defines if mipmaps should not be generated (default is false)
  64848. */
  64849. noMipmap?: boolean,
  64850. /**
  64851. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64852. * but the standard material would require them in Gamma space) (default is true)
  64853. */
  64854. gammaSpace?: boolean);
  64855. /**
  64856. * Execute the current task
  64857. * @param scene defines the scene where you want your assets to be loaded
  64858. * @param onSuccess is a callback called when the task is successfully executed
  64859. * @param onError is a callback called if an error occurs
  64860. */
  64861. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64862. }
  64863. /**
  64864. * This class can be used to easily import assets into a scene
  64865. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64866. */
  64867. export class AssetsManager {
  64868. private _scene;
  64869. private _isLoading;
  64870. protected _tasks: AbstractAssetTask[];
  64871. protected _waitingTasksCount: number;
  64872. protected _totalTasksCount: number;
  64873. /**
  64874. * Callback called when all tasks are processed
  64875. */
  64876. onFinish: (tasks: AbstractAssetTask[]) => void;
  64877. /**
  64878. * Callback called when a task is successful
  64879. */
  64880. onTaskSuccess: (task: AbstractAssetTask) => void;
  64881. /**
  64882. * Callback called when a task had an error
  64883. */
  64884. onTaskError: (task: AbstractAssetTask) => void;
  64885. /**
  64886. * Callback called when a task is done (whatever the result is)
  64887. */
  64888. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64889. /**
  64890. * Observable called when all tasks are processed
  64891. */
  64892. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64893. /**
  64894. * Observable called when a task had an error
  64895. */
  64896. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64897. /**
  64898. * Observable called when all tasks were executed
  64899. */
  64900. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64901. /**
  64902. * Observable called when a task is done (whatever the result is)
  64903. */
  64904. onProgressObservable: Observable<IAssetsProgressEvent>;
  64905. /**
  64906. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64907. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64908. */
  64909. useDefaultLoadingScreen: boolean;
  64910. /**
  64911. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64912. * when all assets have been downloaded.
  64913. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64914. */
  64915. autoHideLoadingUI: boolean;
  64916. /**
  64917. * Creates a new AssetsManager
  64918. * @param scene defines the scene to work on
  64919. */
  64920. constructor(scene: Scene);
  64921. /**
  64922. * Add a MeshAssetTask to the list of active tasks
  64923. * @param taskName defines the name of the new task
  64924. * @param meshesNames defines the name of meshes to load
  64925. * @param rootUrl defines the root url to use to locate files
  64926. * @param sceneFilename defines the filename of the scene file
  64927. * @returns a new MeshAssetTask object
  64928. */
  64929. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64930. /**
  64931. * Add a TextFileAssetTask to the list of active tasks
  64932. * @param taskName defines the name of the new task
  64933. * @param url defines the url of the file to load
  64934. * @returns a new TextFileAssetTask object
  64935. */
  64936. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64937. /**
  64938. * Add a BinaryFileAssetTask to the list of active tasks
  64939. * @param taskName defines the name of the new task
  64940. * @param url defines the url of the file to load
  64941. * @returns a new BinaryFileAssetTask object
  64942. */
  64943. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64944. /**
  64945. * Add a ImageAssetTask to the list of active tasks
  64946. * @param taskName defines the name of the new task
  64947. * @param url defines the url of the file to load
  64948. * @returns a new ImageAssetTask object
  64949. */
  64950. addImageTask(taskName: string, url: string): ImageAssetTask;
  64951. /**
  64952. * Add a TextureAssetTask to the list of active tasks
  64953. * @param taskName defines the name of the new task
  64954. * @param url defines the url of the file to load
  64955. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64956. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64957. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64958. * @returns a new TextureAssetTask object
  64959. */
  64960. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64961. /**
  64962. * Add a CubeTextureAssetTask to the list of active tasks
  64963. * @param taskName defines the name of the new task
  64964. * @param url defines the url of the file to load
  64965. * @param extensions defines the extension to use to load the cube map (can be null)
  64966. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64967. * @param files defines the list of files to load (can be null)
  64968. * @returns a new CubeTextureAssetTask object
  64969. */
  64970. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64971. /**
  64972. *
  64973. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64974. * @param taskName defines the name of the new task
  64975. * @param url defines the url of the file to load
  64976. * @param size defines the size you want for the cubemap (can be null)
  64977. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64978. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64979. * @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)
  64980. * @param reserved Internal use only
  64981. * @returns a new HDRCubeTextureAssetTask object
  64982. */
  64983. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64984. /**
  64985. *
  64986. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64987. * @param taskName defines the name of the new task
  64988. * @param url defines the url of the file to load
  64989. * @param size defines the size you want for the cubemap (can be null)
  64990. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64991. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64992. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64993. * @returns a new EquiRectangularCubeTextureAssetTask object
  64994. */
  64995. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64996. /**
  64997. * Remove a task from the assets manager.
  64998. * @param task the task to remove
  64999. */
  65000. removeTask(task: AbstractAssetTask): void;
  65001. private _decreaseWaitingTasksCount;
  65002. private _runTask;
  65003. /**
  65004. * Reset the AssetsManager and remove all tasks
  65005. * @return the current instance of the AssetsManager
  65006. */
  65007. reset(): AssetsManager;
  65008. /**
  65009. * Start the loading process
  65010. * @return the current instance of the AssetsManager
  65011. */
  65012. load(): AssetsManager;
  65013. /**
  65014. * Start the loading process as an async operation
  65015. * @return a promise returning the list of failed tasks
  65016. */
  65017. loadAsync(): Promise<void>;
  65018. }
  65019. }
  65020. declare module "babylonjs/Misc/deferred" {
  65021. /**
  65022. * Wrapper class for promise with external resolve and reject.
  65023. */
  65024. export class Deferred<T> {
  65025. /**
  65026. * The promise associated with this deferred object.
  65027. */
  65028. readonly promise: Promise<T>;
  65029. private _resolve;
  65030. private _reject;
  65031. /**
  65032. * The resolve method of the promise associated with this deferred object.
  65033. */
  65034. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65035. /**
  65036. * The reject method of the promise associated with this deferred object.
  65037. */
  65038. readonly reject: (reason?: any) => void;
  65039. /**
  65040. * Constructor for this deferred object.
  65041. */
  65042. constructor();
  65043. }
  65044. }
  65045. declare module "babylonjs/Misc/meshExploder" {
  65046. import { Mesh } from "babylonjs/Meshes/mesh";
  65047. /**
  65048. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65049. */
  65050. export class MeshExploder {
  65051. private _centerMesh;
  65052. private _meshes;
  65053. private _meshesOrigins;
  65054. private _toCenterVectors;
  65055. private _scaledDirection;
  65056. private _newPosition;
  65057. private _centerPosition;
  65058. /**
  65059. * Explodes meshes from a center mesh.
  65060. * @param meshes The meshes to explode.
  65061. * @param centerMesh The mesh to be center of explosion.
  65062. */
  65063. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65064. private _setCenterMesh;
  65065. /**
  65066. * Get class name
  65067. * @returns "MeshExploder"
  65068. */
  65069. getClassName(): string;
  65070. /**
  65071. * "Exploded meshes"
  65072. * @returns Array of meshes with the centerMesh at index 0.
  65073. */
  65074. getMeshes(): Array<Mesh>;
  65075. /**
  65076. * Explodes meshes giving a specific direction
  65077. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65078. */
  65079. explode(direction?: number): void;
  65080. }
  65081. }
  65082. declare module "babylonjs/Misc/filesInput" {
  65083. import { Engine } from "babylonjs/Engines/engine";
  65084. import { Scene } from "babylonjs/scene";
  65085. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65086. /**
  65087. * Class used to help managing file picking and drag'n'drop
  65088. */
  65089. export class FilesInput {
  65090. /**
  65091. * List of files ready to be loaded
  65092. */
  65093. static readonly FilesToLoad: {
  65094. [key: string]: File;
  65095. };
  65096. /**
  65097. * Callback called when a file is processed
  65098. */
  65099. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65100. private _engine;
  65101. private _currentScene;
  65102. private _sceneLoadedCallback;
  65103. private _progressCallback;
  65104. private _additionalRenderLoopLogicCallback;
  65105. private _textureLoadingCallback;
  65106. private _startingProcessingFilesCallback;
  65107. private _onReloadCallback;
  65108. private _errorCallback;
  65109. private _elementToMonitor;
  65110. private _sceneFileToLoad;
  65111. private _filesToLoad;
  65112. /**
  65113. * Creates a new FilesInput
  65114. * @param engine defines the rendering engine
  65115. * @param scene defines the hosting scene
  65116. * @param sceneLoadedCallback callback called when scene is loaded
  65117. * @param progressCallback callback called to track progress
  65118. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65119. * @param textureLoadingCallback callback called when a texture is loading
  65120. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65121. * @param onReloadCallback callback called when a reload is requested
  65122. * @param errorCallback callback call if an error occurs
  65123. */
  65124. 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);
  65125. private _dragEnterHandler;
  65126. private _dragOverHandler;
  65127. private _dropHandler;
  65128. /**
  65129. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65130. * @param elementToMonitor defines the DOM element to track
  65131. */
  65132. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65133. /**
  65134. * Release all associated resources
  65135. */
  65136. dispose(): void;
  65137. private renderFunction;
  65138. private drag;
  65139. private drop;
  65140. private _traverseFolder;
  65141. private _processFiles;
  65142. /**
  65143. * Load files from a drop event
  65144. * @param event defines the drop event to use as source
  65145. */
  65146. loadFiles(event: any): void;
  65147. private _processReload;
  65148. /**
  65149. * Reload the current scene from the loaded files
  65150. */
  65151. reload(): void;
  65152. }
  65153. }
  65154. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65155. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65156. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65157. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65158. }
  65159. declare module "babylonjs/Misc/performanceMonitor" {
  65160. import { IPerformanceMonitor } from "babylonjs/Misc/IPerformanceMonitor";
  65161. /**
  65162. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65163. */
  65164. export class PerformanceMonitor implements IPerformanceMonitor {
  65165. private _enabled;
  65166. private _rollingFrameTime;
  65167. private _lastFrameTimeMs;
  65168. /**
  65169. * constructor
  65170. * @param frameSampleSize The number of samples required to saturate the sliding window
  65171. */
  65172. constructor(frameSampleSize?: number);
  65173. /**
  65174. * Samples current frame
  65175. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65176. */
  65177. sampleFrame(timeMs?: number): void;
  65178. /**
  65179. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65180. */
  65181. readonly averageFrameTime: number;
  65182. /**
  65183. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65184. */
  65185. readonly averageFrameTimeVariance: number;
  65186. /**
  65187. * Returns the frame time of the most recent frame
  65188. */
  65189. readonly instantaneousFrameTime: number;
  65190. /**
  65191. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65192. */
  65193. readonly averageFPS: number;
  65194. /**
  65195. * Returns the average framerate in frames per second using the most recent frame time
  65196. */
  65197. readonly instantaneousFPS: number;
  65198. /**
  65199. * Returns true if enough samples have been taken to completely fill the sliding window
  65200. */
  65201. readonly isSaturated: boolean;
  65202. /**
  65203. * Enables contributions to the sliding window sample set
  65204. */
  65205. enable(): void;
  65206. /**
  65207. * Disables contributions to the sliding window sample set
  65208. * Samples will not be interpolated over the disabled period
  65209. */
  65210. disable(): void;
  65211. /**
  65212. * Returns true if sampling is enabled
  65213. */
  65214. readonly isEnabled: boolean;
  65215. /**
  65216. * Resets performance monitor
  65217. */
  65218. reset(): void;
  65219. }
  65220. /**
  65221. * RollingAverage
  65222. *
  65223. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65224. */
  65225. export class RollingAverage {
  65226. /**
  65227. * Current average
  65228. */
  65229. average: number;
  65230. /**
  65231. * Current variance
  65232. */
  65233. variance: number;
  65234. protected _samples: Array<number>;
  65235. protected _sampleCount: number;
  65236. protected _pos: number;
  65237. protected _m2: number;
  65238. /**
  65239. * constructor
  65240. * @param length The number of samples required to saturate the sliding window
  65241. */
  65242. constructor(length: number);
  65243. /**
  65244. * Adds a sample to the sample set
  65245. * @param v The sample value
  65246. */
  65247. add(v: number): void;
  65248. /**
  65249. * Returns previously added values or null if outside of history or outside the sliding window domain
  65250. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65251. * @return Value previously recorded with add() or null if outside of range
  65252. */
  65253. history(i: number): number;
  65254. /**
  65255. * Returns true if enough samples have been taken to completely fill the sliding window
  65256. * @return true if sample-set saturated
  65257. */
  65258. isSaturated(): boolean;
  65259. /**
  65260. * Resets the rolling average (equivalent to 0 samples taken so far)
  65261. */
  65262. reset(): void;
  65263. /**
  65264. * Wraps a value around the sample range boundaries
  65265. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65266. * @return Wrapped position in sample range
  65267. */
  65268. protected _wrapPosition(i: number): number;
  65269. }
  65270. }
  65271. declare module "babylonjs/Misc/sceneOptimizer" {
  65272. import { Scene, IDisposable } from "babylonjs/scene";
  65273. import { Observable } from "babylonjs/Misc/observable";
  65274. /**
  65275. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65277. */
  65278. export class SceneOptimization {
  65279. /**
  65280. * Defines the priority of this optimization (0 by default which means first in the list)
  65281. */
  65282. priority: number;
  65283. /**
  65284. * Gets a string describing the action executed by the current optimization
  65285. * @returns description string
  65286. */
  65287. getDescription(): string;
  65288. /**
  65289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65290. * @param scene defines the current scene where to apply this optimization
  65291. * @param optimizer defines the current optimizer
  65292. * @returns true if everything that can be done was applied
  65293. */
  65294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65295. /**
  65296. * Creates the SceneOptimization object
  65297. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65298. * @param desc defines the description associated with the optimization
  65299. */
  65300. constructor(
  65301. /**
  65302. * Defines the priority of this optimization (0 by default which means first in the list)
  65303. */
  65304. priority?: number);
  65305. }
  65306. /**
  65307. * Defines an optimization used to reduce the size of render target textures
  65308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65309. */
  65310. export class TextureOptimization extends SceneOptimization {
  65311. /**
  65312. * Defines the priority of this optimization (0 by default which means first in the list)
  65313. */
  65314. priority: number;
  65315. /**
  65316. * 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
  65317. */
  65318. maximumSize: number;
  65319. /**
  65320. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65321. */
  65322. step: number;
  65323. /**
  65324. * Gets a string describing the action executed by the current optimization
  65325. * @returns description string
  65326. */
  65327. getDescription(): string;
  65328. /**
  65329. * Creates the TextureOptimization object
  65330. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65331. * @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
  65332. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65333. */
  65334. constructor(
  65335. /**
  65336. * Defines the priority of this optimization (0 by default which means first in the list)
  65337. */
  65338. priority?: number,
  65339. /**
  65340. * 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
  65341. */
  65342. maximumSize?: number,
  65343. /**
  65344. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65345. */
  65346. step?: number);
  65347. /**
  65348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65349. * @param scene defines the current scene where to apply this optimization
  65350. * @param optimizer defines the current optimizer
  65351. * @returns true if everything that can be done was applied
  65352. */
  65353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65354. }
  65355. /**
  65356. * Defines an optimization used to increase or decrease the rendering resolution
  65357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65358. */
  65359. export class HardwareScalingOptimization extends SceneOptimization {
  65360. /**
  65361. * Defines the priority of this optimization (0 by default which means first in the list)
  65362. */
  65363. priority: number;
  65364. /**
  65365. * Defines the maximum scale to use (2 by default)
  65366. */
  65367. maximumScale: number;
  65368. /**
  65369. * Defines the step to use between two passes (0.5 by default)
  65370. */
  65371. step: number;
  65372. private _currentScale;
  65373. private _directionOffset;
  65374. /**
  65375. * Gets a string describing the action executed by the current optimization
  65376. * @return description string
  65377. */
  65378. getDescription(): string;
  65379. /**
  65380. * Creates the HardwareScalingOptimization object
  65381. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65382. * @param maximumScale defines the maximum scale to use (2 by default)
  65383. * @param step defines the step to use between two passes (0.5 by default)
  65384. */
  65385. constructor(
  65386. /**
  65387. * Defines the priority of this optimization (0 by default which means first in the list)
  65388. */
  65389. priority?: number,
  65390. /**
  65391. * Defines the maximum scale to use (2 by default)
  65392. */
  65393. maximumScale?: number,
  65394. /**
  65395. * Defines the step to use between two passes (0.5 by default)
  65396. */
  65397. step?: number);
  65398. /**
  65399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65400. * @param scene defines the current scene where to apply this optimization
  65401. * @param optimizer defines the current optimizer
  65402. * @returns true if everything that can be done was applied
  65403. */
  65404. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65405. }
  65406. /**
  65407. * Defines an optimization used to remove shadows
  65408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65409. */
  65410. export class ShadowsOptimization extends SceneOptimization {
  65411. /**
  65412. * Gets a string describing the action executed by the current optimization
  65413. * @return description string
  65414. */
  65415. getDescription(): string;
  65416. /**
  65417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65418. * @param scene defines the current scene where to apply this optimization
  65419. * @param optimizer defines the current optimizer
  65420. * @returns true if everything that can be done was applied
  65421. */
  65422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65423. }
  65424. /**
  65425. * Defines an optimization used to turn post-processes off
  65426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65427. */
  65428. export class PostProcessesOptimization extends SceneOptimization {
  65429. /**
  65430. * Gets a string describing the action executed by the current optimization
  65431. * @return description string
  65432. */
  65433. getDescription(): string;
  65434. /**
  65435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65436. * @param scene defines the current scene where to apply this optimization
  65437. * @param optimizer defines the current optimizer
  65438. * @returns true if everything that can be done was applied
  65439. */
  65440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65441. }
  65442. /**
  65443. * Defines an optimization used to turn lens flares off
  65444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65445. */
  65446. export class LensFlaresOptimization extends SceneOptimization {
  65447. /**
  65448. * Gets a string describing the action executed by the current optimization
  65449. * @return description string
  65450. */
  65451. getDescription(): string;
  65452. /**
  65453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65454. * @param scene defines the current scene where to apply this optimization
  65455. * @param optimizer defines the current optimizer
  65456. * @returns true if everything that can be done was applied
  65457. */
  65458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65459. }
  65460. /**
  65461. * Defines an optimization based on user defined callback.
  65462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65463. */
  65464. export class CustomOptimization extends SceneOptimization {
  65465. /**
  65466. * Callback called to apply the custom optimization.
  65467. */
  65468. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65469. /**
  65470. * Callback called to get custom description
  65471. */
  65472. onGetDescription: () => string;
  65473. /**
  65474. * Gets a string describing the action executed by the current optimization
  65475. * @returns description string
  65476. */
  65477. getDescription(): string;
  65478. /**
  65479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65480. * @param scene defines the current scene where to apply this optimization
  65481. * @param optimizer defines the current optimizer
  65482. * @returns true if everything that can be done was applied
  65483. */
  65484. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65485. }
  65486. /**
  65487. * Defines an optimization used to turn particles off
  65488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65489. */
  65490. export class ParticlesOptimization extends SceneOptimization {
  65491. /**
  65492. * Gets a string describing the action executed by the current optimization
  65493. * @return description string
  65494. */
  65495. getDescription(): string;
  65496. /**
  65497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65498. * @param scene defines the current scene where to apply this optimization
  65499. * @param optimizer defines the current optimizer
  65500. * @returns true if everything that can be done was applied
  65501. */
  65502. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65503. }
  65504. /**
  65505. * Defines an optimization used to turn render targets off
  65506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65507. */
  65508. export class RenderTargetsOptimization extends SceneOptimization {
  65509. /**
  65510. * Gets a string describing the action executed by the current optimization
  65511. * @return description string
  65512. */
  65513. getDescription(): string;
  65514. /**
  65515. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65516. * @param scene defines the current scene where to apply this optimization
  65517. * @param optimizer defines the current optimizer
  65518. * @returns true if everything that can be done was applied
  65519. */
  65520. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65521. }
  65522. /**
  65523. * Defines an optimization used to merge meshes with compatible materials
  65524. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65525. */
  65526. export class MergeMeshesOptimization extends SceneOptimization {
  65527. private static _UpdateSelectionTree;
  65528. /**
  65529. * Gets or sets a boolean which defines if optimization octree has to be updated
  65530. */
  65531. /**
  65532. * Gets or sets a boolean which defines if optimization octree has to be updated
  65533. */
  65534. static UpdateSelectionTree: boolean;
  65535. /**
  65536. * Gets a string describing the action executed by the current optimization
  65537. * @return description string
  65538. */
  65539. getDescription(): string;
  65540. private _canBeMerged;
  65541. /**
  65542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65543. * @param scene defines the current scene where to apply this optimization
  65544. * @param optimizer defines the current optimizer
  65545. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65546. * @returns true if everything that can be done was applied
  65547. */
  65548. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65549. }
  65550. /**
  65551. * Defines a list of options used by SceneOptimizer
  65552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65553. */
  65554. export class SceneOptimizerOptions {
  65555. /**
  65556. * Defines the target frame rate to reach (60 by default)
  65557. */
  65558. targetFrameRate: number;
  65559. /**
  65560. * Defines the interval between two checkes (2000ms by default)
  65561. */
  65562. trackerDuration: number;
  65563. /**
  65564. * Gets the list of optimizations to apply
  65565. */
  65566. optimizations: SceneOptimization[];
  65567. /**
  65568. * Creates a new list of options used by SceneOptimizer
  65569. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65570. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65571. */
  65572. constructor(
  65573. /**
  65574. * Defines the target frame rate to reach (60 by default)
  65575. */
  65576. targetFrameRate?: number,
  65577. /**
  65578. * Defines the interval between two checkes (2000ms by default)
  65579. */
  65580. trackerDuration?: number);
  65581. /**
  65582. * Add a new optimization
  65583. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65584. * @returns the current SceneOptimizerOptions
  65585. */
  65586. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65587. /**
  65588. * Add a new custom optimization
  65589. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65590. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65591. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65592. * @returns the current SceneOptimizerOptions
  65593. */
  65594. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65595. /**
  65596. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65597. * @param targetFrameRate defines the target frame rate (60 by default)
  65598. * @returns a SceneOptimizerOptions object
  65599. */
  65600. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65601. /**
  65602. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65603. * @param targetFrameRate defines the target frame rate (60 by default)
  65604. * @returns a SceneOptimizerOptions object
  65605. */
  65606. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65607. /**
  65608. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65609. * @param targetFrameRate defines the target frame rate (60 by default)
  65610. * @returns a SceneOptimizerOptions object
  65611. */
  65612. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65613. }
  65614. /**
  65615. * Class used to run optimizations in order to reach a target frame rate
  65616. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65617. */
  65618. export class SceneOptimizer implements IDisposable {
  65619. private _isRunning;
  65620. private _options;
  65621. private _scene;
  65622. private _currentPriorityLevel;
  65623. private _targetFrameRate;
  65624. private _trackerDuration;
  65625. private _currentFrameRate;
  65626. private _sceneDisposeObserver;
  65627. private _improvementMode;
  65628. /**
  65629. * Defines an observable called when the optimizer reaches the target frame rate
  65630. */
  65631. onSuccessObservable: Observable<SceneOptimizer>;
  65632. /**
  65633. * Defines an observable called when the optimizer enables an optimization
  65634. */
  65635. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65636. /**
  65637. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65638. */
  65639. onFailureObservable: Observable<SceneOptimizer>;
  65640. /**
  65641. * Gets a boolean indicating if the optimizer is in improvement mode
  65642. */
  65643. readonly isInImprovementMode: boolean;
  65644. /**
  65645. * Gets the current priority level (0 at start)
  65646. */
  65647. readonly currentPriorityLevel: number;
  65648. /**
  65649. * Gets the current frame rate checked by the SceneOptimizer
  65650. */
  65651. readonly currentFrameRate: number;
  65652. /**
  65653. * Gets or sets the current target frame rate (60 by default)
  65654. */
  65655. /**
  65656. * Gets or sets the current target frame rate (60 by default)
  65657. */
  65658. targetFrameRate: number;
  65659. /**
  65660. * Gets or sets the current interval between two checks (every 2000ms by default)
  65661. */
  65662. /**
  65663. * Gets or sets the current interval between two checks (every 2000ms by default)
  65664. */
  65665. trackerDuration: number;
  65666. /**
  65667. * Gets the list of active optimizations
  65668. */
  65669. readonly optimizations: SceneOptimization[];
  65670. /**
  65671. * Creates a new SceneOptimizer
  65672. * @param scene defines the scene to work on
  65673. * @param options defines the options to use with the SceneOptimizer
  65674. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65675. * @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)
  65676. */
  65677. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65678. /**
  65679. * Stops the current optimizer
  65680. */
  65681. stop(): void;
  65682. /**
  65683. * Reset the optimizer to initial step (current priority level = 0)
  65684. */
  65685. reset(): void;
  65686. /**
  65687. * Start the optimizer. By default it will try to reach a specific framerate
  65688. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65689. */
  65690. start(): void;
  65691. private _checkCurrentState;
  65692. /**
  65693. * Release all resources
  65694. */
  65695. dispose(): void;
  65696. /**
  65697. * Helper function to create a SceneOptimizer with one single line of code
  65698. * @param scene defines the scene to work on
  65699. * @param options defines the options to use with the SceneOptimizer
  65700. * @param onSuccess defines a callback to call on success
  65701. * @param onFailure defines a callback to call on failure
  65702. * @returns the new SceneOptimizer object
  65703. */
  65704. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65705. }
  65706. }
  65707. declare module "babylonjs/Misc/sceneSerializer" {
  65708. import { Scene } from "babylonjs/scene";
  65709. /**
  65710. * Class used to serialize a scene into a string
  65711. */
  65712. export class SceneSerializer {
  65713. /**
  65714. * Clear cache used by a previous serialization
  65715. */
  65716. static ClearCache(): void;
  65717. /**
  65718. * Serialize a scene into a JSON compatible object
  65719. * @param scene defines the scene to serialize
  65720. * @returns a JSON compatible object
  65721. */
  65722. static Serialize(scene: Scene): any;
  65723. /**
  65724. * Serialize a mesh into a JSON compatible object
  65725. * @param toSerialize defines the mesh to serialize
  65726. * @param withParents defines if parents must be serialized as well
  65727. * @param withChildren defines if children must be serialized as well
  65728. * @returns a JSON compatible object
  65729. */
  65730. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65731. }
  65732. }
  65733. declare module "babylonjs/Misc/textureTools" {
  65734. import { Texture } from "babylonjs/Materials/Textures/texture";
  65735. /**
  65736. * Class used to host texture specific utilities
  65737. */
  65738. export class TextureTools {
  65739. /**
  65740. * Uses the GPU to create a copy texture rescaled at a given size
  65741. * @param texture Texture to copy from
  65742. * @param width defines the desired width
  65743. * @param height defines the desired height
  65744. * @param useBilinearMode defines if bilinear mode has to be used
  65745. * @return the generated texture
  65746. */
  65747. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65748. }
  65749. }
  65750. declare module "babylonjs/Misc/videoRecorder" {
  65751. import { Nullable } from "babylonjs/types";
  65752. import { Engine } from "babylonjs/Engines/engine";
  65753. /**
  65754. * This represents the different options available for the video capture.
  65755. */
  65756. export interface VideoRecorderOptions {
  65757. /** Defines the mime type of the video. */
  65758. mimeType: string;
  65759. /** Defines the FPS the video should be recorded at. */
  65760. fps: number;
  65761. /** Defines the chunk size for the recording data. */
  65762. recordChunckSize: number;
  65763. /** The audio tracks to attach to the recording. */
  65764. audioTracks?: MediaStreamTrack[];
  65765. }
  65766. /**
  65767. * This can help with recording videos from BabylonJS.
  65768. * This is based on the available WebRTC functionalities of the browser.
  65769. *
  65770. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65771. */
  65772. export class VideoRecorder {
  65773. private static readonly _defaultOptions;
  65774. /**
  65775. * Returns whether or not the VideoRecorder is available in your browser.
  65776. * @param engine Defines the Babylon Engine.
  65777. * @returns true if supported otherwise false.
  65778. */
  65779. static IsSupported(engine: Engine): boolean;
  65780. private readonly _options;
  65781. private _canvas;
  65782. private _mediaRecorder;
  65783. private _recordedChunks;
  65784. private _fileName;
  65785. private _resolve;
  65786. private _reject;
  65787. /**
  65788. * True when a recording is already in progress.
  65789. */
  65790. readonly isRecording: boolean;
  65791. /**
  65792. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65793. * @param engine Defines the BabylonJS Engine you wish to record.
  65794. * @param options Defines options that can be used to customize the capture.
  65795. */
  65796. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65797. /**
  65798. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65799. */
  65800. stopRecording(): void;
  65801. /**
  65802. * Starts recording the canvas for a max duration specified in parameters.
  65803. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65804. * If null no automatic download will start and you can rely on the promise to get the data back.
  65805. * @param maxDuration Defines the maximum recording time in seconds.
  65806. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65807. * @return A promise callback at the end of the recording with the video data in Blob.
  65808. */
  65809. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65810. /**
  65811. * Releases internal resources used during the recording.
  65812. */
  65813. dispose(): void;
  65814. private _handleDataAvailable;
  65815. private _handleError;
  65816. private _handleStop;
  65817. }
  65818. }
  65819. declare module "babylonjs/Misc/screenshotTools" {
  65820. import { Camera } from "babylonjs/Cameras/camera";
  65821. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65822. import { Engine } from "babylonjs/Engines/engine";
  65823. /**
  65824. * Class containing a set of static utilities functions for screenshots
  65825. */
  65826. export class ScreenshotTools {
  65827. /**
  65828. * Captures a screenshot of the current rendering
  65829. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65830. * @param engine defines the rendering engine
  65831. * @param camera defines the source camera
  65832. * @param size This parameter can be set to a single number or to an object with the
  65833. * following (optional) properties: precision, width, height. If a single number is passed,
  65834. * it will be used for both width and height. If an object is passed, the screenshot size
  65835. * will be derived from the parameters. The precision property is a multiplier allowing
  65836. * rendering at a higher or lower resolution
  65837. * @param successCallback defines the callback receives a single parameter which contains the
  65838. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65839. * src parameter of an <img> to display it
  65840. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65841. * Check your browser for supported MIME types
  65842. */
  65843. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65844. /**
  65845. * Captures a screenshot of the current rendering
  65846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65847. * @param engine defines the rendering engine
  65848. * @param camera defines the source camera
  65849. * @param size This parameter can be set to a single number or to an object with the
  65850. * following (optional) properties: precision, width, height. If a single number is passed,
  65851. * it will be used for both width and height. If an object is passed, the screenshot size
  65852. * will be derived from the parameters. The precision property is a multiplier allowing
  65853. * rendering at a higher or lower resolution
  65854. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65855. * Check your browser for supported MIME types
  65856. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65857. * to the src parameter of an <img> to display it
  65858. */
  65859. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65860. /**
  65861. * Generates an image screenshot from the specified camera.
  65862. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65863. * @param engine The engine to use for rendering
  65864. * @param camera The camera to use for rendering
  65865. * @param size This parameter can be set to a single number or to an object with the
  65866. * following (optional) properties: precision, width, height. If a single number is passed,
  65867. * it will be used for both width and height. If an object is passed, the screenshot size
  65868. * will be derived from the parameters. The precision property is a multiplier allowing
  65869. * rendering at a higher or lower resolution
  65870. * @param successCallback The callback receives a single parameter which contains the
  65871. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65872. * src parameter of an <img> to display it
  65873. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65874. * Check your browser for supported MIME types
  65875. * @param samples Texture samples (default: 1)
  65876. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65877. * @param fileName A name for for the downloaded file.
  65878. */
  65879. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65880. /**
  65881. * Generates an image screenshot from the specified camera.
  65882. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65883. * @param engine The engine to use for rendering
  65884. * @param camera The camera to use for rendering
  65885. * @param size This parameter can be set to a single number or to an object with the
  65886. * following (optional) properties: precision, width, height. If a single number is passed,
  65887. * it will be used for both width and height. If an object is passed, the screenshot size
  65888. * will be derived from the parameters. The precision property is a multiplier allowing
  65889. * rendering at a higher or lower resolution
  65890. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65891. * Check your browser for supported MIME types
  65892. * @param samples Texture samples (default: 1)
  65893. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65894. * @param fileName A name for for the downloaded file.
  65895. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65896. * to the src parameter of an <img> to display it
  65897. */
  65898. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65899. /**
  65900. * Gets height and width for screenshot size
  65901. * @private
  65902. */
  65903. private static _getScreenshotSize;
  65904. }
  65905. }
  65906. declare module "babylonjs/Misc/index" {
  65907. export * from "babylonjs/Misc/andOrNotEvaluator";
  65908. export * from "babylonjs/Misc/assetsManager";
  65909. export * from "babylonjs/Misc/dds";
  65910. export * from "babylonjs/Misc/decorators";
  65911. export * from "babylonjs/Misc/deferred";
  65912. export * from "babylonjs/Misc/environmentTextureTools";
  65913. export * from "babylonjs/Misc/meshExploder";
  65914. export * from "babylonjs/Misc/filesInput";
  65915. export * from "babylonjs/Misc/HighDynamicRange/index";
  65916. export * from "babylonjs/Misc/khronosTextureContainer";
  65917. export * from "babylonjs/Misc/observable";
  65918. export * from "babylonjs/Misc/performanceMonitor";
  65919. export * from "babylonjs/Misc/promise";
  65920. export * from "babylonjs/Misc/sceneOptimizer";
  65921. export * from "babylonjs/Misc/sceneSerializer";
  65922. export * from "babylonjs/Misc/smartArray";
  65923. export * from "babylonjs/Misc/stringDictionary";
  65924. export * from "babylonjs/Misc/tags";
  65925. export * from "babylonjs/Misc/textureTools";
  65926. export * from "babylonjs/Misc/tga";
  65927. export * from "babylonjs/Misc/tools";
  65928. export * from "babylonjs/Misc/videoRecorder";
  65929. export * from "babylonjs/Misc/virtualJoystick";
  65930. export * from "babylonjs/Misc/workerPool";
  65931. export * from "babylonjs/Misc/logger";
  65932. export * from "babylonjs/Misc/typeStore";
  65933. export * from "babylonjs/Misc/filesInputStore";
  65934. export * from "babylonjs/Misc/deepCopier";
  65935. export * from "babylonjs/Misc/pivotTools";
  65936. export * from "babylonjs/Misc/precisionDate";
  65937. export * from "babylonjs/Misc/screenshotTools";
  65938. export * from "babylonjs/Misc/typeStore";
  65939. export * from "babylonjs/Misc/webRequest";
  65940. export * from "babylonjs/Misc/iInspectable";
  65941. export * from "babylonjs/Misc/brdfTextureTools";
  65942. export * from "babylonjs/Misc/rgbdTextureTools";
  65943. export * from "babylonjs/Misc/gradients";
  65944. export * from "babylonjs/Misc/perfCounter";
  65945. export * from "babylonjs/Misc/fileRequest";
  65946. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65947. export * from "babylonjs/Misc/retryStrategy";
  65948. export * from "babylonjs/Misc/loadFileError";
  65949. export * from "babylonjs/Misc/interfaces/screenshotSize";
  65950. }
  65951. declare module "babylonjs/index" {
  65952. export * from "babylonjs/abstractScene";
  65953. export * from "babylonjs/Actions/index";
  65954. export * from "babylonjs/Animations/index";
  65955. export * from "babylonjs/assetContainer";
  65956. export * from "babylonjs/Audio/index";
  65957. export * from "babylonjs/Behaviors/index";
  65958. export * from "babylonjs/Bones/index";
  65959. export * from "babylonjs/Cameras/index";
  65960. export * from "babylonjs/Collisions/index";
  65961. export * from "babylonjs/Culling/index";
  65962. export * from "babylonjs/Debug/index";
  65963. export * from "babylonjs/Engines/index";
  65964. export * from "babylonjs/Events/index";
  65965. export * from "babylonjs/Gamepads/index";
  65966. export * from "babylonjs/Gizmos/index";
  65967. export * from "babylonjs/Helpers/index";
  65968. export * from "babylonjs/Instrumentation/index";
  65969. export * from "babylonjs/Layers/index";
  65970. export * from "babylonjs/LensFlares/index";
  65971. export * from "babylonjs/Lights/index";
  65972. export * from "babylonjs/Loading/index";
  65973. export * from "babylonjs/Materials/index";
  65974. export * from "babylonjs/Maths/index";
  65975. export * from "babylonjs/Meshes/index";
  65976. export * from "babylonjs/Morph/index";
  65977. export * from "babylonjs/Navigation/index";
  65978. export * from "babylonjs/node";
  65979. export * from "babylonjs/Offline/index";
  65980. export * from "babylonjs/Particles/index";
  65981. export * from "babylonjs/Physics/index";
  65982. export * from "babylonjs/PostProcesses/index";
  65983. export * from "babylonjs/Probes/index";
  65984. export * from "babylonjs/Rendering/index";
  65985. export * from "babylonjs/scene";
  65986. export * from "babylonjs/sceneComponent";
  65987. export * from "babylonjs/Sprites/index";
  65988. export * from "babylonjs/States/index";
  65989. export * from "babylonjs/Misc/index";
  65990. export * from "babylonjs/types";
  65991. }
  65992. declare module "babylonjs/Animations/pathCursor" {
  65993. import { Vector3 } from "babylonjs/Maths/math.vector";
  65994. import { Path2 } from "babylonjs/Maths/math.path";
  65995. /**
  65996. * A cursor which tracks a point on a path
  65997. */
  65998. export class PathCursor {
  65999. private path;
  66000. /**
  66001. * Stores path cursor callbacks for when an onchange event is triggered
  66002. */
  66003. private _onchange;
  66004. /**
  66005. * The value of the path cursor
  66006. */
  66007. value: number;
  66008. /**
  66009. * The animation array of the path cursor
  66010. */
  66011. animations: Animation[];
  66012. /**
  66013. * Initializes the path cursor
  66014. * @param path The path to track
  66015. */
  66016. constructor(path: Path2);
  66017. /**
  66018. * Gets the cursor point on the path
  66019. * @returns A point on the path cursor at the cursor location
  66020. */
  66021. getPoint(): Vector3;
  66022. /**
  66023. * Moves the cursor ahead by the step amount
  66024. * @param step The amount to move the cursor forward
  66025. * @returns This path cursor
  66026. */
  66027. moveAhead(step?: number): PathCursor;
  66028. /**
  66029. * Moves the cursor behind by the step amount
  66030. * @param step The amount to move the cursor back
  66031. * @returns This path cursor
  66032. */
  66033. moveBack(step?: number): PathCursor;
  66034. /**
  66035. * Moves the cursor by the step amount
  66036. * If the step amount is greater than one, an exception is thrown
  66037. * @param step The amount to move the cursor
  66038. * @returns This path cursor
  66039. */
  66040. move(step: number): PathCursor;
  66041. /**
  66042. * Ensures that the value is limited between zero and one
  66043. * @returns This path cursor
  66044. */
  66045. private ensureLimits;
  66046. /**
  66047. * Runs onchange callbacks on change (used by the animation engine)
  66048. * @returns This path cursor
  66049. */
  66050. private raiseOnChange;
  66051. /**
  66052. * Executes a function on change
  66053. * @param f A path cursor onchange callback
  66054. * @returns This path cursor
  66055. */
  66056. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66057. }
  66058. }
  66059. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66060. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66061. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66062. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66063. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66064. }
  66065. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66066. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66067. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66068. }
  66069. declare module "babylonjs/Engines/Processors/index" {
  66070. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66071. export * from "babylonjs/Engines/Processors/Expressions/index";
  66072. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66073. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66074. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66075. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66076. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66077. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66078. }
  66079. declare module "babylonjs/Legacy/legacy" {
  66080. import * as Babylon from "babylonjs/index";
  66081. export * from "babylonjs/index";
  66082. }
  66083. declare module "babylonjs/Shaders/blur.fragment" {
  66084. /** @hidden */
  66085. export var blurPixelShader: {
  66086. name: string;
  66087. shader: string;
  66088. };
  66089. }
  66090. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66091. /** @hidden */
  66092. export var pointCloudVertexDeclaration: {
  66093. name: string;
  66094. shader: string;
  66095. };
  66096. }
  66097. declare module "babylonjs" {
  66098. export * from "babylonjs/Legacy/legacy";
  66099. }
  66100. declare module BABYLON {
  66101. /** Alias type for value that can be null */
  66102. export type Nullable<T> = T | null;
  66103. /**
  66104. * Alias type for number that are floats
  66105. * @ignorenaming
  66106. */
  66107. export type float = number;
  66108. /**
  66109. * Alias type for number that are doubles.
  66110. * @ignorenaming
  66111. */
  66112. export type double = number;
  66113. /**
  66114. * Alias type for number that are integer
  66115. * @ignorenaming
  66116. */
  66117. export type int = number;
  66118. /** Alias type for number array or Float32Array */
  66119. export type FloatArray = number[] | Float32Array;
  66120. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66121. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66122. /**
  66123. * Alias for types that can be used by a Buffer or VertexBuffer.
  66124. */
  66125. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66126. /**
  66127. * Alias type for primitive types
  66128. * @ignorenaming
  66129. */
  66130. type Primitive = undefined | null | boolean | string | number | Function;
  66131. /**
  66132. * Type modifier to make all the properties of an object Readonly
  66133. */
  66134. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66135. /**
  66136. * Type modifier to make all the properties of an object Readonly recursively
  66137. */
  66138. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66139. /** @hidden */
  66140. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66141. }
  66142. /** @hidden */
  66143. /** @hidden */
  66144. type DeepImmutableObject<T> = {
  66145. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66146. };
  66147. }
  66148. declare module BABYLON {
  66149. /**
  66150. * A class serves as a medium between the observable and its observers
  66151. */
  66152. export class EventState {
  66153. /**
  66154. * Create a new EventState
  66155. * @param mask defines the mask associated with this state
  66156. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66157. * @param target defines the original target of the state
  66158. * @param currentTarget defines the current target of the state
  66159. */
  66160. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66161. /**
  66162. * Initialize the current event state
  66163. * @param mask defines the mask associated with this state
  66164. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66165. * @param target defines the original target of the state
  66166. * @param currentTarget defines the current target of the state
  66167. * @returns the current event state
  66168. */
  66169. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66170. /**
  66171. * An Observer can set this property to true to prevent subsequent observers of being notified
  66172. */
  66173. skipNextObservers: boolean;
  66174. /**
  66175. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66176. */
  66177. mask: number;
  66178. /**
  66179. * The object that originally notified the event
  66180. */
  66181. target?: any;
  66182. /**
  66183. * The current object in the bubbling phase
  66184. */
  66185. currentTarget?: any;
  66186. /**
  66187. * This will be populated with the return value of the last function that was executed.
  66188. * If it is the first function in the callback chain it will be the event data.
  66189. */
  66190. lastReturnValue?: any;
  66191. }
  66192. /**
  66193. * Represent an Observer registered to a given Observable object.
  66194. */
  66195. export class Observer<T> {
  66196. /**
  66197. * Defines the callback to call when the observer is notified
  66198. */
  66199. callback: (eventData: T, eventState: EventState) => void;
  66200. /**
  66201. * Defines the mask of the observer (used to filter notifications)
  66202. */
  66203. mask: number;
  66204. /**
  66205. * Defines the current scope used to restore the JS context
  66206. */
  66207. scope: any;
  66208. /** @hidden */
  66209. _willBeUnregistered: boolean;
  66210. /**
  66211. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66212. */
  66213. unregisterOnNextCall: boolean;
  66214. /**
  66215. * Creates a new observer
  66216. * @param callback defines the callback to call when the observer is notified
  66217. * @param mask defines the mask of the observer (used to filter notifications)
  66218. * @param scope defines the current scope used to restore the JS context
  66219. */
  66220. constructor(
  66221. /**
  66222. * Defines the callback to call when the observer is notified
  66223. */
  66224. callback: (eventData: T, eventState: EventState) => void,
  66225. /**
  66226. * Defines the mask of the observer (used to filter notifications)
  66227. */
  66228. mask: number,
  66229. /**
  66230. * Defines the current scope used to restore the JS context
  66231. */
  66232. scope?: any);
  66233. }
  66234. /**
  66235. * Represent a list of observers registered to multiple Observables object.
  66236. */
  66237. export class MultiObserver<T> {
  66238. private _observers;
  66239. private _observables;
  66240. /**
  66241. * Release associated resources
  66242. */
  66243. dispose(): void;
  66244. /**
  66245. * Raise a callback when one of the observable will notify
  66246. * @param observables defines a list of observables to watch
  66247. * @param callback defines the callback to call on notification
  66248. * @param mask defines the mask used to filter notifications
  66249. * @param scope defines the current scope used to restore the JS context
  66250. * @returns the new MultiObserver
  66251. */
  66252. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66253. }
  66254. /**
  66255. * The Observable class is a simple implementation of the Observable pattern.
  66256. *
  66257. * 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.
  66258. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66259. * 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).
  66260. * 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.
  66261. */
  66262. export class Observable<T> {
  66263. private _observers;
  66264. private _eventState;
  66265. private _onObserverAdded;
  66266. /**
  66267. * Gets the list of observers
  66268. */
  66269. readonly observers: Array<Observer<T>>;
  66270. /**
  66271. * Creates a new observable
  66272. * @param onObserverAdded defines a callback to call when a new observer is added
  66273. */
  66274. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66275. /**
  66276. * Create a new Observer with the specified callback
  66277. * @param callback the callback that will be executed for that Observer
  66278. * @param mask the mask used to filter observers
  66279. * @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.
  66280. * @param scope optional scope for the callback to be called from
  66281. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66282. * @returns the new observer created for the callback
  66283. */
  66284. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66285. /**
  66286. * Create a new Observer with the specified callback and unregisters after the next notification
  66287. * @param callback the callback that will be executed for that Observer
  66288. * @returns the new observer created for the callback
  66289. */
  66290. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66291. /**
  66292. * Remove an Observer from the Observable object
  66293. * @param observer the instance of the Observer to remove
  66294. * @returns false if it doesn't belong to this Observable
  66295. */
  66296. remove(observer: Nullable<Observer<T>>): boolean;
  66297. /**
  66298. * Remove a callback from the Observable object
  66299. * @param callback the callback to remove
  66300. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66301. * @returns false if it doesn't belong to this Observable
  66302. */
  66303. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66304. private _deferUnregister;
  66305. private _remove;
  66306. /**
  66307. * Moves the observable to the top of the observer list making it get called first when notified
  66308. * @param observer the observer to move
  66309. */
  66310. makeObserverTopPriority(observer: Observer<T>): void;
  66311. /**
  66312. * Moves the observable to the bottom of the observer list making it get called last when notified
  66313. * @param observer the observer to move
  66314. */
  66315. makeObserverBottomPriority(observer: Observer<T>): void;
  66316. /**
  66317. * Notify all Observers by calling their respective callback with the given data
  66318. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66319. * @param eventData defines the data to send to all observers
  66320. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66321. * @param target defines the original target of the state
  66322. * @param currentTarget defines the current target of the state
  66323. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66324. */
  66325. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66326. /**
  66327. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66328. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66329. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66330. * and it is crucial that all callbacks will be executed.
  66331. * The order of the callbacks is kept, callbacks are not executed parallel.
  66332. *
  66333. * @param eventData The data to be sent to each callback
  66334. * @param mask is used to filter observers defaults to -1
  66335. * @param target defines the callback target (see EventState)
  66336. * @param currentTarget defines he current object in the bubbling phase
  66337. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66338. */
  66339. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66340. /**
  66341. * Notify a specific observer
  66342. * @param observer defines the observer to notify
  66343. * @param eventData defines the data to be sent to each callback
  66344. * @param mask is used to filter observers defaults to -1
  66345. */
  66346. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66347. /**
  66348. * Gets a boolean indicating if the observable has at least one observer
  66349. * @returns true is the Observable has at least one Observer registered
  66350. */
  66351. hasObservers(): boolean;
  66352. /**
  66353. * Clear the list of observers
  66354. */
  66355. clear(): void;
  66356. /**
  66357. * Clone the current observable
  66358. * @returns a new observable
  66359. */
  66360. clone(): Observable<T>;
  66361. /**
  66362. * Does this observable handles observer registered with a given mask
  66363. * @param mask defines the mask to be tested
  66364. * @return whether or not one observer registered with the given mask is handeled
  66365. **/
  66366. hasSpecificMask(mask?: number): boolean;
  66367. }
  66368. }
  66369. declare module BABYLON {
  66370. /**
  66371. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66372. * Babylon.js
  66373. */
  66374. export class DomManagement {
  66375. /**
  66376. * Checks if the window object exists
  66377. * @returns true if the window object exists
  66378. */
  66379. static IsWindowObjectExist(): boolean;
  66380. /**
  66381. * Checks if the navigator object exists
  66382. * @returns true if the navigator object exists
  66383. */
  66384. static IsNavigatorAvailable(): boolean;
  66385. /**
  66386. * Extracts text content from a DOM element hierarchy
  66387. * @param element defines the root element
  66388. * @returns a string
  66389. */
  66390. static GetDOMTextContent(element: HTMLElement): string;
  66391. }
  66392. }
  66393. declare module BABYLON {
  66394. /**
  66395. * Logger used througouht the application to allow configuration of
  66396. * the log level required for the messages.
  66397. */
  66398. export class Logger {
  66399. /**
  66400. * No log
  66401. */
  66402. static readonly NoneLogLevel: number;
  66403. /**
  66404. * Only message logs
  66405. */
  66406. static readonly MessageLogLevel: number;
  66407. /**
  66408. * Only warning logs
  66409. */
  66410. static readonly WarningLogLevel: number;
  66411. /**
  66412. * Only error logs
  66413. */
  66414. static readonly ErrorLogLevel: number;
  66415. /**
  66416. * All logs
  66417. */
  66418. static readonly AllLogLevel: number;
  66419. private static _LogCache;
  66420. /**
  66421. * Gets a value indicating the number of loading errors
  66422. * @ignorenaming
  66423. */
  66424. static errorsCount: number;
  66425. /**
  66426. * Callback called when a new log is added
  66427. */
  66428. static OnNewCacheEntry: (entry: string) => void;
  66429. private static _AddLogEntry;
  66430. private static _FormatMessage;
  66431. private static _LogDisabled;
  66432. private static _LogEnabled;
  66433. private static _WarnDisabled;
  66434. private static _WarnEnabled;
  66435. private static _ErrorDisabled;
  66436. private static _ErrorEnabled;
  66437. /**
  66438. * Log a message to the console
  66439. */
  66440. static Log: (message: string) => void;
  66441. /**
  66442. * Write a warning message to the console
  66443. */
  66444. static Warn: (message: string) => void;
  66445. /**
  66446. * Write an error message to the console
  66447. */
  66448. static Error: (message: string) => void;
  66449. /**
  66450. * Gets current log cache (list of logs)
  66451. */
  66452. static readonly LogCache: string;
  66453. /**
  66454. * Clears the log cache
  66455. */
  66456. static ClearLogCache(): void;
  66457. /**
  66458. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66459. */
  66460. static LogLevels: number;
  66461. }
  66462. }
  66463. declare module BABYLON {
  66464. /** @hidden */
  66465. export class _TypeStore {
  66466. /** @hidden */
  66467. static RegisteredTypes: {
  66468. [key: string]: Object;
  66469. };
  66470. /** @hidden */
  66471. static GetClass(fqdn: string): any;
  66472. }
  66473. }
  66474. declare module BABYLON {
  66475. /**
  66476. * Class containing a set of static utilities functions for deep copy.
  66477. */
  66478. export class DeepCopier {
  66479. /**
  66480. * Tries to copy an object by duplicating every property
  66481. * @param source defines the source object
  66482. * @param destination defines the target object
  66483. * @param doNotCopyList defines a list of properties to avoid
  66484. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66485. */
  66486. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66487. }
  66488. }
  66489. declare module BABYLON {
  66490. /**
  66491. * Class containing a set of static utilities functions for precision date
  66492. */
  66493. export class PrecisionDate {
  66494. /**
  66495. * Gets either window.performance.now() if supported or Date.now() else
  66496. */
  66497. static readonly Now: number;
  66498. }
  66499. }
  66500. declare module BABYLON {
  66501. /** @hidden */
  66502. export class _DevTools {
  66503. static WarnImport(name: string): string;
  66504. }
  66505. }
  66506. declare module BABYLON {
  66507. /**
  66508. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66509. */
  66510. export class WebRequest {
  66511. private _xhr;
  66512. /**
  66513. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66514. * i.e. when loading files, where the server/service expects an Authorization header
  66515. */
  66516. static CustomRequestHeaders: {
  66517. [key: string]: string;
  66518. };
  66519. /**
  66520. * Add callback functions in this array to update all the requests before they get sent to the network
  66521. */
  66522. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66523. private _injectCustomRequestHeaders;
  66524. /**
  66525. * Gets or sets a function to be called when loading progress changes
  66526. */
  66527. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66528. /**
  66529. * Returns client's state
  66530. */
  66531. readonly readyState: number;
  66532. /**
  66533. * Returns client's status
  66534. */
  66535. readonly status: number;
  66536. /**
  66537. * Returns client's status as a text
  66538. */
  66539. readonly statusText: string;
  66540. /**
  66541. * Returns client's response
  66542. */
  66543. readonly response: any;
  66544. /**
  66545. * Returns client's response url
  66546. */
  66547. readonly responseURL: string;
  66548. /**
  66549. * Returns client's response as text
  66550. */
  66551. readonly responseText: string;
  66552. /**
  66553. * Gets or sets the expected response type
  66554. */
  66555. responseType: XMLHttpRequestResponseType;
  66556. /** @hidden */
  66557. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66558. /** @hidden */
  66559. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66560. /**
  66561. * Cancels any network activity
  66562. */
  66563. abort(): void;
  66564. /**
  66565. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66566. * @param body defines an optional request body
  66567. */
  66568. send(body?: Document | BodyInit | null): void;
  66569. /**
  66570. * Sets the request method, request URL
  66571. * @param method defines the method to use (GET, POST, etc..)
  66572. * @param url defines the url to connect with
  66573. */
  66574. open(method: string, url: string): void;
  66575. }
  66576. }
  66577. declare module BABYLON {
  66578. /**
  66579. * File request interface
  66580. */
  66581. export interface IFileRequest {
  66582. /**
  66583. * Raised when the request is complete (success or error).
  66584. */
  66585. onCompleteObservable: Observable<IFileRequest>;
  66586. /**
  66587. * Aborts the request for a file.
  66588. */
  66589. abort: () => void;
  66590. }
  66591. }
  66592. declare module BABYLON {
  66593. /**
  66594. * Scalar computation library
  66595. */
  66596. export class Scalar {
  66597. /**
  66598. * Two pi constants convenient for computation.
  66599. */
  66600. static TwoPi: number;
  66601. /**
  66602. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66603. * @param a number
  66604. * @param b number
  66605. * @param epsilon (default = 1.401298E-45)
  66606. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66607. */
  66608. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66609. /**
  66610. * Returns a string : the upper case translation of the number i to hexadecimal.
  66611. * @param i number
  66612. * @returns the upper case translation of the number i to hexadecimal.
  66613. */
  66614. static ToHex(i: number): string;
  66615. /**
  66616. * Returns -1 if value is negative and +1 is value is positive.
  66617. * @param value the value
  66618. * @returns the value itself if it's equal to zero.
  66619. */
  66620. static Sign(value: number): number;
  66621. /**
  66622. * Returns the value itself if it's between min and max.
  66623. * Returns min if the value is lower than min.
  66624. * Returns max if the value is greater than max.
  66625. * @param value the value to clmap
  66626. * @param min the min value to clamp to (default: 0)
  66627. * @param max the max value to clamp to (default: 1)
  66628. * @returns the clamped value
  66629. */
  66630. static Clamp(value: number, min?: number, max?: number): number;
  66631. /**
  66632. * the log2 of value.
  66633. * @param value the value to compute log2 of
  66634. * @returns the log2 of value.
  66635. */
  66636. static Log2(value: number): number;
  66637. /**
  66638. * Loops the value, so that it is never larger than length and never smaller than 0.
  66639. *
  66640. * This is similar to the modulo operator but it works with floating point numbers.
  66641. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66642. * With t = 5 and length = 2.5, the result would be 0.0.
  66643. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66644. * @param value the value
  66645. * @param length the length
  66646. * @returns the looped value
  66647. */
  66648. static Repeat(value: number, length: number): number;
  66649. /**
  66650. * Normalize the value between 0.0 and 1.0 using min and max values
  66651. * @param value value to normalize
  66652. * @param min max to normalize between
  66653. * @param max min to normalize between
  66654. * @returns the normalized value
  66655. */
  66656. static Normalize(value: number, min: number, max: number): number;
  66657. /**
  66658. * Denormalize the value from 0.0 and 1.0 using min and max values
  66659. * @param normalized value to denormalize
  66660. * @param min max to denormalize between
  66661. * @param max min to denormalize between
  66662. * @returns the denormalized value
  66663. */
  66664. static Denormalize(normalized: number, min: number, max: number): number;
  66665. /**
  66666. * Calculates the shortest difference between two given angles given in degrees.
  66667. * @param current current angle in degrees
  66668. * @param target target angle in degrees
  66669. * @returns the delta
  66670. */
  66671. static DeltaAngle(current: number, target: number): number;
  66672. /**
  66673. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66674. * @param tx value
  66675. * @param length length
  66676. * @returns The returned value will move back and forth between 0 and length
  66677. */
  66678. static PingPong(tx: number, length: number): number;
  66679. /**
  66680. * Interpolates between min and max with smoothing at the limits.
  66681. *
  66682. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66683. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66684. * @param from from
  66685. * @param to to
  66686. * @param tx value
  66687. * @returns the smooth stepped value
  66688. */
  66689. static SmoothStep(from: number, to: number, tx: number): number;
  66690. /**
  66691. * Moves a value current towards target.
  66692. *
  66693. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66694. * Negative values of maxDelta pushes the value away from target.
  66695. * @param current current value
  66696. * @param target target value
  66697. * @param maxDelta max distance to move
  66698. * @returns resulting value
  66699. */
  66700. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66701. /**
  66702. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66703. *
  66704. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66705. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66706. * @param current current value
  66707. * @param target target value
  66708. * @param maxDelta max distance to move
  66709. * @returns resulting angle
  66710. */
  66711. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66712. /**
  66713. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66714. * @param start start value
  66715. * @param end target value
  66716. * @param amount amount to lerp between
  66717. * @returns the lerped value
  66718. */
  66719. static Lerp(start: number, end: number, amount: number): number;
  66720. /**
  66721. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66722. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66723. * @param start start value
  66724. * @param end target value
  66725. * @param amount amount to lerp between
  66726. * @returns the lerped value
  66727. */
  66728. static LerpAngle(start: number, end: number, amount: number): number;
  66729. /**
  66730. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66731. * @param a start value
  66732. * @param b target value
  66733. * @param value value between a and b
  66734. * @returns the inverseLerp value
  66735. */
  66736. static InverseLerp(a: number, b: number, value: number): number;
  66737. /**
  66738. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66739. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66740. * @param value1 spline value
  66741. * @param tangent1 spline value
  66742. * @param value2 spline value
  66743. * @param tangent2 spline value
  66744. * @param amount input value
  66745. * @returns hermite result
  66746. */
  66747. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66748. /**
  66749. * Returns a random float number between and min and max values
  66750. * @param min min value of random
  66751. * @param max max value of random
  66752. * @returns random value
  66753. */
  66754. static RandomRange(min: number, max: number): number;
  66755. /**
  66756. * This function returns percentage of a number in a given range.
  66757. *
  66758. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66759. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66760. * @param number to convert to percentage
  66761. * @param min min range
  66762. * @param max max range
  66763. * @returns the percentage
  66764. */
  66765. static RangeToPercent(number: number, min: number, max: number): number;
  66766. /**
  66767. * This function returns number that corresponds to the percentage in a given range.
  66768. *
  66769. * PercentToRange(0.34,0,100) will return 34.
  66770. * @param percent to convert to number
  66771. * @param min min range
  66772. * @param max max range
  66773. * @returns the number
  66774. */
  66775. static PercentToRange(percent: number, min: number, max: number): number;
  66776. /**
  66777. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66778. * @param angle The angle to normalize in radian.
  66779. * @return The converted angle.
  66780. */
  66781. static NormalizeRadians(angle: number): number;
  66782. }
  66783. }
  66784. declare module BABYLON {
  66785. /**
  66786. * Constant used to convert a value to gamma space
  66787. * @ignorenaming
  66788. */
  66789. export const ToGammaSpace: number;
  66790. /**
  66791. * Constant used to convert a value to linear space
  66792. * @ignorenaming
  66793. */
  66794. export const ToLinearSpace = 2.2;
  66795. /**
  66796. * Constant used to define the minimal number value in Babylon.js
  66797. * @ignorenaming
  66798. */
  66799. let Epsilon: number;
  66800. }
  66801. declare module BABYLON {
  66802. /**
  66803. * Class used to represent a viewport on screen
  66804. */
  66805. export class Viewport {
  66806. /** viewport left coordinate */
  66807. x: number;
  66808. /** viewport top coordinate */
  66809. y: number;
  66810. /**viewport width */
  66811. width: number;
  66812. /** viewport height */
  66813. height: number;
  66814. /**
  66815. * Creates a Viewport object located at (x, y) and sized (width, height)
  66816. * @param x defines viewport left coordinate
  66817. * @param y defines viewport top coordinate
  66818. * @param width defines the viewport width
  66819. * @param height defines the viewport height
  66820. */
  66821. constructor(
  66822. /** viewport left coordinate */
  66823. x: number,
  66824. /** viewport top coordinate */
  66825. y: number,
  66826. /**viewport width */
  66827. width: number,
  66828. /** viewport height */
  66829. height: number);
  66830. /**
  66831. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66832. * @param renderWidth defines the rendering width
  66833. * @param renderHeight defines the rendering height
  66834. * @returns a new Viewport
  66835. */
  66836. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66837. /**
  66838. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66839. * @param renderWidth defines the rendering width
  66840. * @param renderHeight defines the rendering height
  66841. * @param ref defines the target viewport
  66842. * @returns the current viewport
  66843. */
  66844. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66845. /**
  66846. * Returns a new Viewport copied from the current one
  66847. * @returns a new Viewport
  66848. */
  66849. clone(): Viewport;
  66850. }
  66851. }
  66852. declare module BABYLON {
  66853. /**
  66854. * Class containing a set of static utilities functions for arrays.
  66855. */
  66856. export class ArrayTools {
  66857. /**
  66858. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66859. * @param size the number of element to construct and put in the array
  66860. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66861. * @returns a new array filled with new objects
  66862. */
  66863. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66864. }
  66865. }
  66866. declare module BABYLON {
  66867. /**
  66868. * @hidden
  66869. */
  66870. export interface IColor4Like {
  66871. r: float;
  66872. g: float;
  66873. b: float;
  66874. a: float;
  66875. }
  66876. /**
  66877. * @hidden
  66878. */
  66879. export interface IColor3Like {
  66880. r: float;
  66881. g: float;
  66882. b: float;
  66883. }
  66884. /**
  66885. * @hidden
  66886. */
  66887. export interface IVector4Like {
  66888. x: float;
  66889. y: float;
  66890. z: float;
  66891. w: float;
  66892. }
  66893. /**
  66894. * @hidden
  66895. */
  66896. export interface IVector3Like {
  66897. x: float;
  66898. y: float;
  66899. z: float;
  66900. }
  66901. /**
  66902. * @hidden
  66903. */
  66904. export interface IVector2Like {
  66905. x: float;
  66906. y: float;
  66907. }
  66908. /**
  66909. * @hidden
  66910. */
  66911. export interface IMatrixLike {
  66912. toArray(): DeepImmutable<Float32Array>;
  66913. updateFlag: int;
  66914. }
  66915. /**
  66916. * @hidden
  66917. */
  66918. export interface IViewportLike {
  66919. x: float;
  66920. y: float;
  66921. width: float;
  66922. height: float;
  66923. }
  66924. /**
  66925. * @hidden
  66926. */
  66927. export interface IPlaneLike {
  66928. normal: IVector3Like;
  66929. d: float;
  66930. normalize(): void;
  66931. }
  66932. }
  66933. declare module BABYLON {
  66934. /**
  66935. * Class representing a vector containing 2 coordinates
  66936. */
  66937. export class Vector2 {
  66938. /** defines the first coordinate */
  66939. x: number;
  66940. /** defines the second coordinate */
  66941. y: number;
  66942. /**
  66943. * Creates a new Vector2 from the given x and y coordinates
  66944. * @param x defines the first coordinate
  66945. * @param y defines the second coordinate
  66946. */
  66947. constructor(
  66948. /** defines the first coordinate */
  66949. x?: number,
  66950. /** defines the second coordinate */
  66951. y?: number);
  66952. /**
  66953. * Gets a string with the Vector2 coordinates
  66954. * @returns a string with the Vector2 coordinates
  66955. */
  66956. toString(): string;
  66957. /**
  66958. * Gets class name
  66959. * @returns the string "Vector2"
  66960. */
  66961. getClassName(): string;
  66962. /**
  66963. * Gets current vector hash code
  66964. * @returns the Vector2 hash code as a number
  66965. */
  66966. getHashCode(): number;
  66967. /**
  66968. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  66969. * @param array defines the source array
  66970. * @param index defines the offset in source array
  66971. * @returns the current Vector2
  66972. */
  66973. toArray(array: FloatArray, index?: number): Vector2;
  66974. /**
  66975. * Copy the current vector to an array
  66976. * @returns a new array with 2 elements: the Vector2 coordinates.
  66977. */
  66978. asArray(): number[];
  66979. /**
  66980. * Sets the Vector2 coordinates with the given Vector2 coordinates
  66981. * @param source defines the source Vector2
  66982. * @returns the current updated Vector2
  66983. */
  66984. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  66985. /**
  66986. * Sets the Vector2 coordinates with the given floats
  66987. * @param x defines the first coordinate
  66988. * @param y defines the second coordinate
  66989. * @returns the current updated Vector2
  66990. */
  66991. copyFromFloats(x: number, y: number): Vector2;
  66992. /**
  66993. * Sets the Vector2 coordinates with the given floats
  66994. * @param x defines the first coordinate
  66995. * @param y defines the second coordinate
  66996. * @returns the current updated Vector2
  66997. */
  66998. set(x: number, y: number): Vector2;
  66999. /**
  67000. * Add another vector with the current one
  67001. * @param otherVector defines the other vector
  67002. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67003. */
  67004. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67005. /**
  67006. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67007. * @param otherVector defines the other vector
  67008. * @param result defines the target vector
  67009. * @returns the unmodified current Vector2
  67010. */
  67011. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67012. /**
  67013. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67014. * @param otherVector defines the other vector
  67015. * @returns the current updated Vector2
  67016. */
  67017. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67018. /**
  67019. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67020. * @param otherVector defines the other vector
  67021. * @returns a new Vector2
  67022. */
  67023. addVector3(otherVector: Vector3): Vector2;
  67024. /**
  67025. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67026. * @param otherVector defines the other vector
  67027. * @returns a new Vector2
  67028. */
  67029. subtract(otherVector: Vector2): Vector2;
  67030. /**
  67031. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67032. * @param otherVector defines the other vector
  67033. * @param result defines the target vector
  67034. * @returns the unmodified current Vector2
  67035. */
  67036. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67037. /**
  67038. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67039. * @param otherVector defines the other vector
  67040. * @returns the current updated Vector2
  67041. */
  67042. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67043. /**
  67044. * Multiplies in place the current Vector2 coordinates by the given ones
  67045. * @param otherVector defines the other vector
  67046. * @returns the current updated Vector2
  67047. */
  67048. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67049. /**
  67050. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67051. * @param otherVector defines the other vector
  67052. * @returns a new Vector2
  67053. */
  67054. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67055. /**
  67056. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67057. * @param otherVector defines the other vector
  67058. * @param result defines the target vector
  67059. * @returns the unmodified current Vector2
  67060. */
  67061. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67062. /**
  67063. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67064. * @param x defines the first coordinate
  67065. * @param y defines the second coordinate
  67066. * @returns a new Vector2
  67067. */
  67068. multiplyByFloats(x: number, y: number): Vector2;
  67069. /**
  67070. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67071. * @param otherVector defines the other vector
  67072. * @returns a new Vector2
  67073. */
  67074. divide(otherVector: Vector2): Vector2;
  67075. /**
  67076. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67077. * @param otherVector defines the other vector
  67078. * @param result defines the target vector
  67079. * @returns the unmodified current Vector2
  67080. */
  67081. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67082. /**
  67083. * Divides the current Vector2 coordinates by the given ones
  67084. * @param otherVector defines the other vector
  67085. * @returns the current updated Vector2
  67086. */
  67087. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67088. /**
  67089. * Gets a new Vector2 with current Vector2 negated coordinates
  67090. * @returns a new Vector2
  67091. */
  67092. negate(): Vector2;
  67093. /**
  67094. * Multiply the Vector2 coordinates by scale
  67095. * @param scale defines the scaling factor
  67096. * @returns the current updated Vector2
  67097. */
  67098. scaleInPlace(scale: number): Vector2;
  67099. /**
  67100. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67101. * @param scale defines the scaling factor
  67102. * @returns a new Vector2
  67103. */
  67104. scale(scale: number): Vector2;
  67105. /**
  67106. * Scale the current Vector2 values by a factor to a given Vector2
  67107. * @param scale defines the scale factor
  67108. * @param result defines the Vector2 object where to store the result
  67109. * @returns the unmodified current Vector2
  67110. */
  67111. scaleToRef(scale: number, result: Vector2): Vector2;
  67112. /**
  67113. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67114. * @param scale defines the scale factor
  67115. * @param result defines the Vector2 object where to store the result
  67116. * @returns the unmodified current Vector2
  67117. */
  67118. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67119. /**
  67120. * Gets a boolean if two vectors are equals
  67121. * @param otherVector defines the other vector
  67122. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67123. */
  67124. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67125. /**
  67126. * Gets a boolean if two vectors are equals (using an epsilon value)
  67127. * @param otherVector defines the other vector
  67128. * @param epsilon defines the minimal distance to consider equality
  67129. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67130. */
  67131. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67132. /**
  67133. * Gets a new Vector2 from current Vector2 floored values
  67134. * @returns a new Vector2
  67135. */
  67136. floor(): Vector2;
  67137. /**
  67138. * Gets a new Vector2 from current Vector2 floored values
  67139. * @returns a new Vector2
  67140. */
  67141. fract(): Vector2;
  67142. /**
  67143. * Gets the length of the vector
  67144. * @returns the vector length (float)
  67145. */
  67146. length(): number;
  67147. /**
  67148. * Gets the vector squared length
  67149. * @returns the vector squared length (float)
  67150. */
  67151. lengthSquared(): number;
  67152. /**
  67153. * Normalize the vector
  67154. * @returns the current updated Vector2
  67155. */
  67156. normalize(): Vector2;
  67157. /**
  67158. * Gets a new Vector2 copied from the Vector2
  67159. * @returns a new Vector2
  67160. */
  67161. clone(): Vector2;
  67162. /**
  67163. * Gets a new Vector2(0, 0)
  67164. * @returns a new Vector2
  67165. */
  67166. static Zero(): Vector2;
  67167. /**
  67168. * Gets a new Vector2(1, 1)
  67169. * @returns a new Vector2
  67170. */
  67171. static One(): Vector2;
  67172. /**
  67173. * Gets a new Vector2 set from the given index element of the given array
  67174. * @param array defines the data source
  67175. * @param offset defines the offset in the data source
  67176. * @returns a new Vector2
  67177. */
  67178. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67179. /**
  67180. * Sets "result" from the given index element of the given array
  67181. * @param array defines the data source
  67182. * @param offset defines the offset in the data source
  67183. * @param result defines the target vector
  67184. */
  67185. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67186. /**
  67187. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67188. * @param value1 defines 1st point of control
  67189. * @param value2 defines 2nd point of control
  67190. * @param value3 defines 3rd point of control
  67191. * @param value4 defines 4th point of control
  67192. * @param amount defines the interpolation factor
  67193. * @returns a new Vector2
  67194. */
  67195. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67196. /**
  67197. * 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".
  67198. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67199. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67200. * @param value defines the value to clamp
  67201. * @param min defines the lower limit
  67202. * @param max defines the upper limit
  67203. * @returns a new Vector2
  67204. */
  67205. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67206. /**
  67207. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67208. * @param value1 defines the 1st control point
  67209. * @param tangent1 defines the outgoing tangent
  67210. * @param value2 defines the 2nd control point
  67211. * @param tangent2 defines the incoming tangent
  67212. * @param amount defines the interpolation factor
  67213. * @returns a new Vector2
  67214. */
  67215. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67216. /**
  67217. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67218. * @param start defines the start vector
  67219. * @param end defines the end vector
  67220. * @param amount defines the interpolation factor
  67221. * @returns a new Vector2
  67222. */
  67223. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67224. /**
  67225. * Gets the dot product of the vector "left" and the vector "right"
  67226. * @param left defines first vector
  67227. * @param right defines second vector
  67228. * @returns the dot product (float)
  67229. */
  67230. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67231. /**
  67232. * Returns a new Vector2 equal to the normalized given vector
  67233. * @param vector defines the vector to normalize
  67234. * @returns a new Vector2
  67235. */
  67236. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67237. /**
  67238. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67239. * @param left defines 1st vector
  67240. * @param right defines 2nd vector
  67241. * @returns a new Vector2
  67242. */
  67243. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67244. /**
  67245. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67246. * @param left defines 1st vector
  67247. * @param right defines 2nd vector
  67248. * @returns a new Vector2
  67249. */
  67250. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67251. /**
  67252. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67253. * @param vector defines the vector to transform
  67254. * @param transformation defines the matrix to apply
  67255. * @returns a new Vector2
  67256. */
  67257. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67258. /**
  67259. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67260. * @param vector defines the vector to transform
  67261. * @param transformation defines the matrix to apply
  67262. * @param result defines the target vector
  67263. */
  67264. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67265. /**
  67266. * Determines if a given vector is included in a triangle
  67267. * @param p defines the vector to test
  67268. * @param p0 defines 1st triangle point
  67269. * @param p1 defines 2nd triangle point
  67270. * @param p2 defines 3rd triangle point
  67271. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67272. */
  67273. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67274. /**
  67275. * Gets the distance between the vectors "value1" and "value2"
  67276. * @param value1 defines first vector
  67277. * @param value2 defines second vector
  67278. * @returns the distance between vectors
  67279. */
  67280. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67281. /**
  67282. * Returns the squared distance between the vectors "value1" and "value2"
  67283. * @param value1 defines first vector
  67284. * @param value2 defines second vector
  67285. * @returns the squared distance between vectors
  67286. */
  67287. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67288. /**
  67289. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67290. * @param value1 defines first vector
  67291. * @param value2 defines second vector
  67292. * @returns a new Vector2
  67293. */
  67294. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67295. /**
  67296. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67297. * @param p defines the middle point
  67298. * @param segA defines one point of the segment
  67299. * @param segB defines the other point of the segment
  67300. * @returns the shortest distance
  67301. */
  67302. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67303. }
  67304. /**
  67305. * Classed used to store (x,y,z) vector representation
  67306. * A Vector3 is the main object used in 3D geometry
  67307. * It can represent etiher the coordinates of a point the space, either a direction
  67308. * Reminder: js uses a left handed forward facing system
  67309. */
  67310. export class Vector3 {
  67311. /**
  67312. * Defines the first coordinates (on X axis)
  67313. */
  67314. x: number;
  67315. /**
  67316. * Defines the second coordinates (on Y axis)
  67317. */
  67318. y: number;
  67319. /**
  67320. * Defines the third coordinates (on Z axis)
  67321. */
  67322. z: number;
  67323. private static _UpReadOnly;
  67324. private static _ZeroReadOnly;
  67325. /**
  67326. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67327. * @param x defines the first coordinates (on X axis)
  67328. * @param y defines the second coordinates (on Y axis)
  67329. * @param z defines the third coordinates (on Z axis)
  67330. */
  67331. constructor(
  67332. /**
  67333. * Defines the first coordinates (on X axis)
  67334. */
  67335. x?: number,
  67336. /**
  67337. * Defines the second coordinates (on Y axis)
  67338. */
  67339. y?: number,
  67340. /**
  67341. * Defines the third coordinates (on Z axis)
  67342. */
  67343. z?: number);
  67344. /**
  67345. * Creates a string representation of the Vector3
  67346. * @returns a string with the Vector3 coordinates.
  67347. */
  67348. toString(): string;
  67349. /**
  67350. * Gets the class name
  67351. * @returns the string "Vector3"
  67352. */
  67353. getClassName(): string;
  67354. /**
  67355. * Creates the Vector3 hash code
  67356. * @returns a number which tends to be unique between Vector3 instances
  67357. */
  67358. getHashCode(): number;
  67359. /**
  67360. * Creates an array containing three elements : the coordinates of the Vector3
  67361. * @returns a new array of numbers
  67362. */
  67363. asArray(): number[];
  67364. /**
  67365. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67366. * @param array defines the destination array
  67367. * @param index defines the offset in the destination array
  67368. * @returns the current Vector3
  67369. */
  67370. toArray(array: FloatArray, index?: number): Vector3;
  67371. /**
  67372. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67373. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67374. */
  67375. toQuaternion(): Quaternion;
  67376. /**
  67377. * Adds the given vector to the current Vector3
  67378. * @param otherVector defines the second operand
  67379. * @returns the current updated Vector3
  67380. */
  67381. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67382. /**
  67383. * Adds the given coordinates to the current Vector3
  67384. * @param x defines the x coordinate of the operand
  67385. * @param y defines the y coordinate of the operand
  67386. * @param z defines the z coordinate of the operand
  67387. * @returns the current updated Vector3
  67388. */
  67389. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67390. /**
  67391. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67392. * @param otherVector defines the second operand
  67393. * @returns the resulting Vector3
  67394. */
  67395. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67396. /**
  67397. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67398. * @param otherVector defines the second operand
  67399. * @param result defines the Vector3 object where to store the result
  67400. * @returns the current Vector3
  67401. */
  67402. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67403. /**
  67404. * Subtract the given vector from the current Vector3
  67405. * @param otherVector defines the second operand
  67406. * @returns the current updated Vector3
  67407. */
  67408. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67409. /**
  67410. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67411. * @param otherVector defines the second operand
  67412. * @returns the resulting Vector3
  67413. */
  67414. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67415. /**
  67416. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67417. * @param otherVector defines the second operand
  67418. * @param result defines the Vector3 object where to store the result
  67419. * @returns the current Vector3
  67420. */
  67421. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67422. /**
  67423. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67424. * @param x defines the x coordinate of the operand
  67425. * @param y defines the y coordinate of the operand
  67426. * @param z defines the z coordinate of the operand
  67427. * @returns the resulting Vector3
  67428. */
  67429. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67430. /**
  67431. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67432. * @param x defines the x coordinate of the operand
  67433. * @param y defines the y coordinate of the operand
  67434. * @param z defines the z coordinate of the operand
  67435. * @param result defines the Vector3 object where to store the result
  67436. * @returns the current Vector3
  67437. */
  67438. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67439. /**
  67440. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67441. * @returns a new Vector3
  67442. */
  67443. negate(): Vector3;
  67444. /**
  67445. * Multiplies the Vector3 coordinates by the float "scale"
  67446. * @param scale defines the multiplier factor
  67447. * @returns the current updated Vector3
  67448. */
  67449. scaleInPlace(scale: number): Vector3;
  67450. /**
  67451. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67452. * @param scale defines the multiplier factor
  67453. * @returns a new Vector3
  67454. */
  67455. scale(scale: number): Vector3;
  67456. /**
  67457. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67458. * @param scale defines the multiplier factor
  67459. * @param result defines the Vector3 object where to store the result
  67460. * @returns the current Vector3
  67461. */
  67462. scaleToRef(scale: number, result: Vector3): Vector3;
  67463. /**
  67464. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67465. * @param scale defines the scale factor
  67466. * @param result defines the Vector3 object where to store the result
  67467. * @returns the unmodified current Vector3
  67468. */
  67469. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67470. /**
  67471. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67472. * @param otherVector defines the second operand
  67473. * @returns true if both vectors are equals
  67474. */
  67475. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67476. /**
  67477. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67478. * @param otherVector defines the second operand
  67479. * @param epsilon defines the minimal distance to define values as equals
  67480. * @returns true if both vectors are distant less than epsilon
  67481. */
  67482. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67483. /**
  67484. * Returns true if the current Vector3 coordinates equals the given floats
  67485. * @param x defines the x coordinate of the operand
  67486. * @param y defines the y coordinate of the operand
  67487. * @param z defines the z coordinate of the operand
  67488. * @returns true if both vectors are equals
  67489. */
  67490. equalsToFloats(x: number, y: number, z: number): boolean;
  67491. /**
  67492. * Multiplies the current Vector3 coordinates by the given ones
  67493. * @param otherVector defines the second operand
  67494. * @returns the current updated Vector3
  67495. */
  67496. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67497. /**
  67498. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67499. * @param otherVector defines the second operand
  67500. * @returns the new Vector3
  67501. */
  67502. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67503. /**
  67504. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67505. * @param otherVector defines the second operand
  67506. * @param result defines the Vector3 object where to store the result
  67507. * @returns the current Vector3
  67508. */
  67509. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67510. /**
  67511. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67512. * @param x defines the x coordinate of the operand
  67513. * @param y defines the y coordinate of the operand
  67514. * @param z defines the z coordinate of the operand
  67515. * @returns the new Vector3
  67516. */
  67517. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67518. /**
  67519. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67520. * @param otherVector defines the second operand
  67521. * @returns the new Vector3
  67522. */
  67523. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67524. /**
  67525. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67526. * @param otherVector defines the second operand
  67527. * @param result defines the Vector3 object where to store the result
  67528. * @returns the current Vector3
  67529. */
  67530. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67531. /**
  67532. * Divides the current Vector3 coordinates by the given ones.
  67533. * @param otherVector defines the second operand
  67534. * @returns the current updated Vector3
  67535. */
  67536. divideInPlace(otherVector: Vector3): Vector3;
  67537. /**
  67538. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67539. * @param other defines the second operand
  67540. * @returns the current updated Vector3
  67541. */
  67542. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67543. /**
  67544. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67545. * @param other defines the second operand
  67546. * @returns the current updated Vector3
  67547. */
  67548. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67549. /**
  67550. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67551. * @param x defines the x coordinate of the operand
  67552. * @param y defines the y coordinate of the operand
  67553. * @param z defines the z coordinate of the operand
  67554. * @returns the current updated Vector3
  67555. */
  67556. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67557. /**
  67558. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67559. * @param x defines the x coordinate of the operand
  67560. * @param y defines the y coordinate of the operand
  67561. * @param z defines the z coordinate of the operand
  67562. * @returns the current updated Vector3
  67563. */
  67564. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67565. /**
  67566. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67567. * Check if is non uniform within a certain amount of decimal places to account for this
  67568. * @param epsilon the amount the values can differ
  67569. * @returns if the the vector is non uniform to a certain number of decimal places
  67570. */
  67571. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67572. /**
  67573. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67574. */
  67575. readonly isNonUniform: boolean;
  67576. /**
  67577. * Gets a new Vector3 from current Vector3 floored values
  67578. * @returns a new Vector3
  67579. */
  67580. floor(): Vector3;
  67581. /**
  67582. * Gets a new Vector3 from current Vector3 floored values
  67583. * @returns a new Vector3
  67584. */
  67585. fract(): Vector3;
  67586. /**
  67587. * Gets the length of the Vector3
  67588. * @returns the length of the Vector3
  67589. */
  67590. length(): number;
  67591. /**
  67592. * Gets the squared length of the Vector3
  67593. * @returns squared length of the Vector3
  67594. */
  67595. lengthSquared(): number;
  67596. /**
  67597. * Normalize the current Vector3.
  67598. * Please note that this is an in place operation.
  67599. * @returns the current updated Vector3
  67600. */
  67601. normalize(): Vector3;
  67602. /**
  67603. * Reorders the x y z properties of the vector in place
  67604. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67605. * @returns the current updated vector
  67606. */
  67607. reorderInPlace(order: string): this;
  67608. /**
  67609. * Rotates the vector around 0,0,0 by a quaternion
  67610. * @param quaternion the rotation quaternion
  67611. * @param result vector to store the result
  67612. * @returns the resulting vector
  67613. */
  67614. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67615. /**
  67616. * Rotates a vector around a given point
  67617. * @param quaternion the rotation quaternion
  67618. * @param point the point to rotate around
  67619. * @param result vector to store the result
  67620. * @returns the resulting vector
  67621. */
  67622. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67623. /**
  67624. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67625. * The cross product is then orthogonal to both current and "other"
  67626. * @param other defines the right operand
  67627. * @returns the cross product
  67628. */
  67629. cross(other: Vector3): Vector3;
  67630. /**
  67631. * Normalize the current Vector3 with the given input length.
  67632. * Please note that this is an in place operation.
  67633. * @param len the length of the vector
  67634. * @returns the current updated Vector3
  67635. */
  67636. normalizeFromLength(len: number): Vector3;
  67637. /**
  67638. * Normalize the current Vector3 to a new vector
  67639. * @returns the new Vector3
  67640. */
  67641. normalizeToNew(): Vector3;
  67642. /**
  67643. * Normalize the current Vector3 to the reference
  67644. * @param reference define the Vector3 to update
  67645. * @returns the updated Vector3
  67646. */
  67647. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67648. /**
  67649. * Creates a new Vector3 copied from the current Vector3
  67650. * @returns the new Vector3
  67651. */
  67652. clone(): Vector3;
  67653. /**
  67654. * Copies the given vector coordinates to the current Vector3 ones
  67655. * @param source defines the source Vector3
  67656. * @returns the current updated Vector3
  67657. */
  67658. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67659. /**
  67660. * Copies the given floats to the current Vector3 coordinates
  67661. * @param x defines the x coordinate of the operand
  67662. * @param y defines the y coordinate of the operand
  67663. * @param z defines the z coordinate of the operand
  67664. * @returns the current updated Vector3
  67665. */
  67666. copyFromFloats(x: number, y: number, z: number): Vector3;
  67667. /**
  67668. * Copies the given floats to the current Vector3 coordinates
  67669. * @param x defines the x coordinate of the operand
  67670. * @param y defines the y coordinate of the operand
  67671. * @param z defines the z coordinate of the operand
  67672. * @returns the current updated Vector3
  67673. */
  67674. set(x: number, y: number, z: number): Vector3;
  67675. /**
  67676. * Copies the given float to the current Vector3 coordinates
  67677. * @param v defines the x, y and z coordinates of the operand
  67678. * @returns the current updated Vector3
  67679. */
  67680. setAll(v: number): Vector3;
  67681. /**
  67682. * Get the clip factor between two vectors
  67683. * @param vector0 defines the first operand
  67684. * @param vector1 defines the second operand
  67685. * @param axis defines the axis to use
  67686. * @param size defines the size along the axis
  67687. * @returns the clip factor
  67688. */
  67689. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67690. /**
  67691. * Get angle between two vectors
  67692. * @param vector0 angle between vector0 and vector1
  67693. * @param vector1 angle between vector0 and vector1
  67694. * @param normal direction of the normal
  67695. * @return the angle between vector0 and vector1
  67696. */
  67697. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67698. /**
  67699. * Returns a new Vector3 set from the index "offset" of the given array
  67700. * @param array defines the source array
  67701. * @param offset defines the offset in the source array
  67702. * @returns the new Vector3
  67703. */
  67704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67705. /**
  67706. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67707. * This function is deprecated. Use FromArray instead
  67708. * @param array defines the source array
  67709. * @param offset defines the offset in the source array
  67710. * @returns the new Vector3
  67711. */
  67712. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67713. /**
  67714. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67715. * @param array defines the source array
  67716. * @param offset defines the offset in the source array
  67717. * @param result defines the Vector3 where to store the result
  67718. */
  67719. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67720. /**
  67721. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67722. * This function is deprecated. Use FromArrayToRef instead.
  67723. * @param array defines the source array
  67724. * @param offset defines the offset in the source array
  67725. * @param result defines the Vector3 where to store the result
  67726. */
  67727. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67728. /**
  67729. * Sets the given vector "result" with the given floats.
  67730. * @param x defines the x coordinate of the source
  67731. * @param y defines the y coordinate of the source
  67732. * @param z defines the z coordinate of the source
  67733. * @param result defines the Vector3 where to store the result
  67734. */
  67735. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67736. /**
  67737. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67738. * @returns a new empty Vector3
  67739. */
  67740. static Zero(): Vector3;
  67741. /**
  67742. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67743. * @returns a new unit Vector3
  67744. */
  67745. static One(): Vector3;
  67746. /**
  67747. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67748. * @returns a new up Vector3
  67749. */
  67750. static Up(): Vector3;
  67751. /**
  67752. * Gets a up Vector3 that must not be updated
  67753. */
  67754. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67755. /**
  67756. * Gets a zero Vector3 that must not be updated
  67757. */
  67758. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67759. /**
  67760. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67761. * @returns a new down Vector3
  67762. */
  67763. static Down(): Vector3;
  67764. /**
  67765. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67766. * @returns a new forward Vector3
  67767. */
  67768. static Forward(): Vector3;
  67769. /**
  67770. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67771. * @returns a new forward Vector3
  67772. */
  67773. static Backward(): Vector3;
  67774. /**
  67775. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67776. * @returns a new right Vector3
  67777. */
  67778. static Right(): Vector3;
  67779. /**
  67780. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67781. * @returns a new left Vector3
  67782. */
  67783. static Left(): Vector3;
  67784. /**
  67785. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67786. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67787. * @param vector defines the Vector3 to transform
  67788. * @param transformation defines the transformation matrix
  67789. * @returns the transformed Vector3
  67790. */
  67791. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67792. /**
  67793. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67795. * @param vector defines the Vector3 to transform
  67796. * @param transformation defines the transformation matrix
  67797. * @param result defines the Vector3 where to store the result
  67798. */
  67799. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67800. /**
  67801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67802. * This method computes tranformed coordinates only, not transformed direction vectors
  67803. * @param x define the x coordinate of the source vector
  67804. * @param y define the y coordinate of the source vector
  67805. * @param z define the z coordinate of the source vector
  67806. * @param transformation defines the transformation matrix
  67807. * @param result defines the Vector3 where to store the result
  67808. */
  67809. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67810. /**
  67811. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67812. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67813. * @param vector defines the Vector3 to transform
  67814. * @param transformation defines the transformation matrix
  67815. * @returns the new Vector3
  67816. */
  67817. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67818. /**
  67819. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67821. * @param vector defines the Vector3 to transform
  67822. * @param transformation defines the transformation matrix
  67823. * @param result defines the Vector3 where to store the result
  67824. */
  67825. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67826. /**
  67827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67829. * @param x define the x coordinate of the source vector
  67830. * @param y define the y coordinate of the source vector
  67831. * @param z define the z coordinate of the source vector
  67832. * @param transformation defines the transformation matrix
  67833. * @param result defines the Vector3 where to store the result
  67834. */
  67835. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67836. /**
  67837. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67838. * @param value1 defines the first control point
  67839. * @param value2 defines the second control point
  67840. * @param value3 defines the third control point
  67841. * @param value4 defines the fourth control point
  67842. * @param amount defines the amount on the spline to use
  67843. * @returns the new Vector3
  67844. */
  67845. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67846. /**
  67847. * 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"
  67848. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67849. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67850. * @param value defines the current value
  67851. * @param min defines the lower range value
  67852. * @param max defines the upper range value
  67853. * @returns the new Vector3
  67854. */
  67855. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67856. /**
  67857. * 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"
  67858. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67859. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67860. * @param value defines the current value
  67861. * @param min defines the lower range value
  67862. * @param max defines the upper range value
  67863. * @param result defines the Vector3 where to store the result
  67864. */
  67865. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67866. /**
  67867. * Checks if a given vector is inside a specific range
  67868. * @param v defines the vector to test
  67869. * @param min defines the minimum range
  67870. * @param max defines the maximum range
  67871. */
  67872. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67873. /**
  67874. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67875. * @param value1 defines the first control point
  67876. * @param tangent1 defines the first tangent vector
  67877. * @param value2 defines the second control point
  67878. * @param tangent2 defines the second tangent vector
  67879. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67880. * @returns the new Vector3
  67881. */
  67882. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67883. /**
  67884. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67885. * @param start defines the start value
  67886. * @param end defines the end value
  67887. * @param amount max defines amount between both (between 0 and 1)
  67888. * @returns the new Vector3
  67889. */
  67890. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  67891. /**
  67892. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  67893. * @param start defines the start value
  67894. * @param end defines the end value
  67895. * @param amount max defines amount between both (between 0 and 1)
  67896. * @param result defines the Vector3 where to store the result
  67897. */
  67898. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  67899. /**
  67900. * Returns the dot product (float) between the vectors "left" and "right"
  67901. * @param left defines the left operand
  67902. * @param right defines the right operand
  67903. * @returns the dot product
  67904. */
  67905. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67906. /**
  67907. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67908. * The cross product is then orthogonal to both "left" and "right"
  67909. * @param left defines the left operand
  67910. * @param right defines the right operand
  67911. * @returns the cross product
  67912. */
  67913. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67914. /**
  67915. * Sets the given vector "result" with the cross product of "left" and "right"
  67916. * The cross product is then orthogonal to both "left" and "right"
  67917. * @param left defines the left operand
  67918. * @param right defines the right operand
  67919. * @param result defines the Vector3 where to store the result
  67920. */
  67921. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67922. /**
  67923. * Returns a new Vector3 as the normalization of the given vector
  67924. * @param vector defines the Vector3 to normalize
  67925. * @returns the new Vector3
  67926. */
  67927. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67928. /**
  67929. * Sets the given vector "result" with the normalization of the given first vector
  67930. * @param vector defines the Vector3 to normalize
  67931. * @param result defines the Vector3 where to store the result
  67932. */
  67933. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67934. /**
  67935. * Project a Vector3 onto screen space
  67936. * @param vector defines the Vector3 to project
  67937. * @param world defines the world matrix to use
  67938. * @param transform defines the transform (view x projection) matrix to use
  67939. * @param viewport defines the screen viewport to use
  67940. * @returns the new Vector3
  67941. */
  67942. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67943. /** @hidden */
  67944. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67945. /**
  67946. * Unproject from screen space to object space
  67947. * @param source defines the screen space Vector3 to use
  67948. * @param viewportWidth defines the current width of the viewport
  67949. * @param viewportHeight defines the current height of the viewport
  67950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67951. * @param transform defines the transform (view x projection) matrix to use
  67952. * @returns the new Vector3
  67953. */
  67954. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67955. /**
  67956. * Unproject from screen space to object space
  67957. * @param source defines the screen space Vector3 to use
  67958. * @param viewportWidth defines the current width of the viewport
  67959. * @param viewportHeight defines the current height of the viewport
  67960. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67961. * @param view defines the view matrix to use
  67962. * @param projection defines the projection matrix to use
  67963. * @returns the new Vector3
  67964. */
  67965. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  67966. /**
  67967. * Unproject from screen space to object space
  67968. * @param source defines the screen space Vector3 to use
  67969. * @param viewportWidth defines the current width of the viewport
  67970. * @param viewportHeight defines the current height of the viewport
  67971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67972. * @param view defines the view matrix to use
  67973. * @param projection defines the projection matrix to use
  67974. * @param result defines the Vector3 where to store the result
  67975. */
  67976. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67977. /**
  67978. * Unproject from screen space to object space
  67979. * @param sourceX defines the screen space x coordinate to use
  67980. * @param sourceY defines the screen space y coordinate to use
  67981. * @param sourceZ defines the screen space z coordinate to use
  67982. * @param viewportWidth defines the current width of the viewport
  67983. * @param viewportHeight defines the current height of the viewport
  67984. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67985. * @param view defines the view matrix to use
  67986. * @param projection defines the projection matrix to use
  67987. * @param result defines the Vector3 where to store the result
  67988. */
  67989. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67990. /**
  67991. * Gets the minimal coordinate values between two Vector3
  67992. * @param left defines the first operand
  67993. * @param right defines the second operand
  67994. * @returns the new Vector3
  67995. */
  67996. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67997. /**
  67998. * Gets the maximal coordinate values between two Vector3
  67999. * @param left defines the first operand
  68000. * @param right defines the second operand
  68001. * @returns the new Vector3
  68002. */
  68003. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68004. /**
  68005. * Returns the distance between the vectors "value1" and "value2"
  68006. * @param value1 defines the first operand
  68007. * @param value2 defines the second operand
  68008. * @returns the distance
  68009. */
  68010. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68011. /**
  68012. * Returns the squared distance between the vectors "value1" and "value2"
  68013. * @param value1 defines the first operand
  68014. * @param value2 defines the second operand
  68015. * @returns the squared distance
  68016. */
  68017. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68018. /**
  68019. * Returns a new Vector3 located at the center between "value1" and "value2"
  68020. * @param value1 defines the first operand
  68021. * @param value2 defines the second operand
  68022. * @returns the new Vector3
  68023. */
  68024. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68025. /**
  68026. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68027. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68028. * to something in order to rotate it from its local system to the given target system
  68029. * Note: axis1, axis2 and axis3 are normalized during this operation
  68030. * @param axis1 defines the first axis
  68031. * @param axis2 defines the second axis
  68032. * @param axis3 defines the third axis
  68033. * @returns a new Vector3
  68034. */
  68035. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68036. /**
  68037. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68038. * @param axis1 defines the first axis
  68039. * @param axis2 defines the second axis
  68040. * @param axis3 defines the third axis
  68041. * @param ref defines the Vector3 where to store the result
  68042. */
  68043. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68044. }
  68045. /**
  68046. * Vector4 class created for EulerAngle class conversion to Quaternion
  68047. */
  68048. export class Vector4 {
  68049. /** x value of the vector */
  68050. x: number;
  68051. /** y value of the vector */
  68052. y: number;
  68053. /** z value of the vector */
  68054. z: number;
  68055. /** w value of the vector */
  68056. w: number;
  68057. /**
  68058. * Creates a Vector4 object from the given floats.
  68059. * @param x x value of the vector
  68060. * @param y y value of the vector
  68061. * @param z z value of the vector
  68062. * @param w w value of the vector
  68063. */
  68064. constructor(
  68065. /** x value of the vector */
  68066. x: number,
  68067. /** y value of the vector */
  68068. y: number,
  68069. /** z value of the vector */
  68070. z: number,
  68071. /** w value of the vector */
  68072. w: number);
  68073. /**
  68074. * Returns the string with the Vector4 coordinates.
  68075. * @returns a string containing all the vector values
  68076. */
  68077. toString(): string;
  68078. /**
  68079. * Returns the string "Vector4".
  68080. * @returns "Vector4"
  68081. */
  68082. getClassName(): string;
  68083. /**
  68084. * Returns the Vector4 hash code.
  68085. * @returns a unique hash code
  68086. */
  68087. getHashCode(): number;
  68088. /**
  68089. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68090. * @returns the resulting array
  68091. */
  68092. asArray(): number[];
  68093. /**
  68094. * Populates the given array from the given index with the Vector4 coordinates.
  68095. * @param array array to populate
  68096. * @param index index of the array to start at (default: 0)
  68097. * @returns the Vector4.
  68098. */
  68099. toArray(array: FloatArray, index?: number): Vector4;
  68100. /**
  68101. * Adds the given vector to the current Vector4.
  68102. * @param otherVector the vector to add
  68103. * @returns the updated Vector4.
  68104. */
  68105. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68106. /**
  68107. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68108. * @param otherVector the vector to add
  68109. * @returns the resulting vector
  68110. */
  68111. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68112. /**
  68113. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68114. * @param otherVector the vector to add
  68115. * @param result the vector to store the result
  68116. * @returns the current Vector4.
  68117. */
  68118. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68119. /**
  68120. * Subtract in place the given vector from the current Vector4.
  68121. * @param otherVector the vector to subtract
  68122. * @returns the updated Vector4.
  68123. */
  68124. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68125. /**
  68126. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68127. * @param otherVector the vector to add
  68128. * @returns the new vector with the result
  68129. */
  68130. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68131. /**
  68132. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68133. * @param otherVector the vector to subtract
  68134. * @param result the vector to store the result
  68135. * @returns the current Vector4.
  68136. */
  68137. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68138. /**
  68139. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68140. */
  68141. /**
  68142. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68143. * @param x value to subtract
  68144. * @param y value to subtract
  68145. * @param z value to subtract
  68146. * @param w value to subtract
  68147. * @returns new vector containing the result
  68148. */
  68149. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68150. /**
  68151. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68152. * @param x value to subtract
  68153. * @param y value to subtract
  68154. * @param z value to subtract
  68155. * @param w value to subtract
  68156. * @param result the vector to store the result in
  68157. * @returns the current Vector4.
  68158. */
  68159. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68160. /**
  68161. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68162. * @returns a new vector with the negated values
  68163. */
  68164. negate(): Vector4;
  68165. /**
  68166. * Multiplies the current Vector4 coordinates by scale (float).
  68167. * @param scale the number to scale with
  68168. * @returns the updated Vector4.
  68169. */
  68170. scaleInPlace(scale: number): Vector4;
  68171. /**
  68172. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68173. * @param scale the number to scale with
  68174. * @returns a new vector with the result
  68175. */
  68176. scale(scale: number): Vector4;
  68177. /**
  68178. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68179. * @param scale the number to scale with
  68180. * @param result a vector to store the result in
  68181. * @returns the current Vector4.
  68182. */
  68183. scaleToRef(scale: number, result: Vector4): Vector4;
  68184. /**
  68185. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68186. * @param scale defines the scale factor
  68187. * @param result defines the Vector4 object where to store the result
  68188. * @returns the unmodified current Vector4
  68189. */
  68190. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68191. /**
  68192. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68193. * @param otherVector the vector to compare against
  68194. * @returns true if they are equal
  68195. */
  68196. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68197. /**
  68198. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68199. * @param otherVector vector to compare against
  68200. * @param epsilon (Default: very small number)
  68201. * @returns true if they are equal
  68202. */
  68203. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68204. /**
  68205. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68206. * @param x x value to compare against
  68207. * @param y y value to compare against
  68208. * @param z z value to compare against
  68209. * @param w w value to compare against
  68210. * @returns true if equal
  68211. */
  68212. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68213. /**
  68214. * Multiplies in place the current Vector4 by the given one.
  68215. * @param otherVector vector to multiple with
  68216. * @returns the updated Vector4.
  68217. */
  68218. multiplyInPlace(otherVector: Vector4): Vector4;
  68219. /**
  68220. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68221. * @param otherVector vector to multiple with
  68222. * @returns resulting new vector
  68223. */
  68224. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68225. /**
  68226. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68227. * @param otherVector vector to multiple with
  68228. * @param result vector to store the result
  68229. * @returns the current Vector4.
  68230. */
  68231. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68232. /**
  68233. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68234. * @param x x value multiply with
  68235. * @param y y value multiply with
  68236. * @param z z value multiply with
  68237. * @param w w value multiply with
  68238. * @returns resulting new vector
  68239. */
  68240. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68241. /**
  68242. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68243. * @param otherVector vector to devide with
  68244. * @returns resulting new vector
  68245. */
  68246. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68247. /**
  68248. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68249. * @param otherVector vector to devide with
  68250. * @param result vector to store the result
  68251. * @returns the current Vector4.
  68252. */
  68253. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68254. /**
  68255. * Divides the current Vector3 coordinates by the given ones.
  68256. * @param otherVector vector to devide with
  68257. * @returns the updated Vector3.
  68258. */
  68259. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68260. /**
  68261. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68262. * @param other defines the second operand
  68263. * @returns the current updated Vector4
  68264. */
  68265. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68266. /**
  68267. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68268. * @param other defines the second operand
  68269. * @returns the current updated Vector4
  68270. */
  68271. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68272. /**
  68273. * Gets a new Vector4 from current Vector4 floored values
  68274. * @returns a new Vector4
  68275. */
  68276. floor(): Vector4;
  68277. /**
  68278. * Gets a new Vector4 from current Vector3 floored values
  68279. * @returns a new Vector4
  68280. */
  68281. fract(): Vector4;
  68282. /**
  68283. * Returns the Vector4 length (float).
  68284. * @returns the length
  68285. */
  68286. length(): number;
  68287. /**
  68288. * Returns the Vector4 squared length (float).
  68289. * @returns the length squared
  68290. */
  68291. lengthSquared(): number;
  68292. /**
  68293. * Normalizes in place the Vector4.
  68294. * @returns the updated Vector4.
  68295. */
  68296. normalize(): Vector4;
  68297. /**
  68298. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68299. * @returns this converted to a new vector3
  68300. */
  68301. toVector3(): Vector3;
  68302. /**
  68303. * Returns a new Vector4 copied from the current one.
  68304. * @returns the new cloned vector
  68305. */
  68306. clone(): Vector4;
  68307. /**
  68308. * Updates the current Vector4 with the given one coordinates.
  68309. * @param source the source vector to copy from
  68310. * @returns the updated Vector4.
  68311. */
  68312. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68313. /**
  68314. * Updates the current Vector4 coordinates with the given floats.
  68315. * @param x float to copy from
  68316. * @param y float to copy from
  68317. * @param z float to copy from
  68318. * @param w float to copy from
  68319. * @returns the updated Vector4.
  68320. */
  68321. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68322. /**
  68323. * Updates the current Vector4 coordinates with the given floats.
  68324. * @param x float to set from
  68325. * @param y float to set from
  68326. * @param z float to set from
  68327. * @param w float to set from
  68328. * @returns the updated Vector4.
  68329. */
  68330. set(x: number, y: number, z: number, w: number): Vector4;
  68331. /**
  68332. * Copies the given float to the current Vector3 coordinates
  68333. * @param v defines the x, y, z and w coordinates of the operand
  68334. * @returns the current updated Vector3
  68335. */
  68336. setAll(v: number): Vector4;
  68337. /**
  68338. * Returns a new Vector4 set from the starting index of the given array.
  68339. * @param array the array to pull values from
  68340. * @param offset the offset into the array to start at
  68341. * @returns the new vector
  68342. */
  68343. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68344. /**
  68345. * Updates the given vector "result" from the starting index of the given array.
  68346. * @param array the array to pull values from
  68347. * @param offset the offset into the array to start at
  68348. * @param result the vector to store the result in
  68349. */
  68350. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68351. /**
  68352. * Updates the given vector "result" from the starting index of the given Float32Array.
  68353. * @param array the array to pull values from
  68354. * @param offset the offset into the array to start at
  68355. * @param result the vector to store the result in
  68356. */
  68357. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68358. /**
  68359. * Updates the given vector "result" coordinates from the given floats.
  68360. * @param x float to set from
  68361. * @param y float to set from
  68362. * @param z float to set from
  68363. * @param w float to set from
  68364. * @param result the vector to the floats in
  68365. */
  68366. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68367. /**
  68368. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68369. * @returns the new vector
  68370. */
  68371. static Zero(): Vector4;
  68372. /**
  68373. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68374. * @returns the new vector
  68375. */
  68376. static One(): Vector4;
  68377. /**
  68378. * Returns a new normalized Vector4 from the given one.
  68379. * @param vector the vector to normalize
  68380. * @returns the vector
  68381. */
  68382. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68383. /**
  68384. * Updates the given vector "result" from the normalization of the given one.
  68385. * @param vector the vector to normalize
  68386. * @param result the vector to store the result in
  68387. */
  68388. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68389. /**
  68390. * Returns a vector with the minimum values from the left and right vectors
  68391. * @param left left vector to minimize
  68392. * @param right right vector to minimize
  68393. * @returns a new vector with the minimum of the left and right vector values
  68394. */
  68395. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68396. /**
  68397. * Returns a vector with the maximum values from the left and right vectors
  68398. * @param left left vector to maximize
  68399. * @param right right vector to maximize
  68400. * @returns a new vector with the maximum of the left and right vector values
  68401. */
  68402. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68403. /**
  68404. * Returns the distance (float) between the vectors "value1" and "value2".
  68405. * @param value1 value to calulate the distance between
  68406. * @param value2 value to calulate the distance between
  68407. * @return the distance between the two vectors
  68408. */
  68409. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68410. /**
  68411. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68412. * @param value1 value to calulate the distance between
  68413. * @param value2 value to calulate the distance between
  68414. * @return the distance between the two vectors squared
  68415. */
  68416. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68417. /**
  68418. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68419. * @param value1 value to calulate the center between
  68420. * @param value2 value to calulate the center between
  68421. * @return the center between the two vectors
  68422. */
  68423. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68424. /**
  68425. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68426. * This methods computes transformed normalized direction vectors only.
  68427. * @param vector the vector to transform
  68428. * @param transformation the transformation matrix to apply
  68429. * @returns the new vector
  68430. */
  68431. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68432. /**
  68433. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68434. * This methods computes transformed normalized direction vectors only.
  68435. * @param vector the vector to transform
  68436. * @param transformation the transformation matrix to apply
  68437. * @param result the vector to store the result in
  68438. */
  68439. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68440. /**
  68441. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68442. * This methods computes transformed normalized direction vectors only.
  68443. * @param x value to transform
  68444. * @param y value to transform
  68445. * @param z value to transform
  68446. * @param w value to transform
  68447. * @param transformation the transformation matrix to apply
  68448. * @param result the vector to store the results in
  68449. */
  68450. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68451. /**
  68452. * Creates a new Vector4 from a Vector3
  68453. * @param source defines the source data
  68454. * @param w defines the 4th component (default is 0)
  68455. * @returns a new Vector4
  68456. */
  68457. static FromVector3(source: Vector3, w?: number): Vector4;
  68458. }
  68459. /**
  68460. * Class used to store quaternion data
  68461. * @see https://en.wikipedia.org/wiki/Quaternion
  68462. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68463. */
  68464. export class Quaternion {
  68465. /** defines the first component (0 by default) */
  68466. x: number;
  68467. /** defines the second component (0 by default) */
  68468. y: number;
  68469. /** defines the third component (0 by default) */
  68470. z: number;
  68471. /** defines the fourth component (1.0 by default) */
  68472. w: number;
  68473. /**
  68474. * Creates a new Quaternion from the given floats
  68475. * @param x defines the first component (0 by default)
  68476. * @param y defines the second component (0 by default)
  68477. * @param z defines the third component (0 by default)
  68478. * @param w defines the fourth component (1.0 by default)
  68479. */
  68480. constructor(
  68481. /** defines the first component (0 by default) */
  68482. x?: number,
  68483. /** defines the second component (0 by default) */
  68484. y?: number,
  68485. /** defines the third component (0 by default) */
  68486. z?: number,
  68487. /** defines the fourth component (1.0 by default) */
  68488. w?: number);
  68489. /**
  68490. * Gets a string representation for the current quaternion
  68491. * @returns a string with the Quaternion coordinates
  68492. */
  68493. toString(): string;
  68494. /**
  68495. * Gets the class name of the quaternion
  68496. * @returns the string "Quaternion"
  68497. */
  68498. getClassName(): string;
  68499. /**
  68500. * Gets a hash code for this quaternion
  68501. * @returns the quaternion hash code
  68502. */
  68503. getHashCode(): number;
  68504. /**
  68505. * Copy the quaternion to an array
  68506. * @returns a new array populated with 4 elements from the quaternion coordinates
  68507. */
  68508. asArray(): number[];
  68509. /**
  68510. * Check if two quaternions are equals
  68511. * @param otherQuaternion defines the second operand
  68512. * @return true if the current quaternion and the given one coordinates are strictly equals
  68513. */
  68514. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68515. /**
  68516. * Clone the current quaternion
  68517. * @returns a new quaternion copied from the current one
  68518. */
  68519. clone(): Quaternion;
  68520. /**
  68521. * Copy a quaternion to the current one
  68522. * @param other defines the other quaternion
  68523. * @returns the updated current quaternion
  68524. */
  68525. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68526. /**
  68527. * Updates the current quaternion with the given float coordinates
  68528. * @param x defines the x coordinate
  68529. * @param y defines the y coordinate
  68530. * @param z defines the z coordinate
  68531. * @param w defines the w coordinate
  68532. * @returns the updated current quaternion
  68533. */
  68534. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68535. /**
  68536. * Updates the current quaternion from the given float coordinates
  68537. * @param x defines the x coordinate
  68538. * @param y defines the y coordinate
  68539. * @param z defines the z coordinate
  68540. * @param w defines the w coordinate
  68541. * @returns the updated current quaternion
  68542. */
  68543. set(x: number, y: number, z: number, w: number): Quaternion;
  68544. /**
  68545. * Adds two quaternions
  68546. * @param other defines the second operand
  68547. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68548. */
  68549. add(other: DeepImmutable<Quaternion>): Quaternion;
  68550. /**
  68551. * Add a quaternion to the current one
  68552. * @param other defines the quaternion to add
  68553. * @returns the current quaternion
  68554. */
  68555. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68556. /**
  68557. * Subtract two quaternions
  68558. * @param other defines the second operand
  68559. * @returns a new quaternion as the subtraction result of the given one from the current one
  68560. */
  68561. subtract(other: Quaternion): Quaternion;
  68562. /**
  68563. * Multiplies the current quaternion by a scale factor
  68564. * @param value defines the scale factor
  68565. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68566. */
  68567. scale(value: number): Quaternion;
  68568. /**
  68569. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68570. * @param scale defines the scale factor
  68571. * @param result defines the Quaternion object where to store the result
  68572. * @returns the unmodified current quaternion
  68573. */
  68574. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68575. /**
  68576. * Multiplies in place the current quaternion by a scale factor
  68577. * @param value defines the scale factor
  68578. * @returns the current modified quaternion
  68579. */
  68580. scaleInPlace(value: number): Quaternion;
  68581. /**
  68582. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68583. * @param scale defines the scale factor
  68584. * @param result defines the Quaternion object where to store the result
  68585. * @returns the unmodified current quaternion
  68586. */
  68587. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68588. /**
  68589. * Multiplies two quaternions
  68590. * @param q1 defines the second operand
  68591. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68592. */
  68593. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68594. /**
  68595. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68596. * @param q1 defines the second operand
  68597. * @param result defines the target quaternion
  68598. * @returns the current quaternion
  68599. */
  68600. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68601. /**
  68602. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68603. * @param q1 defines the second operand
  68604. * @returns the currentupdated quaternion
  68605. */
  68606. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68607. /**
  68608. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68609. * @param ref defines the target quaternion
  68610. * @returns the current quaternion
  68611. */
  68612. conjugateToRef(ref: Quaternion): Quaternion;
  68613. /**
  68614. * Conjugates in place (1-q) the current quaternion
  68615. * @returns the current updated quaternion
  68616. */
  68617. conjugateInPlace(): Quaternion;
  68618. /**
  68619. * Conjugates in place (1-q) the current quaternion
  68620. * @returns a new quaternion
  68621. */
  68622. conjugate(): Quaternion;
  68623. /**
  68624. * Gets length of current quaternion
  68625. * @returns the quaternion length (float)
  68626. */
  68627. length(): number;
  68628. /**
  68629. * Normalize in place the current quaternion
  68630. * @returns the current updated quaternion
  68631. */
  68632. normalize(): Quaternion;
  68633. /**
  68634. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68635. * @param order is a reserved parameter and is ignore for now
  68636. * @returns a new Vector3 containing the Euler angles
  68637. */
  68638. toEulerAngles(order?: string): Vector3;
  68639. /**
  68640. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68641. * @param result defines the vector which will be filled with the Euler angles
  68642. * @param order is a reserved parameter and is ignore for now
  68643. * @returns the current unchanged quaternion
  68644. */
  68645. toEulerAnglesToRef(result: Vector3): Quaternion;
  68646. /**
  68647. * Updates the given rotation matrix with the current quaternion values
  68648. * @param result defines the target matrix
  68649. * @returns the current unchanged quaternion
  68650. */
  68651. toRotationMatrix(result: Matrix): Quaternion;
  68652. /**
  68653. * Updates the current quaternion from the given rotation matrix values
  68654. * @param matrix defines the source matrix
  68655. * @returns the current updated quaternion
  68656. */
  68657. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68658. /**
  68659. * Creates a new quaternion from a rotation matrix
  68660. * @param matrix defines the source matrix
  68661. * @returns a new quaternion created from the given rotation matrix values
  68662. */
  68663. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68664. /**
  68665. * Updates the given quaternion with the given rotation matrix values
  68666. * @param matrix defines the source matrix
  68667. * @param result defines the target quaternion
  68668. */
  68669. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68670. /**
  68671. * Returns the dot product (float) between the quaternions "left" and "right"
  68672. * @param left defines the left operand
  68673. * @param right defines the right operand
  68674. * @returns the dot product
  68675. */
  68676. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68677. /**
  68678. * Checks if the two quaternions are close to each other
  68679. * @param quat0 defines the first quaternion to check
  68680. * @param quat1 defines the second quaternion to check
  68681. * @returns true if the two quaternions are close to each other
  68682. */
  68683. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68684. /**
  68685. * Creates an empty quaternion
  68686. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68687. */
  68688. static Zero(): Quaternion;
  68689. /**
  68690. * Inverse a given quaternion
  68691. * @param q defines the source quaternion
  68692. * @returns a new quaternion as the inverted current quaternion
  68693. */
  68694. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68695. /**
  68696. * Inverse a given quaternion
  68697. * @param q defines the source quaternion
  68698. * @param result the quaternion the result will be stored in
  68699. * @returns the result quaternion
  68700. */
  68701. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68702. /**
  68703. * Creates an identity quaternion
  68704. * @returns the identity quaternion
  68705. */
  68706. static Identity(): Quaternion;
  68707. /**
  68708. * Gets a boolean indicating if the given quaternion is identity
  68709. * @param quaternion defines the quaternion to check
  68710. * @returns true if the quaternion is identity
  68711. */
  68712. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68713. /**
  68714. * Creates a quaternion from a rotation around an axis
  68715. * @param axis defines the axis to use
  68716. * @param angle defines the angle to use
  68717. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68718. */
  68719. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68720. /**
  68721. * Creates a rotation around an axis and stores it into the given quaternion
  68722. * @param axis defines the axis to use
  68723. * @param angle defines the angle to use
  68724. * @param result defines the target quaternion
  68725. * @returns the target quaternion
  68726. */
  68727. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68728. /**
  68729. * Creates a new quaternion from data stored into an array
  68730. * @param array defines the data source
  68731. * @param offset defines the offset in the source array where the data starts
  68732. * @returns a new quaternion
  68733. */
  68734. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68735. /**
  68736. * Create a quaternion from Euler rotation angles
  68737. * @param x Pitch
  68738. * @param y Yaw
  68739. * @param z Roll
  68740. * @returns the new Quaternion
  68741. */
  68742. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68743. /**
  68744. * Updates a quaternion from Euler rotation angles
  68745. * @param x Pitch
  68746. * @param y Yaw
  68747. * @param z Roll
  68748. * @param result the quaternion to store the result
  68749. * @returns the updated quaternion
  68750. */
  68751. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68752. /**
  68753. * Create a quaternion from Euler rotation vector
  68754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68755. * @returns the new Quaternion
  68756. */
  68757. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68758. /**
  68759. * Updates a quaternion from Euler rotation vector
  68760. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68761. * @param result the quaternion to store the result
  68762. * @returns the updated quaternion
  68763. */
  68764. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68765. /**
  68766. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68767. * @param yaw defines the rotation around Y axis
  68768. * @param pitch defines the rotation around X axis
  68769. * @param roll defines the rotation around Z axis
  68770. * @returns the new quaternion
  68771. */
  68772. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68773. /**
  68774. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68775. * @param yaw defines the rotation around Y axis
  68776. * @param pitch defines the rotation around X axis
  68777. * @param roll defines the rotation around Z axis
  68778. * @param result defines the target quaternion
  68779. */
  68780. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68781. /**
  68782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68783. * @param alpha defines the rotation around first axis
  68784. * @param beta defines the rotation around second axis
  68785. * @param gamma defines the rotation around third axis
  68786. * @returns the new quaternion
  68787. */
  68788. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68789. /**
  68790. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68791. * @param alpha defines the rotation around first axis
  68792. * @param beta defines the rotation around second axis
  68793. * @param gamma defines the rotation around third axis
  68794. * @param result defines the target quaternion
  68795. */
  68796. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68797. /**
  68798. * 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)
  68799. * @param axis1 defines the first axis
  68800. * @param axis2 defines the second axis
  68801. * @param axis3 defines the third axis
  68802. * @returns the new quaternion
  68803. */
  68804. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68805. /**
  68806. * 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
  68807. * @param axis1 defines the first axis
  68808. * @param axis2 defines the second axis
  68809. * @param axis3 defines the third axis
  68810. * @param ref defines the target quaternion
  68811. */
  68812. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68813. /**
  68814. * Interpolates between two quaternions
  68815. * @param left defines first quaternion
  68816. * @param right defines second quaternion
  68817. * @param amount defines the gradient to use
  68818. * @returns the new interpolated quaternion
  68819. */
  68820. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68821. /**
  68822. * Interpolates between two quaternions and stores it into a target quaternion
  68823. * @param left defines first quaternion
  68824. * @param right defines second quaternion
  68825. * @param amount defines the gradient to use
  68826. * @param result defines the target quaternion
  68827. */
  68828. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68829. /**
  68830. * Interpolate between two quaternions using Hermite interpolation
  68831. * @param value1 defines first quaternion
  68832. * @param tangent1 defines the incoming tangent
  68833. * @param value2 defines second quaternion
  68834. * @param tangent2 defines the outgoing tangent
  68835. * @param amount defines the target quaternion
  68836. * @returns the new interpolated quaternion
  68837. */
  68838. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68839. }
  68840. /**
  68841. * Class used to store matrix data (4x4)
  68842. */
  68843. export class Matrix {
  68844. private static _updateFlagSeed;
  68845. private static _identityReadOnly;
  68846. private _isIdentity;
  68847. private _isIdentityDirty;
  68848. private _isIdentity3x2;
  68849. private _isIdentity3x2Dirty;
  68850. /**
  68851. * Gets the update flag of the matrix which is an unique number for the matrix.
  68852. * It will be incremented every time the matrix data change.
  68853. * You can use it to speed the comparison between two versions of the same matrix.
  68854. */
  68855. updateFlag: number;
  68856. private readonly _m;
  68857. /**
  68858. * Gets the internal data of the matrix
  68859. */
  68860. readonly m: DeepImmutable<Float32Array>;
  68861. /** @hidden */
  68862. _markAsUpdated(): void;
  68863. /** @hidden */
  68864. private _updateIdentityStatus;
  68865. /**
  68866. * Creates an empty matrix (filled with zeros)
  68867. */
  68868. constructor();
  68869. /**
  68870. * Check if the current matrix is identity
  68871. * @returns true is the matrix is the identity matrix
  68872. */
  68873. isIdentity(): boolean;
  68874. /**
  68875. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68876. * @returns true is the matrix is the identity matrix
  68877. */
  68878. isIdentityAs3x2(): boolean;
  68879. /**
  68880. * Gets the determinant of the matrix
  68881. * @returns the matrix determinant
  68882. */
  68883. determinant(): number;
  68884. /**
  68885. * Returns the matrix as a Float32Array
  68886. * @returns the matrix underlying array
  68887. */
  68888. toArray(): DeepImmutable<Float32Array>;
  68889. /**
  68890. * Returns the matrix as a Float32Array
  68891. * @returns the matrix underlying array.
  68892. */
  68893. asArray(): DeepImmutable<Float32Array>;
  68894. /**
  68895. * Inverts the current matrix in place
  68896. * @returns the current inverted matrix
  68897. */
  68898. invert(): Matrix;
  68899. /**
  68900. * Sets all the matrix elements to zero
  68901. * @returns the current matrix
  68902. */
  68903. reset(): Matrix;
  68904. /**
  68905. * Adds the current matrix with a second one
  68906. * @param other defines the matrix to add
  68907. * @returns a new matrix as the addition of the current matrix and the given one
  68908. */
  68909. add(other: DeepImmutable<Matrix>): Matrix;
  68910. /**
  68911. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68912. * @param other defines the matrix to add
  68913. * @param result defines the target matrix
  68914. * @returns the current matrix
  68915. */
  68916. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68917. /**
  68918. * Adds in place the given matrix to the current matrix
  68919. * @param other defines the second operand
  68920. * @returns the current updated matrix
  68921. */
  68922. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68923. /**
  68924. * Sets the given matrix to the current inverted Matrix
  68925. * @param other defines the target matrix
  68926. * @returns the unmodified current matrix
  68927. */
  68928. invertToRef(other: Matrix): Matrix;
  68929. /**
  68930. * add a value at the specified position in the current Matrix
  68931. * @param index the index of the value within the matrix. between 0 and 15.
  68932. * @param value the value to be added
  68933. * @returns the current updated matrix
  68934. */
  68935. addAtIndex(index: number, value: number): Matrix;
  68936. /**
  68937. * mutiply the specified position in the current Matrix by a value
  68938. * @param index the index of the value within the matrix. between 0 and 15.
  68939. * @param value the value to be added
  68940. * @returns the current updated matrix
  68941. */
  68942. multiplyAtIndex(index: number, value: number): Matrix;
  68943. /**
  68944. * Inserts the translation vector (using 3 floats) in the current matrix
  68945. * @param x defines the 1st component of the translation
  68946. * @param y defines the 2nd component of the translation
  68947. * @param z defines the 3rd component of the translation
  68948. * @returns the current updated matrix
  68949. */
  68950. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68951. /**
  68952. * Adds the translation vector (using 3 floats) in the current matrix
  68953. * @param x defines the 1st component of the translation
  68954. * @param y defines the 2nd component of the translation
  68955. * @param z defines the 3rd component of the translation
  68956. * @returns the current updated matrix
  68957. */
  68958. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68959. /**
  68960. * Inserts the translation vector in the current matrix
  68961. * @param vector3 defines the translation to insert
  68962. * @returns the current updated matrix
  68963. */
  68964. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  68965. /**
  68966. * Gets the translation value of the current matrix
  68967. * @returns a new Vector3 as the extracted translation from the matrix
  68968. */
  68969. getTranslation(): Vector3;
  68970. /**
  68971. * Fill a Vector3 with the extracted translation from the matrix
  68972. * @param result defines the Vector3 where to store the translation
  68973. * @returns the current matrix
  68974. */
  68975. getTranslationToRef(result: Vector3): Matrix;
  68976. /**
  68977. * Remove rotation and scaling part from the matrix
  68978. * @returns the updated matrix
  68979. */
  68980. removeRotationAndScaling(): Matrix;
  68981. /**
  68982. * Multiply two matrices
  68983. * @param other defines the second operand
  68984. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  68985. */
  68986. multiply(other: DeepImmutable<Matrix>): Matrix;
  68987. /**
  68988. * Copy the current matrix from the given one
  68989. * @param other defines the source matrix
  68990. * @returns the current updated matrix
  68991. */
  68992. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  68993. /**
  68994. * Populates the given array from the starting index with the current matrix values
  68995. * @param array defines the target array
  68996. * @param offset defines the offset in the target array where to start storing values
  68997. * @returns the current matrix
  68998. */
  68999. copyToArray(array: Float32Array, offset?: number): Matrix;
  69000. /**
  69001. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69002. * @param other defines the second operand
  69003. * @param result defines the matrix where to store the multiplication
  69004. * @returns the current matrix
  69005. */
  69006. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69007. /**
  69008. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69009. * @param other defines the second operand
  69010. * @param result defines the array where to store the multiplication
  69011. * @param offset defines the offset in the target array where to start storing values
  69012. * @returns the current matrix
  69013. */
  69014. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69015. /**
  69016. * Check equality between this matrix and a second one
  69017. * @param value defines the second matrix to compare
  69018. * @returns true is the current matrix and the given one values are strictly equal
  69019. */
  69020. equals(value: DeepImmutable<Matrix>): boolean;
  69021. /**
  69022. * Clone the current matrix
  69023. * @returns a new matrix from the current matrix
  69024. */
  69025. clone(): Matrix;
  69026. /**
  69027. * Returns the name of the current matrix class
  69028. * @returns the string "Matrix"
  69029. */
  69030. getClassName(): string;
  69031. /**
  69032. * Gets the hash code of the current matrix
  69033. * @returns the hash code
  69034. */
  69035. getHashCode(): number;
  69036. /**
  69037. * Decomposes the current Matrix into a translation, rotation and scaling components
  69038. * @param scale defines the scale vector3 given as a reference to update
  69039. * @param rotation defines the rotation quaternion given as a reference to update
  69040. * @param translation defines the translation vector3 given as a reference to update
  69041. * @returns true if operation was successful
  69042. */
  69043. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69044. /**
  69045. * Gets specific row of the matrix
  69046. * @param index defines the number of the row to get
  69047. * @returns the index-th row of the current matrix as a new Vector4
  69048. */
  69049. getRow(index: number): Nullable<Vector4>;
  69050. /**
  69051. * Sets the index-th row of the current matrix to the vector4 values
  69052. * @param index defines the number of the row to set
  69053. * @param row defines the target vector4
  69054. * @returns the updated current matrix
  69055. */
  69056. setRow(index: number, row: Vector4): Matrix;
  69057. /**
  69058. * Compute the transpose of the matrix
  69059. * @returns the new transposed matrix
  69060. */
  69061. transpose(): Matrix;
  69062. /**
  69063. * Compute the transpose of the matrix and store it in a given matrix
  69064. * @param result defines the target matrix
  69065. * @returns the current matrix
  69066. */
  69067. transposeToRef(result: Matrix): Matrix;
  69068. /**
  69069. * Sets the index-th row of the current matrix with the given 4 x float values
  69070. * @param index defines the row index
  69071. * @param x defines the x component to set
  69072. * @param y defines the y component to set
  69073. * @param z defines the z component to set
  69074. * @param w defines the w component to set
  69075. * @returns the updated current matrix
  69076. */
  69077. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69078. /**
  69079. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69080. * @param scale defines the scale factor
  69081. * @returns a new matrix
  69082. */
  69083. scale(scale: number): Matrix;
  69084. /**
  69085. * Scale the current matrix values by a factor to a given result matrix
  69086. * @param scale defines the scale factor
  69087. * @param result defines the matrix to store the result
  69088. * @returns the current matrix
  69089. */
  69090. scaleToRef(scale: number, result: Matrix): Matrix;
  69091. /**
  69092. * Scale the current matrix values by a factor and add the result to a given matrix
  69093. * @param scale defines the scale factor
  69094. * @param result defines the Matrix to store the result
  69095. * @returns the current matrix
  69096. */
  69097. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69098. /**
  69099. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69100. * @param ref matrix to store the result
  69101. */
  69102. toNormalMatrix(ref: Matrix): void;
  69103. /**
  69104. * Gets only rotation part of the current matrix
  69105. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69106. */
  69107. getRotationMatrix(): Matrix;
  69108. /**
  69109. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69110. * @param result defines the target matrix to store data to
  69111. * @returns the current matrix
  69112. */
  69113. getRotationMatrixToRef(result: Matrix): Matrix;
  69114. /**
  69115. * Toggles model matrix from being right handed to left handed in place and vice versa
  69116. */
  69117. toggleModelMatrixHandInPlace(): void;
  69118. /**
  69119. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69120. */
  69121. toggleProjectionMatrixHandInPlace(): void;
  69122. /**
  69123. * Creates a matrix from an array
  69124. * @param array defines the source array
  69125. * @param offset defines an offset in the source array
  69126. * @returns a new Matrix set from the starting index of the given array
  69127. */
  69128. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69129. /**
  69130. * Copy the content of an array into a given matrix
  69131. * @param array defines the source array
  69132. * @param offset defines an offset in the source array
  69133. * @param result defines the target matrix
  69134. */
  69135. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69136. /**
  69137. * Stores an array into a matrix after having multiplied each component by a given factor
  69138. * @param array defines the source array
  69139. * @param offset defines the offset in the source array
  69140. * @param scale defines the scaling factor
  69141. * @param result defines the target matrix
  69142. */
  69143. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69144. /**
  69145. * Gets an identity matrix that must not be updated
  69146. */
  69147. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69148. /**
  69149. * Stores a list of values (16) inside a given matrix
  69150. * @param initialM11 defines 1st value of 1st row
  69151. * @param initialM12 defines 2nd value of 1st row
  69152. * @param initialM13 defines 3rd value of 1st row
  69153. * @param initialM14 defines 4th value of 1st row
  69154. * @param initialM21 defines 1st value of 2nd row
  69155. * @param initialM22 defines 2nd value of 2nd row
  69156. * @param initialM23 defines 3rd value of 2nd row
  69157. * @param initialM24 defines 4th value of 2nd row
  69158. * @param initialM31 defines 1st value of 3rd row
  69159. * @param initialM32 defines 2nd value of 3rd row
  69160. * @param initialM33 defines 3rd value of 3rd row
  69161. * @param initialM34 defines 4th value of 3rd row
  69162. * @param initialM41 defines 1st value of 4th row
  69163. * @param initialM42 defines 2nd value of 4th row
  69164. * @param initialM43 defines 3rd value of 4th row
  69165. * @param initialM44 defines 4th value of 4th row
  69166. * @param result defines the target matrix
  69167. */
  69168. 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;
  69169. /**
  69170. * Creates new matrix from a list of values (16)
  69171. * @param initialM11 defines 1st value of 1st row
  69172. * @param initialM12 defines 2nd value of 1st row
  69173. * @param initialM13 defines 3rd value of 1st row
  69174. * @param initialM14 defines 4th value of 1st row
  69175. * @param initialM21 defines 1st value of 2nd row
  69176. * @param initialM22 defines 2nd value of 2nd row
  69177. * @param initialM23 defines 3rd value of 2nd row
  69178. * @param initialM24 defines 4th value of 2nd row
  69179. * @param initialM31 defines 1st value of 3rd row
  69180. * @param initialM32 defines 2nd value of 3rd row
  69181. * @param initialM33 defines 3rd value of 3rd row
  69182. * @param initialM34 defines 4th value of 3rd row
  69183. * @param initialM41 defines 1st value of 4th row
  69184. * @param initialM42 defines 2nd value of 4th row
  69185. * @param initialM43 defines 3rd value of 4th row
  69186. * @param initialM44 defines 4th value of 4th row
  69187. * @returns the new matrix
  69188. */
  69189. 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;
  69190. /**
  69191. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69192. * @param scale defines the scale vector3
  69193. * @param rotation defines the rotation quaternion
  69194. * @param translation defines the translation vector3
  69195. * @returns a new matrix
  69196. */
  69197. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69198. /**
  69199. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69200. * @param scale defines the scale vector3
  69201. * @param rotation defines the rotation quaternion
  69202. * @param translation defines the translation vector3
  69203. * @param result defines the target matrix
  69204. */
  69205. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69206. /**
  69207. * Creates a new identity matrix
  69208. * @returns a new identity matrix
  69209. */
  69210. static Identity(): Matrix;
  69211. /**
  69212. * Creates a new identity matrix and stores the result in a given matrix
  69213. * @param result defines the target matrix
  69214. */
  69215. static IdentityToRef(result: Matrix): void;
  69216. /**
  69217. * Creates a new zero matrix
  69218. * @returns a new zero matrix
  69219. */
  69220. static Zero(): Matrix;
  69221. /**
  69222. * Creates a new rotation matrix for "angle" radians around the X axis
  69223. * @param angle defines the angle (in radians) to use
  69224. * @return the new matrix
  69225. */
  69226. static RotationX(angle: number): Matrix;
  69227. /**
  69228. * Creates a new matrix as the invert of a given matrix
  69229. * @param source defines the source matrix
  69230. * @returns the new matrix
  69231. */
  69232. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69233. /**
  69234. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69235. * @param angle defines the angle (in radians) to use
  69236. * @param result defines the target matrix
  69237. */
  69238. static RotationXToRef(angle: number, result: Matrix): void;
  69239. /**
  69240. * Creates a new rotation matrix for "angle" radians around the Y axis
  69241. * @param angle defines the angle (in radians) to use
  69242. * @return the new matrix
  69243. */
  69244. static RotationY(angle: number): Matrix;
  69245. /**
  69246. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69247. * @param angle defines the angle (in radians) to use
  69248. * @param result defines the target matrix
  69249. */
  69250. static RotationYToRef(angle: number, result: Matrix): void;
  69251. /**
  69252. * Creates a new rotation matrix for "angle" radians around the Z axis
  69253. * @param angle defines the angle (in radians) to use
  69254. * @return the new matrix
  69255. */
  69256. static RotationZ(angle: number): Matrix;
  69257. /**
  69258. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69259. * @param angle defines the angle (in radians) to use
  69260. * @param result defines the target matrix
  69261. */
  69262. static RotationZToRef(angle: number, result: Matrix): void;
  69263. /**
  69264. * Creates a new rotation matrix for "angle" radians around the given axis
  69265. * @param axis defines the axis to use
  69266. * @param angle defines the angle (in radians) to use
  69267. * @return the new matrix
  69268. */
  69269. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69270. /**
  69271. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69272. * @param axis defines the axis to use
  69273. * @param angle defines the angle (in radians) to use
  69274. * @param result defines the target matrix
  69275. */
  69276. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69277. /**
  69278. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69279. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69280. * @param from defines the vector to align
  69281. * @param to defines the vector to align to
  69282. * @param result defines the target matrix
  69283. */
  69284. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69285. /**
  69286. * Creates a rotation matrix
  69287. * @param yaw defines the yaw angle in radians (Y axis)
  69288. * @param pitch defines the pitch angle in radians (X axis)
  69289. * @param roll defines the roll angle in radians (X axis)
  69290. * @returns the new rotation matrix
  69291. */
  69292. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69293. /**
  69294. * Creates a rotation matrix and stores it in a given matrix
  69295. * @param yaw defines the yaw angle in radians (Y axis)
  69296. * @param pitch defines the pitch angle in radians (X axis)
  69297. * @param roll defines the roll angle in radians (X axis)
  69298. * @param result defines the target matrix
  69299. */
  69300. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69301. /**
  69302. * Creates a scaling matrix
  69303. * @param x defines the scale factor on X axis
  69304. * @param y defines the scale factor on Y axis
  69305. * @param z defines the scale factor on Z axis
  69306. * @returns the new matrix
  69307. */
  69308. static Scaling(x: number, y: number, z: number): Matrix;
  69309. /**
  69310. * Creates a scaling matrix and stores it in a given matrix
  69311. * @param x defines the scale factor on X axis
  69312. * @param y defines the scale factor on Y axis
  69313. * @param z defines the scale factor on Z axis
  69314. * @param result defines the target matrix
  69315. */
  69316. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69317. /**
  69318. * Creates a translation matrix
  69319. * @param x defines the translation on X axis
  69320. * @param y defines the translation on Y axis
  69321. * @param z defines the translationon Z axis
  69322. * @returns the new matrix
  69323. */
  69324. static Translation(x: number, y: number, z: number): Matrix;
  69325. /**
  69326. * Creates a translation matrix and stores it in a given matrix
  69327. * @param x defines the translation on X axis
  69328. * @param y defines the translation on Y axis
  69329. * @param z defines the translationon Z axis
  69330. * @param result defines the target matrix
  69331. */
  69332. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69333. /**
  69334. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69335. * @param startValue defines the start value
  69336. * @param endValue defines the end value
  69337. * @param gradient defines the gradient factor
  69338. * @returns the new matrix
  69339. */
  69340. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69341. /**
  69342. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69343. * @param startValue defines the start value
  69344. * @param endValue defines the end value
  69345. * @param gradient defines the gradient factor
  69346. * @param result defines the Matrix object where to store data
  69347. */
  69348. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69349. /**
  69350. * Builds a new matrix whose values are computed by:
  69351. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69352. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69353. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69354. * @param startValue defines the first matrix
  69355. * @param endValue defines the second matrix
  69356. * @param gradient defines the gradient between the two matrices
  69357. * @returns the new matrix
  69358. */
  69359. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69360. /**
  69361. * Update a matrix to values which are computed by:
  69362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69365. * @param startValue defines the first matrix
  69366. * @param endValue defines the second matrix
  69367. * @param gradient defines the gradient between the two matrices
  69368. * @param result defines the target matrix
  69369. */
  69370. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69371. /**
  69372. * 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"
  69373. * This function works in left handed mode
  69374. * @param eye defines the final position of the entity
  69375. * @param target defines where the entity should look at
  69376. * @param up defines the up vector for the entity
  69377. * @returns the new matrix
  69378. */
  69379. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69380. /**
  69381. * 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".
  69382. * This function works in left handed mode
  69383. * @param eye defines the final position of the entity
  69384. * @param target defines where the entity should look at
  69385. * @param up defines the up vector for the entity
  69386. * @param result defines the target matrix
  69387. */
  69388. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69389. /**
  69390. * 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"
  69391. * This function works in right handed mode
  69392. * @param eye defines the final position of the entity
  69393. * @param target defines where the entity should look at
  69394. * @param up defines the up vector for the entity
  69395. * @returns the new matrix
  69396. */
  69397. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69398. /**
  69399. * 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".
  69400. * This function works in right handed mode
  69401. * @param eye defines the final position of the entity
  69402. * @param target defines where the entity should look at
  69403. * @param up defines the up vector for the entity
  69404. * @param result defines the target matrix
  69405. */
  69406. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69407. /**
  69408. * Create a left-handed orthographic projection matrix
  69409. * @param width defines the viewport width
  69410. * @param height defines the viewport height
  69411. * @param znear defines the near clip plane
  69412. * @param zfar defines the far clip plane
  69413. * @returns a new matrix as a left-handed orthographic projection matrix
  69414. */
  69415. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69416. /**
  69417. * Store a left-handed orthographic projection to a given matrix
  69418. * @param width defines the viewport width
  69419. * @param height defines the viewport height
  69420. * @param znear defines the near clip plane
  69421. * @param zfar defines the far clip plane
  69422. * @param result defines the target matrix
  69423. */
  69424. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69425. /**
  69426. * Create a left-handed orthographic projection matrix
  69427. * @param left defines the viewport left coordinate
  69428. * @param right defines the viewport right coordinate
  69429. * @param bottom defines the viewport bottom coordinate
  69430. * @param top defines the viewport top coordinate
  69431. * @param znear defines the near clip plane
  69432. * @param zfar defines the far clip plane
  69433. * @returns a new matrix as a left-handed orthographic projection matrix
  69434. */
  69435. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69436. /**
  69437. * Stores a left-handed orthographic projection into a given matrix
  69438. * @param left defines the viewport left coordinate
  69439. * @param right defines the viewport right coordinate
  69440. * @param bottom defines the viewport bottom coordinate
  69441. * @param top defines the viewport top coordinate
  69442. * @param znear defines the near clip plane
  69443. * @param zfar defines the far clip plane
  69444. * @param result defines the target matrix
  69445. */
  69446. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69447. /**
  69448. * Creates a right-handed orthographic projection matrix
  69449. * @param left defines the viewport left coordinate
  69450. * @param right defines the viewport right coordinate
  69451. * @param bottom defines the viewport bottom coordinate
  69452. * @param top defines the viewport top coordinate
  69453. * @param znear defines the near clip plane
  69454. * @param zfar defines the far clip plane
  69455. * @returns a new matrix as a right-handed orthographic projection matrix
  69456. */
  69457. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69458. /**
  69459. * Stores a right-handed orthographic projection into a given matrix
  69460. * @param left defines the viewport left coordinate
  69461. * @param right defines the viewport right coordinate
  69462. * @param bottom defines the viewport bottom coordinate
  69463. * @param top defines the viewport top coordinate
  69464. * @param znear defines the near clip plane
  69465. * @param zfar defines the far clip plane
  69466. * @param result defines the target matrix
  69467. */
  69468. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69469. /**
  69470. * Creates a left-handed perspective projection matrix
  69471. * @param width defines the viewport width
  69472. * @param height defines the viewport height
  69473. * @param znear defines the near clip plane
  69474. * @param zfar defines the far clip plane
  69475. * @returns a new matrix as a left-handed perspective projection matrix
  69476. */
  69477. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69478. /**
  69479. * Creates a left-handed perspective projection matrix
  69480. * @param fov defines the horizontal field of view
  69481. * @param aspect defines the aspect ratio
  69482. * @param znear defines the near clip plane
  69483. * @param zfar defines the far clip plane
  69484. * @returns a new matrix as a left-handed perspective projection matrix
  69485. */
  69486. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69487. /**
  69488. * Stores a left-handed perspective projection into a given matrix
  69489. * @param fov defines the horizontal field of view
  69490. * @param aspect defines the aspect ratio
  69491. * @param znear defines the near clip plane
  69492. * @param zfar defines the far clip plane
  69493. * @param result defines the target matrix
  69494. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69495. */
  69496. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69497. /**
  69498. * Creates a right-handed perspective projection matrix
  69499. * @param fov defines the horizontal field of view
  69500. * @param aspect defines the aspect ratio
  69501. * @param znear defines the near clip plane
  69502. * @param zfar defines the far clip plane
  69503. * @returns a new matrix as a right-handed perspective projection matrix
  69504. */
  69505. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69506. /**
  69507. * Stores a right-handed perspective projection into a given matrix
  69508. * @param fov defines the horizontal field of view
  69509. * @param aspect defines the aspect ratio
  69510. * @param znear defines the near clip plane
  69511. * @param zfar defines the far clip plane
  69512. * @param result defines the target matrix
  69513. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69514. */
  69515. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69516. /**
  69517. * Stores a perspective projection for WebVR info a given matrix
  69518. * @param fov defines the field of view
  69519. * @param znear defines the near clip plane
  69520. * @param zfar defines the far clip plane
  69521. * @param result defines the target matrix
  69522. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69523. */
  69524. static PerspectiveFovWebVRToRef(fov: {
  69525. upDegrees: number;
  69526. downDegrees: number;
  69527. leftDegrees: number;
  69528. rightDegrees: number;
  69529. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69530. /**
  69531. * Computes a complete transformation matrix
  69532. * @param viewport defines the viewport to use
  69533. * @param world defines the world matrix
  69534. * @param view defines the view matrix
  69535. * @param projection defines the projection matrix
  69536. * @param zmin defines the near clip plane
  69537. * @param zmax defines the far clip plane
  69538. * @returns the transformation matrix
  69539. */
  69540. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69541. /**
  69542. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69543. * @param matrix defines the matrix to use
  69544. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69545. */
  69546. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69547. /**
  69548. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69549. * @param matrix defines the matrix to use
  69550. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69551. */
  69552. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69553. /**
  69554. * Compute the transpose of a given matrix
  69555. * @param matrix defines the matrix to transpose
  69556. * @returns the new matrix
  69557. */
  69558. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69559. /**
  69560. * Compute the transpose of a matrix and store it in a target matrix
  69561. * @param matrix defines the matrix to transpose
  69562. * @param result defines the target matrix
  69563. */
  69564. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69565. /**
  69566. * Computes a reflection matrix from a plane
  69567. * @param plane defines the reflection plane
  69568. * @returns a new matrix
  69569. */
  69570. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69571. /**
  69572. * Computes a reflection matrix from a plane
  69573. * @param plane defines the reflection plane
  69574. * @param result defines the target matrix
  69575. */
  69576. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69577. /**
  69578. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69579. * @param xaxis defines the value of the 1st axis
  69580. * @param yaxis defines the value of the 2nd axis
  69581. * @param zaxis defines the value of the 3rd axis
  69582. * @param result defines the target matrix
  69583. */
  69584. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69585. /**
  69586. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69587. * @param quat defines the quaternion to use
  69588. * @param result defines the target matrix
  69589. */
  69590. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69591. }
  69592. /**
  69593. * @hidden
  69594. */
  69595. export class TmpVectors {
  69596. static Vector2: Vector2[];
  69597. static Vector3: Vector3[];
  69598. static Vector4: Vector4[];
  69599. static Quaternion: Quaternion[];
  69600. static Matrix: Matrix[];
  69601. }
  69602. }
  69603. declare module BABYLON {
  69604. /**
  69605. * Class used to hold a RBG color
  69606. */
  69607. export class Color3 {
  69608. /**
  69609. * Defines the red component (between 0 and 1, default is 0)
  69610. */
  69611. r: number;
  69612. /**
  69613. * Defines the green component (between 0 and 1, default is 0)
  69614. */
  69615. g: number;
  69616. /**
  69617. * Defines the blue component (between 0 and 1, default is 0)
  69618. */
  69619. b: number;
  69620. /**
  69621. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69622. * @param r defines the red component (between 0 and 1, default is 0)
  69623. * @param g defines the green component (between 0 and 1, default is 0)
  69624. * @param b defines the blue component (between 0 and 1, default is 0)
  69625. */
  69626. constructor(
  69627. /**
  69628. * Defines the red component (between 0 and 1, default is 0)
  69629. */
  69630. r?: number,
  69631. /**
  69632. * Defines the green component (between 0 and 1, default is 0)
  69633. */
  69634. g?: number,
  69635. /**
  69636. * Defines the blue component (between 0 and 1, default is 0)
  69637. */
  69638. b?: number);
  69639. /**
  69640. * Creates a string with the Color3 current values
  69641. * @returns the string representation of the Color3 object
  69642. */
  69643. toString(): string;
  69644. /**
  69645. * Returns the string "Color3"
  69646. * @returns "Color3"
  69647. */
  69648. getClassName(): string;
  69649. /**
  69650. * Compute the Color3 hash code
  69651. * @returns an unique number that can be used to hash Color3 objects
  69652. */
  69653. getHashCode(): number;
  69654. /**
  69655. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69656. * @param array defines the array where to store the r,g,b components
  69657. * @param index defines an optional index in the target array to define where to start storing values
  69658. * @returns the current Color3 object
  69659. */
  69660. toArray(array: FloatArray, index?: number): Color3;
  69661. /**
  69662. * Returns a new Color4 object from the current Color3 and the given alpha
  69663. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69664. * @returns a new Color4 object
  69665. */
  69666. toColor4(alpha?: number): Color4;
  69667. /**
  69668. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69669. * @returns the new array
  69670. */
  69671. asArray(): number[];
  69672. /**
  69673. * Returns the luminance value
  69674. * @returns a float value
  69675. */
  69676. toLuminance(): number;
  69677. /**
  69678. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69679. * @param otherColor defines the second operand
  69680. * @returns the new Color3 object
  69681. */
  69682. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69683. /**
  69684. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69685. * @param otherColor defines the second operand
  69686. * @param result defines the Color3 object where to store the result
  69687. * @returns the current Color3
  69688. */
  69689. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69690. /**
  69691. * Determines equality between Color3 objects
  69692. * @param otherColor defines the second operand
  69693. * @returns true if the rgb values are equal to the given ones
  69694. */
  69695. equals(otherColor: DeepImmutable<Color3>): boolean;
  69696. /**
  69697. * Determines equality between the current Color3 object and a set of r,b,g values
  69698. * @param r defines the red component to check
  69699. * @param g defines the green component to check
  69700. * @param b defines the blue component to check
  69701. * @returns true if the rgb values are equal to the given ones
  69702. */
  69703. equalsFloats(r: number, g: number, b: number): boolean;
  69704. /**
  69705. * Multiplies in place each rgb value by scale
  69706. * @param scale defines the scaling factor
  69707. * @returns the updated Color3
  69708. */
  69709. scale(scale: number): Color3;
  69710. /**
  69711. * Multiplies the rgb values by scale and stores the result into "result"
  69712. * @param scale defines the scaling factor
  69713. * @param result defines the Color3 object where to store the result
  69714. * @returns the unmodified current Color3
  69715. */
  69716. scaleToRef(scale: number, result: Color3): Color3;
  69717. /**
  69718. * Scale the current Color3 values by a factor and add the result to a given Color3
  69719. * @param scale defines the scale factor
  69720. * @param result defines color to store the result into
  69721. * @returns the unmodified current Color3
  69722. */
  69723. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69724. /**
  69725. * Clamps the rgb values by the min and max values and stores the result into "result"
  69726. * @param min defines minimum clamping value (default is 0)
  69727. * @param max defines maximum clamping value (default is 1)
  69728. * @param result defines color to store the result into
  69729. * @returns the original Color3
  69730. */
  69731. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69732. /**
  69733. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69734. * @param otherColor defines the second operand
  69735. * @returns the new Color3
  69736. */
  69737. add(otherColor: DeepImmutable<Color3>): Color3;
  69738. /**
  69739. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69740. * @param otherColor defines the second operand
  69741. * @param result defines Color3 object to store the result into
  69742. * @returns the unmodified current Color3
  69743. */
  69744. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69745. /**
  69746. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69747. * @param otherColor defines the second operand
  69748. * @returns the new Color3
  69749. */
  69750. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69751. /**
  69752. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69753. * @param otherColor defines the second operand
  69754. * @param result defines Color3 object to store the result into
  69755. * @returns the unmodified current Color3
  69756. */
  69757. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69758. /**
  69759. * Copy the current object
  69760. * @returns a new Color3 copied the current one
  69761. */
  69762. clone(): Color3;
  69763. /**
  69764. * Copies the rgb values from the source in the current Color3
  69765. * @param source defines the source Color3 object
  69766. * @returns the updated Color3 object
  69767. */
  69768. copyFrom(source: DeepImmutable<Color3>): Color3;
  69769. /**
  69770. * Updates the Color3 rgb values from the given floats
  69771. * @param r defines the red component to read from
  69772. * @param g defines the green component to read from
  69773. * @param b defines the blue component to read from
  69774. * @returns the current Color3 object
  69775. */
  69776. copyFromFloats(r: number, g: number, b: number): Color3;
  69777. /**
  69778. * Updates the Color3 rgb values from the given floats
  69779. * @param r defines the red component to read from
  69780. * @param g defines the green component to read from
  69781. * @param b defines the blue component to read from
  69782. * @returns the current Color3 object
  69783. */
  69784. set(r: number, g: number, b: number): Color3;
  69785. /**
  69786. * Compute the Color3 hexadecimal code as a string
  69787. * @returns a string containing the hexadecimal representation of the Color3 object
  69788. */
  69789. toHexString(): string;
  69790. /**
  69791. * Computes a new Color3 converted from the current one to linear space
  69792. * @returns a new Color3 object
  69793. */
  69794. toLinearSpace(): Color3;
  69795. /**
  69796. * Converts current color in rgb space to HSV values
  69797. * @returns a new color3 representing the HSV values
  69798. */
  69799. toHSV(): Color3;
  69800. /**
  69801. * Converts current color in rgb space to HSV values
  69802. * @param result defines the Color3 where to store the HSV values
  69803. */
  69804. toHSVToRef(result: Color3): void;
  69805. /**
  69806. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69807. * @param convertedColor defines the Color3 object where to store the linear space version
  69808. * @returns the unmodified Color3
  69809. */
  69810. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69811. /**
  69812. * Computes a new Color3 converted from the current one to gamma space
  69813. * @returns a new Color3 object
  69814. */
  69815. toGammaSpace(): Color3;
  69816. /**
  69817. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69818. * @param convertedColor defines the Color3 object where to store the gamma space version
  69819. * @returns the unmodified Color3
  69820. */
  69821. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69822. private static _BlackReadOnly;
  69823. /**
  69824. * Convert Hue, saturation and value to a Color3 (RGB)
  69825. * @param hue defines the hue
  69826. * @param saturation defines the saturation
  69827. * @param value defines the value
  69828. * @param result defines the Color3 where to store the RGB values
  69829. */
  69830. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69831. /**
  69832. * Creates a new Color3 from the string containing valid hexadecimal values
  69833. * @param hex defines a string containing valid hexadecimal values
  69834. * @returns a new Color3 object
  69835. */
  69836. static FromHexString(hex: string): Color3;
  69837. /**
  69838. * Creates a new Color3 from the starting index of the given array
  69839. * @param array defines the source array
  69840. * @param offset defines an offset in the source array
  69841. * @returns a new Color3 object
  69842. */
  69843. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69844. /**
  69845. * Creates a new Color3 from integer values (< 256)
  69846. * @param r defines the red component to read from (value between 0 and 255)
  69847. * @param g defines the green component to read from (value between 0 and 255)
  69848. * @param b defines the blue component to read from (value between 0 and 255)
  69849. * @returns a new Color3 object
  69850. */
  69851. static FromInts(r: number, g: number, b: number): Color3;
  69852. /**
  69853. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69854. * @param start defines the start Color3 value
  69855. * @param end defines the end Color3 value
  69856. * @param amount defines the gradient value between start and end
  69857. * @returns a new Color3 object
  69858. */
  69859. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69860. /**
  69861. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69862. * @param left defines the start value
  69863. * @param right defines the end value
  69864. * @param amount defines the gradient factor
  69865. * @param result defines the Color3 object where to store the result
  69866. */
  69867. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69868. /**
  69869. * Returns a Color3 value containing a red color
  69870. * @returns a new Color3 object
  69871. */
  69872. static Red(): Color3;
  69873. /**
  69874. * Returns a Color3 value containing a green color
  69875. * @returns a new Color3 object
  69876. */
  69877. static Green(): Color3;
  69878. /**
  69879. * Returns a Color3 value containing a blue color
  69880. * @returns a new Color3 object
  69881. */
  69882. static Blue(): Color3;
  69883. /**
  69884. * Returns a Color3 value containing a black color
  69885. * @returns a new Color3 object
  69886. */
  69887. static Black(): Color3;
  69888. /**
  69889. * Gets a Color3 value containing a black color that must not be updated
  69890. */
  69891. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69892. /**
  69893. * Returns a Color3 value containing a white color
  69894. * @returns a new Color3 object
  69895. */
  69896. static White(): Color3;
  69897. /**
  69898. * Returns a Color3 value containing a purple color
  69899. * @returns a new Color3 object
  69900. */
  69901. static Purple(): Color3;
  69902. /**
  69903. * Returns a Color3 value containing a magenta color
  69904. * @returns a new Color3 object
  69905. */
  69906. static Magenta(): Color3;
  69907. /**
  69908. * Returns a Color3 value containing a yellow color
  69909. * @returns a new Color3 object
  69910. */
  69911. static Yellow(): Color3;
  69912. /**
  69913. * Returns a Color3 value containing a gray color
  69914. * @returns a new Color3 object
  69915. */
  69916. static Gray(): Color3;
  69917. /**
  69918. * Returns a Color3 value containing a teal color
  69919. * @returns a new Color3 object
  69920. */
  69921. static Teal(): Color3;
  69922. /**
  69923. * Returns a Color3 value containing a random color
  69924. * @returns a new Color3 object
  69925. */
  69926. static Random(): Color3;
  69927. }
  69928. /**
  69929. * Class used to hold a RBGA color
  69930. */
  69931. export class Color4 {
  69932. /**
  69933. * Defines the red component (between 0 and 1, default is 0)
  69934. */
  69935. r: number;
  69936. /**
  69937. * Defines the green component (between 0 and 1, default is 0)
  69938. */
  69939. g: number;
  69940. /**
  69941. * Defines the blue component (between 0 and 1, default is 0)
  69942. */
  69943. b: number;
  69944. /**
  69945. * Defines the alpha component (between 0 and 1, default is 1)
  69946. */
  69947. a: number;
  69948. /**
  69949. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69950. * @param r defines the red component (between 0 and 1, default is 0)
  69951. * @param g defines the green component (between 0 and 1, default is 0)
  69952. * @param b defines the blue component (between 0 and 1, default is 0)
  69953. * @param a defines the alpha component (between 0 and 1, default is 1)
  69954. */
  69955. constructor(
  69956. /**
  69957. * Defines the red component (between 0 and 1, default is 0)
  69958. */
  69959. r?: number,
  69960. /**
  69961. * Defines the green component (between 0 and 1, default is 0)
  69962. */
  69963. g?: number,
  69964. /**
  69965. * Defines the blue component (between 0 and 1, default is 0)
  69966. */
  69967. b?: number,
  69968. /**
  69969. * Defines the alpha component (between 0 and 1, default is 1)
  69970. */
  69971. a?: number);
  69972. /**
  69973. * Adds in place the given Color4 values to the current Color4 object
  69974. * @param right defines the second operand
  69975. * @returns the current updated Color4 object
  69976. */
  69977. addInPlace(right: DeepImmutable<Color4>): Color4;
  69978. /**
  69979. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69980. * @returns the new array
  69981. */
  69982. asArray(): number[];
  69983. /**
  69984. * Stores from the starting index in the given array the Color4 successive values
  69985. * @param array defines the array where to store the r,g,b components
  69986. * @param index defines an optional index in the target array to define where to start storing values
  69987. * @returns the current Color4 object
  69988. */
  69989. toArray(array: number[], index?: number): Color4;
  69990. /**
  69991. * Determines equality between Color4 objects
  69992. * @param otherColor defines the second operand
  69993. * @returns true if the rgba values are equal to the given ones
  69994. */
  69995. equals(otherColor: DeepImmutable<Color4>): boolean;
  69996. /**
  69997. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69998. * @param right defines the second operand
  69999. * @returns a new Color4 object
  70000. */
  70001. add(right: DeepImmutable<Color4>): Color4;
  70002. /**
  70003. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70004. * @param right defines the second operand
  70005. * @returns a new Color4 object
  70006. */
  70007. subtract(right: DeepImmutable<Color4>): Color4;
  70008. /**
  70009. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70010. * @param right defines the second operand
  70011. * @param result defines the Color4 object where to store the result
  70012. * @returns the current Color4 object
  70013. */
  70014. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70015. /**
  70016. * Creates a new Color4 with the current Color4 values multiplied by scale
  70017. * @param scale defines the scaling factor to apply
  70018. * @returns a new Color4 object
  70019. */
  70020. scale(scale: number): Color4;
  70021. /**
  70022. * Multiplies the current Color4 values by scale and stores the result in "result"
  70023. * @param scale defines the scaling factor to apply
  70024. * @param result defines the Color4 object where to store the result
  70025. * @returns the current unmodified Color4
  70026. */
  70027. scaleToRef(scale: number, result: Color4): Color4;
  70028. /**
  70029. * Scale the current Color4 values by a factor and add the result to a given Color4
  70030. * @param scale defines the scale factor
  70031. * @param result defines the Color4 object where to store the result
  70032. * @returns the unmodified current Color4
  70033. */
  70034. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70035. /**
  70036. * Clamps the rgb values by the min and max values and stores the result into "result"
  70037. * @param min defines minimum clamping value (default is 0)
  70038. * @param max defines maximum clamping value (default is 1)
  70039. * @param result defines color to store the result into.
  70040. * @returns the cuurent Color4
  70041. */
  70042. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70043. /**
  70044. * Multipy an Color4 value by another and return a new Color4 object
  70045. * @param color defines the Color4 value to multiply by
  70046. * @returns a new Color4 object
  70047. */
  70048. multiply(color: Color4): Color4;
  70049. /**
  70050. * Multipy a Color4 value by another and push the result in a reference value
  70051. * @param color defines the Color4 value to multiply by
  70052. * @param result defines the Color4 to fill the result in
  70053. * @returns the result Color4
  70054. */
  70055. multiplyToRef(color: Color4, result: Color4): Color4;
  70056. /**
  70057. * Creates a string with the Color4 current values
  70058. * @returns the string representation of the Color4 object
  70059. */
  70060. toString(): string;
  70061. /**
  70062. * Returns the string "Color4"
  70063. * @returns "Color4"
  70064. */
  70065. getClassName(): string;
  70066. /**
  70067. * Compute the Color4 hash code
  70068. * @returns an unique number that can be used to hash Color4 objects
  70069. */
  70070. getHashCode(): number;
  70071. /**
  70072. * Creates a new Color4 copied from the current one
  70073. * @returns a new Color4 object
  70074. */
  70075. clone(): Color4;
  70076. /**
  70077. * Copies the given Color4 values into the current one
  70078. * @param source defines the source Color4 object
  70079. * @returns the current updated Color4 object
  70080. */
  70081. copyFrom(source: Color4): Color4;
  70082. /**
  70083. * Copies the given float values into the current one
  70084. * @param r defines the red component to read from
  70085. * @param g defines the green component to read from
  70086. * @param b defines the blue component to read from
  70087. * @param a defines the alpha component to read from
  70088. * @returns the current updated Color4 object
  70089. */
  70090. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70091. /**
  70092. * Copies the given float values into the current one
  70093. * @param r defines the red component to read from
  70094. * @param g defines the green component to read from
  70095. * @param b defines the blue component to read from
  70096. * @param a defines the alpha component to read from
  70097. * @returns the current updated Color4 object
  70098. */
  70099. set(r: number, g: number, b: number, a: number): Color4;
  70100. /**
  70101. * Compute the Color4 hexadecimal code as a string
  70102. * @returns a string containing the hexadecimal representation of the Color4 object
  70103. */
  70104. toHexString(): string;
  70105. /**
  70106. * Computes a new Color4 converted from the current one to linear space
  70107. * @returns a new Color4 object
  70108. */
  70109. toLinearSpace(): Color4;
  70110. /**
  70111. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70112. * @param convertedColor defines the Color4 object where to store the linear space version
  70113. * @returns the unmodified Color4
  70114. */
  70115. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70116. /**
  70117. * Computes a new Color4 converted from the current one to gamma space
  70118. * @returns a new Color4 object
  70119. */
  70120. toGammaSpace(): Color4;
  70121. /**
  70122. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70123. * @param convertedColor defines the Color4 object where to store the gamma space version
  70124. * @returns the unmodified Color4
  70125. */
  70126. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70127. /**
  70128. * Creates a new Color4 from the string containing valid hexadecimal values
  70129. * @param hex defines a string containing valid hexadecimal values
  70130. * @returns a new Color4 object
  70131. */
  70132. static FromHexString(hex: string): Color4;
  70133. /**
  70134. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70135. * @param left defines the start value
  70136. * @param right defines the end value
  70137. * @param amount defines the gradient factor
  70138. * @returns a new Color4 object
  70139. */
  70140. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70141. /**
  70142. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70143. * @param left defines the start value
  70144. * @param right defines the end value
  70145. * @param amount defines the gradient factor
  70146. * @param result defines the Color4 object where to store data
  70147. */
  70148. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70149. /**
  70150. * Creates a new Color4 from a Color3 and an alpha value
  70151. * @param color3 defines the source Color3 to read from
  70152. * @param alpha defines the alpha component (1.0 by default)
  70153. * @returns a new Color4 object
  70154. */
  70155. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70156. /**
  70157. * Creates a new Color4 from the starting index element of the given array
  70158. * @param array defines the source array to read from
  70159. * @param offset defines the offset in the source array
  70160. * @returns a new Color4 object
  70161. */
  70162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70163. /**
  70164. * Creates a new Color3 from integer values (< 256)
  70165. * @param r defines the red component to read from (value between 0 and 255)
  70166. * @param g defines the green component to read from (value between 0 and 255)
  70167. * @param b defines the blue component to read from (value between 0 and 255)
  70168. * @param a defines the alpha component to read from (value between 0 and 255)
  70169. * @returns a new Color3 object
  70170. */
  70171. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70172. /**
  70173. * Check the content of a given array and convert it to an array containing RGBA data
  70174. * If the original array was already containing count * 4 values then it is returned directly
  70175. * @param colors defines the array to check
  70176. * @param count defines the number of RGBA data to expect
  70177. * @returns an array containing count * 4 values (RGBA)
  70178. */
  70179. static CheckColors4(colors: number[], count: number): number[];
  70180. }
  70181. /**
  70182. * @hidden
  70183. */
  70184. export class TmpColors {
  70185. static Color3: Color3[];
  70186. static Color4: Color4[];
  70187. }
  70188. }
  70189. declare module BABYLON {
  70190. /**
  70191. * Class representing spherical harmonics coefficients to the 3rd degree
  70192. */
  70193. export class SphericalHarmonics {
  70194. /**
  70195. * Defines whether or not the harmonics have been prescaled for rendering.
  70196. */
  70197. preScaled: boolean;
  70198. /**
  70199. * The l0,0 coefficients of the spherical harmonics
  70200. */
  70201. l00: Vector3;
  70202. /**
  70203. * The l1,-1 coefficients of the spherical harmonics
  70204. */
  70205. l1_1: Vector3;
  70206. /**
  70207. * The l1,0 coefficients of the spherical harmonics
  70208. */
  70209. l10: Vector3;
  70210. /**
  70211. * The l1,1 coefficients of the spherical harmonics
  70212. */
  70213. l11: Vector3;
  70214. /**
  70215. * The l2,-2 coefficients of the spherical harmonics
  70216. */
  70217. l2_2: Vector3;
  70218. /**
  70219. * The l2,-1 coefficients of the spherical harmonics
  70220. */
  70221. l2_1: Vector3;
  70222. /**
  70223. * The l2,0 coefficients of the spherical harmonics
  70224. */
  70225. l20: Vector3;
  70226. /**
  70227. * The l2,1 coefficients of the spherical harmonics
  70228. */
  70229. l21: Vector3;
  70230. /**
  70231. * The l2,2 coefficients of the spherical harmonics
  70232. */
  70233. l22: Vector3;
  70234. /**
  70235. * Adds a light to the spherical harmonics
  70236. * @param direction the direction of the light
  70237. * @param color the color of the light
  70238. * @param deltaSolidAngle the delta solid angle of the light
  70239. */
  70240. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70241. /**
  70242. * Scales the spherical harmonics by the given amount
  70243. * @param scale the amount to scale
  70244. */
  70245. scaleInPlace(scale: number): void;
  70246. /**
  70247. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70248. *
  70249. * ```
  70250. * E_lm = A_l * L_lm
  70251. * ```
  70252. *
  70253. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70254. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70255. * the scaling factors are given in equation 9.
  70256. */
  70257. convertIncidentRadianceToIrradiance(): void;
  70258. /**
  70259. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70260. *
  70261. * ```
  70262. * L = (1/pi) * E * rho
  70263. * ```
  70264. *
  70265. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70266. */
  70267. convertIrradianceToLambertianRadiance(): void;
  70268. /**
  70269. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70270. * required operations at run time.
  70271. *
  70272. * This is simply done by scaling back the SH with Ylm constants parameter.
  70273. * The trigonometric part being applied by the shader at run time.
  70274. */
  70275. preScaleForRendering(): void;
  70276. /**
  70277. * Constructs a spherical harmonics from an array.
  70278. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70279. * @returns the spherical harmonics
  70280. */
  70281. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70282. /**
  70283. * Gets the spherical harmonics from polynomial
  70284. * @param polynomial the spherical polynomial
  70285. * @returns the spherical harmonics
  70286. */
  70287. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70288. }
  70289. /**
  70290. * Class representing spherical polynomial coefficients to the 3rd degree
  70291. */
  70292. export class SphericalPolynomial {
  70293. private _harmonics;
  70294. /**
  70295. * The spherical harmonics used to create the polynomials.
  70296. */
  70297. readonly preScaledHarmonics: SphericalHarmonics;
  70298. /**
  70299. * The x coefficients of the spherical polynomial
  70300. */
  70301. x: Vector3;
  70302. /**
  70303. * The y coefficients of the spherical polynomial
  70304. */
  70305. y: Vector3;
  70306. /**
  70307. * The z coefficients of the spherical polynomial
  70308. */
  70309. z: Vector3;
  70310. /**
  70311. * The xx coefficients of the spherical polynomial
  70312. */
  70313. xx: Vector3;
  70314. /**
  70315. * The yy coefficients of the spherical polynomial
  70316. */
  70317. yy: Vector3;
  70318. /**
  70319. * The zz coefficients of the spherical polynomial
  70320. */
  70321. zz: Vector3;
  70322. /**
  70323. * The xy coefficients of the spherical polynomial
  70324. */
  70325. xy: Vector3;
  70326. /**
  70327. * The yz coefficients of the spherical polynomial
  70328. */
  70329. yz: Vector3;
  70330. /**
  70331. * The zx coefficients of the spherical polynomial
  70332. */
  70333. zx: Vector3;
  70334. /**
  70335. * Adds an ambient color to the spherical polynomial
  70336. * @param color the color to add
  70337. */
  70338. addAmbient(color: Color3): void;
  70339. /**
  70340. * Scales the spherical polynomial by the given amount
  70341. * @param scale the amount to scale
  70342. */
  70343. scaleInPlace(scale: number): void;
  70344. /**
  70345. * Gets the spherical polynomial from harmonics
  70346. * @param harmonics the spherical harmonics
  70347. * @returns the spherical polynomial
  70348. */
  70349. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70350. /**
  70351. * Constructs a spherical polynomial from an array.
  70352. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70353. * @returns the spherical polynomial
  70354. */
  70355. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70356. }
  70357. }
  70358. declare module BABYLON {
  70359. /**
  70360. * Define options used to create a render target texture
  70361. */
  70362. export class RenderTargetCreationOptions {
  70363. /**
  70364. * Specifies is mipmaps must be generated
  70365. */
  70366. generateMipMaps?: boolean;
  70367. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70368. generateDepthBuffer?: boolean;
  70369. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70370. generateStencilBuffer?: boolean;
  70371. /** Defines texture type (int by default) */
  70372. type?: number;
  70373. /** Defines sampling mode (trilinear by default) */
  70374. samplingMode?: number;
  70375. /** Defines format (RGBA by default) */
  70376. format?: number;
  70377. }
  70378. }
  70379. declare module BABYLON {
  70380. /**
  70381. * @hidden
  70382. **/
  70383. export class _AlphaState {
  70384. private _isAlphaBlendDirty;
  70385. private _isBlendFunctionParametersDirty;
  70386. private _isBlendEquationParametersDirty;
  70387. private _isBlendConstantsDirty;
  70388. private _alphaBlend;
  70389. private _blendFunctionParameters;
  70390. private _blendEquationParameters;
  70391. private _blendConstants;
  70392. /**
  70393. * Initializes the state.
  70394. */
  70395. constructor();
  70396. readonly isDirty: boolean;
  70397. alphaBlend: boolean;
  70398. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  70399. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  70400. setAlphaEquationParameters(rgb: number, alpha: number): void;
  70401. reset(): void;
  70402. apply(gl: WebGLRenderingContext): void;
  70403. }
  70404. }
  70405. declare module BABYLON {
  70406. /**
  70407. * @hidden
  70408. **/
  70409. export class _DepthCullingState {
  70410. private _isDepthTestDirty;
  70411. private _isDepthMaskDirty;
  70412. private _isDepthFuncDirty;
  70413. private _isCullFaceDirty;
  70414. private _isCullDirty;
  70415. private _isZOffsetDirty;
  70416. private _isFrontFaceDirty;
  70417. private _depthTest;
  70418. private _depthMask;
  70419. private _depthFunc;
  70420. private _cull;
  70421. private _cullFace;
  70422. private _zOffset;
  70423. private _frontFace;
  70424. /**
  70425. * Initializes the state.
  70426. */
  70427. constructor();
  70428. readonly isDirty: boolean;
  70429. zOffset: number;
  70430. cullFace: Nullable<number>;
  70431. cull: Nullable<boolean>;
  70432. depthFunc: Nullable<number>;
  70433. depthMask: boolean;
  70434. depthTest: boolean;
  70435. frontFace: Nullable<number>;
  70436. reset(): void;
  70437. apply(gl: WebGLRenderingContext): void;
  70438. }
  70439. }
  70440. declare module BABYLON {
  70441. /** Defines the cross module used constants to avoid circular dependncies */
  70442. export class Constants {
  70443. /** Defines that alpha blending is disabled */
  70444. static readonly ALPHA_DISABLE: number;
  70445. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  70446. static readonly ALPHA_ADD: number;
  70447. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  70448. static readonly ALPHA_COMBINE: number;
  70449. /** Defines that alpha blending to DEST - SRC * DEST */
  70450. static readonly ALPHA_SUBTRACT: number;
  70451. /** Defines that alpha blending to SRC * DEST */
  70452. static readonly ALPHA_MULTIPLY: number;
  70453. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  70454. static readonly ALPHA_MAXIMIZED: number;
  70455. /** Defines that alpha blending to SRC + DEST */
  70456. static readonly ALPHA_ONEONE: number;
  70457. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  70458. static readonly ALPHA_PREMULTIPLIED: number;
  70459. /**
  70460. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  70461. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  70462. */
  70463. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  70464. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  70465. static readonly ALPHA_INTERPOLATE: number;
  70466. /**
  70467. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  70468. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  70469. */
  70470. static readonly ALPHA_SCREENMODE: number;
  70471. /**
  70472. * Defines that alpha blending to SRC + DST
  70473. * Alpha will be set to SRC ALPHA + DST ALPHA
  70474. */
  70475. static readonly ALPHA_ONEONE_ONEONE: number;
  70476. /**
  70477. * Defines that alpha blending to SRC * DST ALPHA + DST
  70478. * Alpha will be set to 0
  70479. */
  70480. static readonly ALPHA_ALPHATOCOLOR: number;
  70481. /**
  70482. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  70483. */
  70484. static readonly ALPHA_REVERSEONEMINUS: number;
  70485. /**
  70486. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  70487. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  70488. */
  70489. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  70490. /**
  70491. * Defines that alpha blending to SRC + DST
  70492. * Alpha will be set to SRC ALPHA
  70493. */
  70494. static readonly ALPHA_ONEONE_ONEZERO: number;
  70495. /** Defines that alpha blending equation a SUM */
  70496. static readonly ALPHA_EQUATION_ADD: number;
  70497. /** Defines that alpha blending equation a SUBSTRACTION */
  70498. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  70499. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70500. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70501. /** Defines that alpha blending equation a MAX operation */
  70502. static readonly ALPHA_EQUATION_MAX: number;
  70503. /** Defines that alpha blending equation a MIN operation */
  70504. static readonly ALPHA_EQUATION_MIN: number;
  70505. /**
  70506. * Defines that alpha blending equation a DARKEN operation:
  70507. * It takes the min of the src and sums the alpha channels.
  70508. */
  70509. static readonly ALPHA_EQUATION_DARKEN: number;
  70510. /** Defines that the ressource is not delayed*/
  70511. static readonly DELAYLOADSTATE_NONE: number;
  70512. /** Defines that the ressource was successfully delay loaded */
  70513. static readonly DELAYLOADSTATE_LOADED: number;
  70514. /** Defines that the ressource is currently delay loading */
  70515. static readonly DELAYLOADSTATE_LOADING: number;
  70516. /** Defines that the ressource is delayed and has not started loading */
  70517. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70519. static readonly NEVER: number;
  70520. /** 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 */
  70521. static readonly ALWAYS: number;
  70522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70523. static readonly LESS: number;
  70524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70525. static readonly EQUAL: number;
  70526. /** 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 */
  70527. static readonly LEQUAL: number;
  70528. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70529. static readonly GREATER: number;
  70530. /** 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 */
  70531. static readonly GEQUAL: number;
  70532. /** 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 */
  70533. static readonly NOTEQUAL: number;
  70534. /** Passed to stencilOperation to specify that stencil value must be kept */
  70535. static readonly KEEP: number;
  70536. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70537. static readonly REPLACE: number;
  70538. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70539. static readonly INCR: number;
  70540. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70541. static readonly DECR: number;
  70542. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70543. static readonly INVERT: number;
  70544. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70545. static readonly INCR_WRAP: number;
  70546. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70547. static readonly DECR_WRAP: number;
  70548. /** Texture is not repeating outside of 0..1 UVs */
  70549. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70550. /** Texture is repeating outside of 0..1 UVs */
  70551. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70552. /** Texture is repeating and mirrored */
  70553. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70554. /** ALPHA */
  70555. static readonly TEXTUREFORMAT_ALPHA: number;
  70556. /** LUMINANCE */
  70557. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70558. /** LUMINANCE_ALPHA */
  70559. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70560. /** RGB */
  70561. static readonly TEXTUREFORMAT_RGB: number;
  70562. /** RGBA */
  70563. static readonly TEXTUREFORMAT_RGBA: number;
  70564. /** RED */
  70565. static readonly TEXTUREFORMAT_RED: number;
  70566. /** RED (2nd reference) */
  70567. static readonly TEXTUREFORMAT_R: number;
  70568. /** RG */
  70569. static readonly TEXTUREFORMAT_RG: number;
  70570. /** RED_INTEGER */
  70571. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70572. /** RED_INTEGER (2nd reference) */
  70573. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70574. /** RG_INTEGER */
  70575. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70576. /** RGB_INTEGER */
  70577. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70578. /** RGBA_INTEGER */
  70579. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70580. /** UNSIGNED_BYTE */
  70581. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70582. /** UNSIGNED_BYTE (2nd reference) */
  70583. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70584. /** FLOAT */
  70585. static readonly TEXTURETYPE_FLOAT: number;
  70586. /** HALF_FLOAT */
  70587. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70588. /** BYTE */
  70589. static readonly TEXTURETYPE_BYTE: number;
  70590. /** SHORT */
  70591. static readonly TEXTURETYPE_SHORT: number;
  70592. /** UNSIGNED_SHORT */
  70593. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70594. /** INT */
  70595. static readonly TEXTURETYPE_INT: number;
  70596. /** UNSIGNED_INT */
  70597. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70598. /** UNSIGNED_SHORT_4_4_4_4 */
  70599. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70600. /** UNSIGNED_SHORT_5_5_5_1 */
  70601. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70602. /** UNSIGNED_SHORT_5_6_5 */
  70603. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70604. /** UNSIGNED_INT_2_10_10_10_REV */
  70605. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70606. /** UNSIGNED_INT_24_8 */
  70607. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70608. /** UNSIGNED_INT_10F_11F_11F_REV */
  70609. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70610. /** UNSIGNED_INT_5_9_9_9_REV */
  70611. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70612. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70613. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70614. /** nearest is mag = nearest and min = nearest and mip = linear */
  70615. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70616. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70617. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70618. /** Trilinear is mag = linear and min = linear and mip = linear */
  70619. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70620. /** nearest is mag = nearest and min = nearest and mip = linear */
  70621. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70622. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70623. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70624. /** Trilinear is mag = linear and min = linear and mip = linear */
  70625. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70626. /** mag = nearest and min = nearest and mip = nearest */
  70627. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70628. /** mag = nearest and min = linear and mip = nearest */
  70629. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70630. /** mag = nearest and min = linear and mip = linear */
  70631. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70632. /** mag = nearest and min = linear and mip = none */
  70633. static readonly TEXTURE_NEAREST_LINEAR: number;
  70634. /** mag = nearest and min = nearest and mip = none */
  70635. static readonly TEXTURE_NEAREST_NEAREST: number;
  70636. /** mag = linear and min = nearest and mip = nearest */
  70637. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70638. /** mag = linear and min = nearest and mip = linear */
  70639. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70640. /** mag = linear and min = linear and mip = none */
  70641. static readonly TEXTURE_LINEAR_LINEAR: number;
  70642. /** mag = linear and min = nearest and mip = none */
  70643. static readonly TEXTURE_LINEAR_NEAREST: number;
  70644. /** Explicit coordinates mode */
  70645. static readonly TEXTURE_EXPLICIT_MODE: number;
  70646. /** Spherical coordinates mode */
  70647. static readonly TEXTURE_SPHERICAL_MODE: number;
  70648. /** Planar coordinates mode */
  70649. static readonly TEXTURE_PLANAR_MODE: number;
  70650. /** Cubic coordinates mode */
  70651. static readonly TEXTURE_CUBIC_MODE: number;
  70652. /** Projection coordinates mode */
  70653. static readonly TEXTURE_PROJECTION_MODE: number;
  70654. /** Skybox coordinates mode */
  70655. static readonly TEXTURE_SKYBOX_MODE: number;
  70656. /** Inverse Cubic coordinates mode */
  70657. static readonly TEXTURE_INVCUBIC_MODE: number;
  70658. /** Equirectangular coordinates mode */
  70659. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70660. /** Equirectangular Fixed coordinates mode */
  70661. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70662. /** Equirectangular Fixed Mirrored coordinates mode */
  70663. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70664. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70665. static readonly SCALEMODE_FLOOR: number;
  70666. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70667. static readonly SCALEMODE_NEAREST: number;
  70668. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70669. static readonly SCALEMODE_CEILING: number;
  70670. /**
  70671. * The dirty texture flag value
  70672. */
  70673. static readonly MATERIAL_TextureDirtyFlag: number;
  70674. /**
  70675. * The dirty light flag value
  70676. */
  70677. static readonly MATERIAL_LightDirtyFlag: number;
  70678. /**
  70679. * The dirty fresnel flag value
  70680. */
  70681. static readonly MATERIAL_FresnelDirtyFlag: number;
  70682. /**
  70683. * The dirty attribute flag value
  70684. */
  70685. static readonly MATERIAL_AttributesDirtyFlag: number;
  70686. /**
  70687. * The dirty misc flag value
  70688. */
  70689. static readonly MATERIAL_MiscDirtyFlag: number;
  70690. /**
  70691. * The all dirty flag value
  70692. */
  70693. static readonly MATERIAL_AllDirtyFlag: number;
  70694. /**
  70695. * Returns the triangle fill mode
  70696. */
  70697. static readonly MATERIAL_TriangleFillMode: number;
  70698. /**
  70699. * Returns the wireframe mode
  70700. */
  70701. static readonly MATERIAL_WireFrameFillMode: number;
  70702. /**
  70703. * Returns the point fill mode
  70704. */
  70705. static readonly MATERIAL_PointFillMode: number;
  70706. /**
  70707. * Returns the point list draw mode
  70708. */
  70709. static readonly MATERIAL_PointListDrawMode: number;
  70710. /**
  70711. * Returns the line list draw mode
  70712. */
  70713. static readonly MATERIAL_LineListDrawMode: number;
  70714. /**
  70715. * Returns the line loop draw mode
  70716. */
  70717. static readonly MATERIAL_LineLoopDrawMode: number;
  70718. /**
  70719. * Returns the line strip draw mode
  70720. */
  70721. static readonly MATERIAL_LineStripDrawMode: number;
  70722. /**
  70723. * Returns the triangle strip draw mode
  70724. */
  70725. static readonly MATERIAL_TriangleStripDrawMode: number;
  70726. /**
  70727. * Returns the triangle fan draw mode
  70728. */
  70729. static readonly MATERIAL_TriangleFanDrawMode: number;
  70730. /**
  70731. * Stores the clock-wise side orientation
  70732. */
  70733. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70734. /**
  70735. * Stores the counter clock-wise side orientation
  70736. */
  70737. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70738. /**
  70739. * Nothing
  70740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70741. */
  70742. static readonly ACTION_NothingTrigger: number;
  70743. /**
  70744. * On pick
  70745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70746. */
  70747. static readonly ACTION_OnPickTrigger: number;
  70748. /**
  70749. * On left pick
  70750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70751. */
  70752. static readonly ACTION_OnLeftPickTrigger: number;
  70753. /**
  70754. * On right pick
  70755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70756. */
  70757. static readonly ACTION_OnRightPickTrigger: number;
  70758. /**
  70759. * On center pick
  70760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70761. */
  70762. static readonly ACTION_OnCenterPickTrigger: number;
  70763. /**
  70764. * On pick down
  70765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70766. */
  70767. static readonly ACTION_OnPickDownTrigger: number;
  70768. /**
  70769. * On double pick
  70770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70771. */
  70772. static readonly ACTION_OnDoublePickTrigger: number;
  70773. /**
  70774. * On pick up
  70775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70776. */
  70777. static readonly ACTION_OnPickUpTrigger: number;
  70778. /**
  70779. * On pick out.
  70780. * This trigger will only be raised if you also declared a OnPickDown
  70781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70782. */
  70783. static readonly ACTION_OnPickOutTrigger: number;
  70784. /**
  70785. * On long press
  70786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70787. */
  70788. static readonly ACTION_OnLongPressTrigger: number;
  70789. /**
  70790. * On pointer over
  70791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70792. */
  70793. static readonly ACTION_OnPointerOverTrigger: number;
  70794. /**
  70795. * On pointer out
  70796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70797. */
  70798. static readonly ACTION_OnPointerOutTrigger: number;
  70799. /**
  70800. * On every frame
  70801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70802. */
  70803. static readonly ACTION_OnEveryFrameTrigger: number;
  70804. /**
  70805. * On intersection enter
  70806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70807. */
  70808. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70809. /**
  70810. * On intersection exit
  70811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70812. */
  70813. static readonly ACTION_OnIntersectionExitTrigger: number;
  70814. /**
  70815. * On key down
  70816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70817. */
  70818. static readonly ACTION_OnKeyDownTrigger: number;
  70819. /**
  70820. * On key up
  70821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70822. */
  70823. static readonly ACTION_OnKeyUpTrigger: number;
  70824. /**
  70825. * Billboard mode will only apply to Y axis
  70826. */
  70827. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70828. /**
  70829. * Billboard mode will apply to all axes
  70830. */
  70831. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70832. /**
  70833. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70834. */
  70835. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70836. /**
  70837. * Gets or sets base Assets URL
  70838. */
  70839. static PARTICLES_BaseAssetsUrl: string;
  70840. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70841. * Test order :
  70842. * Is the bounding sphere outside the frustum ?
  70843. * If not, are the bounding box vertices outside the frustum ?
  70844. * It not, then the cullable object is in the frustum.
  70845. */
  70846. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70847. /** Culling strategy : Bounding Sphere Only.
  70848. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70849. * It's also less accurate than the standard because some not visible objects can still be selected.
  70850. * Test : is the bounding sphere outside the frustum ?
  70851. * If not, then the cullable object is in the frustum.
  70852. */
  70853. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70854. /** Culling strategy : Optimistic Inclusion.
  70855. * This in an inclusion test first, then the standard exclusion test.
  70856. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70857. * 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.
  70858. * Anyway, it's as accurate as the standard strategy.
  70859. * Test :
  70860. * Is the cullable object bounding sphere center in the frustum ?
  70861. * If not, apply the default culling strategy.
  70862. */
  70863. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70864. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70865. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70866. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70867. * 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.
  70868. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70869. * Test :
  70870. * Is the cullable object bounding sphere center in the frustum ?
  70871. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70872. */
  70873. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70874. /**
  70875. * No logging while loading
  70876. */
  70877. static readonly SCENELOADER_NO_LOGGING: number;
  70878. /**
  70879. * Minimal logging while loading
  70880. */
  70881. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70882. /**
  70883. * Summary logging while loading
  70884. */
  70885. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70886. /**
  70887. * Detailled logging while loading
  70888. */
  70889. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70890. }
  70891. }
  70892. declare module BABYLON {
  70893. /**
  70894. * @hidden
  70895. **/
  70896. export class _StencilState {
  70897. /** 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 */
  70898. static readonly ALWAYS: number;
  70899. /** Passed to stencilOperation to specify that stencil value must be kept */
  70900. static readonly KEEP: number;
  70901. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70902. static readonly REPLACE: number;
  70903. private _isStencilTestDirty;
  70904. private _isStencilMaskDirty;
  70905. private _isStencilFuncDirty;
  70906. private _isStencilOpDirty;
  70907. private _stencilTest;
  70908. private _stencilMask;
  70909. private _stencilFunc;
  70910. private _stencilFuncRef;
  70911. private _stencilFuncMask;
  70912. private _stencilOpStencilFail;
  70913. private _stencilOpDepthFail;
  70914. private _stencilOpStencilDepthPass;
  70915. readonly isDirty: boolean;
  70916. stencilFunc: number;
  70917. stencilFuncRef: number;
  70918. stencilFuncMask: number;
  70919. stencilOpStencilFail: number;
  70920. stencilOpDepthFail: number;
  70921. stencilOpStencilDepthPass: number;
  70922. stencilMask: number;
  70923. stencilTest: boolean;
  70924. constructor();
  70925. reset(): void;
  70926. apply(gl: WebGLRenderingContext): void;
  70927. }
  70928. }
  70929. declare module BABYLON {
  70930. /**
  70931. * @hidden
  70932. **/
  70933. export class _TimeToken {
  70934. _startTimeQuery: Nullable<WebGLQuery>;
  70935. _endTimeQuery: Nullable<WebGLQuery>;
  70936. _timeElapsedQuery: Nullable<WebGLQuery>;
  70937. _timeElapsedQueryEnded: boolean;
  70938. }
  70939. }
  70940. declare module BABYLON {
  70941. /**
  70942. * This represents the required contract to create a new type of texture loader.
  70943. */
  70944. export interface IInternalTextureLoader {
  70945. /**
  70946. * Defines wether the loader supports cascade loading the different faces.
  70947. */
  70948. supportCascades: boolean;
  70949. /**
  70950. * This returns if the loader support the current file information.
  70951. * @param extension defines the file extension of the file being loaded
  70952. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70953. * @param fallback defines the fallback internal texture if any
  70954. * @param isBase64 defines whether the texture is encoded as a base64
  70955. * @param isBuffer defines whether the texture data are stored as a buffer
  70956. * @returns true if the loader can load the specified file
  70957. */
  70958. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70959. /**
  70960. * Transform the url before loading if required.
  70961. * @param rootUrl the url of the texture
  70962. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70963. * @returns the transformed texture
  70964. */
  70965. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70966. /**
  70967. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70968. * @param rootUrl the url of the texture
  70969. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70970. * @returns the fallback texture
  70971. */
  70972. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70973. /**
  70974. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70975. * @param data contains the texture data
  70976. * @param texture defines the BabylonJS internal texture
  70977. * @param createPolynomials will be true if polynomials have been requested
  70978. * @param onLoad defines the callback to trigger once the texture is ready
  70979. * @param onError defines the callback to trigger in case of error
  70980. */
  70981. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70982. /**
  70983. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70984. * @param data contains the texture data
  70985. * @param texture defines the BabylonJS internal texture
  70986. * @param callback defines the method to call once ready to upload
  70987. */
  70988. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70989. }
  70990. }
  70991. declare module BABYLON {
  70992. /**
  70993. * Class used to store and describe the pipeline context associated with an effect
  70994. */
  70995. export interface IPipelineContext {
  70996. /**
  70997. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70998. */
  70999. isAsync: boolean;
  71000. /**
  71001. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71002. */
  71003. isReady: boolean;
  71004. /** @hidden */
  71005. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71006. }
  71007. }
  71008. declare module BABYLON {
  71009. /**
  71010. * Class used to store gfx data (like WebGLBuffer)
  71011. */
  71012. export class DataBuffer {
  71013. /**
  71014. * Gets or sets the number of objects referencing this buffer
  71015. */
  71016. references: number;
  71017. /** Gets or sets the size of the underlying buffer */
  71018. capacity: number;
  71019. /**
  71020. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71021. */
  71022. is32Bits: boolean;
  71023. /**
  71024. * Gets the underlying buffer
  71025. */
  71026. readonly underlyingResource: any;
  71027. }
  71028. }
  71029. declare module BABYLON {
  71030. /** @hidden */
  71031. export interface IShaderProcessor {
  71032. attributeProcessor?: (attribute: string) => string;
  71033. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71034. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71035. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71036. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71037. lineProcessor?: (line: string, isFragment: boolean) => string;
  71038. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71039. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71040. }
  71041. }
  71042. declare module BABYLON {
  71043. /** @hidden */
  71044. export interface ProcessingOptions {
  71045. defines: string[];
  71046. indexParameters: any;
  71047. isFragment: boolean;
  71048. shouldUseHighPrecisionShader: boolean;
  71049. supportsUniformBuffers: boolean;
  71050. shadersRepository: string;
  71051. includesShadersStore: {
  71052. [key: string]: string;
  71053. };
  71054. processor?: IShaderProcessor;
  71055. version: string;
  71056. platformName: string;
  71057. lookForClosingBracketForUniformBuffer?: boolean;
  71058. }
  71059. }
  71060. declare module BABYLON {
  71061. /**
  71062. * Helper to manipulate strings
  71063. */
  71064. export class StringTools {
  71065. /**
  71066. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71067. * @param str Source string
  71068. * @param suffix Suffix to search for in the source string
  71069. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71070. */
  71071. static EndsWith(str: string, suffix: string): boolean;
  71072. /**
  71073. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71074. * @param str Source string
  71075. * @param suffix Suffix to search for in the source string
  71076. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71077. */
  71078. static StartsWith(str: string, suffix: string): boolean;
  71079. }
  71080. }
  71081. declare module BABYLON {
  71082. /** @hidden */
  71083. export class ShaderCodeNode {
  71084. line: string;
  71085. children: ShaderCodeNode[];
  71086. additionalDefineKey?: string;
  71087. additionalDefineValue?: string;
  71088. isValid(preprocessors: {
  71089. [key: string]: string;
  71090. }): boolean;
  71091. process(preprocessors: {
  71092. [key: string]: string;
  71093. }, options: ProcessingOptions): string;
  71094. }
  71095. }
  71096. declare module BABYLON {
  71097. /** @hidden */
  71098. export class ShaderCodeCursor {
  71099. private _lines;
  71100. lineIndex: number;
  71101. readonly currentLine: string;
  71102. readonly canRead: boolean;
  71103. lines: string[];
  71104. }
  71105. }
  71106. declare module BABYLON {
  71107. /** @hidden */
  71108. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71109. process(preprocessors: {
  71110. [key: string]: string;
  71111. }, options: ProcessingOptions): string;
  71112. }
  71113. }
  71114. declare module BABYLON {
  71115. /** @hidden */
  71116. export class ShaderDefineExpression {
  71117. isTrue(preprocessors: {
  71118. [key: string]: string;
  71119. }): boolean;
  71120. }
  71121. }
  71122. declare module BABYLON {
  71123. /** @hidden */
  71124. export class ShaderCodeTestNode extends ShaderCodeNode {
  71125. testExpression: ShaderDefineExpression;
  71126. isValid(preprocessors: {
  71127. [key: string]: string;
  71128. }): boolean;
  71129. }
  71130. }
  71131. declare module BABYLON {
  71132. /** @hidden */
  71133. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71134. define: string;
  71135. not: boolean;
  71136. constructor(define: string, not?: boolean);
  71137. isTrue(preprocessors: {
  71138. [key: string]: string;
  71139. }): boolean;
  71140. }
  71141. }
  71142. declare module BABYLON {
  71143. /** @hidden */
  71144. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71145. leftOperand: ShaderDefineExpression;
  71146. rightOperand: ShaderDefineExpression;
  71147. isTrue(preprocessors: {
  71148. [key: string]: string;
  71149. }): boolean;
  71150. }
  71151. }
  71152. declare module BABYLON {
  71153. /** @hidden */
  71154. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71155. leftOperand: ShaderDefineExpression;
  71156. rightOperand: ShaderDefineExpression;
  71157. isTrue(preprocessors: {
  71158. [key: string]: string;
  71159. }): boolean;
  71160. }
  71161. }
  71162. declare module BABYLON {
  71163. /** @hidden */
  71164. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71165. define: string;
  71166. operand: string;
  71167. testValue: string;
  71168. constructor(define: string, operand: string, testValue: string);
  71169. isTrue(preprocessors: {
  71170. [key: string]: string;
  71171. }): boolean;
  71172. }
  71173. }
  71174. declare module BABYLON {
  71175. /**
  71176. * @ignore
  71177. * Application error to support additional information when loading a file
  71178. */
  71179. export class LoadFileError extends Error {
  71180. /** defines the optional web request */
  71181. request?: WebRequest | undefined;
  71182. private static _setPrototypeOf;
  71183. /**
  71184. * Creates a new LoadFileError
  71185. * @param message defines the message of the error
  71186. * @param request defines the optional web request
  71187. */
  71188. constructor(message: string,
  71189. /** defines the optional web request */
  71190. request?: WebRequest | undefined);
  71191. }
  71192. }
  71193. declare module BABYLON {
  71194. /**
  71195. * Class used to enable access to offline support
  71196. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71197. */
  71198. export interface IOfflineProvider {
  71199. /**
  71200. * Gets a boolean indicating if scene must be saved in the database
  71201. */
  71202. enableSceneOffline: boolean;
  71203. /**
  71204. * Gets a boolean indicating if textures must be saved in the database
  71205. */
  71206. enableTexturesOffline: boolean;
  71207. /**
  71208. * Open the offline support and make it available
  71209. * @param successCallback defines the callback to call on success
  71210. * @param errorCallback defines the callback to call on error
  71211. */
  71212. open(successCallback: () => void, errorCallback: () => void): void;
  71213. /**
  71214. * Loads an image from the offline support
  71215. * @param url defines the url to load from
  71216. * @param image defines the target DOM image
  71217. */
  71218. loadImage(url: string, image: HTMLImageElement): void;
  71219. /**
  71220. * Loads a file from offline support
  71221. * @param url defines the URL to load from
  71222. * @param sceneLoaded defines a callback to call on success
  71223. * @param progressCallBack defines a callback to call when progress changed
  71224. * @param errorCallback defines a callback to call on error
  71225. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71226. */
  71227. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71228. }
  71229. }
  71230. declare module BABYLON {
  71231. /**
  71232. * Class used to help managing file picking and drag'n'drop
  71233. * File Storage
  71234. */
  71235. export class FilesInputStore {
  71236. /**
  71237. * List of files ready to be loaded
  71238. */
  71239. static FilesToLoad: {
  71240. [key: string]: File;
  71241. };
  71242. }
  71243. }
  71244. declare module BABYLON {
  71245. /**
  71246. * Class used to define a retry strategy when error happens while loading assets
  71247. */
  71248. export class RetryStrategy {
  71249. /**
  71250. * Function used to defines an exponential back off strategy
  71251. * @param maxRetries defines the maximum number of retries (3 by default)
  71252. * @param baseInterval defines the interval between retries
  71253. * @returns the strategy function to use
  71254. */
  71255. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71256. }
  71257. }
  71258. declare module BABYLON {
  71259. /**
  71260. * @hidden
  71261. */
  71262. export class FileTools {
  71263. /**
  71264. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71265. */
  71266. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71267. /**
  71268. * Gets or sets the base URL to use to load assets
  71269. */
  71270. static BaseUrl: string;
  71271. /**
  71272. * Default behaviour for cors in the application.
  71273. * It can be a string if the expected behavior is identical in the entire app.
  71274. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71275. */
  71276. static CorsBehavior: string | ((url: string | string[]) => string);
  71277. /**
  71278. * Gets or sets a function used to pre-process url before using them to load assets
  71279. */
  71280. static PreprocessUrl: (url: string) => string;
  71281. /**
  71282. * Removes unwanted characters from an url
  71283. * @param url defines the url to clean
  71284. * @returns the cleaned url
  71285. */
  71286. private static _CleanUrl;
  71287. /**
  71288. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71289. * @param url define the url we are trying
  71290. * @param element define the dom element where to configure the cors policy
  71291. */
  71292. static SetCorsBehavior(url: string | string[], element: {
  71293. crossOrigin: string | null;
  71294. }): void;
  71295. /**
  71296. * Loads an image as an HTMLImageElement.
  71297. * @param input url string, ArrayBuffer, or Blob to load
  71298. * @param onLoad callback called when the image successfully loads
  71299. * @param onError callback called when the image fails to load
  71300. * @param offlineProvider offline provider for caching
  71301. * @returns the HTMLImageElement of the loaded image
  71302. */
  71303. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71304. /**
  71305. * Loads a file
  71306. * @param fileToLoad defines the file to load
  71307. * @param callback defines the callback to call when data is loaded
  71308. * @param progressCallBack defines the callback to call during loading process
  71309. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71310. * @returns a file request object
  71311. */
  71312. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71313. /**
  71314. * Loads a file
  71315. * @param url url string, ArrayBuffer, or Blob to load
  71316. * @param onSuccess callback called when the file successfully loads
  71317. * @param onProgress callback called while file is loading (if the server supports this mode)
  71318. * @param offlineProvider defines the offline provider for caching
  71319. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71320. * @param onError callback called when the file fails to load
  71321. * @returns a file request object
  71322. */
  71323. 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;
  71324. /**
  71325. * Checks if the loaded document was accessed via `file:`-Protocol.
  71326. * @returns boolean
  71327. */
  71328. static IsFileURL(): boolean;
  71329. }
  71330. }
  71331. declare module BABYLON {
  71332. /** @hidden */
  71333. export class ShaderProcessor {
  71334. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71335. private static _ProcessPrecision;
  71336. private static _ExtractOperation;
  71337. private static _BuildSubExpression;
  71338. private static _BuildExpression;
  71339. private static _MoveCursorWithinIf;
  71340. private static _MoveCursor;
  71341. private static _EvaluatePreProcessors;
  71342. private static _PreparePreProcessors;
  71343. private static _ProcessShaderConversion;
  71344. private static _ProcessIncludes;
  71345. }
  71346. }
  71347. declare module BABYLON {
  71348. /**
  71349. * Class used to evalaute queries containing `and` and `or` operators
  71350. */
  71351. export class AndOrNotEvaluator {
  71352. /**
  71353. * Evaluate a query
  71354. * @param query defines the query to evaluate
  71355. * @param evaluateCallback defines the callback used to filter result
  71356. * @returns true if the query matches
  71357. */
  71358. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71359. private static _HandleParenthesisContent;
  71360. private static _SimplifyNegation;
  71361. }
  71362. }
  71363. declare module BABYLON {
  71364. /**
  71365. * Class used to store custom tags
  71366. */
  71367. export class Tags {
  71368. /**
  71369. * Adds support for tags on the given object
  71370. * @param obj defines the object to use
  71371. */
  71372. static EnableFor(obj: any): void;
  71373. /**
  71374. * Removes tags support
  71375. * @param obj defines the object to use
  71376. */
  71377. static DisableFor(obj: any): void;
  71378. /**
  71379. * Gets a boolean indicating if the given object has tags
  71380. * @param obj defines the object to use
  71381. * @returns a boolean
  71382. */
  71383. static HasTags(obj: any): boolean;
  71384. /**
  71385. * Gets the tags available on a given object
  71386. * @param obj defines the object to use
  71387. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71388. * @returns the tags
  71389. */
  71390. static GetTags(obj: any, asString?: boolean): any;
  71391. /**
  71392. * Adds tags to an object
  71393. * @param obj defines the object to use
  71394. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71395. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71396. */
  71397. static AddTagsTo(obj: any, tagsString: string): void;
  71398. /**
  71399. * @hidden
  71400. */
  71401. static _AddTagTo(obj: any, tag: string): void;
  71402. /**
  71403. * Removes specific tags from a specific object
  71404. * @param obj defines the object to use
  71405. * @param tagsString defines the tags to remove
  71406. */
  71407. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71408. /**
  71409. * @hidden
  71410. */
  71411. static _RemoveTagFrom(obj: any, tag: string): void;
  71412. /**
  71413. * Defines if tags hosted on an object match a given query
  71414. * @param obj defines the object to use
  71415. * @param tagsQuery defines the tag query
  71416. * @returns a boolean
  71417. */
  71418. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71419. }
  71420. }
  71421. declare module BABYLON {
  71422. /**
  71423. * Defines potential orientation for back face culling
  71424. */
  71425. export enum Orientation {
  71426. /**
  71427. * Clockwise
  71428. */
  71429. CW = 0,
  71430. /** Counter clockwise */
  71431. CCW = 1
  71432. }
  71433. /** Class used to represent a Bezier curve */
  71434. export class BezierCurve {
  71435. /**
  71436. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71437. * @param t defines the time
  71438. * @param x1 defines the left coordinate on X axis
  71439. * @param y1 defines the left coordinate on Y axis
  71440. * @param x2 defines the right coordinate on X axis
  71441. * @param y2 defines the right coordinate on Y axis
  71442. * @returns the interpolated value
  71443. */
  71444. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71445. }
  71446. /**
  71447. * Defines angle representation
  71448. */
  71449. export class Angle {
  71450. private _radians;
  71451. /**
  71452. * Creates an Angle object of "radians" radians (float).
  71453. * @param radians the angle in radians
  71454. */
  71455. constructor(radians: number);
  71456. /**
  71457. * Get value in degrees
  71458. * @returns the Angle value in degrees (float)
  71459. */
  71460. degrees(): number;
  71461. /**
  71462. * Get value in radians
  71463. * @returns the Angle value in radians (float)
  71464. */
  71465. radians(): number;
  71466. /**
  71467. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71468. * @param a defines first vector
  71469. * @param b defines second vector
  71470. * @returns a new Angle
  71471. */
  71472. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71473. /**
  71474. * Gets a new Angle object from the given float in radians
  71475. * @param radians defines the angle value in radians
  71476. * @returns a new Angle
  71477. */
  71478. static FromRadians(radians: number): Angle;
  71479. /**
  71480. * Gets a new Angle object from the given float in degrees
  71481. * @param degrees defines the angle value in degrees
  71482. * @returns a new Angle
  71483. */
  71484. static FromDegrees(degrees: number): Angle;
  71485. }
  71486. /**
  71487. * This represents an arc in a 2d space.
  71488. */
  71489. export class Arc2 {
  71490. /** Defines the start point of the arc */
  71491. startPoint: Vector2;
  71492. /** Defines the mid point of the arc */
  71493. midPoint: Vector2;
  71494. /** Defines the end point of the arc */
  71495. endPoint: Vector2;
  71496. /**
  71497. * Defines the center point of the arc.
  71498. */
  71499. centerPoint: Vector2;
  71500. /**
  71501. * Defines the radius of the arc.
  71502. */
  71503. radius: number;
  71504. /**
  71505. * Defines the angle of the arc (from mid point to end point).
  71506. */
  71507. angle: Angle;
  71508. /**
  71509. * Defines the start angle of the arc (from start point to middle point).
  71510. */
  71511. startAngle: Angle;
  71512. /**
  71513. * Defines the orientation of the arc (clock wise/counter clock wise).
  71514. */
  71515. orientation: Orientation;
  71516. /**
  71517. * Creates an Arc object from the three given points : start, middle and end.
  71518. * @param startPoint Defines the start point of the arc
  71519. * @param midPoint Defines the midlle point of the arc
  71520. * @param endPoint Defines the end point of the arc
  71521. */
  71522. constructor(
  71523. /** Defines the start point of the arc */
  71524. startPoint: Vector2,
  71525. /** Defines the mid point of the arc */
  71526. midPoint: Vector2,
  71527. /** Defines the end point of the arc */
  71528. endPoint: Vector2);
  71529. }
  71530. /**
  71531. * Represents a 2D path made up of multiple 2D points
  71532. */
  71533. export class Path2 {
  71534. private _points;
  71535. private _length;
  71536. /**
  71537. * If the path start and end point are the same
  71538. */
  71539. closed: boolean;
  71540. /**
  71541. * Creates a Path2 object from the starting 2D coordinates x and y.
  71542. * @param x the starting points x value
  71543. * @param y the starting points y value
  71544. */
  71545. constructor(x: number, y: number);
  71546. /**
  71547. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71548. * @param x the added points x value
  71549. * @param y the added points y value
  71550. * @returns the updated Path2.
  71551. */
  71552. addLineTo(x: number, y: number): Path2;
  71553. /**
  71554. * 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.
  71555. * @param midX middle point x value
  71556. * @param midY middle point y value
  71557. * @param endX end point x value
  71558. * @param endY end point y value
  71559. * @param numberOfSegments (default: 36)
  71560. * @returns the updated Path2.
  71561. */
  71562. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71563. /**
  71564. * Closes the Path2.
  71565. * @returns the Path2.
  71566. */
  71567. close(): Path2;
  71568. /**
  71569. * Gets the sum of the distance between each sequential point in the path
  71570. * @returns the Path2 total length (float).
  71571. */
  71572. length(): number;
  71573. /**
  71574. * Gets the points which construct the path
  71575. * @returns the Path2 internal array of points.
  71576. */
  71577. getPoints(): Vector2[];
  71578. /**
  71579. * Retreives the point at the distance aways from the starting point
  71580. * @param normalizedLengthPosition the length along the path to retreive the point from
  71581. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71582. */
  71583. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71584. /**
  71585. * Creates a new path starting from an x and y position
  71586. * @param x starting x value
  71587. * @param y starting y value
  71588. * @returns a new Path2 starting at the coordinates (x, y).
  71589. */
  71590. static StartingAt(x: number, y: number): Path2;
  71591. }
  71592. /**
  71593. * Represents a 3D path made up of multiple 3D points
  71594. */
  71595. export class Path3D {
  71596. /**
  71597. * an array of Vector3, the curve axis of the Path3D
  71598. */
  71599. path: Vector3[];
  71600. private _curve;
  71601. private _distances;
  71602. private _tangents;
  71603. private _normals;
  71604. private _binormals;
  71605. private _raw;
  71606. /**
  71607. * new Path3D(path, normal, raw)
  71608. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71609. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71610. * @param path an array of Vector3, the curve axis of the Path3D
  71611. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71612. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71613. */
  71614. constructor(
  71615. /**
  71616. * an array of Vector3, the curve axis of the Path3D
  71617. */
  71618. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71619. /**
  71620. * Returns the Path3D array of successive Vector3 designing its curve.
  71621. * @returns the Path3D array of successive Vector3 designing its curve.
  71622. */
  71623. getCurve(): Vector3[];
  71624. /**
  71625. * Returns an array populated with tangent vectors on each Path3D curve point.
  71626. * @returns an array populated with tangent vectors on each Path3D curve point.
  71627. */
  71628. getTangents(): Vector3[];
  71629. /**
  71630. * Returns an array populated with normal vectors on each Path3D curve point.
  71631. * @returns an array populated with normal vectors on each Path3D curve point.
  71632. */
  71633. getNormals(): Vector3[];
  71634. /**
  71635. * Returns an array populated with binormal vectors on each Path3D curve point.
  71636. * @returns an array populated with binormal vectors on each Path3D curve point.
  71637. */
  71638. getBinormals(): Vector3[];
  71639. /**
  71640. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71641. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71642. */
  71643. getDistances(): number[];
  71644. /**
  71645. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71646. * @param path path which all values are copied into the curves points
  71647. * @param firstNormal which should be projected onto the curve
  71648. * @returns the same object updated.
  71649. */
  71650. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71651. private _compute;
  71652. private _getFirstNonNullVector;
  71653. private _getLastNonNullVector;
  71654. private _normalVector;
  71655. }
  71656. /**
  71657. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71658. * A Curve3 is designed from a series of successive Vector3.
  71659. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71660. */
  71661. export class Curve3 {
  71662. private _points;
  71663. private _length;
  71664. /**
  71665. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71666. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71667. * @param v1 (Vector3) the control point
  71668. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71669. * @param nbPoints (integer) the wanted number of points in the curve
  71670. * @returns the created Curve3
  71671. */
  71672. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71673. /**
  71674. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71675. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71676. * @param v1 (Vector3) the first control point
  71677. * @param v2 (Vector3) the second control point
  71678. * @param v3 (Vector3) the end point of the Cubic Bezier
  71679. * @param nbPoints (integer) the wanted number of points in the curve
  71680. * @returns the created Curve3
  71681. */
  71682. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71683. /**
  71684. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71685. * @param p1 (Vector3) the origin point of the Hermite Spline
  71686. * @param t1 (Vector3) the tangent vector at the origin point
  71687. * @param p2 (Vector3) the end point of the Hermite Spline
  71688. * @param t2 (Vector3) the tangent vector at the end point
  71689. * @param nbPoints (integer) the wanted number of points in the curve
  71690. * @returns the created Curve3
  71691. */
  71692. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71693. /**
  71694. * Returns a Curve3 object along a CatmullRom Spline curve :
  71695. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71696. * @param nbPoints (integer) the wanted number of points between each curve control points
  71697. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71698. * @returns the created Curve3
  71699. */
  71700. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71701. /**
  71702. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71703. * A Curve3 is designed from a series of successive Vector3.
  71704. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71705. * @param points points which make up the curve
  71706. */
  71707. constructor(points: Vector3[]);
  71708. /**
  71709. * @returns the Curve3 stored array of successive Vector3
  71710. */
  71711. getPoints(): Vector3[];
  71712. /**
  71713. * @returns the computed length (float) of the curve.
  71714. */
  71715. length(): number;
  71716. /**
  71717. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71718. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71719. * curveA and curveB keep unchanged.
  71720. * @param curve the curve to continue from this curve
  71721. * @returns the newly constructed curve
  71722. */
  71723. continue(curve: DeepImmutable<Curve3>): Curve3;
  71724. private _computeLength;
  71725. }
  71726. }
  71727. declare module BABYLON {
  71728. /**
  71729. * This represents the main contract an easing function should follow.
  71730. * Easing functions are used throughout the animation system.
  71731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71732. */
  71733. export interface IEasingFunction {
  71734. /**
  71735. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71736. * of the easing function.
  71737. * The link below provides some of the most common examples of easing functions.
  71738. * @see https://easings.net/
  71739. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71740. * @returns the corresponding value on the curve defined by the easing function
  71741. */
  71742. ease(gradient: number): number;
  71743. }
  71744. /**
  71745. * Base class used for every default easing function.
  71746. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71747. */
  71748. export class EasingFunction implements IEasingFunction {
  71749. /**
  71750. * Interpolation follows the mathematical formula associated with the easing function.
  71751. */
  71752. static readonly EASINGMODE_EASEIN: number;
  71753. /**
  71754. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71755. */
  71756. static readonly EASINGMODE_EASEOUT: number;
  71757. /**
  71758. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71759. */
  71760. static readonly EASINGMODE_EASEINOUT: number;
  71761. private _easingMode;
  71762. /**
  71763. * Sets the easing mode of the current function.
  71764. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71765. */
  71766. setEasingMode(easingMode: number): void;
  71767. /**
  71768. * Gets the current easing mode.
  71769. * @returns the easing mode
  71770. */
  71771. getEasingMode(): number;
  71772. /**
  71773. * @hidden
  71774. */
  71775. easeInCore(gradient: number): number;
  71776. /**
  71777. * Given an input gradient between 0 and 1, this returns the corresponding value
  71778. * of the easing function.
  71779. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71780. * @returns the corresponding value on the curve defined by the easing function
  71781. */
  71782. ease(gradient: number): number;
  71783. }
  71784. /**
  71785. * Easing function with a circle shape (see link below).
  71786. * @see https://easings.net/#easeInCirc
  71787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71788. */
  71789. export class CircleEase extends EasingFunction implements IEasingFunction {
  71790. /** @hidden */
  71791. easeInCore(gradient: number): number;
  71792. }
  71793. /**
  71794. * Easing function with a ease back shape (see link below).
  71795. * @see https://easings.net/#easeInBack
  71796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71797. */
  71798. export class BackEase extends EasingFunction implements IEasingFunction {
  71799. /** Defines the amplitude of the function */
  71800. amplitude: number;
  71801. /**
  71802. * Instantiates a back ease easing
  71803. * @see https://easings.net/#easeInBack
  71804. * @param amplitude Defines the amplitude of the function
  71805. */
  71806. constructor(
  71807. /** Defines the amplitude of the function */
  71808. amplitude?: number);
  71809. /** @hidden */
  71810. easeInCore(gradient: number): number;
  71811. }
  71812. /**
  71813. * Easing function with a bouncing shape (see link below).
  71814. * @see https://easings.net/#easeInBounce
  71815. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71816. */
  71817. export class BounceEase extends EasingFunction implements IEasingFunction {
  71818. /** Defines the number of bounces */
  71819. bounces: number;
  71820. /** Defines the amplitude of the bounce */
  71821. bounciness: number;
  71822. /**
  71823. * Instantiates a bounce easing
  71824. * @see https://easings.net/#easeInBounce
  71825. * @param bounces Defines the number of bounces
  71826. * @param bounciness Defines the amplitude of the bounce
  71827. */
  71828. constructor(
  71829. /** Defines the number of bounces */
  71830. bounces?: number,
  71831. /** Defines the amplitude of the bounce */
  71832. bounciness?: number);
  71833. /** @hidden */
  71834. easeInCore(gradient: number): number;
  71835. }
  71836. /**
  71837. * Easing function with a power of 3 shape (see link below).
  71838. * @see https://easings.net/#easeInCubic
  71839. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71840. */
  71841. export class CubicEase extends EasingFunction implements IEasingFunction {
  71842. /** @hidden */
  71843. easeInCore(gradient: number): number;
  71844. }
  71845. /**
  71846. * Easing function with an elastic shape (see link below).
  71847. * @see https://easings.net/#easeInElastic
  71848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71849. */
  71850. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71851. /** Defines the number of oscillations*/
  71852. oscillations: number;
  71853. /** Defines the amplitude of the oscillations*/
  71854. springiness: number;
  71855. /**
  71856. * Instantiates an elastic easing function
  71857. * @see https://easings.net/#easeInElastic
  71858. * @param oscillations Defines the number of oscillations
  71859. * @param springiness Defines the amplitude of the oscillations
  71860. */
  71861. constructor(
  71862. /** Defines the number of oscillations*/
  71863. oscillations?: number,
  71864. /** Defines the amplitude of the oscillations*/
  71865. springiness?: number);
  71866. /** @hidden */
  71867. easeInCore(gradient: number): number;
  71868. }
  71869. /**
  71870. * Easing function with an exponential shape (see link below).
  71871. * @see https://easings.net/#easeInExpo
  71872. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71873. */
  71874. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71875. /** Defines the exponent of the function */
  71876. exponent: number;
  71877. /**
  71878. * Instantiates an exponential easing function
  71879. * @see https://easings.net/#easeInExpo
  71880. * @param exponent Defines the exponent of the function
  71881. */
  71882. constructor(
  71883. /** Defines the exponent of the function */
  71884. exponent?: number);
  71885. /** @hidden */
  71886. easeInCore(gradient: number): number;
  71887. }
  71888. /**
  71889. * Easing function with a power shape (see link below).
  71890. * @see https://easings.net/#easeInQuad
  71891. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71892. */
  71893. export class PowerEase extends EasingFunction implements IEasingFunction {
  71894. /** Defines the power of the function */
  71895. power: number;
  71896. /**
  71897. * Instantiates an power base easing function
  71898. * @see https://easings.net/#easeInQuad
  71899. * @param power Defines the power of the function
  71900. */
  71901. constructor(
  71902. /** Defines the power of the function */
  71903. power?: number);
  71904. /** @hidden */
  71905. easeInCore(gradient: number): number;
  71906. }
  71907. /**
  71908. * Easing function with a power of 2 shape (see link below).
  71909. * @see https://easings.net/#easeInQuad
  71910. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71911. */
  71912. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71913. /** @hidden */
  71914. easeInCore(gradient: number): number;
  71915. }
  71916. /**
  71917. * Easing function with a power of 4 shape (see link below).
  71918. * @see https://easings.net/#easeInQuart
  71919. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71920. */
  71921. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71922. /** @hidden */
  71923. easeInCore(gradient: number): number;
  71924. }
  71925. /**
  71926. * Easing function with a power of 5 shape (see link below).
  71927. * @see https://easings.net/#easeInQuint
  71928. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71929. */
  71930. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71931. /** @hidden */
  71932. easeInCore(gradient: number): number;
  71933. }
  71934. /**
  71935. * Easing function with a sin shape (see link below).
  71936. * @see https://easings.net/#easeInSine
  71937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71938. */
  71939. export class SineEase extends EasingFunction implements IEasingFunction {
  71940. /** @hidden */
  71941. easeInCore(gradient: number): number;
  71942. }
  71943. /**
  71944. * Easing function with a bezier shape (see link below).
  71945. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71947. */
  71948. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71949. /** Defines the x component of the start tangent in the bezier curve */
  71950. x1: number;
  71951. /** Defines the y component of the start tangent in the bezier curve */
  71952. y1: number;
  71953. /** Defines the x component of the end tangent in the bezier curve */
  71954. x2: number;
  71955. /** Defines the y component of the end tangent in the bezier curve */
  71956. y2: number;
  71957. /**
  71958. * Instantiates a bezier function
  71959. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71960. * @param x1 Defines the x component of the start tangent in the bezier curve
  71961. * @param y1 Defines the y component of the start tangent in the bezier curve
  71962. * @param x2 Defines the x component of the end tangent in the bezier curve
  71963. * @param y2 Defines the y component of the end tangent in the bezier curve
  71964. */
  71965. constructor(
  71966. /** Defines the x component of the start tangent in the bezier curve */
  71967. x1?: number,
  71968. /** Defines the y component of the start tangent in the bezier curve */
  71969. y1?: number,
  71970. /** Defines the x component of the end tangent in the bezier curve */
  71971. x2?: number,
  71972. /** Defines the y component of the end tangent in the bezier curve */
  71973. y2?: number);
  71974. /** @hidden */
  71975. easeInCore(gradient: number): number;
  71976. }
  71977. }
  71978. declare module BABYLON {
  71979. /**
  71980. * Defines an interface which represents an animation key frame
  71981. */
  71982. export interface IAnimationKey {
  71983. /**
  71984. * Frame of the key frame
  71985. */
  71986. frame: number;
  71987. /**
  71988. * Value at the specifies key frame
  71989. */
  71990. value: any;
  71991. /**
  71992. * The input tangent for the cubic hermite spline
  71993. */
  71994. inTangent?: any;
  71995. /**
  71996. * The output tangent for the cubic hermite spline
  71997. */
  71998. outTangent?: any;
  71999. /**
  72000. * The animation interpolation type
  72001. */
  72002. interpolation?: AnimationKeyInterpolation;
  72003. }
  72004. /**
  72005. * Enum for the animation key frame interpolation type
  72006. */
  72007. export enum AnimationKeyInterpolation {
  72008. /**
  72009. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72010. */
  72011. STEP = 1
  72012. }
  72013. }
  72014. declare module BABYLON {
  72015. /**
  72016. * Represents the range of an animation
  72017. */
  72018. export class AnimationRange {
  72019. /**The name of the animation range**/
  72020. name: string;
  72021. /**The starting frame of the animation */
  72022. from: number;
  72023. /**The ending frame of the animation*/
  72024. to: number;
  72025. /**
  72026. * Initializes the range of an animation
  72027. * @param name The name of the animation range
  72028. * @param from The starting frame of the animation
  72029. * @param to The ending frame of the animation
  72030. */
  72031. constructor(
  72032. /**The name of the animation range**/
  72033. name: string,
  72034. /**The starting frame of the animation */
  72035. from: number,
  72036. /**The ending frame of the animation*/
  72037. to: number);
  72038. /**
  72039. * Makes a copy of the animation range
  72040. * @returns A copy of the animation range
  72041. */
  72042. clone(): AnimationRange;
  72043. }
  72044. }
  72045. declare module BABYLON {
  72046. /**
  72047. * Composed of a frame, and an action function
  72048. */
  72049. export class AnimationEvent {
  72050. /** The frame for which the event is triggered **/
  72051. frame: number;
  72052. /** The event to perform when triggered **/
  72053. action: (currentFrame: number) => void;
  72054. /** Specifies if the event should be triggered only once**/
  72055. onlyOnce?: boolean | undefined;
  72056. /**
  72057. * Specifies if the animation event is done
  72058. */
  72059. isDone: boolean;
  72060. /**
  72061. * Initializes the animation event
  72062. * @param frame The frame for which the event is triggered
  72063. * @param action The event to perform when triggered
  72064. * @param onlyOnce Specifies if the event should be triggered only once
  72065. */
  72066. constructor(
  72067. /** The frame for which the event is triggered **/
  72068. frame: number,
  72069. /** The event to perform when triggered **/
  72070. action: (currentFrame: number) => void,
  72071. /** Specifies if the event should be triggered only once**/
  72072. onlyOnce?: boolean | undefined);
  72073. /** @hidden */
  72074. _clone(): AnimationEvent;
  72075. }
  72076. }
  72077. declare module BABYLON {
  72078. /**
  72079. * Interface used to define a behavior
  72080. */
  72081. export interface Behavior<T> {
  72082. /** gets or sets behavior's name */
  72083. name: string;
  72084. /**
  72085. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72086. */
  72087. init(): void;
  72088. /**
  72089. * Called when the behavior is attached to a target
  72090. * @param target defines the target where the behavior is attached to
  72091. */
  72092. attach(target: T): void;
  72093. /**
  72094. * Called when the behavior is detached from its target
  72095. */
  72096. detach(): void;
  72097. }
  72098. /**
  72099. * Interface implemented by classes supporting behaviors
  72100. */
  72101. export interface IBehaviorAware<T> {
  72102. /**
  72103. * Attach a behavior
  72104. * @param behavior defines the behavior to attach
  72105. * @returns the current host
  72106. */
  72107. addBehavior(behavior: Behavior<T>): T;
  72108. /**
  72109. * Remove a behavior from the current object
  72110. * @param behavior defines the behavior to detach
  72111. * @returns the current host
  72112. */
  72113. removeBehavior(behavior: Behavior<T>): T;
  72114. /**
  72115. * Gets a behavior using its name to search
  72116. * @param name defines the name to search
  72117. * @returns the behavior or null if not found
  72118. */
  72119. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72120. }
  72121. }
  72122. declare module BABYLON {
  72123. /**
  72124. * Defines an array and its length.
  72125. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72126. */
  72127. export interface ISmartArrayLike<T> {
  72128. /**
  72129. * The data of the array.
  72130. */
  72131. data: Array<T>;
  72132. /**
  72133. * The active length of the array.
  72134. */
  72135. length: number;
  72136. }
  72137. /**
  72138. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72139. */
  72140. export class SmartArray<T> implements ISmartArrayLike<T> {
  72141. /**
  72142. * The full set of data from the array.
  72143. */
  72144. data: Array<T>;
  72145. /**
  72146. * The active length of the array.
  72147. */
  72148. length: number;
  72149. protected _id: number;
  72150. /**
  72151. * Instantiates a Smart Array.
  72152. * @param capacity defines the default capacity of the array.
  72153. */
  72154. constructor(capacity: number);
  72155. /**
  72156. * Pushes a value at the end of the active data.
  72157. * @param value defines the object to push in the array.
  72158. */
  72159. push(value: T): void;
  72160. /**
  72161. * Iterates over the active data and apply the lambda to them.
  72162. * @param func defines the action to apply on each value.
  72163. */
  72164. forEach(func: (content: T) => void): void;
  72165. /**
  72166. * Sorts the full sets of data.
  72167. * @param compareFn defines the comparison function to apply.
  72168. */
  72169. sort(compareFn: (a: T, b: T) => number): void;
  72170. /**
  72171. * Resets the active data to an empty array.
  72172. */
  72173. reset(): void;
  72174. /**
  72175. * Releases all the data from the array as well as the array.
  72176. */
  72177. dispose(): void;
  72178. /**
  72179. * Concats the active data with a given array.
  72180. * @param array defines the data to concatenate with.
  72181. */
  72182. concat(array: any): void;
  72183. /**
  72184. * Returns the position of a value in the active data.
  72185. * @param value defines the value to find the index for
  72186. * @returns the index if found in the active data otherwise -1
  72187. */
  72188. indexOf(value: T): number;
  72189. /**
  72190. * Returns whether an element is part of the active data.
  72191. * @param value defines the value to look for
  72192. * @returns true if found in the active data otherwise false
  72193. */
  72194. contains(value: T): boolean;
  72195. private static _GlobalId;
  72196. }
  72197. /**
  72198. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72199. * The data in this array can only be present once
  72200. */
  72201. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72202. private _duplicateId;
  72203. /**
  72204. * Pushes a value at the end of the active data.
  72205. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72206. * @param value defines the object to push in the array.
  72207. */
  72208. push(value: T): void;
  72209. /**
  72210. * Pushes a value at the end of the active data.
  72211. * If the data is already present, it won t be added again
  72212. * @param value defines the object to push in the array.
  72213. * @returns true if added false if it was already present
  72214. */
  72215. pushNoDuplicate(value: T): boolean;
  72216. /**
  72217. * Resets the active data to an empty array.
  72218. */
  72219. reset(): void;
  72220. /**
  72221. * Concats the active data with a given array.
  72222. * This ensures no dupplicate will be present in the result.
  72223. * @param array defines the data to concatenate with.
  72224. */
  72225. concatWithNoDuplicate(array: any): void;
  72226. }
  72227. }
  72228. declare module BABYLON {
  72229. /**
  72230. * @ignore
  72231. * This is a list of all the different input types that are available in the application.
  72232. * Fo instance: ArcRotateCameraGamepadInput...
  72233. */
  72234. export var CameraInputTypes: {};
  72235. /**
  72236. * This is the contract to implement in order to create a new input class.
  72237. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72238. */
  72239. export interface ICameraInput<TCamera extends Camera> {
  72240. /**
  72241. * Defines the camera the input is attached to.
  72242. */
  72243. camera: Nullable<TCamera>;
  72244. /**
  72245. * Gets the class name of the current intput.
  72246. * @returns the class name
  72247. */
  72248. getClassName(): string;
  72249. /**
  72250. * Get the friendly name associated with the input class.
  72251. * @returns the input friendly name
  72252. */
  72253. getSimpleName(): string;
  72254. /**
  72255. * Attach the input controls to a specific dom element to get the input from.
  72256. * @param element Defines the element the controls should be listened from
  72257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72258. */
  72259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72260. /**
  72261. * Detach the current controls from the specified dom element.
  72262. * @param element Defines the element to stop listening the inputs from
  72263. */
  72264. detachControl(element: Nullable<HTMLElement>): void;
  72265. /**
  72266. * Update the current camera state depending on the inputs that have been used this frame.
  72267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72268. */
  72269. checkInputs?: () => void;
  72270. }
  72271. /**
  72272. * Represents a map of input types to input instance or input index to input instance.
  72273. */
  72274. export interface CameraInputsMap<TCamera extends Camera> {
  72275. /**
  72276. * Accessor to the input by input type.
  72277. */
  72278. [name: string]: ICameraInput<TCamera>;
  72279. /**
  72280. * Accessor to the input by input index.
  72281. */
  72282. [idx: number]: ICameraInput<TCamera>;
  72283. }
  72284. /**
  72285. * This represents the input manager used within a camera.
  72286. * It helps dealing with all the different kind of input attached to a camera.
  72287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72288. */
  72289. export class CameraInputsManager<TCamera extends Camera> {
  72290. /**
  72291. * Defines the list of inputs attahed to the camera.
  72292. */
  72293. attached: CameraInputsMap<TCamera>;
  72294. /**
  72295. * Defines the dom element the camera is collecting inputs from.
  72296. * This is null if the controls have not been attached.
  72297. */
  72298. attachedElement: Nullable<HTMLElement>;
  72299. /**
  72300. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72301. */
  72302. noPreventDefault: boolean;
  72303. /**
  72304. * Defined the camera the input manager belongs to.
  72305. */
  72306. camera: TCamera;
  72307. /**
  72308. * Update the current camera state depending on the inputs that have been used this frame.
  72309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72310. */
  72311. checkInputs: () => void;
  72312. /**
  72313. * Instantiate a new Camera Input Manager.
  72314. * @param camera Defines the camera the input manager blongs to
  72315. */
  72316. constructor(camera: TCamera);
  72317. /**
  72318. * Add an input method to a camera
  72319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72320. * @param input camera input method
  72321. */
  72322. add(input: ICameraInput<TCamera>): void;
  72323. /**
  72324. * Remove a specific input method from a camera
  72325. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72326. * @param inputToRemove camera input method
  72327. */
  72328. remove(inputToRemove: ICameraInput<TCamera>): void;
  72329. /**
  72330. * Remove a specific input type from a camera
  72331. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72332. * @param inputType the type of the input to remove
  72333. */
  72334. removeByType(inputType: string): void;
  72335. private _addCheckInputs;
  72336. /**
  72337. * Attach the input controls to the currently attached dom element to listen the events from.
  72338. * @param input Defines the input to attach
  72339. */
  72340. attachInput(input: ICameraInput<TCamera>): void;
  72341. /**
  72342. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72343. * @param element Defines the dom element to collect the events from
  72344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72345. */
  72346. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72347. /**
  72348. * Detach the current manager inputs controls from a specific dom element.
  72349. * @param element Defines the dom element to collect the events from
  72350. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72351. */
  72352. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72353. /**
  72354. * Rebuild the dynamic inputCheck function from the current list of
  72355. * defined inputs in the manager.
  72356. */
  72357. rebuildInputCheck(): void;
  72358. /**
  72359. * Remove all attached input methods from a camera
  72360. */
  72361. clear(): void;
  72362. /**
  72363. * Serialize the current input manager attached to a camera.
  72364. * This ensures than once parsed,
  72365. * the input associated to the camera will be identical to the current ones
  72366. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72367. */
  72368. serialize(serializedCamera: any): void;
  72369. /**
  72370. * Parses an input manager serialized JSON to restore the previous list of inputs
  72371. * and states associated to a camera.
  72372. * @param parsedCamera Defines the JSON to parse
  72373. */
  72374. parse(parsedCamera: any): void;
  72375. }
  72376. }
  72377. declare module BABYLON {
  72378. /**
  72379. * Class used to store data that will be store in GPU memory
  72380. */
  72381. export class Buffer {
  72382. private _engine;
  72383. private _buffer;
  72384. /** @hidden */
  72385. _data: Nullable<DataArray>;
  72386. private _updatable;
  72387. private _instanced;
  72388. /**
  72389. * Gets the byte stride.
  72390. */
  72391. readonly byteStride: number;
  72392. /**
  72393. * Constructor
  72394. * @param engine the engine
  72395. * @param data the data to use for this buffer
  72396. * @param updatable whether the data is updatable
  72397. * @param stride the stride (optional)
  72398. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72399. * @param instanced whether the buffer is instanced (optional)
  72400. * @param useBytes set to true if the stride in in bytes (optional)
  72401. */
  72402. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72403. /**
  72404. * Create a new VertexBuffer based on the current buffer
  72405. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72406. * @param offset defines offset in the buffer (0 by default)
  72407. * @param size defines the size in floats of attributes (position is 3 for instance)
  72408. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72409. * @param instanced defines if the vertex buffer contains indexed data
  72410. * @param useBytes defines if the offset and stride are in bytes
  72411. * @returns the new vertex buffer
  72412. */
  72413. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72414. /**
  72415. * Gets a boolean indicating if the Buffer is updatable?
  72416. * @returns true if the buffer is updatable
  72417. */
  72418. isUpdatable(): boolean;
  72419. /**
  72420. * Gets current buffer's data
  72421. * @returns a DataArray or null
  72422. */
  72423. getData(): Nullable<DataArray>;
  72424. /**
  72425. * Gets underlying native buffer
  72426. * @returns underlying native buffer
  72427. */
  72428. getBuffer(): Nullable<DataBuffer>;
  72429. /**
  72430. * Gets the stride in float32 units (i.e. byte stride / 4).
  72431. * May not be an integer if the byte stride is not divisible by 4.
  72432. * DEPRECATED. Use byteStride instead.
  72433. * @returns the stride in float32 units
  72434. */
  72435. getStrideSize(): number;
  72436. /**
  72437. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72438. * @param data defines the data to store
  72439. */
  72440. create(data?: Nullable<DataArray>): void;
  72441. /** @hidden */
  72442. _rebuild(): void;
  72443. /**
  72444. * Update current buffer data
  72445. * @param data defines the data to store
  72446. */
  72447. update(data: DataArray): void;
  72448. /**
  72449. * Updates the data directly.
  72450. * @param data the new data
  72451. * @param offset the new offset
  72452. * @param vertexCount the vertex count (optional)
  72453. * @param useBytes set to true if the offset is in bytes
  72454. */
  72455. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72456. /**
  72457. * Release all resources
  72458. */
  72459. dispose(): void;
  72460. }
  72461. /**
  72462. * Specialized buffer used to store vertex data
  72463. */
  72464. export class VertexBuffer {
  72465. /** @hidden */
  72466. _buffer: Buffer;
  72467. private _kind;
  72468. private _size;
  72469. private _ownsBuffer;
  72470. private _instanced;
  72471. private _instanceDivisor;
  72472. /**
  72473. * The byte type.
  72474. */
  72475. static readonly BYTE: number;
  72476. /**
  72477. * The unsigned byte type.
  72478. */
  72479. static readonly UNSIGNED_BYTE: number;
  72480. /**
  72481. * The short type.
  72482. */
  72483. static readonly SHORT: number;
  72484. /**
  72485. * The unsigned short type.
  72486. */
  72487. static readonly UNSIGNED_SHORT: number;
  72488. /**
  72489. * The integer type.
  72490. */
  72491. static readonly INT: number;
  72492. /**
  72493. * The unsigned integer type.
  72494. */
  72495. static readonly UNSIGNED_INT: number;
  72496. /**
  72497. * The float type.
  72498. */
  72499. static readonly FLOAT: number;
  72500. /**
  72501. * Gets or sets the instance divisor when in instanced mode
  72502. */
  72503. instanceDivisor: number;
  72504. /**
  72505. * Gets the byte stride.
  72506. */
  72507. readonly byteStride: number;
  72508. /**
  72509. * Gets the byte offset.
  72510. */
  72511. readonly byteOffset: number;
  72512. /**
  72513. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  72514. */
  72515. readonly normalized: boolean;
  72516. /**
  72517. * Gets the data type of each component in the array.
  72518. */
  72519. readonly type: number;
  72520. /**
  72521. * Constructor
  72522. * @param engine the engine
  72523. * @param data the data to use for this vertex buffer
  72524. * @param kind the vertex buffer kind
  72525. * @param updatable whether the data is updatable
  72526. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72527. * @param stride the stride (optional)
  72528. * @param instanced whether the buffer is instanced (optional)
  72529. * @param offset the offset of the data (optional)
  72530. * @param size the number of components (optional)
  72531. * @param type the type of the component (optional)
  72532. * @param normalized whether the data contains normalized data (optional)
  72533. * @param useBytes set to true if stride and offset are in bytes (optional)
  72534. */
  72535. 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);
  72536. /** @hidden */
  72537. _rebuild(): void;
  72538. /**
  72539. * Returns the kind of the VertexBuffer (string)
  72540. * @returns a string
  72541. */
  72542. getKind(): string;
  72543. /**
  72544. * Gets a boolean indicating if the VertexBuffer is updatable?
  72545. * @returns true if the buffer is updatable
  72546. */
  72547. isUpdatable(): boolean;
  72548. /**
  72549. * Gets current buffer's data
  72550. * @returns a DataArray or null
  72551. */
  72552. getData(): Nullable<DataArray>;
  72553. /**
  72554. * Gets underlying native buffer
  72555. * @returns underlying native buffer
  72556. */
  72557. getBuffer(): Nullable<DataBuffer>;
  72558. /**
  72559. * Gets the stride in float32 units (i.e. byte stride / 4).
  72560. * May not be an integer if the byte stride is not divisible by 4.
  72561. * DEPRECATED. Use byteStride instead.
  72562. * @returns the stride in float32 units
  72563. */
  72564. getStrideSize(): number;
  72565. /**
  72566. * Returns the offset as a multiple of the type byte length.
  72567. * DEPRECATED. Use byteOffset instead.
  72568. * @returns the offset in bytes
  72569. */
  72570. getOffset(): number;
  72571. /**
  72572. * Returns the number of components per vertex attribute (integer)
  72573. * @returns the size in float
  72574. */
  72575. getSize(): number;
  72576. /**
  72577. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  72578. * @returns true if this buffer is instanced
  72579. */
  72580. getIsInstanced(): boolean;
  72581. /**
  72582. * Returns the instancing divisor, zero for non-instanced (integer).
  72583. * @returns a number
  72584. */
  72585. getInstanceDivisor(): number;
  72586. /**
  72587. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72588. * @param data defines the data to store
  72589. */
  72590. create(data?: DataArray): void;
  72591. /**
  72592. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  72593. * This function will create a new buffer if the current one is not updatable
  72594. * @param data defines the data to store
  72595. */
  72596. update(data: DataArray): void;
  72597. /**
  72598. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  72599. * Returns the directly updated WebGLBuffer.
  72600. * @param data the new data
  72601. * @param offset the new offset
  72602. * @param useBytes set to true if the offset is in bytes
  72603. */
  72604. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  72605. /**
  72606. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  72607. */
  72608. dispose(): void;
  72609. /**
  72610. * Enumerates each value of this vertex buffer as numbers.
  72611. * @param count the number of values to enumerate
  72612. * @param callback the callback function called for each value
  72613. */
  72614. forEach(count: number, callback: (value: number, index: number) => void): void;
  72615. /**
  72616. * Positions
  72617. */
  72618. static readonly PositionKind: string;
  72619. /**
  72620. * Normals
  72621. */
  72622. static readonly NormalKind: string;
  72623. /**
  72624. * Tangents
  72625. */
  72626. static readonly TangentKind: string;
  72627. /**
  72628. * Texture coordinates
  72629. */
  72630. static readonly UVKind: string;
  72631. /**
  72632. * Texture coordinates 2
  72633. */
  72634. static readonly UV2Kind: string;
  72635. /**
  72636. * Texture coordinates 3
  72637. */
  72638. static readonly UV3Kind: string;
  72639. /**
  72640. * Texture coordinates 4
  72641. */
  72642. static readonly UV4Kind: string;
  72643. /**
  72644. * Texture coordinates 5
  72645. */
  72646. static readonly UV5Kind: string;
  72647. /**
  72648. * Texture coordinates 6
  72649. */
  72650. static readonly UV6Kind: string;
  72651. /**
  72652. * Colors
  72653. */
  72654. static readonly ColorKind: string;
  72655. /**
  72656. * Matrix indices (for bones)
  72657. */
  72658. static readonly MatricesIndicesKind: string;
  72659. /**
  72660. * Matrix weights (for bones)
  72661. */
  72662. static readonly MatricesWeightsKind: string;
  72663. /**
  72664. * Additional matrix indices (for bones)
  72665. */
  72666. static readonly MatricesIndicesExtraKind: string;
  72667. /**
  72668. * Additional matrix weights (for bones)
  72669. */
  72670. static readonly MatricesWeightsExtraKind: string;
  72671. /**
  72672. * Deduces the stride given a kind.
  72673. * @param kind The kind string to deduce
  72674. * @returns The deduced stride
  72675. */
  72676. static DeduceStride(kind: string): number;
  72677. /**
  72678. * Gets the byte length of the given type.
  72679. * @param type the type
  72680. * @returns the number of bytes
  72681. */
  72682. static GetTypeByteLength(type: number): number;
  72683. /**
  72684. * Enumerates each value of the given parameters as numbers.
  72685. * @param data the data to enumerate
  72686. * @param byteOffset the byte offset of the data
  72687. * @param byteStride the byte stride of the data
  72688. * @param componentCount the number of components per element
  72689. * @param componentType the type of the component
  72690. * @param count the number of values to enumerate
  72691. * @param normalized whether the data is normalized
  72692. * @param callback the callback function called for each value
  72693. */
  72694. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  72695. private static _GetFloatValue;
  72696. }
  72697. }
  72698. declare module BABYLON {
  72699. /**
  72700. * @hidden
  72701. */
  72702. export class IntersectionInfo {
  72703. bu: Nullable<number>;
  72704. bv: Nullable<number>;
  72705. distance: number;
  72706. faceId: number;
  72707. subMeshId: number;
  72708. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72709. }
  72710. }
  72711. declare module BABYLON {
  72712. /**
  72713. * Represens a plane by the equation ax + by + cz + d = 0
  72714. */
  72715. export class Plane {
  72716. private static _TmpMatrix;
  72717. /**
  72718. * Normal of the plane (a,b,c)
  72719. */
  72720. normal: Vector3;
  72721. /**
  72722. * d component of the plane
  72723. */
  72724. d: number;
  72725. /**
  72726. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72727. * @param a a component of the plane
  72728. * @param b b component of the plane
  72729. * @param c c component of the plane
  72730. * @param d d component of the plane
  72731. */
  72732. constructor(a: number, b: number, c: number, d: number);
  72733. /**
  72734. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72735. */
  72736. asArray(): number[];
  72737. /**
  72738. * @returns a new plane copied from the current Plane.
  72739. */
  72740. clone(): Plane;
  72741. /**
  72742. * @returns the string "Plane".
  72743. */
  72744. getClassName(): string;
  72745. /**
  72746. * @returns the Plane hash code.
  72747. */
  72748. getHashCode(): number;
  72749. /**
  72750. * Normalize the current Plane in place.
  72751. * @returns the updated Plane.
  72752. */
  72753. normalize(): Plane;
  72754. /**
  72755. * Applies a transformation the plane and returns the result
  72756. * @param transformation the transformation matrix to be applied to the plane
  72757. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72758. */
  72759. transform(transformation: DeepImmutable<Matrix>): Plane;
  72760. /**
  72761. * Calcualtte the dot product between the point and the plane normal
  72762. * @param point point to calculate the dot product with
  72763. * @returns the dot product (float) of the point coordinates and the plane normal.
  72764. */
  72765. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72766. /**
  72767. * Updates the current Plane from the plane defined by the three given points.
  72768. * @param point1 one of the points used to contruct the plane
  72769. * @param point2 one of the points used to contruct the plane
  72770. * @param point3 one of the points used to contruct the plane
  72771. * @returns the updated Plane.
  72772. */
  72773. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72774. /**
  72775. * Checks if the plane is facing a given direction
  72776. * @param direction the direction to check if the plane is facing
  72777. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72778. * @returns True is the vector "direction" is the same side than the plane normal.
  72779. */
  72780. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72781. /**
  72782. * Calculates the distance to a point
  72783. * @param point point to calculate distance to
  72784. * @returns the signed distance (float) from the given point to the Plane.
  72785. */
  72786. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72787. /**
  72788. * Creates a plane from an array
  72789. * @param array the array to create a plane from
  72790. * @returns a new Plane from the given array.
  72791. */
  72792. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72793. /**
  72794. * Creates a plane from three points
  72795. * @param point1 point used to create the plane
  72796. * @param point2 point used to create the plane
  72797. * @param point3 point used to create the plane
  72798. * @returns a new Plane defined by the three given points.
  72799. */
  72800. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72801. /**
  72802. * Creates a plane from an origin point and a normal
  72803. * @param origin origin of the plane to be constructed
  72804. * @param normal normal of the plane to be constructed
  72805. * @returns a new Plane the normal vector to this plane at the given origin point.
  72806. * Note : the vector "normal" is updated because normalized.
  72807. */
  72808. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72809. /**
  72810. * Calculates the distance from a plane and a point
  72811. * @param origin origin of the plane to be constructed
  72812. * @param normal normal of the plane to be constructed
  72813. * @param point point to calculate distance to
  72814. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72815. */
  72816. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72817. }
  72818. }
  72819. declare module BABYLON {
  72820. /**
  72821. * Class used to store bounding sphere information
  72822. */
  72823. export class BoundingSphere {
  72824. /**
  72825. * Gets the center of the bounding sphere in local space
  72826. */
  72827. readonly center: Vector3;
  72828. /**
  72829. * Radius of the bounding sphere in local space
  72830. */
  72831. radius: number;
  72832. /**
  72833. * Gets the center of the bounding sphere in world space
  72834. */
  72835. readonly centerWorld: Vector3;
  72836. /**
  72837. * Radius of the bounding sphere in world space
  72838. */
  72839. radiusWorld: number;
  72840. /**
  72841. * Gets the minimum vector in local space
  72842. */
  72843. readonly minimum: Vector3;
  72844. /**
  72845. * Gets the maximum vector in local space
  72846. */
  72847. readonly maximum: Vector3;
  72848. private _worldMatrix;
  72849. private static readonly TmpVector3;
  72850. /**
  72851. * Creates a new bounding sphere
  72852. * @param min defines the minimum vector (in local space)
  72853. * @param max defines the maximum vector (in local space)
  72854. * @param worldMatrix defines the new world matrix
  72855. */
  72856. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72857. /**
  72858. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72859. * @param min defines the new minimum vector (in local space)
  72860. * @param max defines the new maximum vector (in local space)
  72861. * @param worldMatrix defines the new world matrix
  72862. */
  72863. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72864. /**
  72865. * Scale the current bounding sphere by applying a scale factor
  72866. * @param factor defines the scale factor to apply
  72867. * @returns the current bounding box
  72868. */
  72869. scale(factor: number): BoundingSphere;
  72870. /**
  72871. * Gets the world matrix of the bounding box
  72872. * @returns a matrix
  72873. */
  72874. getWorldMatrix(): DeepImmutable<Matrix>;
  72875. /** @hidden */
  72876. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72877. /**
  72878. * Tests if the bounding sphere is intersecting the frustum planes
  72879. * @param frustumPlanes defines the frustum planes to test
  72880. * @returns true if there is an intersection
  72881. */
  72882. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72883. /**
  72884. * Tests if the bounding sphere center is in between the frustum planes.
  72885. * Used for optimistic fast inclusion.
  72886. * @param frustumPlanes defines the frustum planes to test
  72887. * @returns true if the sphere center is in between the frustum planes
  72888. */
  72889. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72890. /**
  72891. * Tests if a point is inside the bounding sphere
  72892. * @param point defines the point to test
  72893. * @returns true if the point is inside the bounding sphere
  72894. */
  72895. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72896. /**
  72897. * Checks if two sphere intersct
  72898. * @param sphere0 sphere 0
  72899. * @param sphere1 sphere 1
  72900. * @returns true if the speres intersect
  72901. */
  72902. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72903. }
  72904. }
  72905. declare module BABYLON {
  72906. /**
  72907. * Class used to store bounding box information
  72908. */
  72909. export class BoundingBox implements ICullable {
  72910. /**
  72911. * Gets the 8 vectors representing the bounding box in local space
  72912. */
  72913. readonly vectors: Vector3[];
  72914. /**
  72915. * Gets the center of the bounding box in local space
  72916. */
  72917. readonly center: Vector3;
  72918. /**
  72919. * Gets the center of the bounding box in world space
  72920. */
  72921. readonly centerWorld: Vector3;
  72922. /**
  72923. * Gets the extend size in local space
  72924. */
  72925. readonly extendSize: Vector3;
  72926. /**
  72927. * Gets the extend size in world space
  72928. */
  72929. readonly extendSizeWorld: Vector3;
  72930. /**
  72931. * Gets the OBB (object bounding box) directions
  72932. */
  72933. readonly directions: Vector3[];
  72934. /**
  72935. * Gets the 8 vectors representing the bounding box in world space
  72936. */
  72937. readonly vectorsWorld: Vector3[];
  72938. /**
  72939. * Gets the minimum vector in world space
  72940. */
  72941. readonly minimumWorld: Vector3;
  72942. /**
  72943. * Gets the maximum vector in world space
  72944. */
  72945. readonly maximumWorld: Vector3;
  72946. /**
  72947. * Gets the minimum vector in local space
  72948. */
  72949. readonly minimum: Vector3;
  72950. /**
  72951. * Gets the maximum vector in local space
  72952. */
  72953. readonly maximum: Vector3;
  72954. private _worldMatrix;
  72955. private static readonly TmpVector3;
  72956. /**
  72957. * @hidden
  72958. */
  72959. _tag: number;
  72960. /**
  72961. * Creates a new bounding box
  72962. * @param min defines the minimum vector (in local space)
  72963. * @param max defines the maximum vector (in local space)
  72964. * @param worldMatrix defines the new world matrix
  72965. */
  72966. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72967. /**
  72968. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72969. * @param min defines the new minimum vector (in local space)
  72970. * @param max defines the new maximum vector (in local space)
  72971. * @param worldMatrix defines the new world matrix
  72972. */
  72973. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72974. /**
  72975. * Scale the current bounding box by applying a scale factor
  72976. * @param factor defines the scale factor to apply
  72977. * @returns the current bounding box
  72978. */
  72979. scale(factor: number): BoundingBox;
  72980. /**
  72981. * Gets the world matrix of the bounding box
  72982. * @returns a matrix
  72983. */
  72984. getWorldMatrix(): DeepImmutable<Matrix>;
  72985. /** @hidden */
  72986. _update(world: DeepImmutable<Matrix>): void;
  72987. /**
  72988. * Tests if the bounding box is intersecting the frustum planes
  72989. * @param frustumPlanes defines the frustum planes to test
  72990. * @returns true if there is an intersection
  72991. */
  72992. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72993. /**
  72994. * Tests if the bounding box is entirely inside the frustum planes
  72995. * @param frustumPlanes defines the frustum planes to test
  72996. * @returns true if there is an inclusion
  72997. */
  72998. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72999. /**
  73000. * Tests if a point is inside the bounding box
  73001. * @param point defines the point to test
  73002. * @returns true if the point is inside the bounding box
  73003. */
  73004. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73005. /**
  73006. * Tests if the bounding box intersects with a bounding sphere
  73007. * @param sphere defines the sphere to test
  73008. * @returns true if there is an intersection
  73009. */
  73010. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73011. /**
  73012. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73013. * @param min defines the min vector to use
  73014. * @param max defines the max vector to use
  73015. * @returns true if there is an intersection
  73016. */
  73017. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73018. /**
  73019. * Tests if two bounding boxes are intersections
  73020. * @param box0 defines the first box to test
  73021. * @param box1 defines the second box to test
  73022. * @returns true if there is an intersection
  73023. */
  73024. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73025. /**
  73026. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73027. * @param minPoint defines the minimum vector of the bounding box
  73028. * @param maxPoint defines the maximum vector of the bounding box
  73029. * @param sphereCenter defines the sphere center
  73030. * @param sphereRadius defines the sphere radius
  73031. * @returns true if there is an intersection
  73032. */
  73033. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73034. /**
  73035. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73036. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73037. * @param frustumPlanes defines the frustum planes to test
  73038. * @return true if there is an inclusion
  73039. */
  73040. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73041. /**
  73042. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73043. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73044. * @param frustumPlanes defines the frustum planes to test
  73045. * @return true if there is an intersection
  73046. */
  73047. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73048. }
  73049. }
  73050. declare module BABYLON {
  73051. /** @hidden */
  73052. export class Collider {
  73053. /** Define if a collision was found */
  73054. collisionFound: boolean;
  73055. /**
  73056. * Define last intersection point in local space
  73057. */
  73058. intersectionPoint: Vector3;
  73059. /**
  73060. * Define last collided mesh
  73061. */
  73062. collidedMesh: Nullable<AbstractMesh>;
  73063. private _collisionPoint;
  73064. private _planeIntersectionPoint;
  73065. private _tempVector;
  73066. private _tempVector2;
  73067. private _tempVector3;
  73068. private _tempVector4;
  73069. private _edge;
  73070. private _baseToVertex;
  73071. private _destinationPoint;
  73072. private _slidePlaneNormal;
  73073. private _displacementVector;
  73074. /** @hidden */
  73075. _radius: Vector3;
  73076. /** @hidden */
  73077. _retry: number;
  73078. private _velocity;
  73079. private _basePoint;
  73080. private _epsilon;
  73081. /** @hidden */
  73082. _velocityWorldLength: number;
  73083. /** @hidden */
  73084. _basePointWorld: Vector3;
  73085. private _velocityWorld;
  73086. private _normalizedVelocity;
  73087. /** @hidden */
  73088. _initialVelocity: Vector3;
  73089. /** @hidden */
  73090. _initialPosition: Vector3;
  73091. private _nearestDistance;
  73092. private _collisionMask;
  73093. collisionMask: number;
  73094. /**
  73095. * Gets the plane normal used to compute the sliding response (in local space)
  73096. */
  73097. readonly slidePlaneNormal: Vector3;
  73098. /** @hidden */
  73099. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73100. /** @hidden */
  73101. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73102. /** @hidden */
  73103. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73104. /** @hidden */
  73105. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73106. /** @hidden */
  73107. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73108. /** @hidden */
  73109. _getResponse(pos: Vector3, vel: Vector3): void;
  73110. }
  73111. }
  73112. declare module BABYLON {
  73113. /**
  73114. * Interface for cullable objects
  73115. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73116. */
  73117. export interface ICullable {
  73118. /**
  73119. * Checks if the object or part of the object is in the frustum
  73120. * @param frustumPlanes Camera near/planes
  73121. * @returns true if the object is in frustum otherwise false
  73122. */
  73123. isInFrustum(frustumPlanes: Plane[]): boolean;
  73124. /**
  73125. * Checks if a cullable object (mesh...) is in the camera frustum
  73126. * Unlike isInFrustum this cheks the full bounding box
  73127. * @param frustumPlanes Camera near/planes
  73128. * @returns true if the object is in frustum otherwise false
  73129. */
  73130. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73131. }
  73132. /**
  73133. * Info for a bounding data of a mesh
  73134. */
  73135. export class BoundingInfo implements ICullable {
  73136. /**
  73137. * Bounding box for the mesh
  73138. */
  73139. readonly boundingBox: BoundingBox;
  73140. /**
  73141. * Bounding sphere for the mesh
  73142. */
  73143. readonly boundingSphere: BoundingSphere;
  73144. private _isLocked;
  73145. private static readonly TmpVector3;
  73146. /**
  73147. * Constructs bounding info
  73148. * @param minimum min vector of the bounding box/sphere
  73149. * @param maximum max vector of the bounding box/sphere
  73150. * @param worldMatrix defines the new world matrix
  73151. */
  73152. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73153. /**
  73154. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73155. * @param min defines the new minimum vector (in local space)
  73156. * @param max defines the new maximum vector (in local space)
  73157. * @param worldMatrix defines the new world matrix
  73158. */
  73159. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73160. /**
  73161. * min vector of the bounding box/sphere
  73162. */
  73163. readonly minimum: Vector3;
  73164. /**
  73165. * max vector of the bounding box/sphere
  73166. */
  73167. readonly maximum: Vector3;
  73168. /**
  73169. * If the info is locked and won't be updated to avoid perf overhead
  73170. */
  73171. isLocked: boolean;
  73172. /**
  73173. * Updates the bounding sphere and box
  73174. * @param world world matrix to be used to update
  73175. */
  73176. update(world: DeepImmutable<Matrix>): void;
  73177. /**
  73178. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73179. * @param center New center of the bounding info
  73180. * @param extend New extend of the bounding info
  73181. * @returns the current bounding info
  73182. */
  73183. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73184. /**
  73185. * Scale the current bounding info by applying a scale factor
  73186. * @param factor defines the scale factor to apply
  73187. * @returns the current bounding info
  73188. */
  73189. scale(factor: number): BoundingInfo;
  73190. /**
  73191. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73192. * @param frustumPlanes defines the frustum to test
  73193. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73194. * @returns true if the bounding info is in the frustum planes
  73195. */
  73196. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73197. /**
  73198. * Gets the world distance between the min and max points of the bounding box
  73199. */
  73200. readonly diagonalLength: number;
  73201. /**
  73202. * Checks if a cullable object (mesh...) is in the camera frustum
  73203. * Unlike isInFrustum this cheks the full bounding box
  73204. * @param frustumPlanes Camera near/planes
  73205. * @returns true if the object is in frustum otherwise false
  73206. */
  73207. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73208. /** @hidden */
  73209. _checkCollision(collider: Collider): boolean;
  73210. /**
  73211. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73212. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73213. * @param point the point to check intersection with
  73214. * @returns if the point intersects
  73215. */
  73216. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73217. /**
  73218. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73219. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73220. * @param boundingInfo the bounding info to check intersection with
  73221. * @param precise if the intersection should be done using OBB
  73222. * @returns if the bounding info intersects
  73223. */
  73224. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73225. }
  73226. }
  73227. declare module BABYLON {
  73228. /**
  73229. * Extracts minimum and maximum values from a list of indexed positions
  73230. * @param positions defines the positions to use
  73231. * @param indices defines the indices to the positions
  73232. * @param indexStart defines the start index
  73233. * @param indexCount defines the end index
  73234. * @param bias defines bias value to add to the result
  73235. * @return minimum and maximum values
  73236. */
  73237. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73238. minimum: Vector3;
  73239. maximum: Vector3;
  73240. };
  73241. /**
  73242. * Extracts minimum and maximum values from a list of positions
  73243. * @param positions defines the positions to use
  73244. * @param start defines the start index in the positions array
  73245. * @param count defines the number of positions to handle
  73246. * @param bias defines bias value to add to the result
  73247. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73248. * @return minimum and maximum values
  73249. */
  73250. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73251. minimum: Vector3;
  73252. maximum: Vector3;
  73253. };
  73254. }
  73255. declare module BABYLON {
  73256. /**
  73257. * Uniform buffer objects.
  73258. *
  73259. * Handles blocks of uniform on the GPU.
  73260. *
  73261. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73262. *
  73263. * For more information, please refer to :
  73264. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73265. */
  73266. export class UniformBuffer {
  73267. private _engine;
  73268. private _buffer;
  73269. private _data;
  73270. private _bufferData;
  73271. private _dynamic?;
  73272. private _uniformLocations;
  73273. private _uniformSizes;
  73274. private _uniformLocationPointer;
  73275. private _needSync;
  73276. private _noUBO;
  73277. private _currentEffect;
  73278. private static _MAX_UNIFORM_SIZE;
  73279. private static _tempBuffer;
  73280. /**
  73281. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73282. * This is dynamic to allow compat with webgl 1 and 2.
  73283. * You will need to pass the name of the uniform as well as the value.
  73284. */
  73285. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73286. /**
  73287. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73288. * This is dynamic to allow compat with webgl 1 and 2.
  73289. * You will need to pass the name of the uniform as well as the value.
  73290. */
  73291. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73292. /**
  73293. * Lambda to Update a single float in a uniform buffer.
  73294. * This is dynamic to allow compat with webgl 1 and 2.
  73295. * You will need to pass the name of the uniform as well as the value.
  73296. */
  73297. updateFloat: (name: string, x: number) => void;
  73298. /**
  73299. * Lambda to Update a vec2 of float in a uniform buffer.
  73300. * This is dynamic to allow compat with webgl 1 and 2.
  73301. * You will need to pass the name of the uniform as well as the value.
  73302. */
  73303. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73304. /**
  73305. * Lambda to Update a vec3 of float in a uniform buffer.
  73306. * This is dynamic to allow compat with webgl 1 and 2.
  73307. * You will need to pass the name of the uniform as well as the value.
  73308. */
  73309. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73310. /**
  73311. * Lambda to Update a vec4 of float in a uniform buffer.
  73312. * This is dynamic to allow compat with webgl 1 and 2.
  73313. * You will need to pass the name of the uniform as well as the value.
  73314. */
  73315. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73316. /**
  73317. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73318. * This is dynamic to allow compat with webgl 1 and 2.
  73319. * You will need to pass the name of the uniform as well as the value.
  73320. */
  73321. updateMatrix: (name: string, mat: Matrix) => void;
  73322. /**
  73323. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73324. * This is dynamic to allow compat with webgl 1 and 2.
  73325. * You will need to pass the name of the uniform as well as the value.
  73326. */
  73327. updateVector3: (name: string, vector: Vector3) => void;
  73328. /**
  73329. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73330. * This is dynamic to allow compat with webgl 1 and 2.
  73331. * You will need to pass the name of the uniform as well as the value.
  73332. */
  73333. updateVector4: (name: string, vector: Vector4) => void;
  73334. /**
  73335. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73336. * This is dynamic to allow compat with webgl 1 and 2.
  73337. * You will need to pass the name of the uniform as well as the value.
  73338. */
  73339. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73340. /**
  73341. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73342. * This is dynamic to allow compat with webgl 1 and 2.
  73343. * You will need to pass the name of the uniform as well as the value.
  73344. */
  73345. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73346. /**
  73347. * Instantiates a new Uniform buffer objects.
  73348. *
  73349. * Handles blocks of uniform on the GPU.
  73350. *
  73351. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73352. *
  73353. * For more information, please refer to :
  73354. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73355. * @param engine Define the engine the buffer is associated with
  73356. * @param data Define the data contained in the buffer
  73357. * @param dynamic Define if the buffer is updatable
  73358. */
  73359. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73360. /**
  73361. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73362. * or just falling back on setUniformXXX calls.
  73363. */
  73364. readonly useUbo: boolean;
  73365. /**
  73366. * Indicates if the WebGL underlying uniform buffer is in sync
  73367. * with the javascript cache data.
  73368. */
  73369. readonly isSync: boolean;
  73370. /**
  73371. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73372. * Also, a dynamic UniformBuffer will disable cache verification and always
  73373. * update the underlying WebGL uniform buffer to the GPU.
  73374. * @returns if Dynamic, otherwise false
  73375. */
  73376. isDynamic(): boolean;
  73377. /**
  73378. * The data cache on JS side.
  73379. * @returns the underlying data as a float array
  73380. */
  73381. getData(): Float32Array;
  73382. /**
  73383. * The underlying WebGL Uniform buffer.
  73384. * @returns the webgl buffer
  73385. */
  73386. getBuffer(): Nullable<DataBuffer>;
  73387. /**
  73388. * std140 layout specifies how to align data within an UBO structure.
  73389. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73390. * for specs.
  73391. */
  73392. private _fillAlignment;
  73393. /**
  73394. * Adds an uniform in the buffer.
  73395. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73396. * for the layout to be correct !
  73397. * @param name Name of the uniform, as used in the uniform block in the shader.
  73398. * @param size Data size, or data directly.
  73399. */
  73400. addUniform(name: string, size: number | number[]): void;
  73401. /**
  73402. * Adds a Matrix 4x4 to the uniform buffer.
  73403. * @param name Name of the uniform, as used in the uniform block in the shader.
  73404. * @param mat A 4x4 matrix.
  73405. */
  73406. addMatrix(name: string, mat: Matrix): void;
  73407. /**
  73408. * Adds a vec2 to the uniform buffer.
  73409. * @param name Name of the uniform, as used in the uniform block in the shader.
  73410. * @param x Define the x component value of the vec2
  73411. * @param y Define the y component value of the vec2
  73412. */
  73413. addFloat2(name: string, x: number, y: number): void;
  73414. /**
  73415. * Adds a vec3 to the uniform buffer.
  73416. * @param name Name of the uniform, as used in the uniform block in the shader.
  73417. * @param x Define the x component value of the vec3
  73418. * @param y Define the y component value of the vec3
  73419. * @param z Define the z component value of the vec3
  73420. */
  73421. addFloat3(name: string, x: number, y: number, z: number): void;
  73422. /**
  73423. * Adds a vec3 to the uniform buffer.
  73424. * @param name Name of the uniform, as used in the uniform block in the shader.
  73425. * @param color Define the vec3 from a Color
  73426. */
  73427. addColor3(name: string, color: Color3): void;
  73428. /**
  73429. * Adds a vec4 to the uniform buffer.
  73430. * @param name Name of the uniform, as used in the uniform block in the shader.
  73431. * @param color Define the rgb components from a Color
  73432. * @param alpha Define the a component of the vec4
  73433. */
  73434. addColor4(name: string, color: Color3, alpha: number): void;
  73435. /**
  73436. * Adds a vec3 to the uniform buffer.
  73437. * @param name Name of the uniform, as used in the uniform block in the shader.
  73438. * @param vector Define the vec3 components from a Vector
  73439. */
  73440. addVector3(name: string, vector: Vector3): void;
  73441. /**
  73442. * Adds a Matrix 3x3 to the uniform buffer.
  73443. * @param name Name of the uniform, as used in the uniform block in the shader.
  73444. */
  73445. addMatrix3x3(name: string): void;
  73446. /**
  73447. * Adds a Matrix 2x2 to the uniform buffer.
  73448. * @param name Name of the uniform, as used in the uniform block in the shader.
  73449. */
  73450. addMatrix2x2(name: string): void;
  73451. /**
  73452. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  73453. */
  73454. create(): void;
  73455. /** @hidden */
  73456. _rebuild(): void;
  73457. /**
  73458. * Updates the WebGL Uniform Buffer on the GPU.
  73459. * If the `dynamic` flag is set to true, no cache comparison is done.
  73460. * Otherwise, the buffer will be updated only if the cache differs.
  73461. */
  73462. update(): void;
  73463. /**
  73464. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  73465. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73466. * @param data Define the flattened data
  73467. * @param size Define the size of the data.
  73468. */
  73469. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  73470. private _valueCache;
  73471. private _cacheMatrix;
  73472. private _updateMatrix3x3ForUniform;
  73473. private _updateMatrix3x3ForEffect;
  73474. private _updateMatrix2x2ForEffect;
  73475. private _updateMatrix2x2ForUniform;
  73476. private _updateFloatForEffect;
  73477. private _updateFloatForUniform;
  73478. private _updateFloat2ForEffect;
  73479. private _updateFloat2ForUniform;
  73480. private _updateFloat3ForEffect;
  73481. private _updateFloat3ForUniform;
  73482. private _updateFloat4ForEffect;
  73483. private _updateFloat4ForUniform;
  73484. private _updateMatrixForEffect;
  73485. private _updateMatrixForUniform;
  73486. private _updateVector3ForEffect;
  73487. private _updateVector3ForUniform;
  73488. private _updateVector4ForEffect;
  73489. private _updateVector4ForUniform;
  73490. private _updateColor3ForEffect;
  73491. private _updateColor3ForUniform;
  73492. private _updateColor4ForEffect;
  73493. private _updateColor4ForUniform;
  73494. /**
  73495. * Sets a sampler uniform on the effect.
  73496. * @param name Define the name of the sampler.
  73497. * @param texture Define the texture to set in the sampler
  73498. */
  73499. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  73500. /**
  73501. * Directly updates the value of the uniform in the cache AND on the GPU.
  73502. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73503. * @param data Define the flattened data
  73504. */
  73505. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  73506. /**
  73507. * Binds this uniform buffer to an effect.
  73508. * @param effect Define the effect to bind the buffer to
  73509. * @param name Name of the uniform block in the shader.
  73510. */
  73511. bindToEffect(effect: Effect, name: string): void;
  73512. /**
  73513. * Disposes the uniform buffer.
  73514. */
  73515. dispose(): void;
  73516. }
  73517. }
  73518. declare module BABYLON {
  73519. /**
  73520. * Enum that determines the text-wrapping mode to use.
  73521. */
  73522. export enum InspectableType {
  73523. /**
  73524. * Checkbox for booleans
  73525. */
  73526. Checkbox = 0,
  73527. /**
  73528. * Sliders for numbers
  73529. */
  73530. Slider = 1,
  73531. /**
  73532. * Vector3
  73533. */
  73534. Vector3 = 2,
  73535. /**
  73536. * Quaternions
  73537. */
  73538. Quaternion = 3,
  73539. /**
  73540. * Color3
  73541. */
  73542. Color3 = 4,
  73543. /**
  73544. * String
  73545. */
  73546. String = 5
  73547. }
  73548. /**
  73549. * Interface used to define custom inspectable properties.
  73550. * This interface is used by the inspector to display custom property grids
  73551. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73552. */
  73553. export interface IInspectable {
  73554. /**
  73555. * Gets the label to display
  73556. */
  73557. label: string;
  73558. /**
  73559. * Gets the name of the property to edit
  73560. */
  73561. propertyName: string;
  73562. /**
  73563. * Gets the type of the editor to use
  73564. */
  73565. type: InspectableType;
  73566. /**
  73567. * Gets the minimum value of the property when using in "slider" mode
  73568. */
  73569. min?: number;
  73570. /**
  73571. * Gets the maximum value of the property when using in "slider" mode
  73572. */
  73573. max?: number;
  73574. /**
  73575. * Gets the setp to use when using in "slider" mode
  73576. */
  73577. step?: number;
  73578. }
  73579. }
  73580. declare module BABYLON {
  73581. /**
  73582. * Class used to provide helper for timing
  73583. */
  73584. export class TimingTools {
  73585. /**
  73586. * Polyfill for setImmediate
  73587. * @param action defines the action to execute after the current execution block
  73588. */
  73589. static SetImmediate(action: () => void): void;
  73590. }
  73591. }
  73592. declare module BABYLON {
  73593. /**
  73594. * Class used to enable instatition of objects by class name
  73595. */
  73596. export class InstantiationTools {
  73597. /**
  73598. * Use this object to register external classes like custom textures or material
  73599. * to allow the laoders to instantiate them
  73600. */
  73601. static RegisteredExternalClasses: {
  73602. [key: string]: Object;
  73603. };
  73604. /**
  73605. * Tries to instantiate a new object from a given class name
  73606. * @param className defines the class name to instantiate
  73607. * @returns the new object or null if the system was not able to do the instantiation
  73608. */
  73609. static Instantiate(className: string): any;
  73610. }
  73611. }
  73612. declare module BABYLON {
  73613. /**
  73614. * Define options used to create a depth texture
  73615. */
  73616. export class DepthTextureCreationOptions {
  73617. /** Specifies whether or not a stencil should be allocated in the texture */
  73618. generateStencil?: boolean;
  73619. /** Specifies whether or not bilinear filtering is enable on the texture */
  73620. bilinearFiltering?: boolean;
  73621. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  73622. comparisonFunction?: number;
  73623. /** Specifies if the created texture is a cube texture */
  73624. isCube?: boolean;
  73625. }
  73626. }
  73627. declare module BABYLON {
  73628. interface BaseEngine {
  73629. /**
  73630. * Creates a depth stencil cube texture.
  73631. * This is only available in WebGL 2.
  73632. * @param size The size of face edge in the cube texture.
  73633. * @param options The options defining the cube texture.
  73634. * @returns The cube texture
  73635. */
  73636. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73637. /**
  73638. * Creates a cube texture
  73639. * @param rootUrl defines the url where the files to load is located
  73640. * @param scene defines the current scene
  73641. * @param files defines the list of files to load (1 per face)
  73642. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73643. * @param onLoad defines an optional callback raised when the texture is loaded
  73644. * @param onError defines an optional callback raised if there is an issue to load the texture
  73645. * @param format defines the format of the data
  73646. * @param forcedExtension defines the extension to use to pick the right loader
  73647. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73648. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73649. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73650. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73651. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73652. * @returns the cube texture as an InternalTexture
  73653. */
  73654. 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;
  73655. /**
  73656. * Creates a cube texture
  73657. * @param rootUrl defines the url where the files to load is located
  73658. * @param scene defines the current scene
  73659. * @param files defines the list of files to load (1 per face)
  73660. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73661. * @param onLoad defines an optional callback raised when the texture is loaded
  73662. * @param onError defines an optional callback raised if there is an issue to load the texture
  73663. * @param format defines the format of the data
  73664. * @param forcedExtension defines the extension to use to pick the right loader
  73665. * @returns the cube texture as an InternalTexture
  73666. */
  73667. 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;
  73668. /**
  73669. * Creates a cube texture
  73670. * @param rootUrl defines the url where the files to load is located
  73671. * @param scene defines the current scene
  73672. * @param files defines the list of files to load (1 per face)
  73673. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73674. * @param onLoad defines an optional callback raised when the texture is loaded
  73675. * @param onError defines an optional callback raised if there is an issue to load the texture
  73676. * @param format defines the format of the data
  73677. * @param forcedExtension defines the extension to use to pick the right loader
  73678. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73679. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73680. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73681. * @returns the cube texture as an InternalTexture
  73682. */
  73683. 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;
  73684. /** @hidden */
  73685. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73686. /** @hidden */
  73687. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73688. /** @hidden */
  73689. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73690. /** @hidden */
  73691. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73692. }
  73693. }
  73694. declare module BABYLON {
  73695. /**
  73696. * Class for creating a cube texture
  73697. */
  73698. export class CubeTexture extends BaseTexture {
  73699. private _delayedOnLoad;
  73700. /**
  73701. * The url of the texture
  73702. */
  73703. url: string;
  73704. /**
  73705. * Gets or sets the center of the bounding box associated with the cube texture.
  73706. * It must define where the camera used to render the texture was set
  73707. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73708. */
  73709. boundingBoxPosition: Vector3;
  73710. private _boundingBoxSize;
  73711. /**
  73712. * Gets or sets the size of the bounding box associated with the cube texture
  73713. * When defined, the cubemap will switch to local mode
  73714. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73715. * @example https://www.babylonjs-playground.com/#RNASML
  73716. */
  73717. /**
  73718. * Returns the bounding box size
  73719. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73720. */
  73721. boundingBoxSize: Vector3;
  73722. protected _rotationY: number;
  73723. /**
  73724. * Sets texture matrix rotation angle around Y axis in radians.
  73725. */
  73726. /**
  73727. * Gets texture matrix rotation angle around Y axis radians.
  73728. */
  73729. rotationY: number;
  73730. /**
  73731. * Are mip maps generated for this texture or not.
  73732. */
  73733. readonly noMipmap: boolean;
  73734. private _noMipmap;
  73735. private _files;
  73736. private _extensions;
  73737. private _textureMatrix;
  73738. private _format;
  73739. private _createPolynomials;
  73740. /** @hidden */
  73741. _prefiltered: boolean;
  73742. /**
  73743. * Creates a cube texture from an array of image urls
  73744. * @param files defines an array of image urls
  73745. * @param scene defines the hosting scene
  73746. * @param noMipmap specifies if mip maps are not used
  73747. * @returns a cube texture
  73748. */
  73749. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73750. /**
  73751. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73752. * @param url defines the url of the prefiltered texture
  73753. * @param scene defines the scene the texture is attached to
  73754. * @param forcedExtension defines the extension of the file if different from the url
  73755. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73756. * @return the prefiltered texture
  73757. */
  73758. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73759. /**
  73760. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73761. * as prefiltered data.
  73762. * @param rootUrl defines the url of the texture or the root name of the six images
  73763. * @param scene defines the scene the texture is attached to
  73764. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73765. * @param noMipmap defines if mipmaps should be created or not
  73766. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73767. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73768. * @param onError defines a callback triggered in case of error during load
  73769. * @param format defines the internal format to use for the texture once loaded
  73770. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73771. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73772. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73773. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73774. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73775. * @return the cube texture
  73776. */
  73777. 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);
  73778. /**
  73779. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73780. */
  73781. readonly isPrefiltered: boolean;
  73782. /**
  73783. * Get the current class name of the texture useful for serialization or dynamic coding.
  73784. * @returns "CubeTexture"
  73785. */
  73786. getClassName(): string;
  73787. /**
  73788. * Update the url (and optional buffer) of this texture if url was null during construction.
  73789. * @param url the url of the texture
  73790. * @param forcedExtension defines the extension to use
  73791. * @param onLoad callback called when the texture is loaded (defaults to null)
  73792. */
  73793. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73794. /**
  73795. * Delays loading of the cube texture
  73796. * @param forcedExtension defines the extension to use
  73797. */
  73798. delayLoad(forcedExtension?: string): void;
  73799. /**
  73800. * Returns the reflection texture matrix
  73801. * @returns the reflection texture matrix
  73802. */
  73803. getReflectionTextureMatrix(): Matrix;
  73804. /**
  73805. * Sets the reflection texture matrix
  73806. * @param value Reflection texture matrix
  73807. */
  73808. setReflectionTextureMatrix(value: Matrix): void;
  73809. /**
  73810. * Parses text to create a cube texture
  73811. * @param parsedTexture define the serialized text to read from
  73812. * @param scene defines the hosting scene
  73813. * @param rootUrl defines the root url of the cube texture
  73814. * @returns a cube texture
  73815. */
  73816. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73817. /**
  73818. * Makes a clone, or deep copy, of the cube texture
  73819. * @returns a new cube texture
  73820. */
  73821. clone(): CubeTexture;
  73822. }
  73823. }
  73824. declare module BABYLON {
  73825. /**
  73826. * Manages the defines for the Material
  73827. */
  73828. export class MaterialDefines {
  73829. /** @hidden */
  73830. protected _keys: string[];
  73831. private _isDirty;
  73832. /** @hidden */
  73833. _renderId: number;
  73834. /** @hidden */
  73835. _areLightsDirty: boolean;
  73836. /** @hidden */
  73837. _areLightsDisposed: boolean;
  73838. /** @hidden */
  73839. _areAttributesDirty: boolean;
  73840. /** @hidden */
  73841. _areTexturesDirty: boolean;
  73842. /** @hidden */
  73843. _areFresnelDirty: boolean;
  73844. /** @hidden */
  73845. _areMiscDirty: boolean;
  73846. /** @hidden */
  73847. _areImageProcessingDirty: boolean;
  73848. /** @hidden */
  73849. _normals: boolean;
  73850. /** @hidden */
  73851. _uvs: boolean;
  73852. /** @hidden */
  73853. _needNormals: boolean;
  73854. /** @hidden */
  73855. _needUVs: boolean;
  73856. [id: string]: any;
  73857. /**
  73858. * Specifies if the material needs to be re-calculated
  73859. */
  73860. readonly isDirty: boolean;
  73861. /**
  73862. * Marks the material to indicate that it has been re-calculated
  73863. */
  73864. markAsProcessed(): void;
  73865. /**
  73866. * Marks the material to indicate that it needs to be re-calculated
  73867. */
  73868. markAsUnprocessed(): void;
  73869. /**
  73870. * Marks the material to indicate all of its defines need to be re-calculated
  73871. */
  73872. markAllAsDirty(): void;
  73873. /**
  73874. * Marks the material to indicate that image processing needs to be re-calculated
  73875. */
  73876. markAsImageProcessingDirty(): void;
  73877. /**
  73878. * Marks the material to indicate the lights need to be re-calculated
  73879. * @param disposed Defines whether the light is dirty due to dispose or not
  73880. */
  73881. markAsLightDirty(disposed?: boolean): void;
  73882. /**
  73883. * Marks the attribute state as changed
  73884. */
  73885. markAsAttributesDirty(): void;
  73886. /**
  73887. * Marks the texture state as changed
  73888. */
  73889. markAsTexturesDirty(): void;
  73890. /**
  73891. * Marks the fresnel state as changed
  73892. */
  73893. markAsFresnelDirty(): void;
  73894. /**
  73895. * Marks the misc state as changed
  73896. */
  73897. markAsMiscDirty(): void;
  73898. /**
  73899. * Rebuilds the material defines
  73900. */
  73901. rebuild(): void;
  73902. /**
  73903. * Specifies if two material defines are equal
  73904. * @param other - A material define instance to compare to
  73905. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73906. */
  73907. isEqual(other: MaterialDefines): boolean;
  73908. /**
  73909. * Clones this instance's defines to another instance
  73910. * @param other - material defines to clone values to
  73911. */
  73912. cloneTo(other: MaterialDefines): void;
  73913. /**
  73914. * Resets the material define values
  73915. */
  73916. reset(): void;
  73917. /**
  73918. * Converts the material define values to a string
  73919. * @returns - String of material define information
  73920. */
  73921. toString(): string;
  73922. }
  73923. }
  73924. declare module BABYLON {
  73925. /**
  73926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73928. * 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;
  73929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73930. */
  73931. export class ColorCurves {
  73932. private _dirty;
  73933. private _tempColor;
  73934. private _globalCurve;
  73935. private _highlightsCurve;
  73936. private _midtonesCurve;
  73937. private _shadowsCurve;
  73938. private _positiveCurve;
  73939. private _negativeCurve;
  73940. private _globalHue;
  73941. private _globalDensity;
  73942. private _globalSaturation;
  73943. private _globalExposure;
  73944. /**
  73945. * Gets the global Hue value.
  73946. * 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).
  73947. */
  73948. /**
  73949. * Sets the global Hue value.
  73950. * 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).
  73951. */
  73952. globalHue: number;
  73953. /**
  73954. * Gets the global Density value.
  73955. * 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.
  73956. * Values less than zero provide a filter of opposite hue.
  73957. */
  73958. /**
  73959. * Sets the global Density value.
  73960. * 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.
  73961. * Values less than zero provide a filter of opposite hue.
  73962. */
  73963. globalDensity: number;
  73964. /**
  73965. * Gets the global Saturation value.
  73966. * 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.
  73967. */
  73968. /**
  73969. * Sets the global Saturation value.
  73970. * 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.
  73971. */
  73972. globalSaturation: number;
  73973. /**
  73974. * Gets the global Exposure value.
  73975. * 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.
  73976. */
  73977. /**
  73978. * Sets the global Exposure value.
  73979. * 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.
  73980. */
  73981. globalExposure: number;
  73982. private _highlightsHue;
  73983. private _highlightsDensity;
  73984. private _highlightsSaturation;
  73985. private _highlightsExposure;
  73986. /**
  73987. * Gets the highlights Hue value.
  73988. * 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).
  73989. */
  73990. /**
  73991. * Sets the highlights Hue value.
  73992. * 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).
  73993. */
  73994. highlightsHue: number;
  73995. /**
  73996. * Gets the highlights Density value.
  73997. * 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.
  73998. * Values less than zero provide a filter of opposite hue.
  73999. */
  74000. /**
  74001. * Sets the highlights Density value.
  74002. * 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.
  74003. * Values less than zero provide a filter of opposite hue.
  74004. */
  74005. highlightsDensity: number;
  74006. /**
  74007. * Gets the highlights Saturation value.
  74008. * 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.
  74009. */
  74010. /**
  74011. * Sets the highlights Saturation value.
  74012. * 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.
  74013. */
  74014. highlightsSaturation: number;
  74015. /**
  74016. * Gets the highlights Exposure value.
  74017. * 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.
  74018. */
  74019. /**
  74020. * Sets the highlights Exposure value.
  74021. * 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.
  74022. */
  74023. highlightsExposure: number;
  74024. private _midtonesHue;
  74025. private _midtonesDensity;
  74026. private _midtonesSaturation;
  74027. private _midtonesExposure;
  74028. /**
  74029. * Gets the midtones Hue value.
  74030. * 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).
  74031. */
  74032. /**
  74033. * Sets the midtones Hue value.
  74034. * 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).
  74035. */
  74036. midtonesHue: number;
  74037. /**
  74038. * Gets the midtones Density value.
  74039. * 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.
  74040. * Values less than zero provide a filter of opposite hue.
  74041. */
  74042. /**
  74043. * Sets the midtones Density value.
  74044. * 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.
  74045. * Values less than zero provide a filter of opposite hue.
  74046. */
  74047. midtonesDensity: number;
  74048. /**
  74049. * Gets the midtones Saturation value.
  74050. * 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.
  74051. */
  74052. /**
  74053. * Sets the midtones Saturation value.
  74054. * 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.
  74055. */
  74056. midtonesSaturation: number;
  74057. /**
  74058. * Gets the midtones Exposure value.
  74059. * 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.
  74060. */
  74061. /**
  74062. * Sets the midtones Exposure value.
  74063. * 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.
  74064. */
  74065. midtonesExposure: number;
  74066. private _shadowsHue;
  74067. private _shadowsDensity;
  74068. private _shadowsSaturation;
  74069. private _shadowsExposure;
  74070. /**
  74071. * Gets the shadows Hue value.
  74072. * 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).
  74073. */
  74074. /**
  74075. * Sets the shadows Hue value.
  74076. * 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).
  74077. */
  74078. shadowsHue: number;
  74079. /**
  74080. * Gets the shadows Density value.
  74081. * 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.
  74082. * Values less than zero provide a filter of opposite hue.
  74083. */
  74084. /**
  74085. * Sets the shadows Density value.
  74086. * 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.
  74087. * Values less than zero provide a filter of opposite hue.
  74088. */
  74089. shadowsDensity: number;
  74090. /**
  74091. * Gets the shadows Saturation value.
  74092. * 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.
  74093. */
  74094. /**
  74095. * Sets the shadows Saturation value.
  74096. * 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.
  74097. */
  74098. shadowsSaturation: number;
  74099. /**
  74100. * Gets the shadows Exposure value.
  74101. * 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.
  74102. */
  74103. /**
  74104. * Sets the shadows Exposure value.
  74105. * 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.
  74106. */
  74107. shadowsExposure: number;
  74108. /**
  74109. * Returns the class name
  74110. * @returns The class name
  74111. */
  74112. getClassName(): string;
  74113. /**
  74114. * Binds the color curves to the shader.
  74115. * @param colorCurves The color curve to bind
  74116. * @param effect The effect to bind to
  74117. * @param positiveUniform The positive uniform shader parameter
  74118. * @param neutralUniform The neutral uniform shader parameter
  74119. * @param negativeUniform The negative uniform shader parameter
  74120. */
  74121. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74122. /**
  74123. * Prepare the list of uniforms associated with the ColorCurves effects.
  74124. * @param uniformsList The list of uniforms used in the effect
  74125. */
  74126. static PrepareUniforms(uniformsList: string[]): void;
  74127. /**
  74128. * Returns color grading data based on a hue, density, saturation and exposure value.
  74129. * @param filterHue The hue of the color filter.
  74130. * @param filterDensity The density of the color filter.
  74131. * @param saturation The saturation.
  74132. * @param exposure The exposure.
  74133. * @param result The result data container.
  74134. */
  74135. private getColorGradingDataToRef;
  74136. /**
  74137. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74138. * @param value The input slider value in range [-100,100].
  74139. * @returns Adjusted value.
  74140. */
  74141. private static applyColorGradingSliderNonlinear;
  74142. /**
  74143. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74144. * @param hue The hue (H) input.
  74145. * @param saturation The saturation (S) input.
  74146. * @param brightness The brightness (B) input.
  74147. * @result An RGBA color represented as Vector4.
  74148. */
  74149. private static fromHSBToRef;
  74150. /**
  74151. * Returns a value clamped between min and max
  74152. * @param value The value to clamp
  74153. * @param min The minimum of value
  74154. * @param max The maximum of value
  74155. * @returns The clamped value.
  74156. */
  74157. private static clamp;
  74158. /**
  74159. * Clones the current color curve instance.
  74160. * @return The cloned curves
  74161. */
  74162. clone(): ColorCurves;
  74163. /**
  74164. * Serializes the current color curve instance to a json representation.
  74165. * @return a JSON representation
  74166. */
  74167. serialize(): any;
  74168. /**
  74169. * Parses the color curve from a json representation.
  74170. * @param source the JSON source to parse
  74171. * @return The parsed curves
  74172. */
  74173. static Parse(source: any): ColorCurves;
  74174. }
  74175. }
  74176. declare module BABYLON {
  74177. /**
  74178. * Interface to follow in your material defines to integrate easily the
  74179. * Image proccessing functions.
  74180. * @hidden
  74181. */
  74182. export interface IImageProcessingConfigurationDefines {
  74183. IMAGEPROCESSING: boolean;
  74184. VIGNETTE: boolean;
  74185. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74186. VIGNETTEBLENDMODEOPAQUE: boolean;
  74187. TONEMAPPING: boolean;
  74188. TONEMAPPING_ACES: boolean;
  74189. CONTRAST: boolean;
  74190. EXPOSURE: boolean;
  74191. COLORCURVES: boolean;
  74192. COLORGRADING: boolean;
  74193. COLORGRADING3D: boolean;
  74194. SAMPLER3DGREENDEPTH: boolean;
  74195. SAMPLER3DBGRMAP: boolean;
  74196. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74197. }
  74198. /**
  74199. * @hidden
  74200. */
  74201. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74202. IMAGEPROCESSING: boolean;
  74203. VIGNETTE: boolean;
  74204. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74205. VIGNETTEBLENDMODEOPAQUE: boolean;
  74206. TONEMAPPING: boolean;
  74207. TONEMAPPING_ACES: boolean;
  74208. CONTRAST: boolean;
  74209. COLORCURVES: boolean;
  74210. COLORGRADING: boolean;
  74211. COLORGRADING3D: boolean;
  74212. SAMPLER3DGREENDEPTH: boolean;
  74213. SAMPLER3DBGRMAP: boolean;
  74214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74215. EXPOSURE: boolean;
  74216. constructor();
  74217. }
  74218. /**
  74219. * This groups together the common properties used for image processing either in direct forward pass
  74220. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74221. * or not.
  74222. */
  74223. export class ImageProcessingConfiguration {
  74224. /**
  74225. * Default tone mapping applied in BabylonJS.
  74226. */
  74227. static readonly TONEMAPPING_STANDARD: number;
  74228. /**
  74229. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74230. * to other engines rendering to increase portability.
  74231. */
  74232. static readonly TONEMAPPING_ACES: number;
  74233. /**
  74234. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74235. */
  74236. colorCurves: Nullable<ColorCurves>;
  74237. private _colorCurvesEnabled;
  74238. /**
  74239. * Gets wether the color curves effect is enabled.
  74240. */
  74241. /**
  74242. * Sets wether the color curves effect is enabled.
  74243. */
  74244. colorCurvesEnabled: boolean;
  74245. private _colorGradingTexture;
  74246. /**
  74247. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74248. */
  74249. /**
  74250. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74251. */
  74252. colorGradingTexture: Nullable<BaseTexture>;
  74253. private _colorGradingEnabled;
  74254. /**
  74255. * Gets wether the color grading effect is enabled.
  74256. */
  74257. /**
  74258. * Sets wether the color grading effect is enabled.
  74259. */
  74260. colorGradingEnabled: boolean;
  74261. private _colorGradingWithGreenDepth;
  74262. /**
  74263. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74264. */
  74265. /**
  74266. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74267. */
  74268. colorGradingWithGreenDepth: boolean;
  74269. private _colorGradingBGR;
  74270. /**
  74271. * Gets wether the color grading texture contains BGR values.
  74272. */
  74273. /**
  74274. * Sets wether the color grading texture contains BGR values.
  74275. */
  74276. colorGradingBGR: boolean;
  74277. /** @hidden */
  74278. _exposure: number;
  74279. /**
  74280. * Gets the Exposure used in the effect.
  74281. */
  74282. /**
  74283. * Sets the Exposure used in the effect.
  74284. */
  74285. exposure: number;
  74286. private _toneMappingEnabled;
  74287. /**
  74288. * Gets wether the tone mapping effect is enabled.
  74289. */
  74290. /**
  74291. * Sets wether the tone mapping effect is enabled.
  74292. */
  74293. toneMappingEnabled: boolean;
  74294. private _toneMappingType;
  74295. /**
  74296. * Gets the type of tone mapping effect.
  74297. */
  74298. /**
  74299. * Sets the type of tone mapping effect used in BabylonJS.
  74300. */
  74301. toneMappingType: number;
  74302. protected _contrast: number;
  74303. /**
  74304. * Gets the contrast used in the effect.
  74305. */
  74306. /**
  74307. * Sets the contrast used in the effect.
  74308. */
  74309. contrast: number;
  74310. /**
  74311. * Vignette stretch size.
  74312. */
  74313. vignetteStretch: number;
  74314. /**
  74315. * Vignette centre X Offset.
  74316. */
  74317. vignetteCentreX: number;
  74318. /**
  74319. * Vignette centre Y Offset.
  74320. */
  74321. vignetteCentreY: number;
  74322. /**
  74323. * Vignette weight or intensity of the vignette effect.
  74324. */
  74325. vignetteWeight: number;
  74326. /**
  74327. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74328. * if vignetteEnabled is set to true.
  74329. */
  74330. vignetteColor: Color4;
  74331. /**
  74332. * Camera field of view used by the Vignette effect.
  74333. */
  74334. vignetteCameraFov: number;
  74335. private _vignetteBlendMode;
  74336. /**
  74337. * Gets the vignette blend mode allowing different kind of effect.
  74338. */
  74339. /**
  74340. * Sets the vignette blend mode allowing different kind of effect.
  74341. */
  74342. vignetteBlendMode: number;
  74343. private _vignetteEnabled;
  74344. /**
  74345. * Gets wether the vignette effect is enabled.
  74346. */
  74347. /**
  74348. * Sets wether the vignette effect is enabled.
  74349. */
  74350. vignetteEnabled: boolean;
  74351. private _applyByPostProcess;
  74352. /**
  74353. * Gets wether the image processing is applied through a post process or not.
  74354. */
  74355. /**
  74356. * Sets wether the image processing is applied through a post process or not.
  74357. */
  74358. applyByPostProcess: boolean;
  74359. private _isEnabled;
  74360. /**
  74361. * Gets wether the image processing is enabled or not.
  74362. */
  74363. /**
  74364. * Sets wether the image processing is enabled or not.
  74365. */
  74366. isEnabled: boolean;
  74367. /**
  74368. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74369. */
  74370. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74371. /**
  74372. * Method called each time the image processing information changes requires to recompile the effect.
  74373. */
  74374. protected _updateParameters(): void;
  74375. /**
  74376. * Gets the current class name.
  74377. * @return "ImageProcessingConfiguration"
  74378. */
  74379. getClassName(): string;
  74380. /**
  74381. * Prepare the list of uniforms associated with the Image Processing effects.
  74382. * @param uniforms The list of uniforms used in the effect
  74383. * @param defines the list of defines currently in use
  74384. */
  74385. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74386. /**
  74387. * Prepare the list of samplers associated with the Image Processing effects.
  74388. * @param samplersList The list of uniforms used in the effect
  74389. * @param defines the list of defines currently in use
  74390. */
  74391. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74392. /**
  74393. * Prepare the list of defines associated to the shader.
  74394. * @param defines the list of defines to complete
  74395. * @param forPostProcess Define if we are currently in post process mode or not
  74396. */
  74397. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74398. /**
  74399. * Returns true if all the image processing information are ready.
  74400. * @returns True if ready, otherwise, false
  74401. */
  74402. isReady(): boolean;
  74403. /**
  74404. * Binds the image processing to the shader.
  74405. * @param effect The effect to bind to
  74406. * @param aspectRatio Define the current aspect ratio of the effect
  74407. */
  74408. bind(effect: Effect, aspectRatio?: number): void;
  74409. /**
  74410. * Clones the current image processing instance.
  74411. * @return The cloned image processing
  74412. */
  74413. clone(): ImageProcessingConfiguration;
  74414. /**
  74415. * Serializes the current image processing instance to a json representation.
  74416. * @return a JSON representation
  74417. */
  74418. serialize(): any;
  74419. /**
  74420. * Parses the image processing from a json representation.
  74421. * @param source the JSON source to parse
  74422. * @return The parsed image processing
  74423. */
  74424. static Parse(source: any): ImageProcessingConfiguration;
  74425. private static _VIGNETTEMODE_MULTIPLY;
  74426. private static _VIGNETTEMODE_OPAQUE;
  74427. /**
  74428. * Used to apply the vignette as a mix with the pixel color.
  74429. */
  74430. static readonly VIGNETTEMODE_MULTIPLY: number;
  74431. /**
  74432. * Used to apply the vignette as a replacement of the pixel color.
  74433. */
  74434. static readonly VIGNETTEMODE_OPAQUE: number;
  74435. }
  74436. }
  74437. declare module BABYLON {
  74438. /** @hidden */
  74439. export var postprocessVertexShader: {
  74440. name: string;
  74441. shader: string;
  74442. };
  74443. }
  74444. declare module BABYLON {
  74445. /** Defines supported spaces */
  74446. export enum Space {
  74447. /** Local (object) space */
  74448. LOCAL = 0,
  74449. /** World space */
  74450. WORLD = 1,
  74451. /** Bone space */
  74452. BONE = 2
  74453. }
  74454. /** Defines the 3 main axes */
  74455. export class Axis {
  74456. /** X axis */
  74457. static X: Vector3;
  74458. /** Y axis */
  74459. static Y: Vector3;
  74460. /** Z axis */
  74461. static Z: Vector3;
  74462. }
  74463. }
  74464. declare module BABYLON {
  74465. /**
  74466. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74467. * This is the base of the follow, arc rotate cameras and Free camera
  74468. * @see http://doc.babylonjs.com/features/cameras
  74469. */
  74470. export class TargetCamera extends Camera {
  74471. private static _RigCamTransformMatrix;
  74472. private static _TargetTransformMatrix;
  74473. private static _TargetFocalPoint;
  74474. /**
  74475. * Define the current direction the camera is moving to
  74476. */
  74477. cameraDirection: Vector3;
  74478. /**
  74479. * Define the current rotation the camera is rotating to
  74480. */
  74481. cameraRotation: Vector2;
  74482. /**
  74483. * When set, the up vector of the camera will be updated by the rotation of the camera
  74484. */
  74485. updateUpVectorFromRotation: boolean;
  74486. private _tmpQuaternion;
  74487. /**
  74488. * Define the current rotation of the camera
  74489. */
  74490. rotation: Vector3;
  74491. /**
  74492. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74493. */
  74494. rotationQuaternion: Quaternion;
  74495. /**
  74496. * Define the current speed of the camera
  74497. */
  74498. speed: number;
  74499. /**
  74500. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74501. * around all axis.
  74502. */
  74503. noRotationConstraint: boolean;
  74504. /**
  74505. * Define the current target of the camera as an object or a position.
  74506. */
  74507. lockedTarget: any;
  74508. /** @hidden */
  74509. _currentTarget: Vector3;
  74510. /** @hidden */
  74511. _initialFocalDistance: number;
  74512. /** @hidden */
  74513. _viewMatrix: Matrix;
  74514. /** @hidden */
  74515. _camMatrix: Matrix;
  74516. /** @hidden */
  74517. _cameraTransformMatrix: Matrix;
  74518. /** @hidden */
  74519. _cameraRotationMatrix: Matrix;
  74520. /** @hidden */
  74521. _referencePoint: Vector3;
  74522. /** @hidden */
  74523. _transformedReferencePoint: Vector3;
  74524. protected _globalCurrentTarget: Vector3;
  74525. protected _globalCurrentUpVector: Vector3;
  74526. /** @hidden */
  74527. _reset: () => void;
  74528. private _defaultUp;
  74529. /**
  74530. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74531. * This is the base of the follow, arc rotate cameras and Free camera
  74532. * @see http://doc.babylonjs.com/features/cameras
  74533. * @param name Defines the name of the camera in the scene
  74534. * @param position Defines the start position of the camera in the scene
  74535. * @param scene Defines the scene the camera belongs to
  74536. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74537. */
  74538. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74539. /**
  74540. * Gets the position in front of the camera at a given distance.
  74541. * @param distance The distance from the camera we want the position to be
  74542. * @returns the position
  74543. */
  74544. getFrontPosition(distance: number): Vector3;
  74545. /** @hidden */
  74546. _getLockedTargetPosition(): Nullable<Vector3>;
  74547. private _storedPosition;
  74548. private _storedRotation;
  74549. private _storedRotationQuaternion;
  74550. /**
  74551. * Store current camera state of the camera (fov, position, rotation, etc..)
  74552. * @returns the camera
  74553. */
  74554. storeState(): Camera;
  74555. /**
  74556. * Restored camera state. You must call storeState() first
  74557. * @returns whether it was successful or not
  74558. * @hidden
  74559. */
  74560. _restoreStateValues(): boolean;
  74561. /** @hidden */
  74562. _initCache(): void;
  74563. /** @hidden */
  74564. _updateCache(ignoreParentClass?: boolean): void;
  74565. /** @hidden */
  74566. _isSynchronizedViewMatrix(): boolean;
  74567. /** @hidden */
  74568. _computeLocalCameraSpeed(): number;
  74569. /**
  74570. * Defines the target the camera should look at.
  74571. * @param target Defines the new target as a Vector or a mesh
  74572. */
  74573. setTarget(target: Vector3): void;
  74574. /**
  74575. * Return the current target position of the camera. This value is expressed in local space.
  74576. * @returns the target position
  74577. */
  74578. getTarget(): Vector3;
  74579. /** @hidden */
  74580. _decideIfNeedsToMove(): boolean;
  74581. /** @hidden */
  74582. _updatePosition(): void;
  74583. /** @hidden */
  74584. _checkInputs(): void;
  74585. protected _updateCameraRotationMatrix(): void;
  74586. /**
  74587. * 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)
  74588. * @returns the current camera
  74589. */
  74590. private _rotateUpVectorWithCameraRotationMatrix;
  74591. private _cachedRotationZ;
  74592. private _cachedQuaternionRotationZ;
  74593. /** @hidden */
  74594. _getViewMatrix(): Matrix;
  74595. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74596. /**
  74597. * @hidden
  74598. */
  74599. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74600. /**
  74601. * @hidden
  74602. */
  74603. _updateRigCameras(): void;
  74604. private _getRigCamPositionAndTarget;
  74605. /**
  74606. * Gets the current object class name.
  74607. * @return the class name
  74608. */
  74609. getClassName(): string;
  74610. }
  74611. }
  74612. declare module BABYLON {
  74613. /**
  74614. * Gather the list of keyboard event types as constants.
  74615. */
  74616. export class KeyboardEventTypes {
  74617. /**
  74618. * The keydown event is fired when a key becomes active (pressed).
  74619. */
  74620. static readonly KEYDOWN: number;
  74621. /**
  74622. * The keyup event is fired when a key has been released.
  74623. */
  74624. static readonly KEYUP: number;
  74625. }
  74626. /**
  74627. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74628. */
  74629. export class KeyboardInfo {
  74630. /**
  74631. * Defines the type of event (KeyboardEventTypes)
  74632. */
  74633. type: number;
  74634. /**
  74635. * Defines the related dom event
  74636. */
  74637. event: KeyboardEvent;
  74638. /**
  74639. * Instantiates a new keyboard info.
  74640. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74641. * @param type Defines the type of event (KeyboardEventTypes)
  74642. * @param event Defines the related dom event
  74643. */
  74644. constructor(
  74645. /**
  74646. * Defines the type of event (KeyboardEventTypes)
  74647. */
  74648. type: number,
  74649. /**
  74650. * Defines the related dom event
  74651. */
  74652. event: KeyboardEvent);
  74653. }
  74654. /**
  74655. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74656. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74657. */
  74658. export class KeyboardInfoPre extends KeyboardInfo {
  74659. /**
  74660. * Defines the type of event (KeyboardEventTypes)
  74661. */
  74662. type: number;
  74663. /**
  74664. * Defines the related dom event
  74665. */
  74666. event: KeyboardEvent;
  74667. /**
  74668. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74669. */
  74670. skipOnPointerObservable: boolean;
  74671. /**
  74672. * Instantiates a new keyboard pre info.
  74673. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74674. * @param type Defines the type of event (KeyboardEventTypes)
  74675. * @param event Defines the related dom event
  74676. */
  74677. constructor(
  74678. /**
  74679. * Defines the type of event (KeyboardEventTypes)
  74680. */
  74681. type: number,
  74682. /**
  74683. * Defines the related dom event
  74684. */
  74685. event: KeyboardEvent);
  74686. }
  74687. }
  74688. declare module BABYLON {
  74689. /**
  74690. * Manage the keyboard inputs to control the movement of a free camera.
  74691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74692. */
  74693. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74694. /**
  74695. * Defines the camera the input is attached to.
  74696. */
  74697. camera: FreeCamera;
  74698. /**
  74699. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74700. */
  74701. keysUp: number[];
  74702. /**
  74703. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74704. */
  74705. keysDown: number[];
  74706. /**
  74707. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74708. */
  74709. keysLeft: number[];
  74710. /**
  74711. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74712. */
  74713. keysRight: number[];
  74714. private _keys;
  74715. private _onCanvasBlurObserver;
  74716. private _onKeyboardObserver;
  74717. private _engine;
  74718. private _scene;
  74719. /**
  74720. * Attach the input controls to a specific dom element to get the input from.
  74721. * @param element Defines the element the controls should be listened from
  74722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74723. */
  74724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74725. /**
  74726. * Detach the current controls from the specified dom element.
  74727. * @param element Defines the element to stop listening the inputs from
  74728. */
  74729. detachControl(element: Nullable<HTMLElement>): void;
  74730. /**
  74731. * Update the current camera state depending on the inputs that have been used this frame.
  74732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74733. */
  74734. checkInputs(): void;
  74735. /**
  74736. * Gets the class name of the current intput.
  74737. * @returns the class name
  74738. */
  74739. getClassName(): string;
  74740. /** @hidden */
  74741. _onLostFocus(): void;
  74742. /**
  74743. * Get the friendly name associated with the input class.
  74744. * @returns the input friendly name
  74745. */
  74746. getSimpleName(): string;
  74747. }
  74748. }
  74749. declare module BABYLON {
  74750. /**
  74751. * Interface describing all the common properties and methods a shadow light needs to implement.
  74752. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74753. * as well as binding the different shadow properties to the effects.
  74754. */
  74755. export interface IShadowLight extends Light {
  74756. /**
  74757. * The light id in the scene (used in scene.findLighById for instance)
  74758. */
  74759. id: string;
  74760. /**
  74761. * The position the shdow will be casted from.
  74762. */
  74763. position: Vector3;
  74764. /**
  74765. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74766. */
  74767. direction: Vector3;
  74768. /**
  74769. * The transformed position. Position of the light in world space taking parenting in account.
  74770. */
  74771. transformedPosition: Vector3;
  74772. /**
  74773. * The transformed direction. Direction of the light in world space taking parenting in account.
  74774. */
  74775. transformedDirection: Vector3;
  74776. /**
  74777. * The friendly name of the light in the scene.
  74778. */
  74779. name: string;
  74780. /**
  74781. * Defines the shadow projection clipping minimum z value.
  74782. */
  74783. shadowMinZ: number;
  74784. /**
  74785. * Defines the shadow projection clipping maximum z value.
  74786. */
  74787. shadowMaxZ: number;
  74788. /**
  74789. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74790. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74791. */
  74792. computeTransformedInformation(): boolean;
  74793. /**
  74794. * Gets the scene the light belongs to.
  74795. * @returns The scene
  74796. */
  74797. getScene(): Scene;
  74798. /**
  74799. * Callback defining a custom Projection Matrix Builder.
  74800. * This can be used to override the default projection matrix computation.
  74801. */
  74802. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74803. /**
  74804. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74805. * @param matrix The materix to updated with the projection information
  74806. * @param viewMatrix The transform matrix of the light
  74807. * @param renderList The list of mesh to render in the map
  74808. * @returns The current light
  74809. */
  74810. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74811. /**
  74812. * Gets the current depth scale used in ESM.
  74813. * @returns The scale
  74814. */
  74815. getDepthScale(): number;
  74816. /**
  74817. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74818. * @returns true if a cube texture needs to be use
  74819. */
  74820. needCube(): boolean;
  74821. /**
  74822. * Detects if the projection matrix requires to be recomputed this frame.
  74823. * @returns true if it requires to be recomputed otherwise, false.
  74824. */
  74825. needProjectionMatrixCompute(): boolean;
  74826. /**
  74827. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74828. */
  74829. forceProjectionMatrixCompute(): void;
  74830. /**
  74831. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74832. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74833. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74834. */
  74835. getShadowDirection(faceIndex?: number): Vector3;
  74836. /**
  74837. * Gets the minZ used for shadow according to both the scene and the light.
  74838. * @param activeCamera The camera we are returning the min for
  74839. * @returns the depth min z
  74840. */
  74841. getDepthMinZ(activeCamera: Camera): number;
  74842. /**
  74843. * Gets the maxZ used for shadow according to both the scene and the light.
  74844. * @param activeCamera The camera we are returning the max for
  74845. * @returns the depth max z
  74846. */
  74847. getDepthMaxZ(activeCamera: Camera): number;
  74848. }
  74849. /**
  74850. * Base implementation IShadowLight
  74851. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74852. */
  74853. export abstract class ShadowLight extends Light implements IShadowLight {
  74854. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74855. protected _position: Vector3;
  74856. protected _setPosition(value: Vector3): void;
  74857. /**
  74858. * Sets the position the shadow will be casted from. Also use as the light position for both
  74859. * point and spot lights.
  74860. */
  74861. /**
  74862. * Sets the position the shadow will be casted from. Also use as the light position for both
  74863. * point and spot lights.
  74864. */
  74865. position: Vector3;
  74866. protected _direction: Vector3;
  74867. protected _setDirection(value: Vector3): void;
  74868. /**
  74869. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74870. * Also use as the light direction on spot and directional lights.
  74871. */
  74872. /**
  74873. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74874. * Also use as the light direction on spot and directional lights.
  74875. */
  74876. direction: Vector3;
  74877. private _shadowMinZ;
  74878. /**
  74879. * Gets the shadow projection clipping minimum z value.
  74880. */
  74881. /**
  74882. * Sets the shadow projection clipping minimum z value.
  74883. */
  74884. shadowMinZ: number;
  74885. private _shadowMaxZ;
  74886. /**
  74887. * Sets the shadow projection clipping maximum z value.
  74888. */
  74889. /**
  74890. * Gets the shadow projection clipping maximum z value.
  74891. */
  74892. shadowMaxZ: number;
  74893. /**
  74894. * Callback defining a custom Projection Matrix Builder.
  74895. * This can be used to override the default projection matrix computation.
  74896. */
  74897. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74898. /**
  74899. * The transformed position. Position of the light in world space taking parenting in account.
  74900. */
  74901. transformedPosition: Vector3;
  74902. /**
  74903. * The transformed direction. Direction of the light in world space taking parenting in account.
  74904. */
  74905. transformedDirection: Vector3;
  74906. private _needProjectionMatrixCompute;
  74907. /**
  74908. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74909. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74910. */
  74911. computeTransformedInformation(): boolean;
  74912. /**
  74913. * Return the depth scale used for the shadow map.
  74914. * @returns the depth scale.
  74915. */
  74916. getDepthScale(): number;
  74917. /**
  74918. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74919. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74920. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74921. */
  74922. getShadowDirection(faceIndex?: number): Vector3;
  74923. /**
  74924. * Returns the ShadowLight absolute position in the World.
  74925. * @returns the position vector in world space
  74926. */
  74927. getAbsolutePosition(): Vector3;
  74928. /**
  74929. * Sets the ShadowLight direction toward the passed target.
  74930. * @param target The point to target in local space
  74931. * @returns the updated ShadowLight direction
  74932. */
  74933. setDirectionToTarget(target: Vector3): Vector3;
  74934. /**
  74935. * Returns the light rotation in euler definition.
  74936. * @returns the x y z rotation in local space.
  74937. */
  74938. getRotation(): Vector3;
  74939. /**
  74940. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74941. * @returns true if a cube texture needs to be use
  74942. */
  74943. needCube(): boolean;
  74944. /**
  74945. * Detects if the projection matrix requires to be recomputed this frame.
  74946. * @returns true if it requires to be recomputed otherwise, false.
  74947. */
  74948. needProjectionMatrixCompute(): boolean;
  74949. /**
  74950. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74951. */
  74952. forceProjectionMatrixCompute(): void;
  74953. /** @hidden */
  74954. _initCache(): void;
  74955. /** @hidden */
  74956. _isSynchronized(): boolean;
  74957. /**
  74958. * Computes the world matrix of the node
  74959. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74960. * @returns the world matrix
  74961. */
  74962. computeWorldMatrix(force?: boolean): Matrix;
  74963. /**
  74964. * Gets the minZ used for shadow according to both the scene and the light.
  74965. * @param activeCamera The camera we are returning the min for
  74966. * @returns the depth min z
  74967. */
  74968. getDepthMinZ(activeCamera: Camera): number;
  74969. /**
  74970. * Gets the maxZ used for shadow according to both the scene and the light.
  74971. * @param activeCamera The camera we are returning the max for
  74972. * @returns the depth max z
  74973. */
  74974. getDepthMaxZ(activeCamera: Camera): number;
  74975. /**
  74976. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74977. * @param matrix The materix to updated with the projection information
  74978. * @param viewMatrix The transform matrix of the light
  74979. * @param renderList The list of mesh to render in the map
  74980. * @returns The current light
  74981. */
  74982. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74983. }
  74984. }
  74985. declare module BABYLON {
  74986. /**
  74987. * "Static Class" containing the most commonly used helper while dealing with material for
  74988. * rendering purpose.
  74989. *
  74990. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74991. *
  74992. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74993. */
  74994. export class MaterialHelper {
  74995. /**
  74996. * Bind the current view position to an effect.
  74997. * @param effect The effect to be bound
  74998. * @param scene The scene the eyes position is used from
  74999. */
  75000. static BindEyePosition(effect: Effect, scene: Scene): void;
  75001. /**
  75002. * Helps preparing the defines values about the UVs in used in the effect.
  75003. * UVs are shared as much as we can accross channels in the shaders.
  75004. * @param texture The texture we are preparing the UVs for
  75005. * @param defines The defines to update
  75006. * @param key The channel key "diffuse", "specular"... used in the shader
  75007. */
  75008. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75009. /**
  75010. * Binds a texture matrix value to its corrsponding uniform
  75011. * @param texture The texture to bind the matrix for
  75012. * @param uniformBuffer The uniform buffer receivin the data
  75013. * @param key The channel key "diffuse", "specular"... used in the shader
  75014. */
  75015. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75016. /**
  75017. * Gets the current status of the fog (should it be enabled?)
  75018. * @param mesh defines the mesh to evaluate for fog support
  75019. * @param scene defines the hosting scene
  75020. * @returns true if fog must be enabled
  75021. */
  75022. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75023. /**
  75024. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75025. * @param mesh defines the current mesh
  75026. * @param scene defines the current scene
  75027. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75028. * @param pointsCloud defines if point cloud rendering has to be turned on
  75029. * @param fogEnabled defines if fog has to be turned on
  75030. * @param alphaTest defines if alpha testing has to be turned on
  75031. * @param defines defines the current list of defines
  75032. */
  75033. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75034. /**
  75035. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75036. * @param scene defines the current scene
  75037. * @param engine defines the current engine
  75038. * @param defines specifies the list of active defines
  75039. * @param useInstances defines if instances have to be turned on
  75040. * @param useClipPlane defines if clip plane have to be turned on
  75041. */
  75042. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75043. /**
  75044. * Prepares the defines for bones
  75045. * @param mesh The mesh containing the geometry data we will draw
  75046. * @param defines The defines to update
  75047. */
  75048. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75049. /**
  75050. * Prepares the defines for morph targets
  75051. * @param mesh The mesh containing the geometry data we will draw
  75052. * @param defines The defines to update
  75053. */
  75054. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75055. /**
  75056. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75057. * @param mesh The mesh containing the geometry data we will draw
  75058. * @param defines The defines to update
  75059. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75060. * @param useBones Precise whether bones should be used or not (override mesh info)
  75061. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75062. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75063. * @returns false if defines are considered not dirty and have not been checked
  75064. */
  75065. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75066. /**
  75067. * Prepares the defines related to multiview
  75068. * @param scene The scene we are intending to draw
  75069. * @param defines The defines to update
  75070. */
  75071. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75072. /**
  75073. * Prepares the defines related to the light information passed in parameter
  75074. * @param scene The scene we are intending to draw
  75075. * @param mesh The mesh the effect is compiling for
  75076. * @param light The light the effect is compiling for
  75077. * @param lightIndex The index of the light
  75078. * @param defines The defines to update
  75079. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75080. * @param state Defines the current state regarding what is needed (normals, etc...)
  75081. */
  75082. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75083. needNormals: boolean;
  75084. needRebuild: boolean;
  75085. shadowEnabled: boolean;
  75086. specularEnabled: boolean;
  75087. lightmapMode: boolean;
  75088. }): void;
  75089. /**
  75090. * Prepares the defines related to the light information passed in parameter
  75091. * @param scene The scene we are intending to draw
  75092. * @param mesh The mesh the effect is compiling for
  75093. * @param defines The defines to update
  75094. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75095. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75096. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75097. * @returns true if normals will be required for the rest of the effect
  75098. */
  75099. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75100. /**
  75101. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75102. * @param lightIndex defines the light index
  75103. * @param uniformsList The uniform list
  75104. * @param samplersList The sampler list
  75105. * @param projectedLightTexture defines if projected texture must be used
  75106. * @param uniformBuffersList defines an optional list of uniform buffers
  75107. */
  75108. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75109. /**
  75110. * Prepares the uniforms and samplers list to be used in the effect
  75111. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75112. * @param samplersList The sampler list
  75113. * @param defines The defines helping in the list generation
  75114. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75115. */
  75116. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75117. /**
  75118. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75119. * @param defines The defines to update while falling back
  75120. * @param fallbacks The authorized effect fallbacks
  75121. * @param maxSimultaneousLights The maximum number of lights allowed
  75122. * @param rank the current rank of the Effect
  75123. * @returns The newly affected rank
  75124. */
  75125. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75126. private static _TmpMorphInfluencers;
  75127. /**
  75128. * Prepares the list of attributes required for morph targets according to the effect defines.
  75129. * @param attribs The current list of supported attribs
  75130. * @param mesh The mesh to prepare the morph targets attributes for
  75131. * @param influencers The number of influencers
  75132. */
  75133. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75134. /**
  75135. * Prepares the list of attributes required for morph targets according to the effect defines.
  75136. * @param attribs The current list of supported attribs
  75137. * @param mesh The mesh to prepare the morph targets attributes for
  75138. * @param defines The current Defines of the effect
  75139. */
  75140. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75141. /**
  75142. * Prepares the list of attributes required for bones according to the effect defines.
  75143. * @param attribs The current list of supported attribs
  75144. * @param mesh The mesh to prepare the bones attributes for
  75145. * @param defines The current Defines of the effect
  75146. * @param fallbacks The current efffect fallback strategy
  75147. */
  75148. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75149. /**
  75150. * Check and prepare the list of attributes required for instances according to the effect defines.
  75151. * @param attribs The current list of supported attribs
  75152. * @param defines The current MaterialDefines of the effect
  75153. */
  75154. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75155. /**
  75156. * Add the list of attributes required for instances to the attribs array.
  75157. * @param attribs The current list of supported attribs
  75158. */
  75159. static PushAttributesForInstances(attribs: string[]): void;
  75160. /**
  75161. * Binds the light shadow information to the effect for the given mesh.
  75162. * @param light The light containing the generator
  75163. * @param scene The scene the lights belongs to
  75164. * @param mesh The mesh we are binding the information to render
  75165. * @param lightIndex The light index in the effect used to render the mesh
  75166. * @param effect The effect we are binding the data to
  75167. */
  75168. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75169. /**
  75170. * Binds the light information to the effect.
  75171. * @param light The light containing the generator
  75172. * @param effect The effect we are binding the data to
  75173. * @param lightIndex The light index in the effect used to render
  75174. */
  75175. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75176. /**
  75177. * Binds the lights information from the scene to the effect for the given mesh.
  75178. * @param light Light to bind
  75179. * @param lightIndex Light index
  75180. * @param scene The scene where the light belongs to
  75181. * @param mesh The mesh we are binding the information to render
  75182. * @param effect The effect we are binding the data to
  75183. * @param useSpecular Defines if specular is supported
  75184. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75185. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75186. */
  75187. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75188. /**
  75189. * Binds the lights information from the scene to the effect for the given mesh.
  75190. * @param scene The scene the lights belongs to
  75191. * @param mesh The mesh we are binding the information to render
  75192. * @param effect The effect we are binding the data to
  75193. * @param defines The generated defines for the effect
  75194. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75195. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75196. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75197. */
  75198. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75199. private static _tempFogColor;
  75200. /**
  75201. * Binds the fog information from the scene to the effect for the given mesh.
  75202. * @param scene The scene the lights belongs to
  75203. * @param mesh The mesh we are binding the information to render
  75204. * @param effect The effect we are binding the data to
  75205. * @param linearSpace Defines if the fog effect is applied in linear space
  75206. */
  75207. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75208. /**
  75209. * Binds the bones information from the mesh to the effect.
  75210. * @param mesh The mesh we are binding the information to render
  75211. * @param effect The effect we are binding the data to
  75212. */
  75213. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75214. /**
  75215. * Binds the morph targets information from the mesh to the effect.
  75216. * @param abstractMesh The mesh we are binding the information to render
  75217. * @param effect The effect we are binding the data to
  75218. */
  75219. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75220. /**
  75221. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75222. * @param defines The generated defines used in the effect
  75223. * @param effect The effect we are binding the data to
  75224. * @param scene The scene we are willing to render with logarithmic scale for
  75225. */
  75226. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75227. /**
  75228. * Binds the clip plane information from the scene to the effect.
  75229. * @param scene The scene the clip plane information are extracted from
  75230. * @param effect The effect we are binding the data to
  75231. */
  75232. static BindClipPlane(effect: Effect, scene: Scene): void;
  75233. }
  75234. }
  75235. declare module BABYLON {
  75236. /** @hidden */
  75237. export var packingFunctions: {
  75238. name: string;
  75239. shader: string;
  75240. };
  75241. }
  75242. declare module BABYLON {
  75243. /** @hidden */
  75244. export var shadowMapPixelShader: {
  75245. name: string;
  75246. shader: string;
  75247. };
  75248. }
  75249. declare module BABYLON {
  75250. /** @hidden */
  75251. export var bonesDeclaration: {
  75252. name: string;
  75253. shader: string;
  75254. };
  75255. }
  75256. declare module BABYLON {
  75257. /** @hidden */
  75258. export var morphTargetsVertexGlobalDeclaration: {
  75259. name: string;
  75260. shader: string;
  75261. };
  75262. }
  75263. declare module BABYLON {
  75264. /** @hidden */
  75265. export var morphTargetsVertexDeclaration: {
  75266. name: string;
  75267. shader: string;
  75268. };
  75269. }
  75270. declare module BABYLON {
  75271. /** @hidden */
  75272. export var instancesDeclaration: {
  75273. name: string;
  75274. shader: string;
  75275. };
  75276. }
  75277. declare module BABYLON {
  75278. /** @hidden */
  75279. export var helperFunctions: {
  75280. name: string;
  75281. shader: string;
  75282. };
  75283. }
  75284. declare module BABYLON {
  75285. /** @hidden */
  75286. export var morphTargetsVertex: {
  75287. name: string;
  75288. shader: string;
  75289. };
  75290. }
  75291. declare module BABYLON {
  75292. /** @hidden */
  75293. export var instancesVertex: {
  75294. name: string;
  75295. shader: string;
  75296. };
  75297. }
  75298. declare module BABYLON {
  75299. /** @hidden */
  75300. export var bonesVertex: {
  75301. name: string;
  75302. shader: string;
  75303. };
  75304. }
  75305. declare module BABYLON {
  75306. /** @hidden */
  75307. export var shadowMapVertexShader: {
  75308. name: string;
  75309. shader: string;
  75310. };
  75311. }
  75312. declare module BABYLON {
  75313. /** @hidden */
  75314. export var depthBoxBlurPixelShader: {
  75315. name: string;
  75316. shader: string;
  75317. };
  75318. }
  75319. declare module BABYLON {
  75320. /**
  75321. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75322. */
  75323. export interface ICustomShaderOptions {
  75324. /**
  75325. * Gets or sets the custom shader name to use
  75326. */
  75327. shaderName: string;
  75328. /**
  75329. * The list of attribute names used in the shader
  75330. */
  75331. attributes?: string[];
  75332. /**
  75333. * The list of unifrom names used in the shader
  75334. */
  75335. uniforms?: string[];
  75336. /**
  75337. * The list of sampler names used in the shader
  75338. */
  75339. samplers?: string[];
  75340. /**
  75341. * The list of defines used in the shader
  75342. */
  75343. defines?: string[];
  75344. }
  75345. /**
  75346. * Interface to implement to create a shadow generator compatible with BJS.
  75347. */
  75348. export interface IShadowGenerator {
  75349. /**
  75350. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75351. * @returns The render target texture if present otherwise, null
  75352. */
  75353. getShadowMap(): Nullable<RenderTargetTexture>;
  75354. /**
  75355. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75356. * @returns The render target texture if the shadow map is present otherwise, null
  75357. */
  75358. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75359. /**
  75360. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75361. * @param subMesh The submesh we want to render in the shadow map
  75362. * @param useInstances Defines wether will draw in the map using instances
  75363. * @returns true if ready otherwise, false
  75364. */
  75365. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75366. /**
  75367. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75368. * @param defines Defines of the material we want to update
  75369. * @param lightIndex Index of the light in the enabled light list of the material
  75370. */
  75371. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75372. /**
  75373. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75374. * defined in the generator but impacting the effect).
  75375. * It implies the unifroms available on the materials are the standard BJS ones.
  75376. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75377. * @param effect The effect we are binfing the information for
  75378. */
  75379. bindShadowLight(lightIndex: string, effect: Effect): void;
  75380. /**
  75381. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75382. * (eq to shadow prjection matrix * light transform matrix)
  75383. * @returns The transform matrix used to create the shadow map
  75384. */
  75385. getTransformMatrix(): Matrix;
  75386. /**
  75387. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75388. * Cube and 2D textures for instance.
  75389. */
  75390. recreateShadowMap(): void;
  75391. /**
  75392. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75393. * @param onCompiled Callback triggered at the and of the effects compilation
  75394. * @param options Sets of optional options forcing the compilation with different modes
  75395. */
  75396. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75397. useInstances: boolean;
  75398. }>): void;
  75399. /**
  75400. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75401. * @param options Sets of optional options forcing the compilation with different modes
  75402. * @returns A promise that resolves when the compilation completes
  75403. */
  75404. forceCompilationAsync(options?: Partial<{
  75405. useInstances: boolean;
  75406. }>): Promise<void>;
  75407. /**
  75408. * Serializes the shadow generator setup to a json object.
  75409. * @returns The serialized JSON object
  75410. */
  75411. serialize(): any;
  75412. /**
  75413. * Disposes the Shadow map and related Textures and effects.
  75414. */
  75415. dispose(): void;
  75416. }
  75417. /**
  75418. * Default implementation IShadowGenerator.
  75419. * This is the main object responsible of generating shadows in the framework.
  75420. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75421. */
  75422. export class ShadowGenerator implements IShadowGenerator {
  75423. /**
  75424. * Shadow generator mode None: no filtering applied.
  75425. */
  75426. static readonly FILTER_NONE: number;
  75427. /**
  75428. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75429. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75430. */
  75431. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75432. /**
  75433. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75434. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75435. */
  75436. static readonly FILTER_POISSONSAMPLING: number;
  75437. /**
  75438. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75439. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75440. */
  75441. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75442. /**
  75443. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75444. * edge artifacts on steep falloff.
  75445. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75446. */
  75447. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75448. /**
  75449. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75450. * edge artifacts on steep falloff.
  75451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75452. */
  75453. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75454. /**
  75455. * Shadow generator mode PCF: Percentage Closer Filtering
  75456. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75457. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75458. */
  75459. static readonly FILTER_PCF: number;
  75460. /**
  75461. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75462. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75463. * Contact Hardening
  75464. */
  75465. static readonly FILTER_PCSS: number;
  75466. /**
  75467. * Reserved for PCF and PCSS
  75468. * Highest Quality.
  75469. *
  75470. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75471. *
  75472. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75473. */
  75474. static readonly QUALITY_HIGH: number;
  75475. /**
  75476. * Reserved for PCF and PCSS
  75477. * Good tradeoff for quality/perf cross devices
  75478. *
  75479. * Execute PCF on a 3*3 kernel.
  75480. *
  75481. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75482. */
  75483. static readonly QUALITY_MEDIUM: number;
  75484. /**
  75485. * Reserved for PCF and PCSS
  75486. * The lowest quality but the fastest.
  75487. *
  75488. * Execute PCF on a 1*1 kernel.
  75489. *
  75490. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75491. */
  75492. static readonly QUALITY_LOW: number;
  75493. /** Gets or sets the custom shader name to use */
  75494. customShaderOptions: ICustomShaderOptions;
  75495. /**
  75496. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75497. */
  75498. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75499. /**
  75500. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75501. */
  75502. onAfterShadowMapRenderObservable: Observable<Effect>;
  75503. /**
  75504. * Observable triggered before a mesh is rendered in the shadow map.
  75505. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75506. */
  75507. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75508. /**
  75509. * Observable triggered after a mesh is rendered in the shadow map.
  75510. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75511. */
  75512. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75513. private _bias;
  75514. /**
  75515. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75516. */
  75517. /**
  75518. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75519. */
  75520. bias: number;
  75521. private _normalBias;
  75522. /**
  75523. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75524. */
  75525. /**
  75526. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75527. */
  75528. normalBias: number;
  75529. private _blurBoxOffset;
  75530. /**
  75531. * Gets the blur box offset: offset applied during the blur pass.
  75532. * Only useful if useKernelBlur = false
  75533. */
  75534. /**
  75535. * Sets the blur box offset: offset applied during the blur pass.
  75536. * Only useful if useKernelBlur = false
  75537. */
  75538. blurBoxOffset: number;
  75539. private _blurScale;
  75540. /**
  75541. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75542. * 2 means half of the size.
  75543. */
  75544. /**
  75545. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75546. * 2 means half of the size.
  75547. */
  75548. blurScale: number;
  75549. private _blurKernel;
  75550. /**
  75551. * Gets the blur kernel: kernel size of the blur pass.
  75552. * Only useful if useKernelBlur = true
  75553. */
  75554. /**
  75555. * Sets the blur kernel: kernel size of the blur pass.
  75556. * Only useful if useKernelBlur = true
  75557. */
  75558. blurKernel: number;
  75559. private _useKernelBlur;
  75560. /**
  75561. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75562. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75563. */
  75564. /**
  75565. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75566. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75567. */
  75568. useKernelBlur: boolean;
  75569. private _depthScale;
  75570. /**
  75571. * Gets the depth scale used in ESM mode.
  75572. */
  75573. /**
  75574. * Sets the depth scale used in ESM mode.
  75575. * This can override the scale stored on the light.
  75576. */
  75577. depthScale: number;
  75578. private _filter;
  75579. /**
  75580. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75581. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75582. */
  75583. /**
  75584. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75585. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75586. */
  75587. filter: number;
  75588. /**
  75589. * Gets if the current filter is set to Poisson Sampling.
  75590. */
  75591. /**
  75592. * Sets the current filter to Poisson Sampling.
  75593. */
  75594. usePoissonSampling: boolean;
  75595. /**
  75596. * Gets if the current filter is set to ESM.
  75597. */
  75598. /**
  75599. * Sets the current filter is to ESM.
  75600. */
  75601. useExponentialShadowMap: boolean;
  75602. /**
  75603. * Gets if the current filter is set to filtered ESM.
  75604. */
  75605. /**
  75606. * Gets if the current filter is set to filtered ESM.
  75607. */
  75608. useBlurExponentialShadowMap: boolean;
  75609. /**
  75610. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75611. * exponential to prevent steep falloff artifacts).
  75612. */
  75613. /**
  75614. * Sets the current filter to "close ESM" (using the inverse of the
  75615. * exponential to prevent steep falloff artifacts).
  75616. */
  75617. useCloseExponentialShadowMap: boolean;
  75618. /**
  75619. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75620. * exponential to prevent steep falloff artifacts).
  75621. */
  75622. /**
  75623. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75624. * exponential to prevent steep falloff artifacts).
  75625. */
  75626. useBlurCloseExponentialShadowMap: boolean;
  75627. /**
  75628. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75629. */
  75630. /**
  75631. * Sets the current filter to "PCF" (percentage closer filtering).
  75632. */
  75633. usePercentageCloserFiltering: boolean;
  75634. private _filteringQuality;
  75635. /**
  75636. * Gets the PCF or PCSS Quality.
  75637. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75638. */
  75639. /**
  75640. * Sets the PCF or PCSS Quality.
  75641. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75642. */
  75643. filteringQuality: number;
  75644. /**
  75645. * Gets if the current filter is set to "PCSS" (contact hardening).
  75646. */
  75647. /**
  75648. * Sets the current filter to "PCSS" (contact hardening).
  75649. */
  75650. useContactHardeningShadow: boolean;
  75651. private _contactHardeningLightSizeUVRatio;
  75652. /**
  75653. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75654. * Using a ratio helps keeping shape stability independently of the map size.
  75655. *
  75656. * It does not account for the light projection as it was having too much
  75657. * instability during the light setup or during light position changes.
  75658. *
  75659. * Only valid if useContactHardeningShadow is true.
  75660. */
  75661. /**
  75662. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75663. * Using a ratio helps keeping shape stability independently of the map size.
  75664. *
  75665. * It does not account for the light projection as it was having too much
  75666. * instability during the light setup or during light position changes.
  75667. *
  75668. * Only valid if useContactHardeningShadow is true.
  75669. */
  75670. contactHardeningLightSizeUVRatio: number;
  75671. private _darkness;
  75672. /** Gets or sets the actual darkness of a shadow */
  75673. darkness: number;
  75674. /**
  75675. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75676. * 0 means strongest and 1 would means no shadow.
  75677. * @returns the darkness.
  75678. */
  75679. getDarkness(): number;
  75680. /**
  75681. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75682. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75683. * @returns the shadow generator allowing fluent coding.
  75684. */
  75685. setDarkness(darkness: number): ShadowGenerator;
  75686. private _transparencyShadow;
  75687. /** Gets or sets the ability to have transparent shadow */
  75688. transparencyShadow: boolean;
  75689. /**
  75690. * Sets the ability to have transparent shadow (boolean).
  75691. * @param transparent True if transparent else False
  75692. * @returns the shadow generator allowing fluent coding
  75693. */
  75694. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75695. private _shadowMap;
  75696. private _shadowMap2;
  75697. /**
  75698. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75699. * @returns The render target texture if present otherwise, null
  75700. */
  75701. getShadowMap(): Nullable<RenderTargetTexture>;
  75702. /**
  75703. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75704. * @returns The render target texture if the shadow map is present otherwise, null
  75705. */
  75706. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75707. /**
  75708. * Gets the class name of that object
  75709. * @returns "ShadowGenerator"
  75710. */
  75711. getClassName(): string;
  75712. /**
  75713. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75714. * @param mesh Mesh to add
  75715. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75716. * @returns the Shadow Generator itself
  75717. */
  75718. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75719. /**
  75720. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75721. * @param mesh Mesh to remove
  75722. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75723. * @returns the Shadow Generator itself
  75724. */
  75725. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75726. /**
  75727. * Controls the extent to which the shadows fade out at the edge of the frustum
  75728. * Used only by directionals and spots
  75729. */
  75730. frustumEdgeFalloff: number;
  75731. private _light;
  75732. /**
  75733. * Returns the associated light object.
  75734. * @returns the light generating the shadow
  75735. */
  75736. getLight(): IShadowLight;
  75737. /**
  75738. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75739. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75740. * It might on the other hand introduce peter panning.
  75741. */
  75742. forceBackFacesOnly: boolean;
  75743. private _scene;
  75744. private _lightDirection;
  75745. private _effect;
  75746. private _viewMatrix;
  75747. private _projectionMatrix;
  75748. private _transformMatrix;
  75749. private _cachedPosition;
  75750. private _cachedDirection;
  75751. private _cachedDefines;
  75752. private _currentRenderID;
  75753. private _boxBlurPostprocess;
  75754. private _kernelBlurXPostprocess;
  75755. private _kernelBlurYPostprocess;
  75756. private _blurPostProcesses;
  75757. private _mapSize;
  75758. private _currentFaceIndex;
  75759. private _currentFaceIndexCache;
  75760. private _textureType;
  75761. private _defaultTextureMatrix;
  75762. /** @hidden */
  75763. static _SceneComponentInitialization: (scene: Scene) => void;
  75764. /**
  75765. * Creates a ShadowGenerator object.
  75766. * A ShadowGenerator is the required tool to use the shadows.
  75767. * Each light casting shadows needs to use its own ShadowGenerator.
  75768. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75769. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75770. * @param light The light object generating the shadows.
  75771. * @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.
  75772. */
  75773. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75774. private _initializeGenerator;
  75775. private _initializeShadowMap;
  75776. private _initializeBlurRTTAndPostProcesses;
  75777. private _renderForShadowMap;
  75778. private _renderSubMeshForShadowMap;
  75779. private _applyFilterValues;
  75780. /**
  75781. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75782. * @param onCompiled Callback triggered at the and of the effects compilation
  75783. * @param options Sets of optional options forcing the compilation with different modes
  75784. */
  75785. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75786. useInstances: boolean;
  75787. }>): void;
  75788. /**
  75789. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75790. * @param options Sets of optional options forcing the compilation with different modes
  75791. * @returns A promise that resolves when the compilation completes
  75792. */
  75793. forceCompilationAsync(options?: Partial<{
  75794. useInstances: boolean;
  75795. }>): Promise<void>;
  75796. /**
  75797. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75798. * @param subMesh The submesh we want to render in the shadow map
  75799. * @param useInstances Defines wether will draw in the map using instances
  75800. * @returns true if ready otherwise, false
  75801. */
  75802. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75803. /**
  75804. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75805. * @param defines Defines of the material we want to update
  75806. * @param lightIndex Index of the light in the enabled light list of the material
  75807. */
  75808. prepareDefines(defines: any, lightIndex: number): void;
  75809. /**
  75810. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75811. * defined in the generator but impacting the effect).
  75812. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75813. * @param effect The effect we are binfing the information for
  75814. */
  75815. bindShadowLight(lightIndex: string, effect: Effect): void;
  75816. /**
  75817. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75818. * (eq to shadow prjection matrix * light transform matrix)
  75819. * @returns The transform matrix used to create the shadow map
  75820. */
  75821. getTransformMatrix(): Matrix;
  75822. /**
  75823. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75824. * Cube and 2D textures for instance.
  75825. */
  75826. recreateShadowMap(): void;
  75827. private _disposeBlurPostProcesses;
  75828. private _disposeRTTandPostProcesses;
  75829. /**
  75830. * Disposes the ShadowGenerator.
  75831. * Returns nothing.
  75832. */
  75833. dispose(): void;
  75834. /**
  75835. * Serializes the shadow generator setup to a json object.
  75836. * @returns The serialized JSON object
  75837. */
  75838. serialize(): any;
  75839. /**
  75840. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75841. * @param parsedShadowGenerator The JSON object to parse
  75842. * @param scene The scene to create the shadow map for
  75843. * @returns The parsed shadow generator
  75844. */
  75845. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75846. }
  75847. }
  75848. declare module BABYLON {
  75849. /**
  75850. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75851. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75852. * 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.
  75853. */
  75854. export abstract class Light extends Node {
  75855. /**
  75856. * Falloff Default: light is falling off following the material specification:
  75857. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75858. */
  75859. static readonly FALLOFF_DEFAULT: number;
  75860. /**
  75861. * Falloff Physical: light is falling off following the inverse squared distance law.
  75862. */
  75863. static readonly FALLOFF_PHYSICAL: number;
  75864. /**
  75865. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75866. * to enhance interoperability with other engines.
  75867. */
  75868. static readonly FALLOFF_GLTF: number;
  75869. /**
  75870. * Falloff Standard: light is falling off like in the standard material
  75871. * to enhance interoperability with other materials.
  75872. */
  75873. static readonly FALLOFF_STANDARD: number;
  75874. /**
  75875. * If every light affecting the material is in this lightmapMode,
  75876. * material.lightmapTexture adds or multiplies
  75877. * (depends on material.useLightmapAsShadowmap)
  75878. * after every other light calculations.
  75879. */
  75880. static readonly LIGHTMAP_DEFAULT: number;
  75881. /**
  75882. * material.lightmapTexture as only diffuse lighting from this light
  75883. * adds only specular lighting from this light
  75884. * adds dynamic shadows
  75885. */
  75886. static readonly LIGHTMAP_SPECULAR: number;
  75887. /**
  75888. * material.lightmapTexture as only lighting
  75889. * no light calculation from this light
  75890. * only adds dynamic shadows from this light
  75891. */
  75892. static readonly LIGHTMAP_SHADOWSONLY: number;
  75893. /**
  75894. * Each light type uses the default quantity according to its type:
  75895. * point/spot lights use luminous intensity
  75896. * directional lights use illuminance
  75897. */
  75898. static readonly INTENSITYMODE_AUTOMATIC: number;
  75899. /**
  75900. * lumen (lm)
  75901. */
  75902. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75903. /**
  75904. * candela (lm/sr)
  75905. */
  75906. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75907. /**
  75908. * lux (lm/m^2)
  75909. */
  75910. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75911. /**
  75912. * nit (cd/m^2)
  75913. */
  75914. static readonly INTENSITYMODE_LUMINANCE: number;
  75915. /**
  75916. * Light type const id of the point light.
  75917. */
  75918. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75919. /**
  75920. * Light type const id of the directional light.
  75921. */
  75922. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75923. /**
  75924. * Light type const id of the spot light.
  75925. */
  75926. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75927. /**
  75928. * Light type const id of the hemispheric light.
  75929. */
  75930. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75931. /**
  75932. * Diffuse gives the basic color to an object.
  75933. */
  75934. diffuse: Color3;
  75935. /**
  75936. * Specular produces a highlight color on an object.
  75937. * Note: This is note affecting PBR materials.
  75938. */
  75939. specular: Color3;
  75940. /**
  75941. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75942. * falling off base on range or angle.
  75943. * This can be set to any values in Light.FALLOFF_x.
  75944. *
  75945. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75946. * other types of materials.
  75947. */
  75948. falloffType: number;
  75949. /**
  75950. * Strength of the light.
  75951. * Note: By default it is define in the framework own unit.
  75952. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75953. */
  75954. intensity: number;
  75955. private _range;
  75956. protected _inverseSquaredRange: number;
  75957. /**
  75958. * Defines how far from the source the light is impacting in scene units.
  75959. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75960. */
  75961. /**
  75962. * Defines how far from the source the light is impacting in scene units.
  75963. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75964. */
  75965. range: number;
  75966. /**
  75967. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75968. * of light.
  75969. */
  75970. private _photometricScale;
  75971. private _intensityMode;
  75972. /**
  75973. * Gets the photometric scale used to interpret the intensity.
  75974. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75975. */
  75976. /**
  75977. * Sets the photometric scale used to interpret the intensity.
  75978. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75979. */
  75980. intensityMode: number;
  75981. private _radius;
  75982. /**
  75983. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75984. */
  75985. /**
  75986. * sets the light radius used by PBR Materials to simulate soft area lights.
  75987. */
  75988. radius: number;
  75989. private _renderPriority;
  75990. /**
  75991. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75992. * exceeding the number allowed of the materials.
  75993. */
  75994. renderPriority: number;
  75995. private _shadowEnabled;
  75996. /**
  75997. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75998. * the current shadow generator.
  75999. */
  76000. /**
  76001. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76002. * the current shadow generator.
  76003. */
  76004. shadowEnabled: boolean;
  76005. private _includedOnlyMeshes;
  76006. /**
  76007. * Gets the only meshes impacted by this light.
  76008. */
  76009. /**
  76010. * Sets the only meshes impacted by this light.
  76011. */
  76012. includedOnlyMeshes: AbstractMesh[];
  76013. private _excludedMeshes;
  76014. /**
  76015. * Gets the meshes not impacted by this light.
  76016. */
  76017. /**
  76018. * Sets the meshes not impacted by this light.
  76019. */
  76020. excludedMeshes: AbstractMesh[];
  76021. private _excludeWithLayerMask;
  76022. /**
  76023. * Gets the layer id use to find what meshes are not impacted by the light.
  76024. * Inactive if 0
  76025. */
  76026. /**
  76027. * Sets the layer id use to find what meshes are not impacted by the light.
  76028. * Inactive if 0
  76029. */
  76030. excludeWithLayerMask: number;
  76031. private _includeOnlyWithLayerMask;
  76032. /**
  76033. * Gets the layer id use to find what meshes are impacted by the light.
  76034. * Inactive if 0
  76035. */
  76036. /**
  76037. * Sets the layer id use to find what meshes are impacted by the light.
  76038. * Inactive if 0
  76039. */
  76040. includeOnlyWithLayerMask: number;
  76041. private _lightmapMode;
  76042. /**
  76043. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76044. */
  76045. /**
  76046. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76047. */
  76048. lightmapMode: number;
  76049. /**
  76050. * Shadow generator associted to the light.
  76051. * @hidden Internal use only.
  76052. */
  76053. _shadowGenerator: Nullable<IShadowGenerator>;
  76054. /**
  76055. * @hidden Internal use only.
  76056. */
  76057. _excludedMeshesIds: string[];
  76058. /**
  76059. * @hidden Internal use only.
  76060. */
  76061. _includedOnlyMeshesIds: string[];
  76062. /**
  76063. * The current light unifom buffer.
  76064. * @hidden Internal use only.
  76065. */
  76066. _uniformBuffer: UniformBuffer;
  76067. /**
  76068. * Creates a Light object in the scene.
  76069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76070. * @param name The firendly name of the light
  76071. * @param scene The scene the light belongs too
  76072. */
  76073. constructor(name: string, scene: Scene);
  76074. protected abstract _buildUniformLayout(): void;
  76075. /**
  76076. * Sets the passed Effect "effect" with the Light information.
  76077. * @param effect The effect to update
  76078. * @param lightIndex The index of the light in the effect to update
  76079. * @returns The light
  76080. */
  76081. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76082. /**
  76083. * Sets the passed Effect "effect" with the Light information.
  76084. * @param effect The effect to update
  76085. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76086. * @returns The light
  76087. */
  76088. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76089. /**
  76090. * Returns the string "Light".
  76091. * @returns the class name
  76092. */
  76093. getClassName(): string;
  76094. /** @hidden */
  76095. readonly _isLight: boolean;
  76096. /**
  76097. * Converts the light information to a readable string for debug purpose.
  76098. * @param fullDetails Supports for multiple levels of logging within scene loading
  76099. * @returns the human readable light info
  76100. */
  76101. toString(fullDetails?: boolean): string;
  76102. /** @hidden */
  76103. protected _syncParentEnabledState(): void;
  76104. /**
  76105. * Set the enabled state of this node.
  76106. * @param value - the new enabled state
  76107. */
  76108. setEnabled(value: boolean): void;
  76109. /**
  76110. * Returns the Light associated shadow generator if any.
  76111. * @return the associated shadow generator.
  76112. */
  76113. getShadowGenerator(): Nullable<IShadowGenerator>;
  76114. /**
  76115. * Returns a Vector3, the absolute light position in the World.
  76116. * @returns the world space position of the light
  76117. */
  76118. getAbsolutePosition(): Vector3;
  76119. /**
  76120. * Specifies if the light will affect the passed mesh.
  76121. * @param mesh The mesh to test against the light
  76122. * @return true the mesh is affected otherwise, false.
  76123. */
  76124. canAffectMesh(mesh: AbstractMesh): boolean;
  76125. /**
  76126. * Sort function to order lights for rendering.
  76127. * @param a First Light object to compare to second.
  76128. * @param b Second Light object to compare first.
  76129. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76130. */
  76131. static CompareLightsPriority(a: Light, b: Light): number;
  76132. /**
  76133. * Releases resources associated with this node.
  76134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76136. */
  76137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76138. /**
  76139. * Returns the light type ID (integer).
  76140. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76141. */
  76142. getTypeID(): number;
  76143. /**
  76144. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76145. * @returns the scaled intensity in intensity mode unit
  76146. */
  76147. getScaledIntensity(): number;
  76148. /**
  76149. * Returns a new Light object, named "name", from the current one.
  76150. * @param name The name of the cloned light
  76151. * @returns the new created light
  76152. */
  76153. clone(name: string): Nullable<Light>;
  76154. /**
  76155. * Serializes the current light into a Serialization object.
  76156. * @returns the serialized object.
  76157. */
  76158. serialize(): any;
  76159. /**
  76160. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76161. * This new light is named "name" and added to the passed scene.
  76162. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76163. * @param name The friendly name of the light
  76164. * @param scene The scene the new light will belong to
  76165. * @returns the constructor function
  76166. */
  76167. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76168. /**
  76169. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76170. * @param parsedLight The JSON representation of the light
  76171. * @param scene The scene to create the parsed light in
  76172. * @returns the created light after parsing
  76173. */
  76174. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76175. private _hookArrayForExcluded;
  76176. private _hookArrayForIncludedOnly;
  76177. private _resyncMeshes;
  76178. /**
  76179. * Forces the meshes to update their light related information in their rendering used effects
  76180. * @hidden Internal Use Only
  76181. */
  76182. _markMeshesAsLightDirty(): void;
  76183. /**
  76184. * Recomputes the cached photometric scale if needed.
  76185. */
  76186. private _computePhotometricScale;
  76187. /**
  76188. * Returns the Photometric Scale according to the light type and intensity mode.
  76189. */
  76190. private _getPhotometricScale;
  76191. /**
  76192. * Reorder the light in the scene according to their defined priority.
  76193. * @hidden Internal Use Only
  76194. */
  76195. _reorderLightsInScene(): void;
  76196. /**
  76197. * Prepares the list of defines specific to the light type.
  76198. * @param defines the list of defines
  76199. * @param lightIndex defines the index of the light for the effect
  76200. */
  76201. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76202. }
  76203. }
  76204. declare module BABYLON {
  76205. /**
  76206. * Interface used to define Action
  76207. */
  76208. export interface IAction {
  76209. /**
  76210. * Trigger for the action
  76211. */
  76212. trigger: number;
  76213. /** Options of the trigger */
  76214. triggerOptions: any;
  76215. /**
  76216. * Gets the trigger parameters
  76217. * @returns the trigger parameters
  76218. */
  76219. getTriggerParameter(): any;
  76220. /**
  76221. * Internal only - executes current action event
  76222. * @hidden
  76223. */
  76224. _executeCurrent(evt?: ActionEvent): void;
  76225. /**
  76226. * Serialize placeholder for child classes
  76227. * @param parent of child
  76228. * @returns the serialized object
  76229. */
  76230. serialize(parent: any): any;
  76231. /**
  76232. * Internal only
  76233. * @hidden
  76234. */
  76235. _prepare(): void;
  76236. /**
  76237. * Internal only - manager for action
  76238. * @hidden
  76239. */
  76240. _actionManager: AbstractActionManager;
  76241. /**
  76242. * Adds action to chain of actions, may be a DoNothingAction
  76243. * @param action defines the next action to execute
  76244. * @returns The action passed in
  76245. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76246. */
  76247. then(action: IAction): IAction;
  76248. }
  76249. /**
  76250. * The action to be carried out following a trigger
  76251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76252. */
  76253. export class Action implements IAction {
  76254. /** the trigger, with or without parameters, for the action */
  76255. triggerOptions: any;
  76256. /**
  76257. * Trigger for the action
  76258. */
  76259. trigger: number;
  76260. /**
  76261. * Internal only - manager for action
  76262. * @hidden
  76263. */
  76264. _actionManager: ActionManager;
  76265. private _nextActiveAction;
  76266. private _child;
  76267. private _condition?;
  76268. private _triggerParameter;
  76269. /**
  76270. * An event triggered prior to action being executed.
  76271. */
  76272. onBeforeExecuteObservable: Observable<Action>;
  76273. /**
  76274. * Creates a new Action
  76275. * @param triggerOptions the trigger, with or without parameters, for the action
  76276. * @param condition an optional determinant of action
  76277. */
  76278. constructor(
  76279. /** the trigger, with or without parameters, for the action */
  76280. triggerOptions: any, condition?: Condition);
  76281. /**
  76282. * Internal only
  76283. * @hidden
  76284. */
  76285. _prepare(): void;
  76286. /**
  76287. * Gets the trigger parameters
  76288. * @returns the trigger parameters
  76289. */
  76290. getTriggerParameter(): any;
  76291. /**
  76292. * Internal only - executes current action event
  76293. * @hidden
  76294. */
  76295. _executeCurrent(evt?: ActionEvent): void;
  76296. /**
  76297. * Execute placeholder for child classes
  76298. * @param evt optional action event
  76299. */
  76300. execute(evt?: ActionEvent): void;
  76301. /**
  76302. * Skips to next active action
  76303. */
  76304. skipToNextActiveAction(): void;
  76305. /**
  76306. * Adds action to chain of actions, may be a DoNothingAction
  76307. * @param action defines the next action to execute
  76308. * @returns The action passed in
  76309. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76310. */
  76311. then(action: Action): Action;
  76312. /**
  76313. * Internal only
  76314. * @hidden
  76315. */
  76316. _getProperty(propertyPath: string): string;
  76317. /**
  76318. * Internal only
  76319. * @hidden
  76320. */
  76321. _getEffectiveTarget(target: any, propertyPath: string): any;
  76322. /**
  76323. * Serialize placeholder for child classes
  76324. * @param parent of child
  76325. * @returns the serialized object
  76326. */
  76327. serialize(parent: any): any;
  76328. /**
  76329. * Internal only called by serialize
  76330. * @hidden
  76331. */
  76332. protected _serialize(serializedAction: any, parent?: any): any;
  76333. /**
  76334. * Internal only
  76335. * @hidden
  76336. */
  76337. static _SerializeValueAsString: (value: any) => string;
  76338. /**
  76339. * Internal only
  76340. * @hidden
  76341. */
  76342. static _GetTargetProperty: (target: Node | Scene) => {
  76343. name: string;
  76344. targetType: string;
  76345. value: string;
  76346. };
  76347. }
  76348. }
  76349. declare module BABYLON {
  76350. /**
  76351. * A Condition applied to an Action
  76352. */
  76353. export class Condition {
  76354. /**
  76355. * Internal only - manager for action
  76356. * @hidden
  76357. */
  76358. _actionManager: ActionManager;
  76359. /**
  76360. * Internal only
  76361. * @hidden
  76362. */
  76363. _evaluationId: number;
  76364. /**
  76365. * Internal only
  76366. * @hidden
  76367. */
  76368. _currentResult: boolean;
  76369. /**
  76370. * Creates a new Condition
  76371. * @param actionManager the manager of the action the condition is applied to
  76372. */
  76373. constructor(actionManager: ActionManager);
  76374. /**
  76375. * Check if the current condition is valid
  76376. * @returns a boolean
  76377. */
  76378. isValid(): boolean;
  76379. /**
  76380. * Internal only
  76381. * @hidden
  76382. */
  76383. _getProperty(propertyPath: string): string;
  76384. /**
  76385. * Internal only
  76386. * @hidden
  76387. */
  76388. _getEffectiveTarget(target: any, propertyPath: string): any;
  76389. /**
  76390. * Serialize placeholder for child classes
  76391. * @returns the serialized object
  76392. */
  76393. serialize(): any;
  76394. /**
  76395. * Internal only
  76396. * @hidden
  76397. */
  76398. protected _serialize(serializedCondition: any): any;
  76399. }
  76400. /**
  76401. * Defines specific conditional operators as extensions of Condition
  76402. */
  76403. export class ValueCondition extends Condition {
  76404. /** path to specify the property of the target the conditional operator uses */
  76405. propertyPath: string;
  76406. /** the value compared by the conditional operator against the current value of the property */
  76407. value: any;
  76408. /** the conditional operator, default ValueCondition.IsEqual */
  76409. operator: number;
  76410. /**
  76411. * Internal only
  76412. * @hidden
  76413. */
  76414. private static _IsEqual;
  76415. /**
  76416. * Internal only
  76417. * @hidden
  76418. */
  76419. private static _IsDifferent;
  76420. /**
  76421. * Internal only
  76422. * @hidden
  76423. */
  76424. private static _IsGreater;
  76425. /**
  76426. * Internal only
  76427. * @hidden
  76428. */
  76429. private static _IsLesser;
  76430. /**
  76431. * returns the number for IsEqual
  76432. */
  76433. static readonly IsEqual: number;
  76434. /**
  76435. * Returns the number for IsDifferent
  76436. */
  76437. static readonly IsDifferent: number;
  76438. /**
  76439. * Returns the number for IsGreater
  76440. */
  76441. static readonly IsGreater: number;
  76442. /**
  76443. * Returns the number for IsLesser
  76444. */
  76445. static readonly IsLesser: number;
  76446. /**
  76447. * Internal only The action manager for the condition
  76448. * @hidden
  76449. */
  76450. _actionManager: ActionManager;
  76451. /**
  76452. * Internal only
  76453. * @hidden
  76454. */
  76455. private _target;
  76456. /**
  76457. * Internal only
  76458. * @hidden
  76459. */
  76460. private _effectiveTarget;
  76461. /**
  76462. * Internal only
  76463. * @hidden
  76464. */
  76465. private _property;
  76466. /**
  76467. * Creates a new ValueCondition
  76468. * @param actionManager manager for the action the condition applies to
  76469. * @param target for the action
  76470. * @param propertyPath path to specify the property of the target the conditional operator uses
  76471. * @param value the value compared by the conditional operator against the current value of the property
  76472. * @param operator the conditional operator, default ValueCondition.IsEqual
  76473. */
  76474. constructor(actionManager: ActionManager, target: any,
  76475. /** path to specify the property of the target the conditional operator uses */
  76476. propertyPath: string,
  76477. /** the value compared by the conditional operator against the current value of the property */
  76478. value: any,
  76479. /** the conditional operator, default ValueCondition.IsEqual */
  76480. operator?: number);
  76481. /**
  76482. * Compares the given value with the property value for the specified conditional operator
  76483. * @returns the result of the comparison
  76484. */
  76485. isValid(): boolean;
  76486. /**
  76487. * Serialize the ValueCondition into a JSON compatible object
  76488. * @returns serialization object
  76489. */
  76490. serialize(): any;
  76491. /**
  76492. * Gets the name of the conditional operator for the ValueCondition
  76493. * @param operator the conditional operator
  76494. * @returns the name
  76495. */
  76496. static GetOperatorName(operator: number): string;
  76497. }
  76498. /**
  76499. * Defines a predicate condition as an extension of Condition
  76500. */
  76501. export class PredicateCondition extends Condition {
  76502. /** defines the predicate function used to validate the condition */
  76503. predicate: () => boolean;
  76504. /**
  76505. * Internal only - manager for action
  76506. * @hidden
  76507. */
  76508. _actionManager: ActionManager;
  76509. /**
  76510. * Creates a new PredicateCondition
  76511. * @param actionManager manager for the action the condition applies to
  76512. * @param predicate defines the predicate function used to validate the condition
  76513. */
  76514. constructor(actionManager: ActionManager,
  76515. /** defines the predicate function used to validate the condition */
  76516. predicate: () => boolean);
  76517. /**
  76518. * @returns the validity of the predicate condition
  76519. */
  76520. isValid(): boolean;
  76521. }
  76522. /**
  76523. * Defines a state condition as an extension of Condition
  76524. */
  76525. export class StateCondition extends Condition {
  76526. /** Value to compare with target state */
  76527. value: string;
  76528. /**
  76529. * Internal only - manager for action
  76530. * @hidden
  76531. */
  76532. _actionManager: ActionManager;
  76533. /**
  76534. * Internal only
  76535. * @hidden
  76536. */
  76537. private _target;
  76538. /**
  76539. * Creates a new StateCondition
  76540. * @param actionManager manager for the action the condition applies to
  76541. * @param target of the condition
  76542. * @param value to compare with target state
  76543. */
  76544. constructor(actionManager: ActionManager, target: any,
  76545. /** Value to compare with target state */
  76546. value: string);
  76547. /**
  76548. * Gets a boolean indicating if the current condition is met
  76549. * @returns the validity of the state
  76550. */
  76551. isValid(): boolean;
  76552. /**
  76553. * Serialize the StateCondition into a JSON compatible object
  76554. * @returns serialization object
  76555. */
  76556. serialize(): any;
  76557. }
  76558. }
  76559. declare module BABYLON {
  76560. /**
  76561. * This defines an action responsible to toggle a boolean once triggered.
  76562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76563. */
  76564. export class SwitchBooleanAction extends Action {
  76565. /**
  76566. * The path to the boolean property in the target object
  76567. */
  76568. propertyPath: string;
  76569. private _target;
  76570. private _effectiveTarget;
  76571. private _property;
  76572. /**
  76573. * Instantiate the action
  76574. * @param triggerOptions defines the trigger options
  76575. * @param target defines the object containing the boolean
  76576. * @param propertyPath defines the path to the boolean property in the target object
  76577. * @param condition defines the trigger related conditions
  76578. */
  76579. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76580. /** @hidden */
  76581. _prepare(): void;
  76582. /**
  76583. * Execute the action toggle the boolean value.
  76584. */
  76585. execute(): void;
  76586. /**
  76587. * Serializes the actions and its related information.
  76588. * @param parent defines the object to serialize in
  76589. * @returns the serialized object
  76590. */
  76591. serialize(parent: any): any;
  76592. }
  76593. /**
  76594. * This defines an action responsible to set a the state field of the target
  76595. * to a desired value once triggered.
  76596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76597. */
  76598. export class SetStateAction extends Action {
  76599. /**
  76600. * The value to store in the state field.
  76601. */
  76602. value: string;
  76603. private _target;
  76604. /**
  76605. * Instantiate the action
  76606. * @param triggerOptions defines the trigger options
  76607. * @param target defines the object containing the state property
  76608. * @param value defines the value to store in the state field
  76609. * @param condition defines the trigger related conditions
  76610. */
  76611. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76612. /**
  76613. * Execute the action and store the value on the target state property.
  76614. */
  76615. execute(): void;
  76616. /**
  76617. * Serializes the actions and its related information.
  76618. * @param parent defines the object to serialize in
  76619. * @returns the serialized object
  76620. */
  76621. serialize(parent: any): any;
  76622. }
  76623. /**
  76624. * This defines an action responsible to set a property of the target
  76625. * to a desired value once triggered.
  76626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76627. */
  76628. export class SetValueAction extends Action {
  76629. /**
  76630. * The path of the property to set in the target.
  76631. */
  76632. propertyPath: string;
  76633. /**
  76634. * The value to set in the property
  76635. */
  76636. value: any;
  76637. private _target;
  76638. private _effectiveTarget;
  76639. private _property;
  76640. /**
  76641. * Instantiate the action
  76642. * @param triggerOptions defines the trigger options
  76643. * @param target defines the object containing the property
  76644. * @param propertyPath defines the path of the property to set in the target
  76645. * @param value defines the value to set in the property
  76646. * @param condition defines the trigger related conditions
  76647. */
  76648. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76649. /** @hidden */
  76650. _prepare(): void;
  76651. /**
  76652. * Execute the action and set the targetted property to the desired value.
  76653. */
  76654. execute(): void;
  76655. /**
  76656. * Serializes the actions and its related information.
  76657. * @param parent defines the object to serialize in
  76658. * @returns the serialized object
  76659. */
  76660. serialize(parent: any): any;
  76661. }
  76662. /**
  76663. * This defines an action responsible to increment the target value
  76664. * to a desired value once triggered.
  76665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76666. */
  76667. export class IncrementValueAction extends Action {
  76668. /**
  76669. * The path of the property to increment in the target.
  76670. */
  76671. propertyPath: string;
  76672. /**
  76673. * The value we should increment the property by.
  76674. */
  76675. value: any;
  76676. private _target;
  76677. private _effectiveTarget;
  76678. private _property;
  76679. /**
  76680. * Instantiate the action
  76681. * @param triggerOptions defines the trigger options
  76682. * @param target defines the object containing the property
  76683. * @param propertyPath defines the path of the property to increment in the target
  76684. * @param value defines the value value we should increment the property by
  76685. * @param condition defines the trigger related conditions
  76686. */
  76687. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76688. /** @hidden */
  76689. _prepare(): void;
  76690. /**
  76691. * Execute the action and increment the target of the value amount.
  76692. */
  76693. execute(): void;
  76694. /**
  76695. * Serializes the actions and its related information.
  76696. * @param parent defines the object to serialize in
  76697. * @returns the serialized object
  76698. */
  76699. serialize(parent: any): any;
  76700. }
  76701. /**
  76702. * This defines an action responsible to start an animation once triggered.
  76703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76704. */
  76705. export class PlayAnimationAction extends Action {
  76706. /**
  76707. * Where the animation should start (animation frame)
  76708. */
  76709. from: number;
  76710. /**
  76711. * Where the animation should stop (animation frame)
  76712. */
  76713. to: number;
  76714. /**
  76715. * Define if the animation should loop or stop after the first play.
  76716. */
  76717. loop?: boolean;
  76718. private _target;
  76719. /**
  76720. * Instantiate the action
  76721. * @param triggerOptions defines the trigger options
  76722. * @param target defines the target animation or animation name
  76723. * @param from defines from where the animation should start (animation frame)
  76724. * @param end defines where the animation should stop (animation frame)
  76725. * @param loop defines if the animation should loop or stop after the first play
  76726. * @param condition defines the trigger related conditions
  76727. */
  76728. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76729. /** @hidden */
  76730. _prepare(): void;
  76731. /**
  76732. * Execute the action and play the animation.
  76733. */
  76734. execute(): void;
  76735. /**
  76736. * Serializes the actions and its related information.
  76737. * @param parent defines the object to serialize in
  76738. * @returns the serialized object
  76739. */
  76740. serialize(parent: any): any;
  76741. }
  76742. /**
  76743. * This defines an action responsible to stop an animation once triggered.
  76744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76745. */
  76746. export class StopAnimationAction extends Action {
  76747. private _target;
  76748. /**
  76749. * Instantiate the action
  76750. * @param triggerOptions defines the trigger options
  76751. * @param target defines the target animation or animation name
  76752. * @param condition defines the trigger related conditions
  76753. */
  76754. constructor(triggerOptions: any, target: any, condition?: Condition);
  76755. /** @hidden */
  76756. _prepare(): void;
  76757. /**
  76758. * Execute the action and stop the animation.
  76759. */
  76760. execute(): void;
  76761. /**
  76762. * Serializes the actions and its related information.
  76763. * @param parent defines the object to serialize in
  76764. * @returns the serialized object
  76765. */
  76766. serialize(parent: any): any;
  76767. }
  76768. /**
  76769. * This defines an action responsible that does nothing once triggered.
  76770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76771. */
  76772. export class DoNothingAction extends Action {
  76773. /**
  76774. * Instantiate the action
  76775. * @param triggerOptions defines the trigger options
  76776. * @param condition defines the trigger related conditions
  76777. */
  76778. constructor(triggerOptions?: any, condition?: Condition);
  76779. /**
  76780. * Execute the action and do nothing.
  76781. */
  76782. execute(): void;
  76783. /**
  76784. * Serializes the actions and its related information.
  76785. * @param parent defines the object to serialize in
  76786. * @returns the serialized object
  76787. */
  76788. serialize(parent: any): any;
  76789. }
  76790. /**
  76791. * This defines an action responsible to trigger several actions once triggered.
  76792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76793. */
  76794. export class CombineAction extends Action {
  76795. /**
  76796. * The list of aggregated animations to run.
  76797. */
  76798. children: Action[];
  76799. /**
  76800. * Instantiate the action
  76801. * @param triggerOptions defines the trigger options
  76802. * @param children defines the list of aggregated animations to run
  76803. * @param condition defines the trigger related conditions
  76804. */
  76805. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76806. /** @hidden */
  76807. _prepare(): void;
  76808. /**
  76809. * Execute the action and executes all the aggregated actions.
  76810. */
  76811. execute(evt: ActionEvent): void;
  76812. /**
  76813. * Serializes the actions and its related information.
  76814. * @param parent defines the object to serialize in
  76815. * @returns the serialized object
  76816. */
  76817. serialize(parent: any): any;
  76818. }
  76819. /**
  76820. * This defines an action responsible to run code (external event) once triggered.
  76821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76822. */
  76823. export class ExecuteCodeAction extends Action {
  76824. /**
  76825. * The callback function to run.
  76826. */
  76827. func: (evt: ActionEvent) => void;
  76828. /**
  76829. * Instantiate the action
  76830. * @param triggerOptions defines the trigger options
  76831. * @param func defines the callback function to run
  76832. * @param condition defines the trigger related conditions
  76833. */
  76834. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76835. /**
  76836. * Execute the action and run the attached code.
  76837. */
  76838. execute(evt: ActionEvent): void;
  76839. }
  76840. /**
  76841. * This defines an action responsible to set the parent property of the target once triggered.
  76842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76843. */
  76844. export class SetParentAction extends Action {
  76845. private _parent;
  76846. private _target;
  76847. /**
  76848. * Instantiate the action
  76849. * @param triggerOptions defines the trigger options
  76850. * @param target defines the target containing the parent property
  76851. * @param parent defines from where the animation should start (animation frame)
  76852. * @param condition defines the trigger related conditions
  76853. */
  76854. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76855. /** @hidden */
  76856. _prepare(): void;
  76857. /**
  76858. * Execute the action and set the parent property.
  76859. */
  76860. execute(): void;
  76861. /**
  76862. * Serializes the actions and its related information.
  76863. * @param parent defines the object to serialize in
  76864. * @returns the serialized object
  76865. */
  76866. serialize(parent: any): any;
  76867. }
  76868. }
  76869. declare module BABYLON {
  76870. /**
  76871. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76872. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76874. */
  76875. export class ActionManager extends AbstractActionManager {
  76876. /**
  76877. * Nothing
  76878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76879. */
  76880. static readonly NothingTrigger: number;
  76881. /**
  76882. * On pick
  76883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76884. */
  76885. static readonly OnPickTrigger: number;
  76886. /**
  76887. * On left pick
  76888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76889. */
  76890. static readonly OnLeftPickTrigger: number;
  76891. /**
  76892. * On right pick
  76893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76894. */
  76895. static readonly OnRightPickTrigger: number;
  76896. /**
  76897. * On center pick
  76898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76899. */
  76900. static readonly OnCenterPickTrigger: number;
  76901. /**
  76902. * On pick down
  76903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76904. */
  76905. static readonly OnPickDownTrigger: number;
  76906. /**
  76907. * On double pick
  76908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76909. */
  76910. static readonly OnDoublePickTrigger: number;
  76911. /**
  76912. * On pick up
  76913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76914. */
  76915. static readonly OnPickUpTrigger: number;
  76916. /**
  76917. * On pick out.
  76918. * This trigger will only be raised if you also declared a OnPickDown
  76919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76920. */
  76921. static readonly OnPickOutTrigger: number;
  76922. /**
  76923. * On long press
  76924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76925. */
  76926. static readonly OnLongPressTrigger: number;
  76927. /**
  76928. * On pointer over
  76929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76930. */
  76931. static readonly OnPointerOverTrigger: number;
  76932. /**
  76933. * On pointer out
  76934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76935. */
  76936. static readonly OnPointerOutTrigger: number;
  76937. /**
  76938. * On every frame
  76939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76940. */
  76941. static readonly OnEveryFrameTrigger: number;
  76942. /**
  76943. * On intersection enter
  76944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76945. */
  76946. static readonly OnIntersectionEnterTrigger: number;
  76947. /**
  76948. * On intersection exit
  76949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76950. */
  76951. static readonly OnIntersectionExitTrigger: number;
  76952. /**
  76953. * On key down
  76954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76955. */
  76956. static readonly OnKeyDownTrigger: number;
  76957. /**
  76958. * On key up
  76959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76960. */
  76961. static readonly OnKeyUpTrigger: number;
  76962. private _scene;
  76963. /**
  76964. * Creates a new action manager
  76965. * @param scene defines the hosting scene
  76966. */
  76967. constructor(scene: Scene);
  76968. /**
  76969. * Releases all associated resources
  76970. */
  76971. dispose(): void;
  76972. /**
  76973. * Gets hosting scene
  76974. * @returns the hosting scene
  76975. */
  76976. getScene(): Scene;
  76977. /**
  76978. * Does this action manager handles actions of any of the given triggers
  76979. * @param triggers defines the triggers to be tested
  76980. * @return a boolean indicating whether one (or more) of the triggers is handled
  76981. */
  76982. hasSpecificTriggers(triggers: number[]): boolean;
  76983. /**
  76984. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76985. * speed.
  76986. * @param triggerA defines the trigger to be tested
  76987. * @param triggerB defines the trigger to be tested
  76988. * @return a boolean indicating whether one (or more) of the triggers is handled
  76989. */
  76990. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76991. /**
  76992. * Does this action manager handles actions of a given trigger
  76993. * @param trigger defines the trigger to be tested
  76994. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76995. * @return whether the trigger is handled
  76996. */
  76997. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76998. /**
  76999. * Does this action manager has pointer triggers
  77000. */
  77001. readonly hasPointerTriggers: boolean;
  77002. /**
  77003. * Does this action manager has pick triggers
  77004. */
  77005. readonly hasPickTriggers: boolean;
  77006. /**
  77007. * Registers an action to this action manager
  77008. * @param action defines the action to be registered
  77009. * @return the action amended (prepared) after registration
  77010. */
  77011. registerAction(action: IAction): Nullable<IAction>;
  77012. /**
  77013. * Unregisters an action to this action manager
  77014. * @param action defines the action to be unregistered
  77015. * @return a boolean indicating whether the action has been unregistered
  77016. */
  77017. unregisterAction(action: IAction): Boolean;
  77018. /**
  77019. * Process a specific trigger
  77020. * @param trigger defines the trigger to process
  77021. * @param evt defines the event details to be processed
  77022. */
  77023. processTrigger(trigger: number, evt?: IActionEvent): void;
  77024. /** @hidden */
  77025. _getEffectiveTarget(target: any, propertyPath: string): any;
  77026. /** @hidden */
  77027. _getProperty(propertyPath: string): string;
  77028. /**
  77029. * Serialize this manager to a JSON object
  77030. * @param name defines the property name to store this manager
  77031. * @returns a JSON representation of this manager
  77032. */
  77033. serialize(name: string): any;
  77034. /**
  77035. * Creates a new ActionManager from a JSON data
  77036. * @param parsedActions defines the JSON data to read from
  77037. * @param object defines the hosting mesh
  77038. * @param scene defines the hosting scene
  77039. */
  77040. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77041. /**
  77042. * Get a trigger name by index
  77043. * @param trigger defines the trigger index
  77044. * @returns a trigger name
  77045. */
  77046. static GetTriggerName(trigger: number): string;
  77047. }
  77048. }
  77049. declare module BABYLON {
  77050. /**
  77051. * Class representing a ray with position and direction
  77052. */
  77053. export class Ray {
  77054. /** origin point */
  77055. origin: Vector3;
  77056. /** direction */
  77057. direction: Vector3;
  77058. /** length of the ray */
  77059. length: number;
  77060. private static readonly TmpVector3;
  77061. private _tmpRay;
  77062. /**
  77063. * Creates a new ray
  77064. * @param origin origin point
  77065. * @param direction direction
  77066. * @param length length of the ray
  77067. */
  77068. constructor(
  77069. /** origin point */
  77070. origin: Vector3,
  77071. /** direction */
  77072. direction: Vector3,
  77073. /** length of the ray */
  77074. length?: number);
  77075. /**
  77076. * Checks if the ray intersects a box
  77077. * @param minimum bound of the box
  77078. * @param maximum bound of the box
  77079. * @param intersectionTreshold extra extend to be added to the box in all direction
  77080. * @returns if the box was hit
  77081. */
  77082. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77083. /**
  77084. * Checks if the ray intersects a box
  77085. * @param box the bounding box to check
  77086. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77087. * @returns if the box was hit
  77088. */
  77089. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77090. /**
  77091. * If the ray hits a sphere
  77092. * @param sphere the bounding sphere to check
  77093. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77094. * @returns true if it hits the sphere
  77095. */
  77096. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77097. /**
  77098. * If the ray hits a triange
  77099. * @param vertex0 triangle vertex
  77100. * @param vertex1 triangle vertex
  77101. * @param vertex2 triangle vertex
  77102. * @returns intersection information if hit
  77103. */
  77104. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77105. /**
  77106. * Checks if ray intersects a plane
  77107. * @param plane the plane to check
  77108. * @returns the distance away it was hit
  77109. */
  77110. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77111. /**
  77112. * Calculate the intercept of a ray on a given axis
  77113. * @param axis to check 'x' | 'y' | 'z'
  77114. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77115. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77116. */
  77117. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77118. /**
  77119. * Checks if ray intersects a mesh
  77120. * @param mesh the mesh to check
  77121. * @param fastCheck if only the bounding box should checked
  77122. * @returns picking info of the intersecton
  77123. */
  77124. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77125. /**
  77126. * Checks if ray intersects a mesh
  77127. * @param meshes the meshes to check
  77128. * @param fastCheck if only the bounding box should checked
  77129. * @param results array to store result in
  77130. * @returns Array of picking infos
  77131. */
  77132. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77133. private _comparePickingInfo;
  77134. private static smallnum;
  77135. private static rayl;
  77136. /**
  77137. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77138. * @param sega the first point of the segment to test the intersection against
  77139. * @param segb the second point of the segment to test the intersection against
  77140. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77141. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77142. */
  77143. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77144. /**
  77145. * Update the ray from viewport position
  77146. * @param x position
  77147. * @param y y position
  77148. * @param viewportWidth viewport width
  77149. * @param viewportHeight viewport height
  77150. * @param world world matrix
  77151. * @param view view matrix
  77152. * @param projection projection matrix
  77153. * @returns this ray updated
  77154. */
  77155. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77156. /**
  77157. * Creates a ray with origin and direction of 0,0,0
  77158. * @returns the new ray
  77159. */
  77160. static Zero(): Ray;
  77161. /**
  77162. * Creates a new ray from screen space and viewport
  77163. * @param x position
  77164. * @param y y position
  77165. * @param viewportWidth viewport width
  77166. * @param viewportHeight viewport height
  77167. * @param world world matrix
  77168. * @param view view matrix
  77169. * @param projection projection matrix
  77170. * @returns new ray
  77171. */
  77172. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77173. /**
  77174. * 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
  77175. * transformed to the given world matrix.
  77176. * @param origin The origin point
  77177. * @param end The end point
  77178. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77179. * @returns the new ray
  77180. */
  77181. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77182. /**
  77183. * Transforms a ray by a matrix
  77184. * @param ray ray to transform
  77185. * @param matrix matrix to apply
  77186. * @returns the resulting new ray
  77187. */
  77188. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77189. /**
  77190. * Transforms a ray by a matrix
  77191. * @param ray ray to transform
  77192. * @param matrix matrix to apply
  77193. * @param result ray to store result in
  77194. */
  77195. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77196. /**
  77197. * Unproject a ray from screen space to object space
  77198. * @param sourceX defines the screen space x coordinate to use
  77199. * @param sourceY defines the screen space y coordinate to use
  77200. * @param viewportWidth defines the current width of the viewport
  77201. * @param viewportHeight defines the current height of the viewport
  77202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77203. * @param view defines the view matrix to use
  77204. * @param projection defines the projection matrix to use
  77205. */
  77206. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77207. }
  77208. /**
  77209. * Type used to define predicate used to select faces when a mesh intersection is detected
  77210. */
  77211. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77212. interface Scene {
  77213. /** @hidden */
  77214. _tempPickingRay: Nullable<Ray>;
  77215. /** @hidden */
  77216. _cachedRayForTransform: Ray;
  77217. /** @hidden */
  77218. _pickWithRayInverseMatrix: Matrix;
  77219. /** @hidden */
  77220. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77221. /** @hidden */
  77222. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77223. }
  77224. }
  77225. declare module BABYLON {
  77226. /**
  77227. * Groups all the scene component constants in one place to ease maintenance.
  77228. * @hidden
  77229. */
  77230. export class SceneComponentConstants {
  77231. static readonly NAME_EFFECTLAYER: string;
  77232. static readonly NAME_LAYER: string;
  77233. static readonly NAME_LENSFLARESYSTEM: string;
  77234. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77235. static readonly NAME_PARTICLESYSTEM: string;
  77236. static readonly NAME_GAMEPAD: string;
  77237. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77238. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77239. static readonly NAME_DEPTHRENDERER: string;
  77240. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77241. static readonly NAME_SPRITE: string;
  77242. static readonly NAME_OUTLINERENDERER: string;
  77243. static readonly NAME_PROCEDURALTEXTURE: string;
  77244. static readonly NAME_SHADOWGENERATOR: string;
  77245. static readonly NAME_OCTREE: string;
  77246. static readonly NAME_PHYSICSENGINE: string;
  77247. static readonly NAME_AUDIO: string;
  77248. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77249. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77250. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77251. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77252. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77253. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77254. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77255. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77256. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77257. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77258. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77259. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77260. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77261. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77262. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77263. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77264. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77265. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77266. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77267. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77268. static readonly STEP_AFTERRENDER_AUDIO: number;
  77269. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77270. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77271. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77272. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77273. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77274. static readonly STEP_POINTERMOVE_SPRITE: number;
  77275. static readonly STEP_POINTERDOWN_SPRITE: number;
  77276. static readonly STEP_POINTERUP_SPRITE: number;
  77277. }
  77278. /**
  77279. * This represents a scene component.
  77280. *
  77281. * This is used to decouple the dependency the scene is having on the different workloads like
  77282. * layers, post processes...
  77283. */
  77284. export interface ISceneComponent {
  77285. /**
  77286. * The name of the component. Each component must have a unique name.
  77287. */
  77288. name: string;
  77289. /**
  77290. * The scene the component belongs to.
  77291. */
  77292. scene: Scene;
  77293. /**
  77294. * Register the component to one instance of a scene.
  77295. */
  77296. register(): void;
  77297. /**
  77298. * Rebuilds the elements related to this component in case of
  77299. * context lost for instance.
  77300. */
  77301. rebuild(): void;
  77302. /**
  77303. * Disposes the component and the associated ressources.
  77304. */
  77305. dispose(): void;
  77306. }
  77307. /**
  77308. * This represents a SERIALIZABLE scene component.
  77309. *
  77310. * This extends Scene Component to add Serialization methods on top.
  77311. */
  77312. export interface ISceneSerializableComponent extends ISceneComponent {
  77313. /**
  77314. * Adds all the elements from the container to the scene
  77315. * @param container the container holding the elements
  77316. */
  77317. addFromContainer(container: AbstractScene): void;
  77318. /**
  77319. * Removes all the elements in the container from the scene
  77320. * @param container contains the elements to remove
  77321. * @param dispose if the removed element should be disposed (default: false)
  77322. */
  77323. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77324. /**
  77325. * Serializes the component data to the specified json object
  77326. * @param serializationObject The object to serialize to
  77327. */
  77328. serialize(serializationObject: any): void;
  77329. }
  77330. /**
  77331. * Strong typing of a Mesh related stage step action
  77332. */
  77333. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77334. /**
  77335. * Strong typing of a Evaluate Sub Mesh related stage step action
  77336. */
  77337. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77338. /**
  77339. * Strong typing of a Active Mesh related stage step action
  77340. */
  77341. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77342. /**
  77343. * Strong typing of a Camera related stage step action
  77344. */
  77345. export type CameraStageAction = (camera: Camera) => void;
  77346. /**
  77347. * Strong typing of a Camera Frame buffer related stage step action
  77348. */
  77349. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77350. /**
  77351. * Strong typing of a Render Target related stage step action
  77352. */
  77353. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77354. /**
  77355. * Strong typing of a RenderingGroup related stage step action
  77356. */
  77357. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77358. /**
  77359. * Strong typing of a Mesh Render related stage step action
  77360. */
  77361. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77362. /**
  77363. * Strong typing of a simple stage step action
  77364. */
  77365. export type SimpleStageAction = () => void;
  77366. /**
  77367. * Strong typing of a render target action.
  77368. */
  77369. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77370. /**
  77371. * Strong typing of a pointer move action.
  77372. */
  77373. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77374. /**
  77375. * Strong typing of a pointer up/down action.
  77376. */
  77377. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77378. /**
  77379. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77380. * @hidden
  77381. */
  77382. export class Stage<T extends Function> extends Array<{
  77383. index: number;
  77384. component: ISceneComponent;
  77385. action: T;
  77386. }> {
  77387. /**
  77388. * Hide ctor from the rest of the world.
  77389. * @param items The items to add.
  77390. */
  77391. private constructor();
  77392. /**
  77393. * Creates a new Stage.
  77394. * @returns A new instance of a Stage
  77395. */
  77396. static Create<T extends Function>(): Stage<T>;
  77397. /**
  77398. * Registers a step in an ordered way in the targeted stage.
  77399. * @param index Defines the position to register the step in
  77400. * @param component Defines the component attached to the step
  77401. * @param action Defines the action to launch during the step
  77402. */
  77403. registerStep(index: number, component: ISceneComponent, action: T): void;
  77404. /**
  77405. * Clears all the steps from the stage.
  77406. */
  77407. clear(): void;
  77408. }
  77409. }
  77410. declare module BABYLON {
  77411. interface Scene {
  77412. /** @hidden */
  77413. _pointerOverSprite: Nullable<Sprite>;
  77414. /** @hidden */
  77415. _pickedDownSprite: Nullable<Sprite>;
  77416. /** @hidden */
  77417. _tempSpritePickingRay: Nullable<Ray>;
  77418. /**
  77419. * All of the sprite managers added to this scene
  77420. * @see http://doc.babylonjs.com/babylon101/sprites
  77421. */
  77422. spriteManagers: Array<ISpriteManager>;
  77423. /**
  77424. * An event triggered when sprites rendering is about to start
  77425. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77426. */
  77427. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77428. /**
  77429. * An event triggered when sprites rendering is done
  77430. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77431. */
  77432. onAfterSpritesRenderingObservable: Observable<Scene>;
  77433. /** @hidden */
  77434. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77435. /** Launch a ray to try to pick a sprite in the scene
  77436. * @param x position on screen
  77437. * @param y position on screen
  77438. * @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
  77439. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77440. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77441. * @returns a PickingInfo
  77442. */
  77443. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77444. /** Use the given ray to pick a sprite in the scene
  77445. * @param ray The ray (in world space) to use to pick meshes
  77446. * @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
  77447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77448. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77449. * @returns a PickingInfo
  77450. */
  77451. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77452. /** @hidden */
  77453. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77454. /** Launch a ray to try to pick sprites in the scene
  77455. * @param x position on screen
  77456. * @param y position on screen
  77457. * @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
  77458. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77459. * @returns a PickingInfo array
  77460. */
  77461. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77462. /** Use the given ray to pick sprites in the scene
  77463. * @param ray The ray (in world space) to use to pick meshes
  77464. * @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
  77465. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77466. * @returns a PickingInfo array
  77467. */
  77468. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77469. /**
  77470. * Force the sprite under the pointer
  77471. * @param sprite defines the sprite to use
  77472. */
  77473. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77474. /**
  77475. * Gets the sprite under the pointer
  77476. * @returns a Sprite or null if no sprite is under the pointer
  77477. */
  77478. getPointerOverSprite(): Nullable<Sprite>;
  77479. }
  77480. /**
  77481. * Defines the sprite scene component responsible to manage sprites
  77482. * in a given scene.
  77483. */
  77484. export class SpriteSceneComponent implements ISceneComponent {
  77485. /**
  77486. * The component name helpfull to identify the component in the list of scene components.
  77487. */
  77488. readonly name: string;
  77489. /**
  77490. * The scene the component belongs to.
  77491. */
  77492. scene: Scene;
  77493. /** @hidden */
  77494. private _spritePredicate;
  77495. /**
  77496. * Creates a new instance of the component for the given scene
  77497. * @param scene Defines the scene to register the component in
  77498. */
  77499. constructor(scene: Scene);
  77500. /**
  77501. * Registers the component in a given scene
  77502. */
  77503. register(): void;
  77504. /**
  77505. * Rebuilds the elements related to this component in case of
  77506. * context lost for instance.
  77507. */
  77508. rebuild(): void;
  77509. /**
  77510. * Disposes the component and the associated ressources.
  77511. */
  77512. dispose(): void;
  77513. private _pickSpriteButKeepRay;
  77514. private _pointerMove;
  77515. private _pointerDown;
  77516. private _pointerUp;
  77517. }
  77518. }
  77519. declare module BABYLON {
  77520. /** @hidden */
  77521. export var fogFragmentDeclaration: {
  77522. name: string;
  77523. shader: string;
  77524. };
  77525. }
  77526. declare module BABYLON {
  77527. /** @hidden */
  77528. export var fogFragment: {
  77529. name: string;
  77530. shader: string;
  77531. };
  77532. }
  77533. declare module BABYLON {
  77534. /** @hidden */
  77535. export var spritesPixelShader: {
  77536. name: string;
  77537. shader: string;
  77538. };
  77539. }
  77540. declare module BABYLON {
  77541. /** @hidden */
  77542. export var fogVertexDeclaration: {
  77543. name: string;
  77544. shader: string;
  77545. };
  77546. }
  77547. declare module BABYLON {
  77548. /** @hidden */
  77549. export var spritesVertexShader: {
  77550. name: string;
  77551. shader: string;
  77552. };
  77553. }
  77554. declare module BABYLON {
  77555. /**
  77556. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77557. */
  77558. export interface ISpriteManager extends IDisposable {
  77559. /**
  77560. * Restricts the camera to viewing objects with the same layerMask.
  77561. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77562. */
  77563. layerMask: number;
  77564. /**
  77565. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77566. */
  77567. isPickable: boolean;
  77568. /**
  77569. * Specifies the rendering group id for this mesh (0 by default)
  77570. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77571. */
  77572. renderingGroupId: number;
  77573. /**
  77574. * Defines the list of sprites managed by the manager.
  77575. */
  77576. sprites: Array<Sprite>;
  77577. /**
  77578. * Tests the intersection of a sprite with a specific ray.
  77579. * @param ray The ray we are sending to test the collision
  77580. * @param camera The camera space we are sending rays in
  77581. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77582. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77583. * @returns picking info or null.
  77584. */
  77585. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77586. /**
  77587. * Intersects the sprites with a ray
  77588. * @param ray defines the ray to intersect with
  77589. * @param camera defines the current active camera
  77590. * @param predicate defines a predicate used to select candidate sprites
  77591. * @returns null if no hit or a PickingInfo array
  77592. */
  77593. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77594. /**
  77595. * Renders the list of sprites on screen.
  77596. */
  77597. render(): void;
  77598. }
  77599. /**
  77600. * Class used to manage multiple sprites on the same spritesheet
  77601. * @see http://doc.babylonjs.com/babylon101/sprites
  77602. */
  77603. export class SpriteManager implements ISpriteManager {
  77604. /** defines the manager's name */
  77605. name: string;
  77606. /** Gets the list of sprites */
  77607. sprites: Sprite[];
  77608. /** Gets or sets the rendering group id (0 by default) */
  77609. renderingGroupId: number;
  77610. /** Gets or sets camera layer mask */
  77611. layerMask: number;
  77612. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77613. fogEnabled: boolean;
  77614. /** Gets or sets a boolean indicating if the sprites are pickable */
  77615. isPickable: boolean;
  77616. /** Defines the default width of a cell in the spritesheet */
  77617. cellWidth: number;
  77618. /** Defines the default height of a cell in the spritesheet */
  77619. cellHeight: number;
  77620. /** Associative array from JSON sprite data file */
  77621. private _cellData;
  77622. /** Array of sprite names from JSON sprite data file */
  77623. private _spriteMap;
  77624. /** True when packed cell data from JSON file is ready*/
  77625. private _packedAndReady;
  77626. /**
  77627. * An event triggered when the manager is disposed.
  77628. */
  77629. onDisposeObservable: Observable<SpriteManager>;
  77630. private _onDisposeObserver;
  77631. /**
  77632. * Callback called when the manager is disposed
  77633. */
  77634. onDispose: () => void;
  77635. private _capacity;
  77636. private _fromPacked;
  77637. private _spriteTexture;
  77638. private _epsilon;
  77639. private _scene;
  77640. private _vertexData;
  77641. private _buffer;
  77642. private _vertexBuffers;
  77643. private _indexBuffer;
  77644. private _effectBase;
  77645. private _effectFog;
  77646. /**
  77647. * Gets or sets the spritesheet texture
  77648. */
  77649. texture: Texture;
  77650. /**
  77651. * Creates a new sprite manager
  77652. * @param name defines the manager's name
  77653. * @param imgUrl defines the sprite sheet url
  77654. * @param capacity defines the maximum allowed number of sprites
  77655. * @param cellSize defines the size of a sprite cell
  77656. * @param scene defines the hosting scene
  77657. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77658. * @param samplingMode defines the smapling mode to use with spritesheet
  77659. * @param fromPacked set to false; do not alter
  77660. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77661. */
  77662. constructor(
  77663. /** defines the manager's name */
  77664. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77665. private _makePacked;
  77666. private _appendSpriteVertex;
  77667. /**
  77668. * Intersects the sprites with a ray
  77669. * @param ray defines the ray to intersect with
  77670. * @param camera defines the current active camera
  77671. * @param predicate defines a predicate used to select candidate sprites
  77672. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77673. * @returns null if no hit or a PickingInfo
  77674. */
  77675. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77676. /**
  77677. * Intersects the sprites with a ray
  77678. * @param ray defines the ray to intersect with
  77679. * @param camera defines the current active camera
  77680. * @param predicate defines a predicate used to select candidate sprites
  77681. * @returns null if no hit or a PickingInfo array
  77682. */
  77683. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77684. /**
  77685. * Render all child sprites
  77686. */
  77687. render(): void;
  77688. /**
  77689. * Release associated resources
  77690. */
  77691. dispose(): void;
  77692. }
  77693. }
  77694. declare module BABYLON {
  77695. /**
  77696. * Class used to represent a sprite
  77697. * @see http://doc.babylonjs.com/babylon101/sprites
  77698. */
  77699. export class Sprite {
  77700. /** defines the name */
  77701. name: string;
  77702. /** Gets or sets the current world position */
  77703. position: Vector3;
  77704. /** Gets or sets the main color */
  77705. color: Color4;
  77706. /** Gets or sets the width */
  77707. width: number;
  77708. /** Gets or sets the height */
  77709. height: number;
  77710. /** Gets or sets rotation angle */
  77711. angle: number;
  77712. /** Gets or sets the cell index in the sprite sheet */
  77713. cellIndex: number;
  77714. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77715. cellRef: string;
  77716. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77717. invertU: number;
  77718. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77719. invertV: number;
  77720. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77721. disposeWhenFinishedAnimating: boolean;
  77722. /** Gets the list of attached animations */
  77723. animations: Animation[];
  77724. /** Gets or sets a boolean indicating if the sprite can be picked */
  77725. isPickable: boolean;
  77726. /**
  77727. * Gets or sets the associated action manager
  77728. */
  77729. actionManager: Nullable<ActionManager>;
  77730. private _animationStarted;
  77731. private _loopAnimation;
  77732. private _fromIndex;
  77733. private _toIndex;
  77734. private _delay;
  77735. private _direction;
  77736. private _manager;
  77737. private _time;
  77738. private _onAnimationEnd;
  77739. /**
  77740. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77741. */
  77742. isVisible: boolean;
  77743. /**
  77744. * Gets or sets the sprite size
  77745. */
  77746. size: number;
  77747. /**
  77748. * Creates a new Sprite
  77749. * @param name defines the name
  77750. * @param manager defines the manager
  77751. */
  77752. constructor(
  77753. /** defines the name */
  77754. name: string, manager: ISpriteManager);
  77755. /**
  77756. * Starts an animation
  77757. * @param from defines the initial key
  77758. * @param to defines the end key
  77759. * @param loop defines if the animation must loop
  77760. * @param delay defines the start delay (in ms)
  77761. * @param onAnimationEnd defines a callback to call when animation ends
  77762. */
  77763. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77764. /** Stops current animation (if any) */
  77765. stopAnimation(): void;
  77766. /** @hidden */
  77767. _animate(deltaTime: number): void;
  77768. /** Release associated resources */
  77769. dispose(): void;
  77770. }
  77771. }
  77772. declare module BABYLON {
  77773. /**
  77774. * Information about the result of picking within a scene
  77775. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77776. */
  77777. export class PickingInfo {
  77778. /** @hidden */
  77779. _pickingUnavailable: boolean;
  77780. /**
  77781. * If the pick collided with an object
  77782. */
  77783. hit: boolean;
  77784. /**
  77785. * Distance away where the pick collided
  77786. */
  77787. distance: number;
  77788. /**
  77789. * The location of pick collision
  77790. */
  77791. pickedPoint: Nullable<Vector3>;
  77792. /**
  77793. * The mesh corresponding the the pick collision
  77794. */
  77795. pickedMesh: Nullable<AbstractMesh>;
  77796. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77797. bu: number;
  77798. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77799. bv: number;
  77800. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77801. faceId: number;
  77802. /** Id of the the submesh that was picked */
  77803. subMeshId: number;
  77804. /** If a sprite was picked, this will be the sprite the pick collided with */
  77805. pickedSprite: Nullable<Sprite>;
  77806. /**
  77807. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77808. */
  77809. originMesh: Nullable<AbstractMesh>;
  77810. /**
  77811. * The ray that was used to perform the picking.
  77812. */
  77813. ray: Nullable<Ray>;
  77814. /**
  77815. * Gets the normal correspodning to the face the pick collided with
  77816. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77817. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77818. * @returns The normal correspodning to the face the pick collided with
  77819. */
  77820. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77821. /**
  77822. * Gets the texture coordinates of where the pick occured
  77823. * @returns the vector containing the coordnates of the texture
  77824. */
  77825. getTextureCoordinates(): Nullable<Vector2>;
  77826. }
  77827. }
  77828. declare module BABYLON {
  77829. /**
  77830. * Gather the list of pointer event types as constants.
  77831. */
  77832. export class PointerEventTypes {
  77833. /**
  77834. * 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.
  77835. */
  77836. static readonly POINTERDOWN: number;
  77837. /**
  77838. * The pointerup event is fired when a pointer is no longer active.
  77839. */
  77840. static readonly POINTERUP: number;
  77841. /**
  77842. * The pointermove event is fired when a pointer changes coordinates.
  77843. */
  77844. static readonly POINTERMOVE: number;
  77845. /**
  77846. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77847. */
  77848. static readonly POINTERWHEEL: number;
  77849. /**
  77850. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77851. */
  77852. static readonly POINTERPICK: number;
  77853. /**
  77854. * The pointertap event is fired when a the object has been touched and released without drag.
  77855. */
  77856. static readonly POINTERTAP: number;
  77857. /**
  77858. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77859. */
  77860. static readonly POINTERDOUBLETAP: number;
  77861. }
  77862. /**
  77863. * Base class of pointer info types.
  77864. */
  77865. export class PointerInfoBase {
  77866. /**
  77867. * Defines the type of event (PointerEventTypes)
  77868. */
  77869. type: number;
  77870. /**
  77871. * Defines the related dom event
  77872. */
  77873. event: PointerEvent | MouseWheelEvent;
  77874. /**
  77875. * Instantiates the base class of pointers info.
  77876. * @param type Defines the type of event (PointerEventTypes)
  77877. * @param event Defines the related dom event
  77878. */
  77879. constructor(
  77880. /**
  77881. * Defines the type of event (PointerEventTypes)
  77882. */
  77883. type: number,
  77884. /**
  77885. * Defines the related dom event
  77886. */
  77887. event: PointerEvent | MouseWheelEvent);
  77888. }
  77889. /**
  77890. * This class is used to store pointer related info for the onPrePointerObservable event.
  77891. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77892. */
  77893. export class PointerInfoPre extends PointerInfoBase {
  77894. /**
  77895. * Ray from a pointer if availible (eg. 6dof controller)
  77896. */
  77897. ray: Nullable<Ray>;
  77898. /**
  77899. * Defines the local position of the pointer on the canvas.
  77900. */
  77901. localPosition: Vector2;
  77902. /**
  77903. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77904. */
  77905. skipOnPointerObservable: boolean;
  77906. /**
  77907. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77908. * @param type Defines the type of event (PointerEventTypes)
  77909. * @param event Defines the related dom event
  77910. * @param localX Defines the local x coordinates of the pointer when the event occured
  77911. * @param localY Defines the local y coordinates of the pointer when the event occured
  77912. */
  77913. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77914. }
  77915. /**
  77916. * This type contains all the data related to a pointer event in Babylon.js.
  77917. * 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.
  77918. */
  77919. export class PointerInfo extends PointerInfoBase {
  77920. /**
  77921. * Defines the picking info associated to the info (if any)\
  77922. */
  77923. pickInfo: Nullable<PickingInfo>;
  77924. /**
  77925. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77926. * @param type Defines the type of event (PointerEventTypes)
  77927. * @param event Defines the related dom event
  77928. * @param pickInfo Defines the picking info associated to the info (if any)\
  77929. */
  77930. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77931. /**
  77932. * Defines the picking info associated to the info (if any)\
  77933. */
  77934. pickInfo: Nullable<PickingInfo>);
  77935. }
  77936. /**
  77937. * Data relating to a touch event on the screen.
  77938. */
  77939. export interface PointerTouch {
  77940. /**
  77941. * X coordinate of touch.
  77942. */
  77943. x: number;
  77944. /**
  77945. * Y coordinate of touch.
  77946. */
  77947. y: number;
  77948. /**
  77949. * Id of touch. Unique for each finger.
  77950. */
  77951. pointerId: number;
  77952. /**
  77953. * Event type passed from DOM.
  77954. */
  77955. type: any;
  77956. }
  77957. }
  77958. declare module BABYLON {
  77959. /**
  77960. * Manage the mouse inputs to control the movement of a free camera.
  77961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77962. */
  77963. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77964. /**
  77965. * Define if touch is enabled in the mouse input
  77966. */
  77967. touchEnabled: boolean;
  77968. /**
  77969. * Defines the camera the input is attached to.
  77970. */
  77971. camera: FreeCamera;
  77972. /**
  77973. * Defines the buttons associated with the input to handle camera move.
  77974. */
  77975. buttons: number[];
  77976. /**
  77977. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77978. */
  77979. angularSensibility: number;
  77980. private _pointerInput;
  77981. private _onMouseMove;
  77982. private _observer;
  77983. private previousPosition;
  77984. /**
  77985. * Observable for when a pointer move event occurs containing the move offset
  77986. */
  77987. onPointerMovedObservable: Observable<{
  77988. offsetX: number;
  77989. offsetY: number;
  77990. }>;
  77991. /**
  77992. * @hidden
  77993. * If the camera should be rotated automatically based on pointer movement
  77994. */
  77995. _allowCameraRotation: boolean;
  77996. /**
  77997. * Manage the mouse inputs to control the movement of a free camera.
  77998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77999. * @param touchEnabled Defines if touch is enabled or not
  78000. */
  78001. constructor(
  78002. /**
  78003. * Define if touch is enabled in the mouse input
  78004. */
  78005. touchEnabled?: boolean);
  78006. /**
  78007. * Attach the input controls to a specific dom element to get the input from.
  78008. * @param element Defines the element the controls should be listened from
  78009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78010. */
  78011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78012. /**
  78013. * Called on JS contextmenu event.
  78014. * Override this method to provide functionality.
  78015. */
  78016. protected onContextMenu(evt: PointerEvent): void;
  78017. /**
  78018. * Detach the current controls from the specified dom element.
  78019. * @param element Defines the element to stop listening the inputs from
  78020. */
  78021. detachControl(element: Nullable<HTMLElement>): void;
  78022. /**
  78023. * Gets the class name of the current intput.
  78024. * @returns the class name
  78025. */
  78026. getClassName(): string;
  78027. /**
  78028. * Get the friendly name associated with the input class.
  78029. * @returns the input friendly name
  78030. */
  78031. getSimpleName(): string;
  78032. }
  78033. }
  78034. declare module BABYLON {
  78035. /**
  78036. * Manage the touch inputs to control the movement of a free camera.
  78037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78038. */
  78039. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78040. /**
  78041. * Defines the camera the input is attached to.
  78042. */
  78043. camera: FreeCamera;
  78044. /**
  78045. * Defines the touch sensibility for rotation.
  78046. * The higher the faster.
  78047. */
  78048. touchAngularSensibility: number;
  78049. /**
  78050. * Defines the touch sensibility for move.
  78051. * The higher the faster.
  78052. */
  78053. touchMoveSensibility: number;
  78054. private _offsetX;
  78055. private _offsetY;
  78056. private _pointerPressed;
  78057. private _pointerInput;
  78058. private _observer;
  78059. private _onLostFocus;
  78060. /**
  78061. * Attach the input controls to a specific dom element to get the input from.
  78062. * @param element Defines the element the controls should be listened from
  78063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78064. */
  78065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78066. /**
  78067. * Detach the current controls from the specified dom element.
  78068. * @param element Defines the element to stop listening the inputs from
  78069. */
  78070. detachControl(element: Nullable<HTMLElement>): void;
  78071. /**
  78072. * Update the current camera state depending on the inputs that have been used this frame.
  78073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78074. */
  78075. checkInputs(): void;
  78076. /**
  78077. * Gets the class name of the current intput.
  78078. * @returns the class name
  78079. */
  78080. getClassName(): string;
  78081. /**
  78082. * Get the friendly name associated with the input class.
  78083. * @returns the input friendly name
  78084. */
  78085. getSimpleName(): string;
  78086. }
  78087. }
  78088. declare module BABYLON {
  78089. /**
  78090. * Default Inputs manager for the FreeCamera.
  78091. * It groups all the default supported inputs for ease of use.
  78092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78093. */
  78094. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78095. /**
  78096. * @hidden
  78097. */
  78098. _mouseInput: Nullable<FreeCameraMouseInput>;
  78099. /**
  78100. * Instantiates a new FreeCameraInputsManager.
  78101. * @param camera Defines the camera the inputs belong to
  78102. */
  78103. constructor(camera: FreeCamera);
  78104. /**
  78105. * Add keyboard input support to the input manager.
  78106. * @returns the current input manager
  78107. */
  78108. addKeyboard(): FreeCameraInputsManager;
  78109. /**
  78110. * Add mouse input support to the input manager.
  78111. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78112. * @returns the current input manager
  78113. */
  78114. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78115. /**
  78116. * Removes the mouse input support from the manager
  78117. * @returns the current input manager
  78118. */
  78119. removeMouse(): FreeCameraInputsManager;
  78120. /**
  78121. * Add touch input support to the input manager.
  78122. * @returns the current input manager
  78123. */
  78124. addTouch(): FreeCameraInputsManager;
  78125. /**
  78126. * Remove all attached input methods from a camera
  78127. */
  78128. clear(): void;
  78129. }
  78130. }
  78131. declare module BABYLON {
  78132. /**
  78133. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78134. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78135. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78136. */
  78137. export class FreeCamera extends TargetCamera {
  78138. /**
  78139. * Define the collision ellipsoid of the camera.
  78140. * This is helpful to simulate a camera body like the player body around the camera
  78141. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78142. */
  78143. ellipsoid: Vector3;
  78144. /**
  78145. * Define an offset for the position of the ellipsoid around the camera.
  78146. * This can be helpful to determine the center of the body near the gravity center of the body
  78147. * instead of its head.
  78148. */
  78149. ellipsoidOffset: Vector3;
  78150. /**
  78151. * Enable or disable collisions of the camera with the rest of the scene objects.
  78152. */
  78153. checkCollisions: boolean;
  78154. /**
  78155. * Enable or disable gravity on the camera.
  78156. */
  78157. applyGravity: boolean;
  78158. /**
  78159. * Define the input manager associated to the camera.
  78160. */
  78161. inputs: FreeCameraInputsManager;
  78162. /**
  78163. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78164. * Higher values reduce sensitivity.
  78165. */
  78166. /**
  78167. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78168. * Higher values reduce sensitivity.
  78169. */
  78170. angularSensibility: number;
  78171. /**
  78172. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78173. */
  78174. keysUp: number[];
  78175. /**
  78176. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78177. */
  78178. keysDown: number[];
  78179. /**
  78180. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78181. */
  78182. keysLeft: number[];
  78183. /**
  78184. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78185. */
  78186. keysRight: number[];
  78187. /**
  78188. * Event raised when the camera collide with a mesh in the scene.
  78189. */
  78190. onCollide: (collidedMesh: AbstractMesh) => void;
  78191. private _collider;
  78192. private _needMoveForGravity;
  78193. private _oldPosition;
  78194. private _diffPosition;
  78195. private _newPosition;
  78196. /** @hidden */
  78197. _localDirection: Vector3;
  78198. /** @hidden */
  78199. _transformedDirection: Vector3;
  78200. /**
  78201. * Instantiates a Free Camera.
  78202. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78203. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78204. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78205. * @param name Define the name of the camera in the scene
  78206. * @param position Define the start position of the camera in the scene
  78207. * @param scene Define the scene the camera belongs to
  78208. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78209. */
  78210. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78211. /**
  78212. * Attached controls to the current camera.
  78213. * @param element Defines the element the controls should be listened from
  78214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78215. */
  78216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78217. /**
  78218. * Detach the current controls from the camera.
  78219. * The camera will stop reacting to inputs.
  78220. * @param element Defines the element to stop listening the inputs from
  78221. */
  78222. detachControl(element: HTMLElement): void;
  78223. private _collisionMask;
  78224. /**
  78225. * Define a collision mask to limit the list of object the camera can collide with
  78226. */
  78227. collisionMask: number;
  78228. /** @hidden */
  78229. _collideWithWorld(displacement: Vector3): void;
  78230. private _onCollisionPositionChange;
  78231. /** @hidden */
  78232. _checkInputs(): void;
  78233. /** @hidden */
  78234. _decideIfNeedsToMove(): boolean;
  78235. /** @hidden */
  78236. _updatePosition(): void;
  78237. /**
  78238. * Destroy the camera and release the current resources hold by it.
  78239. */
  78240. dispose(): void;
  78241. /**
  78242. * Gets the current object class name.
  78243. * @return the class name
  78244. */
  78245. getClassName(): string;
  78246. }
  78247. }
  78248. declare module BABYLON {
  78249. /**
  78250. * Represents a gamepad control stick position
  78251. */
  78252. export class StickValues {
  78253. /**
  78254. * The x component of the control stick
  78255. */
  78256. x: number;
  78257. /**
  78258. * The y component of the control stick
  78259. */
  78260. y: number;
  78261. /**
  78262. * Initializes the gamepad x and y control stick values
  78263. * @param x The x component of the gamepad control stick value
  78264. * @param y The y component of the gamepad control stick value
  78265. */
  78266. constructor(
  78267. /**
  78268. * The x component of the control stick
  78269. */
  78270. x: number,
  78271. /**
  78272. * The y component of the control stick
  78273. */
  78274. y: number);
  78275. }
  78276. /**
  78277. * An interface which manages callbacks for gamepad button changes
  78278. */
  78279. export interface GamepadButtonChanges {
  78280. /**
  78281. * Called when a gamepad has been changed
  78282. */
  78283. changed: boolean;
  78284. /**
  78285. * Called when a gamepad press event has been triggered
  78286. */
  78287. pressChanged: boolean;
  78288. /**
  78289. * Called when a touch event has been triggered
  78290. */
  78291. touchChanged: boolean;
  78292. /**
  78293. * Called when a value has changed
  78294. */
  78295. valueChanged: boolean;
  78296. }
  78297. /**
  78298. * Represents a gamepad
  78299. */
  78300. export class Gamepad {
  78301. /**
  78302. * The id of the gamepad
  78303. */
  78304. id: string;
  78305. /**
  78306. * The index of the gamepad
  78307. */
  78308. index: number;
  78309. /**
  78310. * The browser gamepad
  78311. */
  78312. browserGamepad: any;
  78313. /**
  78314. * Specifies what type of gamepad this represents
  78315. */
  78316. type: number;
  78317. private _leftStick;
  78318. private _rightStick;
  78319. /** @hidden */
  78320. _isConnected: boolean;
  78321. private _leftStickAxisX;
  78322. private _leftStickAxisY;
  78323. private _rightStickAxisX;
  78324. private _rightStickAxisY;
  78325. /**
  78326. * Triggered when the left control stick has been changed
  78327. */
  78328. private _onleftstickchanged;
  78329. /**
  78330. * Triggered when the right control stick has been changed
  78331. */
  78332. private _onrightstickchanged;
  78333. /**
  78334. * Represents a gamepad controller
  78335. */
  78336. static GAMEPAD: number;
  78337. /**
  78338. * Represents a generic controller
  78339. */
  78340. static GENERIC: number;
  78341. /**
  78342. * Represents an XBox controller
  78343. */
  78344. static XBOX: number;
  78345. /**
  78346. * Represents a pose-enabled controller
  78347. */
  78348. static POSE_ENABLED: number;
  78349. /**
  78350. * Represents an Dual Shock controller
  78351. */
  78352. static DUALSHOCK: number;
  78353. /**
  78354. * Specifies whether the left control stick should be Y-inverted
  78355. */
  78356. protected _invertLeftStickY: boolean;
  78357. /**
  78358. * Specifies if the gamepad has been connected
  78359. */
  78360. readonly isConnected: boolean;
  78361. /**
  78362. * Initializes the gamepad
  78363. * @param id The id of the gamepad
  78364. * @param index The index of the gamepad
  78365. * @param browserGamepad The browser gamepad
  78366. * @param leftStickX The x component of the left joystick
  78367. * @param leftStickY The y component of the left joystick
  78368. * @param rightStickX The x component of the right joystick
  78369. * @param rightStickY The y component of the right joystick
  78370. */
  78371. constructor(
  78372. /**
  78373. * The id of the gamepad
  78374. */
  78375. id: string,
  78376. /**
  78377. * The index of the gamepad
  78378. */
  78379. index: number,
  78380. /**
  78381. * The browser gamepad
  78382. */
  78383. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78384. /**
  78385. * Callback triggered when the left joystick has changed
  78386. * @param callback
  78387. */
  78388. onleftstickchanged(callback: (values: StickValues) => void): void;
  78389. /**
  78390. * Callback triggered when the right joystick has changed
  78391. * @param callback
  78392. */
  78393. onrightstickchanged(callback: (values: StickValues) => void): void;
  78394. /**
  78395. * Gets the left joystick
  78396. */
  78397. /**
  78398. * Sets the left joystick values
  78399. */
  78400. leftStick: StickValues;
  78401. /**
  78402. * Gets the right joystick
  78403. */
  78404. /**
  78405. * Sets the right joystick value
  78406. */
  78407. rightStick: StickValues;
  78408. /**
  78409. * Updates the gamepad joystick positions
  78410. */
  78411. update(): void;
  78412. /**
  78413. * Disposes the gamepad
  78414. */
  78415. dispose(): void;
  78416. }
  78417. /**
  78418. * Represents a generic gamepad
  78419. */
  78420. export class GenericPad extends Gamepad {
  78421. private _buttons;
  78422. private _onbuttondown;
  78423. private _onbuttonup;
  78424. /**
  78425. * Observable triggered when a button has been pressed
  78426. */
  78427. onButtonDownObservable: Observable<number>;
  78428. /**
  78429. * Observable triggered when a button has been released
  78430. */
  78431. onButtonUpObservable: Observable<number>;
  78432. /**
  78433. * Callback triggered when a button has been pressed
  78434. * @param callback Called when a button has been pressed
  78435. */
  78436. onbuttondown(callback: (buttonPressed: number) => void): void;
  78437. /**
  78438. * Callback triggered when a button has been released
  78439. * @param callback Called when a button has been released
  78440. */
  78441. onbuttonup(callback: (buttonReleased: number) => void): void;
  78442. /**
  78443. * Initializes the generic gamepad
  78444. * @param id The id of the generic gamepad
  78445. * @param index The index of the generic gamepad
  78446. * @param browserGamepad The browser gamepad
  78447. */
  78448. constructor(id: string, index: number, browserGamepad: any);
  78449. private _setButtonValue;
  78450. /**
  78451. * Updates the generic gamepad
  78452. */
  78453. update(): void;
  78454. /**
  78455. * Disposes the generic gamepad
  78456. */
  78457. dispose(): void;
  78458. }
  78459. }
  78460. declare module BABYLON {
  78461. interface BaseEngine {
  78462. /**
  78463. * Creates a raw texture
  78464. * @param data defines the data to store in the texture
  78465. * @param width defines the width of the texture
  78466. * @param height defines the height of the texture
  78467. * @param format defines the format of the data
  78468. * @param generateMipMaps defines if the engine should generate the mip levels
  78469. * @param invertY defines if data must be stored with Y axis inverted
  78470. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78471. * @param compression defines the compression used (null by default)
  78472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78473. * @returns the raw texture inside an InternalTexture
  78474. */
  78475. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78476. /**
  78477. * Update a raw texture
  78478. * @param texture defines the texture to update
  78479. * @param data defines the data to store in the texture
  78480. * @param format defines the format of the data
  78481. * @param invertY defines if data must be stored with Y axis inverted
  78482. */
  78483. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78484. /**
  78485. * Update a raw texture
  78486. * @param texture defines the texture to update
  78487. * @param data defines the data to store in the texture
  78488. * @param format defines the format of the data
  78489. * @param invertY defines if data must be stored with Y axis inverted
  78490. * @param compression defines the compression used (null by default)
  78491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78492. */
  78493. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78494. /**
  78495. * Creates a new raw cube texture
  78496. * @param data defines the array of data to use to create each face
  78497. * @param size defines the size of the textures
  78498. * @param format defines the format of the data
  78499. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78500. * @param generateMipMaps defines if the engine should generate the mip levels
  78501. * @param invertY defines if data must be stored with Y axis inverted
  78502. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78503. * @param compression defines the compression used (null by default)
  78504. * @returns the cube texture as an InternalTexture
  78505. */
  78506. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78507. /**
  78508. * Update a raw cube texture
  78509. * @param texture defines the texture to udpdate
  78510. * @param data defines the data to store
  78511. * @param format defines the data format
  78512. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78513. * @param invertY defines if data must be stored with Y axis inverted
  78514. */
  78515. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78516. /**
  78517. * Update a raw cube texture
  78518. * @param texture defines the texture to udpdate
  78519. * @param data defines the data to store
  78520. * @param format defines the data format
  78521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78522. * @param invertY defines if data must be stored with Y axis inverted
  78523. * @param compression defines the compression used (null by default)
  78524. */
  78525. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78526. /**
  78527. * Update a raw cube texture
  78528. * @param texture defines the texture to udpdate
  78529. * @param data defines the data to store
  78530. * @param format defines the data format
  78531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78532. * @param invertY defines if data must be stored with Y axis inverted
  78533. * @param compression defines the compression used (null by default)
  78534. * @param level defines which level of the texture to update
  78535. */
  78536. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78537. /**
  78538. * Creates a new raw cube texture from a specified url
  78539. * @param url defines the url where the data is located
  78540. * @param scene defines the current scene
  78541. * @param size defines the size of the textures
  78542. * @param format defines the format of the data
  78543. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78544. * @param noMipmap defines if the engine should avoid generating the mip levels
  78545. * @param callback defines a callback used to extract texture data from loaded data
  78546. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78547. * @param onLoad defines a callback called when texture is loaded
  78548. * @param onError defines a callback called if there is an error
  78549. * @returns the cube texture as an InternalTexture
  78550. */
  78551. 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;
  78552. /**
  78553. * Creates a new raw cube texture from a specified url
  78554. * @param url defines the url where the data is located
  78555. * @param scene defines the current scene
  78556. * @param size defines the size of the textures
  78557. * @param format defines the format of the data
  78558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78559. * @param noMipmap defines if the engine should avoid generating the mip levels
  78560. * @param callback defines a callback used to extract texture data from loaded data
  78561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78562. * @param onLoad defines a callback called when texture is loaded
  78563. * @param onError defines a callback called if there is an error
  78564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78565. * @param invertY defines if data must be stored with Y axis inverted
  78566. * @returns the cube texture as an InternalTexture
  78567. */
  78568. 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;
  78569. /**
  78570. * Creates a new raw 3D texture
  78571. * @param data defines the data used to create the texture
  78572. * @param width defines the width of the texture
  78573. * @param height defines the height of the texture
  78574. * @param depth defines the depth of the texture
  78575. * @param format defines the format of the texture
  78576. * @param generateMipMaps defines if the engine must generate mip levels
  78577. * @param invertY defines if data must be stored with Y axis inverted
  78578. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78579. * @param compression defines the compressed used (can be null)
  78580. * @param textureType defines the compressed used (can be null)
  78581. * @returns a new raw 3D texture (stored in an InternalTexture)
  78582. */
  78583. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78584. /**
  78585. * Update a raw 3D texture
  78586. * @param texture defines the texture to update
  78587. * @param data defines the data to store
  78588. * @param format defines the data format
  78589. * @param invertY defines if data must be stored with Y axis inverted
  78590. */
  78591. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78592. /**
  78593. * Update a raw 3D texture
  78594. * @param texture defines the texture to update
  78595. * @param data defines the data to store
  78596. * @param format defines the data format
  78597. * @param invertY defines if data must be stored with Y axis inverted
  78598. * @param compression defines the used compression (can be null)
  78599. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78600. */
  78601. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78602. }
  78603. }
  78604. declare module BABYLON {
  78605. /**
  78606. * Raw texture can help creating a texture directly from an array of data.
  78607. * This can be super useful if you either get the data from an uncompressed source or
  78608. * if you wish to create your texture pixel by pixel.
  78609. */
  78610. export class RawTexture extends Texture {
  78611. /**
  78612. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78613. */
  78614. format: number;
  78615. private _engine;
  78616. /**
  78617. * Instantiates a new RawTexture.
  78618. * Raw texture can help creating a texture directly from an array of data.
  78619. * This can be super useful if you either get the data from an uncompressed source or
  78620. * if you wish to create your texture pixel by pixel.
  78621. * @param data define the array of data to use to create the texture
  78622. * @param width define the width of the texture
  78623. * @param height define the height of the texture
  78624. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78625. * @param scene define the scene the texture belongs to
  78626. * @param generateMipMaps define whether mip maps should be generated or not
  78627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78629. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78630. */
  78631. constructor(data: ArrayBufferView, width: number, height: number,
  78632. /**
  78633. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78634. */
  78635. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78636. /**
  78637. * Updates the texture underlying data.
  78638. * @param data Define the new data of the texture
  78639. */
  78640. update(data: ArrayBufferView): void;
  78641. /**
  78642. * Creates a luminance texture from some data.
  78643. * @param data Define the texture data
  78644. * @param width Define the width of the texture
  78645. * @param height Define the height of the texture
  78646. * @param scene Define the scene the texture belongs to
  78647. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78648. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78649. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78650. * @returns the luminance texture
  78651. */
  78652. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78653. /**
  78654. * Creates a luminance alpha texture from some data.
  78655. * @param data Define the texture data
  78656. * @param width Define the width of the texture
  78657. * @param height Define the height of the texture
  78658. * @param scene Define the scene the texture belongs to
  78659. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78662. * @returns the luminance alpha texture
  78663. */
  78664. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78665. /**
  78666. * Creates an alpha texture from some data.
  78667. * @param data Define the texture data
  78668. * @param width Define the width of the texture
  78669. * @param height Define the height of the texture
  78670. * @param scene Define the scene the texture belongs to
  78671. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78672. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78673. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78674. * @returns the alpha texture
  78675. */
  78676. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78677. /**
  78678. * Creates a RGB texture from some data.
  78679. * @param data Define the texture data
  78680. * @param width Define the width of the texture
  78681. * @param height Define the height of the texture
  78682. * @param scene Define the scene the texture belongs to
  78683. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78684. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78685. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78686. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78687. * @returns the RGB alpha texture
  78688. */
  78689. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78690. /**
  78691. * Creates a RGBA texture from some data.
  78692. * @param data Define the texture data
  78693. * @param width Define the width of the texture
  78694. * @param height Define the height of the texture
  78695. * @param scene Define the scene the texture belongs to
  78696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78699. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78700. * @returns the RGBA texture
  78701. */
  78702. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78703. /**
  78704. * Creates a R texture from some data.
  78705. * @param data Define the texture data
  78706. * @param width Define the width of the texture
  78707. * @param height Define the height of the texture
  78708. * @param scene Define the scene the texture belongs to
  78709. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78713. * @returns the R texture
  78714. */
  78715. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78716. }
  78717. }
  78718. declare module BABYLON {
  78719. /**
  78720. * Interface for the size containing width and height
  78721. */
  78722. export interface ISize {
  78723. /**
  78724. * Width
  78725. */
  78726. width: number;
  78727. /**
  78728. * Heighht
  78729. */
  78730. height: number;
  78731. }
  78732. /**
  78733. * Size containing widht and height
  78734. */
  78735. export class Size implements ISize {
  78736. /**
  78737. * Width
  78738. */
  78739. width: number;
  78740. /**
  78741. * Height
  78742. */
  78743. height: number;
  78744. /**
  78745. * Creates a Size object from the given width and height (floats).
  78746. * @param width width of the new size
  78747. * @param height height of the new size
  78748. */
  78749. constructor(width: number, height: number);
  78750. /**
  78751. * Returns a string with the Size width and height
  78752. * @returns a string with the Size width and height
  78753. */
  78754. toString(): string;
  78755. /**
  78756. * "Size"
  78757. * @returns the string "Size"
  78758. */
  78759. getClassName(): string;
  78760. /**
  78761. * Returns the Size hash code.
  78762. * @returns a hash code for a unique width and height
  78763. */
  78764. getHashCode(): number;
  78765. /**
  78766. * Updates the current size from the given one.
  78767. * @param src the given size
  78768. */
  78769. copyFrom(src: Size): void;
  78770. /**
  78771. * Updates in place the current Size from the given floats.
  78772. * @param width width of the new size
  78773. * @param height height of the new size
  78774. * @returns the updated Size.
  78775. */
  78776. copyFromFloats(width: number, height: number): Size;
  78777. /**
  78778. * Updates in place the current Size from the given floats.
  78779. * @param width width to set
  78780. * @param height height to set
  78781. * @returns the updated Size.
  78782. */
  78783. set(width: number, height: number): Size;
  78784. /**
  78785. * Multiplies the width and height by numbers
  78786. * @param w factor to multiple the width by
  78787. * @param h factor to multiple the height by
  78788. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78789. */
  78790. multiplyByFloats(w: number, h: number): Size;
  78791. /**
  78792. * Clones the size
  78793. * @returns a new Size copied from the given one.
  78794. */
  78795. clone(): Size;
  78796. /**
  78797. * True if the current Size and the given one width and height are strictly equal.
  78798. * @param other the other size to compare against
  78799. * @returns True if the current Size and the given one width and height are strictly equal.
  78800. */
  78801. equals(other: Size): boolean;
  78802. /**
  78803. * The surface of the Size : width * height (float).
  78804. */
  78805. readonly surface: number;
  78806. /**
  78807. * Create a new size of zero
  78808. * @returns a new Size set to (0.0, 0.0)
  78809. */
  78810. static Zero(): Size;
  78811. /**
  78812. * Sums the width and height of two sizes
  78813. * @param otherSize size to add to this size
  78814. * @returns a new Size set as the addition result of the current Size and the given one.
  78815. */
  78816. add(otherSize: Size): Size;
  78817. /**
  78818. * Subtracts the width and height of two
  78819. * @param otherSize size to subtract to this size
  78820. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78821. */
  78822. subtract(otherSize: Size): Size;
  78823. /**
  78824. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78825. * @param start starting size to lerp between
  78826. * @param end end size to lerp between
  78827. * @param amount amount to lerp between the start and end values
  78828. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78829. */
  78830. static Lerp(start: Size, end: Size, amount: number): Size;
  78831. }
  78832. }
  78833. declare module BABYLON {
  78834. /**
  78835. * Defines a runtime animation
  78836. */
  78837. export class RuntimeAnimation {
  78838. private _events;
  78839. /**
  78840. * The current frame of the runtime animation
  78841. */
  78842. private _currentFrame;
  78843. /**
  78844. * The animation used by the runtime animation
  78845. */
  78846. private _animation;
  78847. /**
  78848. * The target of the runtime animation
  78849. */
  78850. private _target;
  78851. /**
  78852. * The initiating animatable
  78853. */
  78854. private _host;
  78855. /**
  78856. * The original value of the runtime animation
  78857. */
  78858. private _originalValue;
  78859. /**
  78860. * The original blend value of the runtime animation
  78861. */
  78862. private _originalBlendValue;
  78863. /**
  78864. * The offsets cache of the runtime animation
  78865. */
  78866. private _offsetsCache;
  78867. /**
  78868. * The high limits cache of the runtime animation
  78869. */
  78870. private _highLimitsCache;
  78871. /**
  78872. * Specifies if the runtime animation has been stopped
  78873. */
  78874. private _stopped;
  78875. /**
  78876. * The blending factor of the runtime animation
  78877. */
  78878. private _blendingFactor;
  78879. /**
  78880. * The BabylonJS scene
  78881. */
  78882. private _scene;
  78883. /**
  78884. * The current value of the runtime animation
  78885. */
  78886. private _currentValue;
  78887. /** @hidden */
  78888. _animationState: _IAnimationState;
  78889. /**
  78890. * The active target of the runtime animation
  78891. */
  78892. private _activeTargets;
  78893. private _currentActiveTarget;
  78894. private _directTarget;
  78895. /**
  78896. * The target path of the runtime animation
  78897. */
  78898. private _targetPath;
  78899. /**
  78900. * The weight of the runtime animation
  78901. */
  78902. private _weight;
  78903. /**
  78904. * The ratio offset of the runtime animation
  78905. */
  78906. private _ratioOffset;
  78907. /**
  78908. * The previous delay of the runtime animation
  78909. */
  78910. private _previousDelay;
  78911. /**
  78912. * The previous ratio of the runtime animation
  78913. */
  78914. private _previousRatio;
  78915. private _enableBlending;
  78916. private _keys;
  78917. private _minFrame;
  78918. private _maxFrame;
  78919. private _minValue;
  78920. private _maxValue;
  78921. private _targetIsArray;
  78922. /**
  78923. * Gets the current frame of the runtime animation
  78924. */
  78925. readonly currentFrame: number;
  78926. /**
  78927. * Gets the weight of the runtime animation
  78928. */
  78929. readonly weight: number;
  78930. /**
  78931. * Gets the current value of the runtime animation
  78932. */
  78933. readonly currentValue: any;
  78934. /**
  78935. * Gets the target path of the runtime animation
  78936. */
  78937. readonly targetPath: string;
  78938. /**
  78939. * Gets the actual target of the runtime animation
  78940. */
  78941. readonly target: any;
  78942. /** @hidden */
  78943. _onLoop: () => void;
  78944. /**
  78945. * Create a new RuntimeAnimation object
  78946. * @param target defines the target of the animation
  78947. * @param animation defines the source animation object
  78948. * @param scene defines the hosting scene
  78949. * @param host defines the initiating Animatable
  78950. */
  78951. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78952. private _preparePath;
  78953. /**
  78954. * Gets the animation from the runtime animation
  78955. */
  78956. readonly animation: Animation;
  78957. /**
  78958. * Resets the runtime animation to the beginning
  78959. * @param restoreOriginal defines whether to restore the target property to the original value
  78960. */
  78961. reset(restoreOriginal?: boolean): void;
  78962. /**
  78963. * Specifies if the runtime animation is stopped
  78964. * @returns Boolean specifying if the runtime animation is stopped
  78965. */
  78966. isStopped(): boolean;
  78967. /**
  78968. * Disposes of the runtime animation
  78969. */
  78970. dispose(): void;
  78971. /**
  78972. * Apply the interpolated value to the target
  78973. * @param currentValue defines the value computed by the animation
  78974. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78975. */
  78976. setValue(currentValue: any, weight: number): void;
  78977. private _getOriginalValues;
  78978. private _setValue;
  78979. /**
  78980. * Gets the loop pmode of the runtime animation
  78981. * @returns Loop Mode
  78982. */
  78983. private _getCorrectLoopMode;
  78984. /**
  78985. * Move the current animation to a given frame
  78986. * @param frame defines the frame to move to
  78987. */
  78988. goToFrame(frame: number): void;
  78989. /**
  78990. * @hidden Internal use only
  78991. */
  78992. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78993. /**
  78994. * Execute the current animation
  78995. * @param delay defines the delay to add to the current frame
  78996. * @param from defines the lower bound of the animation range
  78997. * @param to defines the upper bound of the animation range
  78998. * @param loop defines if the current animation must loop
  78999. * @param speedRatio defines the current speed ratio
  79000. * @param weight defines the weight of the animation (default is -1 so no weight)
  79001. * @param onLoop optional callback called when animation loops
  79002. * @returns a boolean indicating if the animation is running
  79003. */
  79004. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79005. }
  79006. }
  79007. declare module BABYLON {
  79008. /**
  79009. * Class used to store an actual running animation
  79010. */
  79011. export class Animatable {
  79012. /** defines the target object */
  79013. target: any;
  79014. /** defines the starting frame number (default is 0) */
  79015. fromFrame: number;
  79016. /** defines the ending frame number (default is 100) */
  79017. toFrame: number;
  79018. /** defines if the animation must loop (default is false) */
  79019. loopAnimation: boolean;
  79020. /** defines a callback to call when animation ends if it is not looping */
  79021. onAnimationEnd?: (() => void) | null | undefined;
  79022. /** defines a callback to call when animation loops */
  79023. onAnimationLoop?: (() => void) | null | undefined;
  79024. private _localDelayOffset;
  79025. private _pausedDelay;
  79026. private _runtimeAnimations;
  79027. private _paused;
  79028. private _scene;
  79029. private _speedRatio;
  79030. private _weight;
  79031. private _syncRoot;
  79032. /**
  79033. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79034. * This will only apply for non looping animation (default is true)
  79035. */
  79036. disposeOnEnd: boolean;
  79037. /**
  79038. * Gets a boolean indicating if the animation has started
  79039. */
  79040. animationStarted: boolean;
  79041. /**
  79042. * Observer raised when the animation ends
  79043. */
  79044. onAnimationEndObservable: Observable<Animatable>;
  79045. /**
  79046. * Observer raised when the animation loops
  79047. */
  79048. onAnimationLoopObservable: Observable<Animatable>;
  79049. /**
  79050. * Gets the root Animatable used to synchronize and normalize animations
  79051. */
  79052. readonly syncRoot: Nullable<Animatable>;
  79053. /**
  79054. * Gets the current frame of the first RuntimeAnimation
  79055. * Used to synchronize Animatables
  79056. */
  79057. readonly masterFrame: number;
  79058. /**
  79059. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79060. */
  79061. weight: number;
  79062. /**
  79063. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79064. */
  79065. speedRatio: number;
  79066. /**
  79067. * Creates a new Animatable
  79068. * @param scene defines the hosting scene
  79069. * @param target defines the target object
  79070. * @param fromFrame defines the starting frame number (default is 0)
  79071. * @param toFrame defines the ending frame number (default is 100)
  79072. * @param loopAnimation defines if the animation must loop (default is false)
  79073. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79074. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79075. * @param animations defines a group of animation to add to the new Animatable
  79076. * @param onAnimationLoop defines a callback to call when animation loops
  79077. */
  79078. constructor(scene: Scene,
  79079. /** defines the target object */
  79080. target: any,
  79081. /** defines the starting frame number (default is 0) */
  79082. fromFrame?: number,
  79083. /** defines the ending frame number (default is 100) */
  79084. toFrame?: number,
  79085. /** defines if the animation must loop (default is false) */
  79086. loopAnimation?: boolean, speedRatio?: number,
  79087. /** defines a callback to call when animation ends if it is not looping */
  79088. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79089. /** defines a callback to call when animation loops */
  79090. onAnimationLoop?: (() => void) | null | undefined);
  79091. /**
  79092. * Synchronize and normalize current Animatable with a source Animatable
  79093. * This is useful when using animation weights and when animations are not of the same length
  79094. * @param root defines the root Animatable to synchronize with
  79095. * @returns the current Animatable
  79096. */
  79097. syncWith(root: Animatable): Animatable;
  79098. /**
  79099. * Gets the list of runtime animations
  79100. * @returns an array of RuntimeAnimation
  79101. */
  79102. getAnimations(): RuntimeAnimation[];
  79103. /**
  79104. * Adds more animations to the current animatable
  79105. * @param target defines the target of the animations
  79106. * @param animations defines the new animations to add
  79107. */
  79108. appendAnimations(target: any, animations: Animation[]): void;
  79109. /**
  79110. * Gets the source animation for a specific property
  79111. * @param property defines the propertyu to look for
  79112. * @returns null or the source animation for the given property
  79113. */
  79114. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79115. /**
  79116. * Gets the runtime animation for a specific property
  79117. * @param property defines the propertyu to look for
  79118. * @returns null or the runtime animation for the given property
  79119. */
  79120. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79121. /**
  79122. * Resets the animatable to its original state
  79123. */
  79124. reset(): void;
  79125. /**
  79126. * Allows the animatable to blend with current running animations
  79127. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79128. * @param blendingSpeed defines the blending speed to use
  79129. */
  79130. enableBlending(blendingSpeed: number): void;
  79131. /**
  79132. * Disable animation blending
  79133. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79134. */
  79135. disableBlending(): void;
  79136. /**
  79137. * Jump directly to a given frame
  79138. * @param frame defines the frame to jump to
  79139. */
  79140. goToFrame(frame: number): void;
  79141. /**
  79142. * Pause the animation
  79143. */
  79144. pause(): void;
  79145. /**
  79146. * Restart the animation
  79147. */
  79148. restart(): void;
  79149. private _raiseOnAnimationEnd;
  79150. /**
  79151. * Stop and delete the current animation
  79152. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79153. * @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)
  79154. */
  79155. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79156. /**
  79157. * Wait asynchronously for the animation to end
  79158. * @returns a promise which will be fullfilled when the animation ends
  79159. */
  79160. waitAsync(): Promise<Animatable>;
  79161. /** @hidden */
  79162. _animate(delay: number): boolean;
  79163. }
  79164. interface Scene {
  79165. /** @hidden */
  79166. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79167. /** @hidden */
  79168. _processLateAnimationBindingsForMatrices(holder: {
  79169. totalWeight: number;
  79170. animations: RuntimeAnimation[];
  79171. originalValue: Matrix;
  79172. }): any;
  79173. /** @hidden */
  79174. _processLateAnimationBindingsForQuaternions(holder: {
  79175. totalWeight: number;
  79176. animations: RuntimeAnimation[];
  79177. originalValue: Quaternion;
  79178. }, refQuaternion: Quaternion): Quaternion;
  79179. /** @hidden */
  79180. _processLateAnimationBindings(): void;
  79181. /**
  79182. * Will start the animation sequence of a given target
  79183. * @param target defines the target
  79184. * @param from defines from which frame should animation start
  79185. * @param to defines until which frame should animation run.
  79186. * @param weight defines the weight to apply to the animation (1.0 by default)
  79187. * @param loop defines if the animation loops
  79188. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79189. * @param onAnimationEnd defines the function to be executed when the animation ends
  79190. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79191. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79192. * @param onAnimationLoop defines the callback to call when an animation loops
  79193. * @returns the animatable object created for this animation
  79194. */
  79195. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79196. /**
  79197. * Will start the animation sequence of a given target
  79198. * @param target defines the target
  79199. * @param from defines from which frame should animation start
  79200. * @param to defines until which frame should animation run.
  79201. * @param loop defines if the animation loops
  79202. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79203. * @param onAnimationEnd defines the function to be executed when the animation ends
  79204. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79205. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79206. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79207. * @param onAnimationLoop defines the callback to call when an animation loops
  79208. * @returns the animatable object created for this animation
  79209. */
  79210. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79211. /**
  79212. * Will start the animation sequence of a given target and its hierarchy
  79213. * @param target defines the target
  79214. * @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.
  79215. * @param from defines from which frame should animation start
  79216. * @param to defines until which frame should animation run.
  79217. * @param loop defines if the animation loops
  79218. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79219. * @param onAnimationEnd defines the function to be executed when the animation ends
  79220. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79221. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79222. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79223. * @param onAnimationLoop defines the callback to call when an animation loops
  79224. * @returns the list of created animatables
  79225. */
  79226. 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[];
  79227. /**
  79228. * Begin a new animation on a given node
  79229. * @param target defines the target where the animation will take place
  79230. * @param animations defines the list of animations to start
  79231. * @param from defines the initial value
  79232. * @param to defines the final value
  79233. * @param loop defines if you want animation to loop (off by default)
  79234. * @param speedRatio defines the speed ratio to apply to all animations
  79235. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79236. * @param onAnimationLoop defines the callback to call when an animation loops
  79237. * @returns the list of created animatables
  79238. */
  79239. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79240. /**
  79241. * Begin a new animation on a given node and its hierarchy
  79242. * @param target defines the root node where the animation will take place
  79243. * @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.
  79244. * @param animations defines the list of animations to start
  79245. * @param from defines the initial value
  79246. * @param to defines the final value
  79247. * @param loop defines if you want animation to loop (off by default)
  79248. * @param speedRatio defines the speed ratio to apply to all animations
  79249. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79250. * @param onAnimationLoop defines the callback to call when an animation loops
  79251. * @returns the list of animatables created for all nodes
  79252. */
  79253. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79254. /**
  79255. * Gets the animatable associated with a specific target
  79256. * @param target defines the target of the animatable
  79257. * @returns the required animatable if found
  79258. */
  79259. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79260. /**
  79261. * Gets all animatables associated with a given target
  79262. * @param target defines the target to look animatables for
  79263. * @returns an array of Animatables
  79264. */
  79265. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79266. /**
  79267. * Stops and removes all animations that have been applied to the scene
  79268. */
  79269. stopAllAnimations(): void;
  79270. }
  79271. interface Bone {
  79272. /**
  79273. * Copy an animation range from another bone
  79274. * @param source defines the source bone
  79275. * @param rangeName defines the range name to copy
  79276. * @param frameOffset defines the frame offset
  79277. * @param rescaleAsRequired defines if rescaling must be applied if required
  79278. * @param skelDimensionsRatio defines the scaling ratio
  79279. * @returns true if operation was successful
  79280. */
  79281. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79282. }
  79283. }
  79284. declare module BABYLON {
  79285. /**
  79286. * Class used to override all child animations of a given target
  79287. */
  79288. export class AnimationPropertiesOverride {
  79289. /**
  79290. * Gets or sets a value indicating if animation blending must be used
  79291. */
  79292. enableBlending: boolean;
  79293. /**
  79294. * Gets or sets the blending speed to use when enableBlending is true
  79295. */
  79296. blendingSpeed: number;
  79297. /**
  79298. * Gets or sets the default loop mode to use
  79299. */
  79300. loopMode: number;
  79301. }
  79302. }
  79303. declare module BABYLON {
  79304. /**
  79305. * Class used to handle skinning animations
  79306. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79307. */
  79308. export class Skeleton implements IAnimatable {
  79309. /** defines the skeleton name */
  79310. name: string;
  79311. /** defines the skeleton Id */
  79312. id: string;
  79313. /**
  79314. * Defines the list of child bones
  79315. */
  79316. bones: Bone[];
  79317. /**
  79318. * Defines an estimate of the dimension of the skeleton at rest
  79319. */
  79320. dimensionsAtRest: Vector3;
  79321. /**
  79322. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79323. */
  79324. needInitialSkinMatrix: boolean;
  79325. /**
  79326. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79327. */
  79328. overrideMesh: Nullable<AbstractMesh>;
  79329. /**
  79330. * Gets the list of animations attached to this skeleton
  79331. */
  79332. animations: Array<Animation>;
  79333. private _scene;
  79334. private _isDirty;
  79335. private _transformMatrices;
  79336. private _transformMatrixTexture;
  79337. private _meshesWithPoseMatrix;
  79338. private _animatables;
  79339. private _identity;
  79340. private _synchronizedWithMesh;
  79341. private _ranges;
  79342. private _lastAbsoluteTransformsUpdateId;
  79343. private _canUseTextureForBones;
  79344. private _uniqueId;
  79345. /** @hidden */
  79346. _numBonesWithLinkedTransformNode: number;
  79347. /** @hidden */
  79348. _hasWaitingData: Nullable<boolean>;
  79349. /**
  79350. * Specifies if the skeleton should be serialized
  79351. */
  79352. doNotSerialize: boolean;
  79353. private _useTextureToStoreBoneMatrices;
  79354. /**
  79355. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79356. * Please note that this option is not available if the hardware does not support it
  79357. */
  79358. useTextureToStoreBoneMatrices: boolean;
  79359. private _animationPropertiesOverride;
  79360. /**
  79361. * Gets or sets the animation properties override
  79362. */
  79363. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79364. /**
  79365. * List of inspectable custom properties (used by the Inspector)
  79366. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79367. */
  79368. inspectableCustomProperties: IInspectable[];
  79369. /**
  79370. * An observable triggered before computing the skeleton's matrices
  79371. */
  79372. onBeforeComputeObservable: Observable<Skeleton>;
  79373. /**
  79374. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79375. */
  79376. readonly isUsingTextureForMatrices: boolean;
  79377. /**
  79378. * Gets the unique ID of this skeleton
  79379. */
  79380. readonly uniqueId: number;
  79381. /**
  79382. * Creates a new skeleton
  79383. * @param name defines the skeleton name
  79384. * @param id defines the skeleton Id
  79385. * @param scene defines the hosting scene
  79386. */
  79387. constructor(
  79388. /** defines the skeleton name */
  79389. name: string,
  79390. /** defines the skeleton Id */
  79391. id: string, scene: Scene);
  79392. /**
  79393. * Gets the current object class name.
  79394. * @return the class name
  79395. */
  79396. getClassName(): string;
  79397. /**
  79398. * Returns an array containing the root bones
  79399. * @returns an array containing the root bones
  79400. */
  79401. getChildren(): Array<Bone>;
  79402. /**
  79403. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79404. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79405. * @returns a Float32Array containing matrices data
  79406. */
  79407. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79408. /**
  79409. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79410. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79411. * @returns a raw texture containing the data
  79412. */
  79413. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79414. /**
  79415. * Gets the current hosting scene
  79416. * @returns a scene object
  79417. */
  79418. getScene(): Scene;
  79419. /**
  79420. * Gets a string representing the current skeleton data
  79421. * @param fullDetails defines a boolean indicating if we want a verbose version
  79422. * @returns a string representing the current skeleton data
  79423. */
  79424. toString(fullDetails?: boolean): string;
  79425. /**
  79426. * Get bone's index searching by name
  79427. * @param name defines bone's name to search for
  79428. * @return the indice of the bone. Returns -1 if not found
  79429. */
  79430. getBoneIndexByName(name: string): number;
  79431. /**
  79432. * Creater a new animation range
  79433. * @param name defines the name of the range
  79434. * @param from defines the start key
  79435. * @param to defines the end key
  79436. */
  79437. createAnimationRange(name: string, from: number, to: number): void;
  79438. /**
  79439. * Delete a specific animation range
  79440. * @param name defines the name of the range
  79441. * @param deleteFrames defines if frames must be removed as well
  79442. */
  79443. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79444. /**
  79445. * Gets a specific animation range
  79446. * @param name defines the name of the range to look for
  79447. * @returns the requested animation range or null if not found
  79448. */
  79449. getAnimationRange(name: string): Nullable<AnimationRange>;
  79450. /**
  79451. * Gets the list of all animation ranges defined on this skeleton
  79452. * @returns an array
  79453. */
  79454. getAnimationRanges(): Nullable<AnimationRange>[];
  79455. /**
  79456. * Copy animation range from a source skeleton.
  79457. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79458. * @param source defines the source skeleton
  79459. * @param name defines the name of the range to copy
  79460. * @param rescaleAsRequired defines if rescaling must be applied if required
  79461. * @returns true if operation was successful
  79462. */
  79463. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79464. /**
  79465. * Forces the skeleton to go to rest pose
  79466. */
  79467. returnToRest(): void;
  79468. private _getHighestAnimationFrame;
  79469. /**
  79470. * Begin a specific animation range
  79471. * @param name defines the name of the range to start
  79472. * @param loop defines if looping must be turned on (false by default)
  79473. * @param speedRatio defines the speed ratio to apply (1 by default)
  79474. * @param onAnimationEnd defines a callback which will be called when animation will end
  79475. * @returns a new animatable
  79476. */
  79477. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79478. /** @hidden */
  79479. _markAsDirty(): void;
  79480. /** @hidden */
  79481. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79482. /** @hidden */
  79483. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79484. private _computeTransformMatrices;
  79485. /**
  79486. * Build all resources required to render a skeleton
  79487. */
  79488. prepare(): void;
  79489. /**
  79490. * Gets the list of animatables currently running for this skeleton
  79491. * @returns an array of animatables
  79492. */
  79493. getAnimatables(): IAnimatable[];
  79494. /**
  79495. * Clone the current skeleton
  79496. * @param name defines the name of the new skeleton
  79497. * @param id defines the id of the new skeleton
  79498. * @returns the new skeleton
  79499. */
  79500. clone(name: string, id: string): Skeleton;
  79501. /**
  79502. * Enable animation blending for this skeleton
  79503. * @param blendingSpeed defines the blending speed to apply
  79504. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79505. */
  79506. enableBlending(blendingSpeed?: number): void;
  79507. /**
  79508. * Releases all resources associated with the current skeleton
  79509. */
  79510. dispose(): void;
  79511. /**
  79512. * Serialize the skeleton in a JSON object
  79513. * @returns a JSON object
  79514. */
  79515. serialize(): any;
  79516. /**
  79517. * Creates a new skeleton from serialized data
  79518. * @param parsedSkeleton defines the serialized data
  79519. * @param scene defines the hosting scene
  79520. * @returns a new skeleton
  79521. */
  79522. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79523. /**
  79524. * Compute all node absolute transforms
  79525. * @param forceUpdate defines if computation must be done even if cache is up to date
  79526. */
  79527. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79528. /**
  79529. * Gets the root pose matrix
  79530. * @returns a matrix
  79531. */
  79532. getPoseMatrix(): Nullable<Matrix>;
  79533. /**
  79534. * Sorts bones per internal index
  79535. */
  79536. sortBones(): void;
  79537. private _sortBones;
  79538. }
  79539. }
  79540. declare module BABYLON {
  79541. /**
  79542. * Class used to store bone information
  79543. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79544. */
  79545. export class Bone extends Node {
  79546. /**
  79547. * defines the bone name
  79548. */
  79549. name: string;
  79550. private static _tmpVecs;
  79551. private static _tmpQuat;
  79552. private static _tmpMats;
  79553. /**
  79554. * Gets the list of child bones
  79555. */
  79556. children: Bone[];
  79557. /** Gets the animations associated with this bone */
  79558. animations: Animation[];
  79559. /**
  79560. * Gets or sets bone length
  79561. */
  79562. length: number;
  79563. /**
  79564. * @hidden Internal only
  79565. * Set this value to map this bone to a different index in the transform matrices
  79566. * Set this value to -1 to exclude the bone from the transform matrices
  79567. */
  79568. _index: Nullable<number>;
  79569. private _skeleton;
  79570. private _localMatrix;
  79571. private _restPose;
  79572. private _baseMatrix;
  79573. private _absoluteTransform;
  79574. private _invertedAbsoluteTransform;
  79575. private _parent;
  79576. private _scalingDeterminant;
  79577. private _worldTransform;
  79578. private _localScaling;
  79579. private _localRotation;
  79580. private _localPosition;
  79581. private _needToDecompose;
  79582. private _needToCompose;
  79583. /** @hidden */
  79584. _linkedTransformNode: Nullable<TransformNode>;
  79585. /** @hidden */
  79586. _waitingTransformNodeId: Nullable<string>;
  79587. /** @hidden */
  79588. /** @hidden */
  79589. _matrix: Matrix;
  79590. /**
  79591. * Create a new bone
  79592. * @param name defines the bone name
  79593. * @param skeleton defines the parent skeleton
  79594. * @param parentBone defines the parent (can be null if the bone is the root)
  79595. * @param localMatrix defines the local matrix
  79596. * @param restPose defines the rest pose matrix
  79597. * @param baseMatrix defines the base matrix
  79598. * @param index defines index of the bone in the hiearchy
  79599. */
  79600. constructor(
  79601. /**
  79602. * defines the bone name
  79603. */
  79604. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79605. /**
  79606. * Gets the current object class name.
  79607. * @return the class name
  79608. */
  79609. getClassName(): string;
  79610. /**
  79611. * Gets the parent skeleton
  79612. * @returns a skeleton
  79613. */
  79614. getSkeleton(): Skeleton;
  79615. /**
  79616. * Gets parent bone
  79617. * @returns a bone or null if the bone is the root of the bone hierarchy
  79618. */
  79619. getParent(): Nullable<Bone>;
  79620. /**
  79621. * Returns an array containing the root bones
  79622. * @returns an array containing the root bones
  79623. */
  79624. getChildren(): Array<Bone>;
  79625. /**
  79626. * Sets the parent bone
  79627. * @param parent defines the parent (can be null if the bone is the root)
  79628. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79629. */
  79630. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79631. /**
  79632. * Gets the local matrix
  79633. * @returns a matrix
  79634. */
  79635. getLocalMatrix(): Matrix;
  79636. /**
  79637. * Gets the base matrix (initial matrix which remains unchanged)
  79638. * @returns a matrix
  79639. */
  79640. getBaseMatrix(): Matrix;
  79641. /**
  79642. * Gets the rest pose matrix
  79643. * @returns a matrix
  79644. */
  79645. getRestPose(): Matrix;
  79646. /**
  79647. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79648. */
  79649. getWorldMatrix(): Matrix;
  79650. /**
  79651. * Sets the local matrix to rest pose matrix
  79652. */
  79653. returnToRest(): void;
  79654. /**
  79655. * Gets the inverse of the absolute transform matrix.
  79656. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79657. * @returns a matrix
  79658. */
  79659. getInvertedAbsoluteTransform(): Matrix;
  79660. /**
  79661. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79662. * @returns a matrix
  79663. */
  79664. getAbsoluteTransform(): Matrix;
  79665. /**
  79666. * Links with the given transform node.
  79667. * The local matrix of this bone is copied from the transform node every frame.
  79668. * @param transformNode defines the transform node to link to
  79669. */
  79670. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79671. /**
  79672. * Gets the node used to drive the bone's transformation
  79673. * @returns a transform node or null
  79674. */
  79675. getTransformNode(): Nullable<TransformNode>;
  79676. /** Gets or sets current position (in local space) */
  79677. position: Vector3;
  79678. /** Gets or sets current rotation (in local space) */
  79679. rotation: Vector3;
  79680. /** Gets or sets current rotation quaternion (in local space) */
  79681. rotationQuaternion: Quaternion;
  79682. /** Gets or sets current scaling (in local space) */
  79683. scaling: Vector3;
  79684. /**
  79685. * Gets the animation properties override
  79686. */
  79687. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79688. private _decompose;
  79689. private _compose;
  79690. /**
  79691. * Update the base and local matrices
  79692. * @param matrix defines the new base or local matrix
  79693. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79694. * @param updateLocalMatrix defines if the local matrix should be updated
  79695. */
  79696. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79697. /** @hidden */
  79698. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79699. /**
  79700. * Flag the bone as dirty (Forcing it to update everything)
  79701. */
  79702. markAsDirty(): void;
  79703. /** @hidden */
  79704. _markAsDirtyAndCompose(): void;
  79705. private _markAsDirtyAndDecompose;
  79706. /**
  79707. * Translate the bone in local or world space
  79708. * @param vec The amount to translate the bone
  79709. * @param space The space that the translation is in
  79710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79711. */
  79712. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79713. /**
  79714. * Set the postion of the bone in local or world space
  79715. * @param position The position to set the bone
  79716. * @param space The space that the position is in
  79717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79718. */
  79719. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79720. /**
  79721. * Set the absolute position of the bone (world space)
  79722. * @param position The position to set the bone
  79723. * @param mesh The mesh that this bone is attached to
  79724. */
  79725. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79726. /**
  79727. * Scale the bone on the x, y and z axes (in local space)
  79728. * @param x The amount to scale the bone on the x axis
  79729. * @param y The amount to scale the bone on the y axis
  79730. * @param z The amount to scale the bone on the z axis
  79731. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79732. */
  79733. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79734. /**
  79735. * Set the bone scaling in local space
  79736. * @param scale defines the scaling vector
  79737. */
  79738. setScale(scale: Vector3): void;
  79739. /**
  79740. * Gets the current scaling in local space
  79741. * @returns the current scaling vector
  79742. */
  79743. getScale(): Vector3;
  79744. /**
  79745. * Gets the current scaling in local space and stores it in a target vector
  79746. * @param result defines the target vector
  79747. */
  79748. getScaleToRef(result: Vector3): void;
  79749. /**
  79750. * Set the yaw, pitch, and roll of the bone in local or world space
  79751. * @param yaw The rotation of the bone on the y axis
  79752. * @param pitch The rotation of the bone on the x axis
  79753. * @param roll The rotation of the bone on the z axis
  79754. * @param space The space that the axes of rotation are in
  79755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79756. */
  79757. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79758. /**
  79759. * Add a rotation to the bone on an axis in local or world space
  79760. * @param axis The axis to rotate the bone on
  79761. * @param amount The amount to rotate the bone
  79762. * @param space The space that the axis is in
  79763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79764. */
  79765. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79766. /**
  79767. * Set the rotation of the bone to a particular axis angle in local or world space
  79768. * @param axis The axis to rotate the bone on
  79769. * @param angle The angle that the bone should be rotated to
  79770. * @param space The space that the axis is in
  79771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79772. */
  79773. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79774. /**
  79775. * Set the euler rotation of the bone in local of world space
  79776. * @param rotation The euler rotation that the bone should be set to
  79777. * @param space The space that the rotation is in
  79778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79779. */
  79780. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79781. /**
  79782. * Set the quaternion rotation of the bone in local of world space
  79783. * @param quat The quaternion rotation that the bone should be set to
  79784. * @param space The space that the rotation is in
  79785. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79786. */
  79787. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79788. /**
  79789. * Set the rotation matrix of the bone in local of world space
  79790. * @param rotMat The rotation matrix that the bone should be set to
  79791. * @param space The space that the rotation is in
  79792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79793. */
  79794. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79795. private _rotateWithMatrix;
  79796. private _getNegativeRotationToRef;
  79797. /**
  79798. * Get the position of the bone in local or world space
  79799. * @param space The space that the returned position is in
  79800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79801. * @returns The position of the bone
  79802. */
  79803. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79804. /**
  79805. * Copy the position of the bone to a vector3 in local or world space
  79806. * @param space The space that the returned position is in
  79807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79808. * @param result The vector3 to copy the position to
  79809. */
  79810. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79811. /**
  79812. * Get the absolute position of the bone (world space)
  79813. * @param mesh The mesh that this bone is attached to
  79814. * @returns The absolute position of the bone
  79815. */
  79816. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79817. /**
  79818. * Copy the absolute position of the bone (world space) to the result param
  79819. * @param mesh The mesh that this bone is attached to
  79820. * @param result The vector3 to copy the absolute position to
  79821. */
  79822. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79823. /**
  79824. * Compute the absolute transforms of this bone and its children
  79825. */
  79826. computeAbsoluteTransforms(): void;
  79827. /**
  79828. * Get the world direction from an axis that is in the local space of the bone
  79829. * @param localAxis The local direction that is used to compute the world direction
  79830. * @param mesh The mesh that this bone is attached to
  79831. * @returns The world direction
  79832. */
  79833. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79834. /**
  79835. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79836. * @param localAxis The local direction that is used to compute the world direction
  79837. * @param mesh The mesh that this bone is attached to
  79838. * @param result The vector3 that the world direction will be copied to
  79839. */
  79840. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79841. /**
  79842. * Get the euler rotation of the bone in local or world space
  79843. * @param space The space that the rotation should be in
  79844. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79845. * @returns The euler rotation
  79846. */
  79847. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79848. /**
  79849. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79850. * @param space The space that the rotation should be in
  79851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79852. * @param result The vector3 that the rotation should be copied to
  79853. */
  79854. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79855. /**
  79856. * Get the quaternion rotation of the bone in either local or world space
  79857. * @param space The space that the rotation should be in
  79858. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79859. * @returns The quaternion rotation
  79860. */
  79861. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79862. /**
  79863. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79864. * @param space The space that the rotation should be in
  79865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79866. * @param result The quaternion that the rotation should be copied to
  79867. */
  79868. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79869. /**
  79870. * Get the rotation matrix of the bone in local or world space
  79871. * @param space The space that the rotation should be in
  79872. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79873. * @returns The rotation matrix
  79874. */
  79875. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79876. /**
  79877. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79878. * @param space The space that the rotation should be in
  79879. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79880. * @param result The quaternion that the rotation should be copied to
  79881. */
  79882. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79883. /**
  79884. * Get the world position of a point that is in the local space of the bone
  79885. * @param position The local position
  79886. * @param mesh The mesh that this bone is attached to
  79887. * @returns The world position
  79888. */
  79889. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79890. /**
  79891. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79892. * @param position The local position
  79893. * @param mesh The mesh that this bone is attached to
  79894. * @param result The vector3 that the world position should be copied to
  79895. */
  79896. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79897. /**
  79898. * Get the local position of a point that is in world space
  79899. * @param position The world position
  79900. * @param mesh The mesh that this bone is attached to
  79901. * @returns The local position
  79902. */
  79903. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79904. /**
  79905. * Get the local position of a point that is in world space and copy it to the result param
  79906. * @param position The world position
  79907. * @param mesh The mesh that this bone is attached to
  79908. * @param result The vector3 that the local position should be copied to
  79909. */
  79910. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79911. }
  79912. }
  79913. declare module BABYLON {
  79914. /**
  79915. * 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.
  79916. * @see https://doc.babylonjs.com/how_to/transformnode
  79917. */
  79918. export class TransformNode extends Node {
  79919. /**
  79920. * Object will not rotate to face the camera
  79921. */
  79922. static BILLBOARDMODE_NONE: number;
  79923. /**
  79924. * Object will rotate to face the camera but only on the x axis
  79925. */
  79926. static BILLBOARDMODE_X: number;
  79927. /**
  79928. * Object will rotate to face the camera but only on the y axis
  79929. */
  79930. static BILLBOARDMODE_Y: number;
  79931. /**
  79932. * Object will rotate to face the camera but only on the z axis
  79933. */
  79934. static BILLBOARDMODE_Z: number;
  79935. /**
  79936. * Object will rotate to face the camera
  79937. */
  79938. static BILLBOARDMODE_ALL: number;
  79939. /**
  79940. * Object will rotate to face the camera's position instead of orientation
  79941. */
  79942. static BILLBOARDMODE_USE_POSITION: number;
  79943. private _forward;
  79944. private _forwardInverted;
  79945. private _up;
  79946. private _right;
  79947. private _rightInverted;
  79948. private _position;
  79949. private _rotation;
  79950. private _rotationQuaternion;
  79951. protected _scaling: Vector3;
  79952. protected _isDirty: boolean;
  79953. private _transformToBoneReferal;
  79954. private _isAbsoluteSynced;
  79955. private _billboardMode;
  79956. /**
  79957. * Gets or sets the billboard mode. Default is 0.
  79958. *
  79959. * | Value | Type | Description |
  79960. * | --- | --- | --- |
  79961. * | 0 | BILLBOARDMODE_NONE | |
  79962. * | 1 | BILLBOARDMODE_X | |
  79963. * | 2 | BILLBOARDMODE_Y | |
  79964. * | 4 | BILLBOARDMODE_Z | |
  79965. * | 7 | BILLBOARDMODE_ALL | |
  79966. *
  79967. */
  79968. billboardMode: number;
  79969. private _preserveParentRotationForBillboard;
  79970. /**
  79971. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79972. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79973. */
  79974. preserveParentRotationForBillboard: boolean;
  79975. /**
  79976. * 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
  79977. */
  79978. scalingDeterminant: number;
  79979. private _infiniteDistance;
  79980. /**
  79981. * Gets or sets the distance of the object to max, often used by skybox
  79982. */
  79983. infiniteDistance: boolean;
  79984. /**
  79985. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79986. * By default the system will update normals to compensate
  79987. */
  79988. ignoreNonUniformScaling: boolean;
  79989. /**
  79990. * 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
  79991. */
  79992. reIntegrateRotationIntoRotationQuaternion: boolean;
  79993. /** @hidden */
  79994. _poseMatrix: Nullable<Matrix>;
  79995. /** @hidden */
  79996. _localMatrix: Matrix;
  79997. private _usePivotMatrix;
  79998. private _absolutePosition;
  79999. private _absoluteScaling;
  80000. private _absoluteRotationQuaternion;
  80001. private _pivotMatrix;
  80002. private _pivotMatrixInverse;
  80003. protected _postMultiplyPivotMatrix: boolean;
  80004. protected _isWorldMatrixFrozen: boolean;
  80005. /** @hidden */
  80006. _indexInSceneTransformNodesArray: number;
  80007. /**
  80008. * An event triggered after the world matrix is updated
  80009. */
  80010. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80011. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80012. /**
  80013. * Gets a string identifying the name of the class
  80014. * @returns "TransformNode" string
  80015. */
  80016. getClassName(): string;
  80017. /**
  80018. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80019. */
  80020. position: Vector3;
  80021. /**
  80022. * 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)).
  80023. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80024. */
  80025. rotation: Vector3;
  80026. /**
  80027. * 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)).
  80028. */
  80029. scaling: Vector3;
  80030. /**
  80031. * 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).
  80032. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80033. */
  80034. rotationQuaternion: Nullable<Quaternion>;
  80035. /**
  80036. * The forward direction of that transform in world space.
  80037. */
  80038. readonly forward: Vector3;
  80039. /**
  80040. * The up direction of that transform in world space.
  80041. */
  80042. readonly up: Vector3;
  80043. /**
  80044. * The right direction of that transform in world space.
  80045. */
  80046. readonly right: Vector3;
  80047. /**
  80048. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80049. * @param matrix the matrix to copy the pose from
  80050. * @returns this TransformNode.
  80051. */
  80052. updatePoseMatrix(matrix: Matrix): TransformNode;
  80053. /**
  80054. * Returns the mesh Pose matrix.
  80055. * @returns the pose matrix
  80056. */
  80057. getPoseMatrix(): Matrix;
  80058. /** @hidden */
  80059. _isSynchronized(): boolean;
  80060. /** @hidden */
  80061. _initCache(): void;
  80062. /**
  80063. * Flag the transform node as dirty (Forcing it to update everything)
  80064. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80065. * @returns this transform node
  80066. */
  80067. markAsDirty(property: string): TransformNode;
  80068. /**
  80069. * Returns the current mesh absolute position.
  80070. * Returns a Vector3.
  80071. */
  80072. readonly absolutePosition: Vector3;
  80073. /**
  80074. * Returns the current mesh absolute scaling.
  80075. * Returns a Vector3.
  80076. */
  80077. readonly absoluteScaling: Vector3;
  80078. /**
  80079. * Returns the current mesh absolute rotation.
  80080. * Returns a Quaternion.
  80081. */
  80082. readonly absoluteRotationQuaternion: Quaternion;
  80083. /**
  80084. * Sets a new matrix to apply before all other transformation
  80085. * @param matrix defines the transform matrix
  80086. * @returns the current TransformNode
  80087. */
  80088. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80089. /**
  80090. * Sets a new pivot matrix to the current node
  80091. * @param matrix defines the new pivot matrix to use
  80092. * @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
  80093. * @returns the current TransformNode
  80094. */
  80095. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80096. /**
  80097. * Returns the mesh pivot matrix.
  80098. * Default : Identity.
  80099. * @returns the matrix
  80100. */
  80101. getPivotMatrix(): Matrix;
  80102. /**
  80103. * Instantiate (when possible) or clone that node with its hierarchy
  80104. * @param newParent defines the new parent to use for the instance (or clone)
  80105. * @returns an instance (or a clone) of the current node with its hiearchy
  80106. */
  80107. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80108. /**
  80109. * Prevents the World matrix to be computed any longer
  80110. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80111. * @returns the TransformNode.
  80112. */
  80113. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80114. /**
  80115. * Allows back the World matrix computation.
  80116. * @returns the TransformNode.
  80117. */
  80118. unfreezeWorldMatrix(): this;
  80119. /**
  80120. * True if the World matrix has been frozen.
  80121. */
  80122. readonly isWorldMatrixFrozen: boolean;
  80123. /**
  80124. * Retuns the mesh absolute position in the World.
  80125. * @returns a Vector3.
  80126. */
  80127. getAbsolutePosition(): Vector3;
  80128. /**
  80129. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80130. * @param absolutePosition the absolute position to set
  80131. * @returns the TransformNode.
  80132. */
  80133. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80134. /**
  80135. * Sets the mesh position in its local space.
  80136. * @param vector3 the position to set in localspace
  80137. * @returns the TransformNode.
  80138. */
  80139. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80140. /**
  80141. * Returns the mesh position in the local space from the current World matrix values.
  80142. * @returns a new Vector3.
  80143. */
  80144. getPositionExpressedInLocalSpace(): Vector3;
  80145. /**
  80146. * Translates the mesh along the passed Vector3 in its local space.
  80147. * @param vector3 the distance to translate in localspace
  80148. * @returns the TransformNode.
  80149. */
  80150. locallyTranslate(vector3: Vector3): TransformNode;
  80151. private static _lookAtVectorCache;
  80152. /**
  80153. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80154. * @param targetPoint the position (must be in same space as current mesh) to look at
  80155. * @param yawCor optional yaw (y-axis) correction in radians
  80156. * @param pitchCor optional pitch (x-axis) correction in radians
  80157. * @param rollCor optional roll (z-axis) correction in radians
  80158. * @param space the choosen space of the target
  80159. * @returns the TransformNode.
  80160. */
  80161. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80162. /**
  80163. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80164. * This Vector3 is expressed in the World space.
  80165. * @param localAxis axis to rotate
  80166. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80167. */
  80168. getDirection(localAxis: Vector3): Vector3;
  80169. /**
  80170. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80171. * localAxis is expressed in the mesh local space.
  80172. * result is computed in the Wordl space from the mesh World matrix.
  80173. * @param localAxis axis to rotate
  80174. * @param result the resulting transformnode
  80175. * @returns this TransformNode.
  80176. */
  80177. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80178. /**
  80179. * Sets this transform node rotation to the given local axis.
  80180. * @param localAxis the axis in local space
  80181. * @param yawCor optional yaw (y-axis) correction in radians
  80182. * @param pitchCor optional pitch (x-axis) correction in radians
  80183. * @param rollCor optional roll (z-axis) correction in radians
  80184. * @returns this TransformNode
  80185. */
  80186. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80187. /**
  80188. * Sets a new pivot point to the current node
  80189. * @param point defines the new pivot point to use
  80190. * @param space defines if the point is in world or local space (local by default)
  80191. * @returns the current TransformNode
  80192. */
  80193. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80194. /**
  80195. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80196. * @returns the pivot point
  80197. */
  80198. getPivotPoint(): Vector3;
  80199. /**
  80200. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80201. * @param result the vector3 to store the result
  80202. * @returns this TransformNode.
  80203. */
  80204. getPivotPointToRef(result: Vector3): TransformNode;
  80205. /**
  80206. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80207. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80208. */
  80209. getAbsolutePivotPoint(): Vector3;
  80210. /**
  80211. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80212. * @param result vector3 to store the result
  80213. * @returns this TransformNode.
  80214. */
  80215. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80216. /**
  80217. * Defines the passed node as the parent of the current node.
  80218. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80219. * @see https://doc.babylonjs.com/how_to/parenting
  80220. * @param node the node ot set as the parent
  80221. * @returns this TransformNode.
  80222. */
  80223. setParent(node: Nullable<Node>): TransformNode;
  80224. private _nonUniformScaling;
  80225. /**
  80226. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80227. */
  80228. readonly nonUniformScaling: boolean;
  80229. /** @hidden */
  80230. _updateNonUniformScalingState(value: boolean): boolean;
  80231. /**
  80232. * Attach the current TransformNode to another TransformNode associated with a bone
  80233. * @param bone Bone affecting the TransformNode
  80234. * @param affectedTransformNode TransformNode associated with the bone
  80235. * @returns this object
  80236. */
  80237. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80238. /**
  80239. * Detach the transform node if its associated with a bone
  80240. * @returns this object
  80241. */
  80242. detachFromBone(): TransformNode;
  80243. private static _rotationAxisCache;
  80244. /**
  80245. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80246. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80247. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80248. * The passed axis is also normalized.
  80249. * @param axis the axis to rotate around
  80250. * @param amount the amount to rotate in radians
  80251. * @param space Space to rotate in (Default: local)
  80252. * @returns the TransformNode.
  80253. */
  80254. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80255. /**
  80256. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80257. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80258. * The passed axis is also normalized. .
  80259. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80260. * @param point the point to rotate around
  80261. * @param axis the axis to rotate around
  80262. * @param amount the amount to rotate in radians
  80263. * @returns the TransformNode
  80264. */
  80265. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80266. /**
  80267. * Translates the mesh along the axis vector for the passed distance in the given space.
  80268. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80269. * @param axis the axis to translate in
  80270. * @param distance the distance to translate
  80271. * @param space Space to rotate in (Default: local)
  80272. * @returns the TransformNode.
  80273. */
  80274. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80275. /**
  80276. * Adds a rotation step to the mesh current rotation.
  80277. * x, y, z are Euler angles expressed in radians.
  80278. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80279. * This means this rotation is made in the mesh local space only.
  80280. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80281. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80282. * ```javascript
  80283. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80284. * ```
  80285. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80286. * 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.
  80287. * @param x Rotation to add
  80288. * @param y Rotation to add
  80289. * @param z Rotation to add
  80290. * @returns the TransformNode.
  80291. */
  80292. addRotation(x: number, y: number, z: number): TransformNode;
  80293. /**
  80294. * @hidden
  80295. */
  80296. protected _getEffectiveParent(): Nullable<Node>;
  80297. /**
  80298. * Computes the world matrix of the node
  80299. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80300. * @returns the world matrix
  80301. */
  80302. computeWorldMatrix(force?: boolean): Matrix;
  80303. protected _afterComputeWorldMatrix(): void;
  80304. /**
  80305. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80306. * @param func callback function to add
  80307. *
  80308. * @returns the TransformNode.
  80309. */
  80310. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80311. /**
  80312. * Removes a registered callback function.
  80313. * @param func callback function to remove
  80314. * @returns the TransformNode.
  80315. */
  80316. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80317. /**
  80318. * Gets the position of the current mesh in camera space
  80319. * @param camera defines the camera to use
  80320. * @returns a position
  80321. */
  80322. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80323. /**
  80324. * Returns the distance from the mesh to the active camera
  80325. * @param camera defines the camera to use
  80326. * @returns the distance
  80327. */
  80328. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80329. /**
  80330. * Clone the current transform node
  80331. * @param name Name of the new clone
  80332. * @param newParent New parent for the clone
  80333. * @param doNotCloneChildren Do not clone children hierarchy
  80334. * @returns the new transform node
  80335. */
  80336. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80337. /**
  80338. * Serializes the objects information.
  80339. * @param currentSerializationObject defines the object to serialize in
  80340. * @returns the serialized object
  80341. */
  80342. serialize(currentSerializationObject?: any): any;
  80343. /**
  80344. * Returns a new TransformNode object parsed from the source provided.
  80345. * @param parsedTransformNode is the source.
  80346. * @param scene the scne the object belongs to
  80347. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80348. * @returns a new TransformNode object parsed from the source provided.
  80349. */
  80350. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80351. /**
  80352. * Get all child-transformNodes of this node
  80353. * @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
  80354. * @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
  80355. * @returns an array of TransformNode
  80356. */
  80357. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80358. /**
  80359. * Releases resources associated with this transform node.
  80360. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80361. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80362. */
  80363. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80364. /**
  80365. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80366. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80367. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80368. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80369. * @returns the current mesh
  80370. */
  80371. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80372. private _syncAbsoluteScalingAndRotation;
  80373. }
  80374. }
  80375. declare module BABYLON {
  80376. /**
  80377. * Defines the types of pose enabled controllers that are supported
  80378. */
  80379. export enum PoseEnabledControllerType {
  80380. /**
  80381. * HTC Vive
  80382. */
  80383. VIVE = 0,
  80384. /**
  80385. * Oculus Rift
  80386. */
  80387. OCULUS = 1,
  80388. /**
  80389. * Windows mixed reality
  80390. */
  80391. WINDOWS = 2,
  80392. /**
  80393. * Samsung gear VR
  80394. */
  80395. GEAR_VR = 3,
  80396. /**
  80397. * Google Daydream
  80398. */
  80399. DAYDREAM = 4,
  80400. /**
  80401. * Generic
  80402. */
  80403. GENERIC = 5
  80404. }
  80405. /**
  80406. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80407. */
  80408. export interface MutableGamepadButton {
  80409. /**
  80410. * Value of the button/trigger
  80411. */
  80412. value: number;
  80413. /**
  80414. * If the button/trigger is currently touched
  80415. */
  80416. touched: boolean;
  80417. /**
  80418. * If the button/trigger is currently pressed
  80419. */
  80420. pressed: boolean;
  80421. }
  80422. /**
  80423. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80424. * @hidden
  80425. */
  80426. export interface ExtendedGamepadButton extends GamepadButton {
  80427. /**
  80428. * If the button/trigger is currently pressed
  80429. */
  80430. readonly pressed: boolean;
  80431. /**
  80432. * If the button/trigger is currently touched
  80433. */
  80434. readonly touched: boolean;
  80435. /**
  80436. * Value of the button/trigger
  80437. */
  80438. readonly value: number;
  80439. }
  80440. /** @hidden */
  80441. export interface _GamePadFactory {
  80442. /**
  80443. * Returns wether or not the current gamepad can be created for this type of controller.
  80444. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80445. * @returns true if it can be created, otherwise false
  80446. */
  80447. canCreate(gamepadInfo: any): boolean;
  80448. /**
  80449. * Creates a new instance of the Gamepad.
  80450. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80451. * @returns the new gamepad instance
  80452. */
  80453. create(gamepadInfo: any): Gamepad;
  80454. }
  80455. /**
  80456. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80457. */
  80458. export class PoseEnabledControllerHelper {
  80459. /** @hidden */
  80460. static _ControllerFactories: _GamePadFactory[];
  80461. /** @hidden */
  80462. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80463. /**
  80464. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80465. * @param vrGamepad the gamepad to initialized
  80466. * @returns a vr controller of the type the gamepad identified as
  80467. */
  80468. static InitiateController(vrGamepad: any): Gamepad;
  80469. }
  80470. /**
  80471. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80472. */
  80473. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80474. /**
  80475. * If the controller is used in a webXR session
  80476. */
  80477. isXR: boolean;
  80478. private _deviceRoomPosition;
  80479. private _deviceRoomRotationQuaternion;
  80480. /**
  80481. * The device position in babylon space
  80482. */
  80483. devicePosition: Vector3;
  80484. /**
  80485. * The device rotation in babylon space
  80486. */
  80487. deviceRotationQuaternion: Quaternion;
  80488. /**
  80489. * The scale factor of the device in babylon space
  80490. */
  80491. deviceScaleFactor: number;
  80492. /**
  80493. * (Likely devicePosition should be used instead) The device position in its room space
  80494. */
  80495. position: Vector3;
  80496. /**
  80497. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80498. */
  80499. rotationQuaternion: Quaternion;
  80500. /**
  80501. * The type of controller (Eg. Windows mixed reality)
  80502. */
  80503. controllerType: PoseEnabledControllerType;
  80504. protected _calculatedPosition: Vector3;
  80505. private _calculatedRotation;
  80506. /**
  80507. * The raw pose from the device
  80508. */
  80509. rawPose: DevicePose;
  80510. private _trackPosition;
  80511. private _maxRotationDistFromHeadset;
  80512. private _draggedRoomRotation;
  80513. /**
  80514. * @hidden
  80515. */
  80516. _disableTrackPosition(fixedPosition: Vector3): void;
  80517. /**
  80518. * Internal, the mesh attached to the controller
  80519. * @hidden
  80520. */
  80521. _mesh: Nullable<AbstractMesh>;
  80522. private _poseControlledCamera;
  80523. private _leftHandSystemQuaternion;
  80524. /**
  80525. * Internal, matrix used to convert room space to babylon space
  80526. * @hidden
  80527. */
  80528. _deviceToWorld: Matrix;
  80529. /**
  80530. * Node to be used when casting a ray from the controller
  80531. * @hidden
  80532. */
  80533. _pointingPoseNode: Nullable<TransformNode>;
  80534. /**
  80535. * Name of the child mesh that can be used to cast a ray from the controller
  80536. */
  80537. static readonly POINTING_POSE: string;
  80538. /**
  80539. * Creates a new PoseEnabledController from a gamepad
  80540. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80541. */
  80542. constructor(browserGamepad: any);
  80543. private _workingMatrix;
  80544. /**
  80545. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80546. */
  80547. update(): void;
  80548. /**
  80549. * Updates only the pose device and mesh without doing any button event checking
  80550. */
  80551. protected _updatePoseAndMesh(): void;
  80552. /**
  80553. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80554. * @param poseData raw pose fromthe device
  80555. */
  80556. updateFromDevice(poseData: DevicePose): void;
  80557. /**
  80558. * @hidden
  80559. */
  80560. _meshAttachedObservable: Observable<AbstractMesh>;
  80561. /**
  80562. * Attaches a mesh to the controller
  80563. * @param mesh the mesh to be attached
  80564. */
  80565. attachToMesh(mesh: AbstractMesh): void;
  80566. /**
  80567. * Attaches the controllers mesh to a camera
  80568. * @param camera the camera the mesh should be attached to
  80569. */
  80570. attachToPoseControlledCamera(camera: TargetCamera): void;
  80571. /**
  80572. * Disposes of the controller
  80573. */
  80574. dispose(): void;
  80575. /**
  80576. * The mesh that is attached to the controller
  80577. */
  80578. readonly mesh: Nullable<AbstractMesh>;
  80579. /**
  80580. * Gets the ray of the controller in the direction the controller is pointing
  80581. * @param length the length the resulting ray should be
  80582. * @returns a ray in the direction the controller is pointing
  80583. */
  80584. getForwardRay(length?: number): Ray;
  80585. }
  80586. }
  80587. declare module BABYLON {
  80588. /**
  80589. * Defines the WebVRController object that represents controllers tracked in 3D space
  80590. */
  80591. export abstract class WebVRController extends PoseEnabledController {
  80592. /**
  80593. * Internal, the default controller model for the controller
  80594. */
  80595. protected _defaultModel: Nullable<AbstractMesh>;
  80596. /**
  80597. * Fired when the trigger state has changed
  80598. */
  80599. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80600. /**
  80601. * Fired when the main button state has changed
  80602. */
  80603. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80604. /**
  80605. * Fired when the secondary button state has changed
  80606. */
  80607. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80608. /**
  80609. * Fired when the pad state has changed
  80610. */
  80611. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80612. /**
  80613. * Fired when controllers stick values have changed
  80614. */
  80615. onPadValuesChangedObservable: Observable<StickValues>;
  80616. /**
  80617. * Array of button availible on the controller
  80618. */
  80619. protected _buttons: Array<MutableGamepadButton>;
  80620. private _onButtonStateChange;
  80621. /**
  80622. * Fired when a controller button's state has changed
  80623. * @param callback the callback containing the button that was modified
  80624. */
  80625. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80626. /**
  80627. * X and Y axis corresponding to the controllers joystick
  80628. */
  80629. pad: StickValues;
  80630. /**
  80631. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80632. */
  80633. hand: string;
  80634. /**
  80635. * The default controller model for the controller
  80636. */
  80637. readonly defaultModel: Nullable<AbstractMesh>;
  80638. /**
  80639. * Creates a new WebVRController from a gamepad
  80640. * @param vrGamepad the gamepad that the WebVRController should be created from
  80641. */
  80642. constructor(vrGamepad: any);
  80643. /**
  80644. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80645. */
  80646. update(): void;
  80647. /**
  80648. * Function to be called when a button is modified
  80649. */
  80650. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80651. /**
  80652. * Loads a mesh and attaches it to the controller
  80653. * @param scene the scene the mesh should be added to
  80654. * @param meshLoaded callback for when the mesh has been loaded
  80655. */
  80656. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80657. private _setButtonValue;
  80658. private _changes;
  80659. private _checkChanges;
  80660. /**
  80661. * Disposes of th webVRCOntroller
  80662. */
  80663. dispose(): void;
  80664. }
  80665. }
  80666. declare module BABYLON {
  80667. /**
  80668. * The HemisphericLight simulates the ambient environment light,
  80669. * so the passed direction is the light reflection direction, not the incoming direction.
  80670. */
  80671. export class HemisphericLight extends Light {
  80672. /**
  80673. * The groundColor is the light in the opposite direction to the one specified during creation.
  80674. * 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.
  80675. */
  80676. groundColor: Color3;
  80677. /**
  80678. * The light reflection direction, not the incoming direction.
  80679. */
  80680. direction: Vector3;
  80681. /**
  80682. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80683. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80684. * The HemisphericLight can't cast shadows.
  80685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80686. * @param name The friendly name of the light
  80687. * @param direction The direction of the light reflection
  80688. * @param scene The scene the light belongs to
  80689. */
  80690. constructor(name: string, direction: Vector3, scene: Scene);
  80691. protected _buildUniformLayout(): void;
  80692. /**
  80693. * Returns the string "HemisphericLight".
  80694. * @return The class name
  80695. */
  80696. getClassName(): string;
  80697. /**
  80698. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80699. * Returns the updated direction.
  80700. * @param target The target the direction should point to
  80701. * @return The computed direction
  80702. */
  80703. setDirectionToTarget(target: Vector3): Vector3;
  80704. /**
  80705. * Returns the shadow generator associated to the light.
  80706. * @returns Always null for hemispheric lights because it does not support shadows.
  80707. */
  80708. getShadowGenerator(): Nullable<IShadowGenerator>;
  80709. /**
  80710. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80711. * @param effect The effect to update
  80712. * @param lightIndex The index of the light in the effect to update
  80713. * @returns The hemispheric light
  80714. */
  80715. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80716. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80717. /**
  80718. * Computes the world matrix of the node
  80719. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80720. * @param useWasUpdatedFlag defines a reserved property
  80721. * @returns the world matrix
  80722. */
  80723. computeWorldMatrix(): Matrix;
  80724. /**
  80725. * Returns the integer 3.
  80726. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80727. */
  80728. getTypeID(): number;
  80729. /**
  80730. * Prepares the list of defines specific to the light type.
  80731. * @param defines the list of defines
  80732. * @param lightIndex defines the index of the light for the effect
  80733. */
  80734. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80735. }
  80736. }
  80737. declare module BABYLON {
  80738. /** @hidden */
  80739. export var vrMultiviewToSingleviewPixelShader: {
  80740. name: string;
  80741. shader: string;
  80742. };
  80743. }
  80744. declare module BABYLON {
  80745. /**
  80746. * Renders to multiple views with a single draw call
  80747. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80748. */
  80749. export class MultiviewRenderTarget extends RenderTargetTexture {
  80750. /**
  80751. * Creates a multiview render target
  80752. * @param scene scene used with the render target
  80753. * @param size the size of the render target (used for each view)
  80754. */
  80755. constructor(scene: Scene, size?: number | {
  80756. width: number;
  80757. height: number;
  80758. } | {
  80759. ratio: number;
  80760. });
  80761. /**
  80762. * @hidden
  80763. * @param faceIndex the face index, if its a cube texture
  80764. */
  80765. _bindFrameBuffer(faceIndex?: number): void;
  80766. /**
  80767. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80768. * @returns the view count
  80769. */
  80770. getViewCount(): number;
  80771. }
  80772. }
  80773. declare module BABYLON {
  80774. /**
  80775. * Represents a camera frustum
  80776. */
  80777. export class Frustum {
  80778. /**
  80779. * Gets the planes representing the frustum
  80780. * @param transform matrix to be applied to the returned planes
  80781. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80782. */
  80783. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80784. /**
  80785. * Gets the near frustum plane transformed by the transform matrix
  80786. * @param transform transformation matrix to be applied to the resulting frustum plane
  80787. * @param frustumPlane the resuling frustum plane
  80788. */
  80789. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80790. /**
  80791. * Gets the far frustum plane transformed by the transform matrix
  80792. * @param transform transformation matrix to be applied to the resulting frustum plane
  80793. * @param frustumPlane the resuling frustum plane
  80794. */
  80795. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80796. /**
  80797. * Gets the left frustum plane transformed by the transform matrix
  80798. * @param transform transformation matrix to be applied to the resulting frustum plane
  80799. * @param frustumPlane the resuling frustum plane
  80800. */
  80801. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80802. /**
  80803. * Gets the right frustum plane transformed by the transform matrix
  80804. * @param transform transformation matrix to be applied to the resulting frustum plane
  80805. * @param frustumPlane the resuling frustum plane
  80806. */
  80807. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80808. /**
  80809. * Gets the top frustum plane transformed by the transform matrix
  80810. * @param transform transformation matrix to be applied to the resulting frustum plane
  80811. * @param frustumPlane the resuling frustum plane
  80812. */
  80813. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80814. /**
  80815. * Gets the bottom frustum plane transformed by the transform matrix
  80816. * @param transform transformation matrix to be applied to the resulting frustum plane
  80817. * @param frustumPlane the resuling frustum plane
  80818. */
  80819. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80820. /**
  80821. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80822. * @param transform transformation matrix to be applied to the resulting frustum planes
  80823. * @param frustumPlanes the resuling frustum planes
  80824. */
  80825. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80826. }
  80827. }
  80828. declare module BABYLON {
  80829. interface Engine {
  80830. /**
  80831. * Creates a new multiview render target
  80832. * @param width defines the width of the texture
  80833. * @param height defines the height of the texture
  80834. * @returns the created multiview texture
  80835. */
  80836. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80837. /**
  80838. * Binds a multiview framebuffer to be drawn to
  80839. * @param multiviewTexture texture to bind
  80840. */
  80841. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80842. }
  80843. interface Camera {
  80844. /**
  80845. * @hidden
  80846. * 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)
  80847. */
  80848. _useMultiviewToSingleView: boolean;
  80849. /**
  80850. * @hidden
  80851. * 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)
  80852. */
  80853. _multiviewTexture: Nullable<RenderTargetTexture>;
  80854. /**
  80855. * @hidden
  80856. * ensures the multiview texture of the camera exists and has the specified width/height
  80857. * @param width height to set on the multiview texture
  80858. * @param height width to set on the multiview texture
  80859. */
  80860. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80861. }
  80862. interface Scene {
  80863. /** @hidden */
  80864. _transformMatrixR: Matrix;
  80865. /** @hidden */
  80866. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80867. /** @hidden */
  80868. _createMultiviewUbo(): void;
  80869. /** @hidden */
  80870. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80871. /** @hidden */
  80872. _renderMultiviewToSingleView(camera: Camera): void;
  80873. }
  80874. }
  80875. declare module BABYLON {
  80876. /**
  80877. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80878. * This will not be used for webXR as it supports displaying texture arrays directly
  80879. */
  80880. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80881. /**
  80882. * Initializes a VRMultiviewToSingleview
  80883. * @param name name of the post process
  80884. * @param camera camera to be applied to
  80885. * @param scaleFactor scaling factor to the size of the output texture
  80886. */
  80887. constructor(name: string, camera: Camera, scaleFactor: number);
  80888. }
  80889. }
  80890. declare module BABYLON {
  80891. interface Engine {
  80892. /** @hidden */
  80893. _vrDisplay: any;
  80894. /** @hidden */
  80895. _vrSupported: boolean;
  80896. /** @hidden */
  80897. _oldSize: Size;
  80898. /** @hidden */
  80899. _oldHardwareScaleFactor: number;
  80900. /** @hidden */
  80901. _vrExclusivePointerMode: boolean;
  80902. /** @hidden */
  80903. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80904. /** @hidden */
  80905. _onVRDisplayPointerRestricted: () => void;
  80906. /** @hidden */
  80907. _onVRDisplayPointerUnrestricted: () => void;
  80908. /** @hidden */
  80909. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80910. /** @hidden */
  80911. _onVrDisplayDisconnect: Nullable<() => void>;
  80912. /** @hidden */
  80913. _onVrDisplayPresentChange: Nullable<() => void>;
  80914. /**
  80915. * Observable signaled when VR display mode changes
  80916. */
  80917. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80918. /**
  80919. * Observable signaled when VR request present is complete
  80920. */
  80921. onVRRequestPresentComplete: Observable<boolean>;
  80922. /**
  80923. * Observable signaled when VR request present starts
  80924. */
  80925. onVRRequestPresentStart: Observable<Engine>;
  80926. /**
  80927. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80928. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80929. */
  80930. isInVRExclusivePointerMode: boolean;
  80931. /**
  80932. * Gets a boolean indicating if a webVR device was detected
  80933. * @returns true if a webVR device was detected
  80934. */
  80935. isVRDevicePresent(): boolean;
  80936. /**
  80937. * Gets the current webVR device
  80938. * @returns the current webVR device (or null)
  80939. */
  80940. getVRDevice(): any;
  80941. /**
  80942. * Initializes a webVR display and starts listening to display change events
  80943. * The onVRDisplayChangedObservable will be notified upon these changes
  80944. * @returns A promise containing a VRDisplay and if vr is supported
  80945. */
  80946. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80947. /** @hidden */
  80948. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80949. /**
  80950. * Call this function to switch to webVR mode
  80951. * Will do nothing if webVR is not supported or if there is no webVR device
  80952. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80953. */
  80954. enableVR(): void;
  80955. /** @hidden */
  80956. _onVRFullScreenTriggered(): void;
  80957. }
  80958. }
  80959. declare module BABYLON {
  80960. /**
  80961. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80962. * IMPORTANT!! The data is right-hand data.
  80963. * @export
  80964. * @interface DevicePose
  80965. */
  80966. export interface DevicePose {
  80967. /**
  80968. * The position of the device, values in array are [x,y,z].
  80969. */
  80970. readonly position: Nullable<Float32Array>;
  80971. /**
  80972. * The linearVelocity of the device, values in array are [x,y,z].
  80973. */
  80974. readonly linearVelocity: Nullable<Float32Array>;
  80975. /**
  80976. * The linearAcceleration of the device, values in array are [x,y,z].
  80977. */
  80978. readonly linearAcceleration: Nullable<Float32Array>;
  80979. /**
  80980. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80981. */
  80982. readonly orientation: Nullable<Float32Array>;
  80983. /**
  80984. * The angularVelocity of the device, values in array are [x,y,z].
  80985. */
  80986. readonly angularVelocity: Nullable<Float32Array>;
  80987. /**
  80988. * The angularAcceleration of the device, values in array are [x,y,z].
  80989. */
  80990. readonly angularAcceleration: Nullable<Float32Array>;
  80991. }
  80992. /**
  80993. * Interface representing a pose controlled object in Babylon.
  80994. * A pose controlled object has both regular pose values as well as pose values
  80995. * from an external device such as a VR head mounted display
  80996. */
  80997. export interface PoseControlled {
  80998. /**
  80999. * The position of the object in babylon space.
  81000. */
  81001. position: Vector3;
  81002. /**
  81003. * The rotation quaternion of the object in babylon space.
  81004. */
  81005. rotationQuaternion: Quaternion;
  81006. /**
  81007. * The position of the device in babylon space.
  81008. */
  81009. devicePosition?: Vector3;
  81010. /**
  81011. * The rotation quaternion of the device in babylon space.
  81012. */
  81013. deviceRotationQuaternion: Quaternion;
  81014. /**
  81015. * The raw pose coming from the device.
  81016. */
  81017. rawPose: Nullable<DevicePose>;
  81018. /**
  81019. * The scale of the device to be used when translating from device space to babylon space.
  81020. */
  81021. deviceScaleFactor: number;
  81022. /**
  81023. * Updates the poseControlled values based on the input device pose.
  81024. * @param poseData the pose data to update the object with
  81025. */
  81026. updateFromDevice(poseData: DevicePose): void;
  81027. }
  81028. /**
  81029. * Set of options to customize the webVRCamera
  81030. */
  81031. export interface WebVROptions {
  81032. /**
  81033. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81034. */
  81035. trackPosition?: boolean;
  81036. /**
  81037. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81038. */
  81039. positionScale?: number;
  81040. /**
  81041. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81042. */
  81043. displayName?: string;
  81044. /**
  81045. * Should the native controller meshes be initialized. (default: true)
  81046. */
  81047. controllerMeshes?: boolean;
  81048. /**
  81049. * Creating a default HemiLight only on controllers. (default: true)
  81050. */
  81051. defaultLightingOnControllers?: boolean;
  81052. /**
  81053. * If you don't want to use the default VR button of the helper. (default: false)
  81054. */
  81055. useCustomVRButton?: boolean;
  81056. /**
  81057. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81058. */
  81059. customVRButton?: HTMLButtonElement;
  81060. /**
  81061. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81062. */
  81063. rayLength?: number;
  81064. /**
  81065. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81066. */
  81067. defaultHeight?: number;
  81068. /**
  81069. * If multiview should be used if availible (default: false)
  81070. */
  81071. useMultiview?: boolean;
  81072. }
  81073. /**
  81074. * This represents a WebVR camera.
  81075. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81076. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81077. */
  81078. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81079. private webVROptions;
  81080. /**
  81081. * @hidden
  81082. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81083. */
  81084. _vrDevice: any;
  81085. /**
  81086. * The rawPose of the vrDevice.
  81087. */
  81088. rawPose: Nullable<DevicePose>;
  81089. private _onVREnabled;
  81090. private _specsVersion;
  81091. private _attached;
  81092. private _frameData;
  81093. protected _descendants: Array<Node>;
  81094. private _deviceRoomPosition;
  81095. /** @hidden */
  81096. _deviceRoomRotationQuaternion: Quaternion;
  81097. private _standingMatrix;
  81098. /**
  81099. * Represents device position in babylon space.
  81100. */
  81101. devicePosition: Vector3;
  81102. /**
  81103. * Represents device rotation in babylon space.
  81104. */
  81105. deviceRotationQuaternion: Quaternion;
  81106. /**
  81107. * The scale of the device to be used when translating from device space to babylon space.
  81108. */
  81109. deviceScaleFactor: number;
  81110. private _deviceToWorld;
  81111. private _worldToDevice;
  81112. /**
  81113. * References to the webVR controllers for the vrDevice.
  81114. */
  81115. controllers: Array<WebVRController>;
  81116. /**
  81117. * Emits an event when a controller is attached.
  81118. */
  81119. onControllersAttachedObservable: Observable<WebVRController[]>;
  81120. /**
  81121. * Emits an event when a controller's mesh has been loaded;
  81122. */
  81123. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81124. /**
  81125. * Emits an event when the HMD's pose has been updated.
  81126. */
  81127. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81128. private _poseSet;
  81129. /**
  81130. * If the rig cameras be used as parent instead of this camera.
  81131. */
  81132. rigParenting: boolean;
  81133. private _lightOnControllers;
  81134. private _defaultHeight?;
  81135. /**
  81136. * Instantiates a WebVRFreeCamera.
  81137. * @param name The name of the WebVRFreeCamera
  81138. * @param position The starting anchor position for the camera
  81139. * @param scene The scene the camera belongs to
  81140. * @param webVROptions a set of customizable options for the webVRCamera
  81141. */
  81142. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81143. /**
  81144. * Gets the device distance from the ground in meters.
  81145. * @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.
  81146. */
  81147. deviceDistanceToRoomGround(): number;
  81148. /**
  81149. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81150. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81151. */
  81152. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81153. /**
  81154. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81155. * @returns A promise with a boolean set to if the standing matrix is supported.
  81156. */
  81157. useStandingMatrixAsync(): Promise<boolean>;
  81158. /**
  81159. * Disposes the camera
  81160. */
  81161. dispose(): void;
  81162. /**
  81163. * Gets a vrController by name.
  81164. * @param name The name of the controller to retreive
  81165. * @returns the controller matching the name specified or null if not found
  81166. */
  81167. getControllerByName(name: string): Nullable<WebVRController>;
  81168. private _leftController;
  81169. /**
  81170. * The controller corresponding to the users left hand.
  81171. */
  81172. readonly leftController: Nullable<WebVRController>;
  81173. private _rightController;
  81174. /**
  81175. * The controller corresponding to the users right hand.
  81176. */
  81177. readonly rightController: Nullable<WebVRController>;
  81178. /**
  81179. * Casts a ray forward from the vrCamera's gaze.
  81180. * @param length Length of the ray (default: 100)
  81181. * @returns the ray corresponding to the gaze
  81182. */
  81183. getForwardRay(length?: number): Ray;
  81184. /**
  81185. * @hidden
  81186. * Updates the camera based on device's frame data
  81187. */
  81188. _checkInputs(): void;
  81189. /**
  81190. * Updates the poseControlled values based on the input device pose.
  81191. * @param poseData Pose coming from the device
  81192. */
  81193. updateFromDevice(poseData: DevicePose): void;
  81194. private _htmlElementAttached;
  81195. private _detachIfAttached;
  81196. /**
  81197. * WebVR's attach control will start broadcasting frames to the device.
  81198. * Note that in certain browsers (chrome for example) this function must be called
  81199. * within a user-interaction callback. Example:
  81200. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81201. *
  81202. * @param element html element to attach the vrDevice to
  81203. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81204. */
  81205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81206. /**
  81207. * Detaches the camera from the html element and disables VR
  81208. *
  81209. * @param element html element to detach from
  81210. */
  81211. detachControl(element: HTMLElement): void;
  81212. /**
  81213. * @returns the name of this class
  81214. */
  81215. getClassName(): string;
  81216. /**
  81217. * Calls resetPose on the vrDisplay
  81218. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81219. */
  81220. resetToCurrentRotation(): void;
  81221. /**
  81222. * @hidden
  81223. * Updates the rig cameras (left and right eye)
  81224. */
  81225. _updateRigCameras(): void;
  81226. private _workingVector;
  81227. private _oneVector;
  81228. private _workingMatrix;
  81229. private updateCacheCalled;
  81230. private _correctPositionIfNotTrackPosition;
  81231. /**
  81232. * @hidden
  81233. * Updates the cached values of the camera
  81234. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81235. */
  81236. _updateCache(ignoreParentClass?: boolean): void;
  81237. /**
  81238. * @hidden
  81239. * Get current device position in babylon world
  81240. */
  81241. _computeDevicePosition(): void;
  81242. /**
  81243. * Updates the current device position and rotation in the babylon world
  81244. */
  81245. update(): void;
  81246. /**
  81247. * @hidden
  81248. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81249. * @returns an identity matrix
  81250. */
  81251. _getViewMatrix(): Matrix;
  81252. private _tmpMatrix;
  81253. /**
  81254. * This function is called by the two RIG cameras.
  81255. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81256. * @hidden
  81257. */
  81258. _getWebVRViewMatrix(): Matrix;
  81259. /** @hidden */
  81260. _getWebVRProjectionMatrix(): Matrix;
  81261. private _onGamepadConnectedObserver;
  81262. private _onGamepadDisconnectedObserver;
  81263. private _updateCacheWhenTrackingDisabledObserver;
  81264. /**
  81265. * Initializes the controllers and their meshes
  81266. */
  81267. initControllers(): void;
  81268. }
  81269. }
  81270. declare module BABYLON {
  81271. /**
  81272. * Size options for a post process
  81273. */
  81274. export type PostProcessOptions = {
  81275. width: number;
  81276. height: number;
  81277. };
  81278. /**
  81279. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81280. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81281. */
  81282. export class PostProcess {
  81283. /** Name of the PostProcess. */
  81284. name: string;
  81285. /**
  81286. * Gets or sets the unique id of the post process
  81287. */
  81288. uniqueId: number;
  81289. /**
  81290. * Width of the texture to apply the post process on
  81291. */
  81292. width: number;
  81293. /**
  81294. * Height of the texture to apply the post process on
  81295. */
  81296. height: number;
  81297. /**
  81298. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81299. * @hidden
  81300. */
  81301. _outputTexture: Nullable<InternalTexture>;
  81302. /**
  81303. * Sampling mode used by the shader
  81304. * See https://doc.babylonjs.com/classes/3.1/texture
  81305. */
  81306. renderTargetSamplingMode: number;
  81307. /**
  81308. * Clear color to use when screen clearing
  81309. */
  81310. clearColor: Color4;
  81311. /**
  81312. * If the buffer needs to be cleared before applying the post process. (default: true)
  81313. * Should be set to false if shader will overwrite all previous pixels.
  81314. */
  81315. autoClear: boolean;
  81316. /**
  81317. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81318. */
  81319. alphaMode: number;
  81320. /**
  81321. * Sets the setAlphaBlendConstants of the babylon engine
  81322. */
  81323. alphaConstants: Color4;
  81324. /**
  81325. * Animations to be used for the post processing
  81326. */
  81327. animations: Animation[];
  81328. /**
  81329. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81330. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81331. */
  81332. enablePixelPerfectMode: boolean;
  81333. /**
  81334. * Force the postprocess to be applied without taking in account viewport
  81335. */
  81336. forceFullscreenViewport: boolean;
  81337. /**
  81338. * List of inspectable custom properties (used by the Inspector)
  81339. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81340. */
  81341. inspectableCustomProperties: IInspectable[];
  81342. /**
  81343. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81344. *
  81345. * | Value | Type | Description |
  81346. * | ----- | ----------------------------------- | ----------- |
  81347. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81348. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81349. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81350. *
  81351. */
  81352. scaleMode: number;
  81353. /**
  81354. * Force textures to be a power of two (default: false)
  81355. */
  81356. alwaysForcePOT: boolean;
  81357. private _samples;
  81358. /**
  81359. * Number of sample textures (default: 1)
  81360. */
  81361. samples: number;
  81362. /**
  81363. * Modify the scale of the post process to be the same as the viewport (default: false)
  81364. */
  81365. adaptScaleToCurrentViewport: boolean;
  81366. private _camera;
  81367. private _scene;
  81368. private _engine;
  81369. private _options;
  81370. private _reusable;
  81371. private _textureType;
  81372. /**
  81373. * Smart array of input and output textures for the post process.
  81374. * @hidden
  81375. */
  81376. _textures: SmartArray<InternalTexture>;
  81377. /**
  81378. * The index in _textures that corresponds to the output texture.
  81379. * @hidden
  81380. */
  81381. _currentRenderTextureInd: number;
  81382. private _effect;
  81383. private _samplers;
  81384. private _fragmentUrl;
  81385. private _vertexUrl;
  81386. private _parameters;
  81387. private _scaleRatio;
  81388. protected _indexParameters: any;
  81389. private _shareOutputWithPostProcess;
  81390. private _texelSize;
  81391. private _forcedOutputTexture;
  81392. /**
  81393. * Returns the fragment url or shader name used in the post process.
  81394. * @returns the fragment url or name in the shader store.
  81395. */
  81396. getEffectName(): string;
  81397. /**
  81398. * An event triggered when the postprocess is activated.
  81399. */
  81400. onActivateObservable: Observable<Camera>;
  81401. private _onActivateObserver;
  81402. /**
  81403. * A function that is added to the onActivateObservable
  81404. */
  81405. onActivate: Nullable<(camera: Camera) => void>;
  81406. /**
  81407. * An event triggered when the postprocess changes its size.
  81408. */
  81409. onSizeChangedObservable: Observable<PostProcess>;
  81410. private _onSizeChangedObserver;
  81411. /**
  81412. * A function that is added to the onSizeChangedObservable
  81413. */
  81414. onSizeChanged: (postProcess: PostProcess) => void;
  81415. /**
  81416. * An event triggered when the postprocess applies its effect.
  81417. */
  81418. onApplyObservable: Observable<Effect>;
  81419. private _onApplyObserver;
  81420. /**
  81421. * A function that is added to the onApplyObservable
  81422. */
  81423. onApply: (effect: Effect) => void;
  81424. /**
  81425. * An event triggered before rendering the postprocess
  81426. */
  81427. onBeforeRenderObservable: Observable<Effect>;
  81428. private _onBeforeRenderObserver;
  81429. /**
  81430. * A function that is added to the onBeforeRenderObservable
  81431. */
  81432. onBeforeRender: (effect: Effect) => void;
  81433. /**
  81434. * An event triggered after rendering the postprocess
  81435. */
  81436. onAfterRenderObservable: Observable<Effect>;
  81437. private _onAfterRenderObserver;
  81438. /**
  81439. * A function that is added to the onAfterRenderObservable
  81440. */
  81441. onAfterRender: (efect: Effect) => void;
  81442. /**
  81443. * 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
  81444. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81445. */
  81446. inputTexture: InternalTexture;
  81447. /**
  81448. * Gets the camera which post process is applied to.
  81449. * @returns The camera the post process is applied to.
  81450. */
  81451. getCamera(): Camera;
  81452. /**
  81453. * Gets the texel size of the postprocess.
  81454. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81455. */
  81456. readonly texelSize: Vector2;
  81457. /**
  81458. * Creates a new instance PostProcess
  81459. * @param name The name of the PostProcess.
  81460. * @param fragmentUrl The url of the fragment shader to be used.
  81461. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81462. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81463. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81464. * @param camera The camera to apply the render pass to.
  81465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81466. * @param engine The engine which the post process will be applied. (default: current engine)
  81467. * @param reusable If the post process can be reused on the same frame. (default: false)
  81468. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81469. * @param textureType Type of textures used when performing the post process. (default: 0)
  81470. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81471. * @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
  81472. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81473. */
  81474. constructor(
  81475. /** Name of the PostProcess. */
  81476. 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);
  81477. /**
  81478. * Gets a string idenfifying the name of the class
  81479. * @returns "PostProcess" string
  81480. */
  81481. getClassName(): string;
  81482. /**
  81483. * Gets the engine which this post process belongs to.
  81484. * @returns The engine the post process was enabled with.
  81485. */
  81486. getEngine(): Engine;
  81487. /**
  81488. * The effect that is created when initializing the post process.
  81489. * @returns The created effect corresponding the the postprocess.
  81490. */
  81491. getEffect(): Effect;
  81492. /**
  81493. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81494. * @param postProcess The post process to share the output with.
  81495. * @returns This post process.
  81496. */
  81497. shareOutputWith(postProcess: PostProcess): PostProcess;
  81498. /**
  81499. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81500. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81501. */
  81502. useOwnOutput(): void;
  81503. /**
  81504. * Updates the effect with the current post process compile time values and recompiles the shader.
  81505. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81506. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81507. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81508. * @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
  81509. * @param onCompiled Called when the shader has been compiled.
  81510. * @param onError Called if there is an error when compiling a shader.
  81511. */
  81512. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81513. /**
  81514. * The post process is reusable if it can be used multiple times within one frame.
  81515. * @returns If the post process is reusable
  81516. */
  81517. isReusable(): boolean;
  81518. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81519. markTextureDirty(): void;
  81520. /**
  81521. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81522. * 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.
  81523. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81524. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81525. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81526. * @returns The target texture that was bound to be written to.
  81527. */
  81528. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81529. /**
  81530. * If the post process is supported.
  81531. */
  81532. readonly isSupported: boolean;
  81533. /**
  81534. * The aspect ratio of the output texture.
  81535. */
  81536. readonly aspectRatio: number;
  81537. /**
  81538. * Get a value indicating if the post-process is ready to be used
  81539. * @returns true if the post-process is ready (shader is compiled)
  81540. */
  81541. isReady(): boolean;
  81542. /**
  81543. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81544. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81545. */
  81546. apply(): Nullable<Effect>;
  81547. private _disposeTextures;
  81548. /**
  81549. * Disposes the post process.
  81550. * @param camera The camera to dispose the post process on.
  81551. */
  81552. dispose(camera?: Camera): void;
  81553. }
  81554. }
  81555. declare module BABYLON {
  81556. /** @hidden */
  81557. export var kernelBlurVaryingDeclaration: {
  81558. name: string;
  81559. shader: string;
  81560. };
  81561. }
  81562. declare module BABYLON {
  81563. /** @hidden */
  81564. export var kernelBlurFragment: {
  81565. name: string;
  81566. shader: string;
  81567. };
  81568. }
  81569. declare module BABYLON {
  81570. /** @hidden */
  81571. export var kernelBlurFragment2: {
  81572. name: string;
  81573. shader: string;
  81574. };
  81575. }
  81576. declare module BABYLON {
  81577. /** @hidden */
  81578. export var kernelBlurPixelShader: {
  81579. name: string;
  81580. shader: string;
  81581. };
  81582. }
  81583. declare module BABYLON {
  81584. /** @hidden */
  81585. export var kernelBlurVertex: {
  81586. name: string;
  81587. shader: string;
  81588. };
  81589. }
  81590. declare module BABYLON {
  81591. /** @hidden */
  81592. export var kernelBlurVertexShader: {
  81593. name: string;
  81594. shader: string;
  81595. };
  81596. }
  81597. declare module BABYLON {
  81598. /**
  81599. * The Blur Post Process which blurs an image based on a kernel and direction.
  81600. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81601. */
  81602. export class BlurPostProcess extends PostProcess {
  81603. /** The direction in which to blur the image. */
  81604. direction: Vector2;
  81605. private blockCompilation;
  81606. protected _kernel: number;
  81607. protected _idealKernel: number;
  81608. protected _packedFloat: boolean;
  81609. private _staticDefines;
  81610. /**
  81611. * Sets the length in pixels of the blur sample region
  81612. */
  81613. /**
  81614. * Gets the length in pixels of the blur sample region
  81615. */
  81616. kernel: number;
  81617. /**
  81618. * Sets wether or not the blur needs to unpack/repack floats
  81619. */
  81620. /**
  81621. * Gets wether or not the blur is unpacking/repacking floats
  81622. */
  81623. packedFloat: boolean;
  81624. /**
  81625. * Creates a new instance BlurPostProcess
  81626. * @param name The name of the effect.
  81627. * @param direction The direction in which to blur the image.
  81628. * @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.
  81629. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81630. * @param camera The camera to apply the render pass to.
  81631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81632. * @param engine The engine which the post process will be applied. (default: current engine)
  81633. * @param reusable If the post process can be reused on the same frame. (default: false)
  81634. * @param textureType Type of textures used when performing the post process. (default: 0)
  81635. * @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)
  81636. */
  81637. constructor(name: string,
  81638. /** The direction in which to blur the image. */
  81639. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81640. /**
  81641. * Updates the effect with the current post process compile time values and recompiles the shader.
  81642. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81643. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81644. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81645. * @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
  81646. * @param onCompiled Called when the shader has been compiled.
  81647. * @param onError Called if there is an error when compiling a shader.
  81648. */
  81649. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81650. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81651. /**
  81652. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81653. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81654. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81655. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81656. * The gaps between physical kernels are compensated for in the weighting of the samples
  81657. * @param idealKernel Ideal blur kernel.
  81658. * @return Nearest best kernel.
  81659. */
  81660. protected _nearestBestKernel(idealKernel: number): number;
  81661. /**
  81662. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81663. * @param x The point on the Gaussian distribution to sample.
  81664. * @return the value of the Gaussian function at x.
  81665. */
  81666. protected _gaussianWeight(x: number): number;
  81667. /**
  81668. * Generates a string that can be used as a floating point number in GLSL.
  81669. * @param x Value to print.
  81670. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81671. * @return GLSL float string.
  81672. */
  81673. protected _glslFloat(x: number, decimalFigures?: number): string;
  81674. }
  81675. }
  81676. declare module BABYLON {
  81677. /**
  81678. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81679. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81680. * You can then easily use it as a reflectionTexture on a flat surface.
  81681. * In case the surface is not a plane, please consider relying on reflection probes.
  81682. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81683. */
  81684. export class MirrorTexture extends RenderTargetTexture {
  81685. private scene;
  81686. /**
  81687. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81688. * 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.
  81689. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81690. */
  81691. mirrorPlane: Plane;
  81692. /**
  81693. * Define the blur ratio used to blur the reflection if needed.
  81694. */
  81695. blurRatio: number;
  81696. /**
  81697. * Define the adaptive blur kernel used to blur the reflection if needed.
  81698. * This will autocompute the closest best match for the `blurKernel`
  81699. */
  81700. adaptiveBlurKernel: number;
  81701. /**
  81702. * Define the blur kernel used to blur the reflection if needed.
  81703. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81704. */
  81705. blurKernel: number;
  81706. /**
  81707. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81708. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81709. */
  81710. blurKernelX: number;
  81711. /**
  81712. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81713. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81714. */
  81715. blurKernelY: number;
  81716. private _autoComputeBlurKernel;
  81717. protected _onRatioRescale(): void;
  81718. private _updateGammaSpace;
  81719. private _imageProcessingConfigChangeObserver;
  81720. private _transformMatrix;
  81721. private _mirrorMatrix;
  81722. private _savedViewMatrix;
  81723. private _blurX;
  81724. private _blurY;
  81725. private _adaptiveBlurKernel;
  81726. private _blurKernelX;
  81727. private _blurKernelY;
  81728. private _blurRatio;
  81729. /**
  81730. * Instantiates a Mirror Texture.
  81731. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81732. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81733. * You can then easily use it as a reflectionTexture on a flat surface.
  81734. * In case the surface is not a plane, please consider relying on reflection probes.
  81735. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81736. * @param name
  81737. * @param size
  81738. * @param scene
  81739. * @param generateMipMaps
  81740. * @param type
  81741. * @param samplingMode
  81742. * @param generateDepthBuffer
  81743. */
  81744. constructor(name: string, size: number | {
  81745. width: number;
  81746. height: number;
  81747. } | {
  81748. ratio: number;
  81749. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81750. private _preparePostProcesses;
  81751. /**
  81752. * Clone the mirror texture.
  81753. * @returns the cloned texture
  81754. */
  81755. clone(): MirrorTexture;
  81756. /**
  81757. * Serialize the texture to a JSON representation you could use in Parse later on
  81758. * @returns the serialized JSON representation
  81759. */
  81760. serialize(): any;
  81761. /**
  81762. * Dispose the texture and release its associated resources.
  81763. */
  81764. dispose(): void;
  81765. }
  81766. }
  81767. declare module BABYLON {
  81768. /**
  81769. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81770. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81771. */
  81772. export class Texture extends BaseTexture {
  81773. /**
  81774. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81775. */
  81776. static SerializeBuffers: boolean;
  81777. /** @hidden */
  81778. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81779. /** @hidden */
  81780. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81781. /** @hidden */
  81782. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81783. /** nearest is mag = nearest and min = nearest and mip = linear */
  81784. static readonly NEAREST_SAMPLINGMODE: number;
  81785. /** nearest is mag = nearest and min = nearest and mip = linear */
  81786. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81787. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81788. static readonly BILINEAR_SAMPLINGMODE: number;
  81789. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81790. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81791. /** Trilinear is mag = linear and min = linear and mip = linear */
  81792. static readonly TRILINEAR_SAMPLINGMODE: number;
  81793. /** Trilinear is mag = linear and min = linear and mip = linear */
  81794. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81795. /** mag = nearest and min = nearest and mip = nearest */
  81796. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81797. /** mag = nearest and min = linear and mip = nearest */
  81798. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81799. /** mag = nearest and min = linear and mip = linear */
  81800. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81801. /** mag = nearest and min = linear and mip = none */
  81802. static readonly NEAREST_LINEAR: number;
  81803. /** mag = nearest and min = nearest and mip = none */
  81804. static readonly NEAREST_NEAREST: number;
  81805. /** mag = linear and min = nearest and mip = nearest */
  81806. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81807. /** mag = linear and min = nearest and mip = linear */
  81808. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81809. /** mag = linear and min = linear and mip = none */
  81810. static readonly LINEAR_LINEAR: number;
  81811. /** mag = linear and min = nearest and mip = none */
  81812. static readonly LINEAR_NEAREST: number;
  81813. /** Explicit coordinates mode */
  81814. static readonly EXPLICIT_MODE: number;
  81815. /** Spherical coordinates mode */
  81816. static readonly SPHERICAL_MODE: number;
  81817. /** Planar coordinates mode */
  81818. static readonly PLANAR_MODE: number;
  81819. /** Cubic coordinates mode */
  81820. static readonly CUBIC_MODE: number;
  81821. /** Projection coordinates mode */
  81822. static readonly PROJECTION_MODE: number;
  81823. /** Inverse Cubic coordinates mode */
  81824. static readonly SKYBOX_MODE: number;
  81825. /** Inverse Cubic coordinates mode */
  81826. static readonly INVCUBIC_MODE: number;
  81827. /** Equirectangular coordinates mode */
  81828. static readonly EQUIRECTANGULAR_MODE: number;
  81829. /** Equirectangular Fixed coordinates mode */
  81830. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81831. /** Equirectangular Fixed Mirrored coordinates mode */
  81832. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81833. /** Texture is not repeating outside of 0..1 UVs */
  81834. static readonly CLAMP_ADDRESSMODE: number;
  81835. /** Texture is repeating outside of 0..1 UVs */
  81836. static readonly WRAP_ADDRESSMODE: number;
  81837. /** Texture is repeating and mirrored */
  81838. static readonly MIRROR_ADDRESSMODE: number;
  81839. /**
  81840. * 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
  81841. */
  81842. static UseSerializedUrlIfAny: boolean;
  81843. /**
  81844. * Define the url of the texture.
  81845. */
  81846. url: Nullable<string>;
  81847. /**
  81848. * Define an offset on the texture to offset the u coordinates of the UVs
  81849. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81850. */
  81851. uOffset: number;
  81852. /**
  81853. * Define an offset on the texture to offset the v coordinates of the UVs
  81854. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81855. */
  81856. vOffset: number;
  81857. /**
  81858. * Define an offset on the texture to scale the u coordinates of the UVs
  81859. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81860. */
  81861. uScale: number;
  81862. /**
  81863. * Define an offset on the texture to scale the v coordinates of the UVs
  81864. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81865. */
  81866. vScale: number;
  81867. /**
  81868. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81869. * @see http://doc.babylonjs.com/how_to/more_materials
  81870. */
  81871. uAng: number;
  81872. /**
  81873. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81874. * @see http://doc.babylonjs.com/how_to/more_materials
  81875. */
  81876. vAng: number;
  81877. /**
  81878. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81879. * @see http://doc.babylonjs.com/how_to/more_materials
  81880. */
  81881. wAng: number;
  81882. /**
  81883. * Defines the center of rotation (U)
  81884. */
  81885. uRotationCenter: number;
  81886. /**
  81887. * Defines the center of rotation (V)
  81888. */
  81889. vRotationCenter: number;
  81890. /**
  81891. * Defines the center of rotation (W)
  81892. */
  81893. wRotationCenter: number;
  81894. /**
  81895. * Are mip maps generated for this texture or not.
  81896. */
  81897. readonly noMipmap: boolean;
  81898. /**
  81899. * List of inspectable custom properties (used by the Inspector)
  81900. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81901. */
  81902. inspectableCustomProperties: Nullable<IInspectable[]>;
  81903. private _noMipmap;
  81904. /** @hidden */
  81905. _invertY: boolean;
  81906. private _rowGenerationMatrix;
  81907. private _cachedTextureMatrix;
  81908. private _projectionModeMatrix;
  81909. private _t0;
  81910. private _t1;
  81911. private _t2;
  81912. private _cachedUOffset;
  81913. private _cachedVOffset;
  81914. private _cachedUScale;
  81915. private _cachedVScale;
  81916. private _cachedUAng;
  81917. private _cachedVAng;
  81918. private _cachedWAng;
  81919. private _cachedProjectionMatrixId;
  81920. private _cachedCoordinatesMode;
  81921. /** @hidden */
  81922. protected _initialSamplingMode: number;
  81923. /** @hidden */
  81924. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81925. private _deleteBuffer;
  81926. protected _format: Nullable<number>;
  81927. private _delayedOnLoad;
  81928. private _delayedOnError;
  81929. /**
  81930. * Observable triggered once the texture has been loaded.
  81931. */
  81932. onLoadObservable: Observable<Texture>;
  81933. protected _isBlocking: boolean;
  81934. /**
  81935. * Is the texture preventing material to render while loading.
  81936. * If false, a default texture will be used instead of the loading one during the preparation step.
  81937. */
  81938. isBlocking: boolean;
  81939. /**
  81940. * Get the current sampling mode associated with the texture.
  81941. */
  81942. readonly samplingMode: number;
  81943. /**
  81944. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81945. */
  81946. readonly invertY: boolean;
  81947. /**
  81948. * Instantiates a new texture.
  81949. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81950. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81951. * @param url define the url of the picture to load as a texture
  81952. * @param scene define the scene or engine the texture will belong to
  81953. * @param noMipmap define if the texture will require mip maps or not
  81954. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81955. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81956. * @param onLoad define a callback triggered when the texture has been loaded
  81957. * @param onError define a callback triggered when an error occurred during the loading session
  81958. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81959. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81960. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81961. */
  81962. 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);
  81963. /**
  81964. * Update the url (and optional buffer) of this texture if url was null during construction.
  81965. * @param url the url of the texture
  81966. * @param buffer the buffer of the texture (defaults to null)
  81967. * @param onLoad callback called when the texture is loaded (defaults to null)
  81968. */
  81969. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81970. /**
  81971. * Finish the loading sequence of a texture flagged as delayed load.
  81972. * @hidden
  81973. */
  81974. delayLoad(): void;
  81975. private _prepareRowForTextureGeneration;
  81976. /**
  81977. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81978. * @returns the transform matrix of the texture.
  81979. */
  81980. getTextureMatrix(): Matrix;
  81981. /**
  81982. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81983. * @returns The reflection texture transform
  81984. */
  81985. getReflectionTextureMatrix(): Matrix;
  81986. /**
  81987. * Clones the texture.
  81988. * @returns the cloned texture
  81989. */
  81990. clone(): Texture;
  81991. /**
  81992. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81993. * @returns The JSON representation of the texture
  81994. */
  81995. serialize(): any;
  81996. /**
  81997. * Get the current class name of the texture useful for serialization or dynamic coding.
  81998. * @returns "Texture"
  81999. */
  82000. getClassName(): string;
  82001. /**
  82002. * Dispose the texture and release its associated resources.
  82003. */
  82004. dispose(): void;
  82005. /**
  82006. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82007. * @param parsedTexture Define the JSON representation of the texture
  82008. * @param scene Define the scene the parsed texture should be instantiated in
  82009. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82010. * @returns The parsed texture if successful
  82011. */
  82012. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82013. /**
  82014. * Creates a texture from its base 64 representation.
  82015. * @param data Define the base64 payload without the data: prefix
  82016. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82017. * @param scene Define the scene the texture should belong to
  82018. * @param noMipmap Forces the texture to not create mip map information if true
  82019. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82020. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82021. * @param onLoad define a callback triggered when the texture has been loaded
  82022. * @param onError define a callback triggered when an error occurred during the loading session
  82023. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82024. * @returns the created texture
  82025. */
  82026. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82027. /**
  82028. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82029. * @param data Define the base64 payload without the data: prefix
  82030. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82031. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82032. * @param scene Define the scene the texture should belong to
  82033. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82034. * @param noMipmap Forces the texture to not create mip map information if true
  82035. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82036. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82037. * @param onLoad define a callback triggered when the texture has been loaded
  82038. * @param onError define a callback triggered when an error occurred during the loading session
  82039. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82040. * @returns the created texture
  82041. */
  82042. 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;
  82043. }
  82044. }
  82045. declare module BABYLON {
  82046. /**
  82047. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82048. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82049. */
  82050. export class PostProcessManager {
  82051. private _scene;
  82052. private _indexBuffer;
  82053. private _vertexBuffers;
  82054. /**
  82055. * Creates a new instance PostProcess
  82056. * @param scene The scene that the post process is associated with.
  82057. */
  82058. constructor(scene: Scene);
  82059. private _prepareBuffers;
  82060. private _buildIndexBuffer;
  82061. /**
  82062. * Rebuilds the vertex buffers of the manager.
  82063. * @hidden
  82064. */
  82065. _rebuild(): void;
  82066. /**
  82067. * Prepares a frame to be run through a post process.
  82068. * @param sourceTexture The input texture to the post procesess. (default: null)
  82069. * @param postProcesses An array of post processes to be run. (default: null)
  82070. * @returns True if the post processes were able to be run.
  82071. * @hidden
  82072. */
  82073. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82074. /**
  82075. * Manually render a set of post processes to a texture.
  82076. * @param postProcesses An array of post processes to be run.
  82077. * @param targetTexture The target texture to render to.
  82078. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82079. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82080. * @param lodLevel defines which lod of the texture to render to
  82081. */
  82082. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82083. /**
  82084. * Finalize the result of the output of the postprocesses.
  82085. * @param doNotPresent If true the result will not be displayed to the screen.
  82086. * @param targetTexture The target texture to render to.
  82087. * @param faceIndex The index of the face to bind the target texture to.
  82088. * @param postProcesses The array of post processes to render.
  82089. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82090. * @hidden
  82091. */
  82092. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82093. /**
  82094. * Disposes of the post process manager.
  82095. */
  82096. dispose(): void;
  82097. }
  82098. }
  82099. declare module BABYLON {
  82100. /** Interface used by value gradients (color, factor, ...) */
  82101. export interface IValueGradient {
  82102. /**
  82103. * Gets or sets the gradient value (between 0 and 1)
  82104. */
  82105. gradient: number;
  82106. }
  82107. /** Class used to store color4 gradient */
  82108. export class ColorGradient implements IValueGradient {
  82109. /**
  82110. * Gets or sets the gradient value (between 0 and 1)
  82111. */
  82112. gradient: number;
  82113. /**
  82114. * Gets or sets first associated color
  82115. */
  82116. color1: Color4;
  82117. /**
  82118. * Gets or sets second associated color
  82119. */
  82120. color2?: Color4;
  82121. /**
  82122. * Will get a color picked randomly between color1 and color2.
  82123. * If color2 is undefined then color1 will be used
  82124. * @param result defines the target Color4 to store the result in
  82125. */
  82126. getColorToRef(result: Color4): void;
  82127. }
  82128. /** Class used to store color 3 gradient */
  82129. export class Color3Gradient implements IValueGradient {
  82130. /**
  82131. * Gets or sets the gradient value (between 0 and 1)
  82132. */
  82133. gradient: number;
  82134. /**
  82135. * Gets or sets the associated color
  82136. */
  82137. color: Color3;
  82138. }
  82139. /** Class used to store factor gradient */
  82140. export class FactorGradient implements IValueGradient {
  82141. /**
  82142. * Gets or sets the gradient value (between 0 and 1)
  82143. */
  82144. gradient: number;
  82145. /**
  82146. * Gets or sets first associated factor
  82147. */
  82148. factor1: number;
  82149. /**
  82150. * Gets or sets second associated factor
  82151. */
  82152. factor2?: number;
  82153. /**
  82154. * Will get a number picked randomly between factor1 and factor2.
  82155. * If factor2 is undefined then factor1 will be used
  82156. * @returns the picked number
  82157. */
  82158. getFactor(): number;
  82159. }
  82160. /**
  82161. * Helper used to simplify some generic gradient tasks
  82162. */
  82163. export class GradientHelper {
  82164. /**
  82165. * Gets the current gradient from an array of IValueGradient
  82166. * @param ratio defines the current ratio to get
  82167. * @param gradients defines the array of IValueGradient
  82168. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82169. */
  82170. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82171. }
  82172. }
  82173. declare module BABYLON {
  82174. /**
  82175. * A class extending Texture allowing drawing on a texture
  82176. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82177. */
  82178. export class DynamicTexture extends Texture {
  82179. private _generateMipMaps;
  82180. private _canvas;
  82181. private _context;
  82182. private _engine;
  82183. /**
  82184. * Creates a DynamicTexture
  82185. * @param name defines the name of the texture
  82186. * @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
  82187. * @param scene defines the scene where you want the texture
  82188. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82189. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82190. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82191. */
  82192. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82193. /**
  82194. * Get the current class name of the texture useful for serialization or dynamic coding.
  82195. * @returns "DynamicTexture"
  82196. */
  82197. getClassName(): string;
  82198. /**
  82199. * Gets the current state of canRescale
  82200. */
  82201. readonly canRescale: boolean;
  82202. private _recreate;
  82203. /**
  82204. * Scales the texture
  82205. * @param ratio the scale factor to apply to both width and height
  82206. */
  82207. scale(ratio: number): void;
  82208. /**
  82209. * Resizes the texture
  82210. * @param width the new width
  82211. * @param height the new height
  82212. */
  82213. scaleTo(width: number, height: number): void;
  82214. /**
  82215. * Gets the context of the canvas used by the texture
  82216. * @returns the canvas context of the dynamic texture
  82217. */
  82218. getContext(): CanvasRenderingContext2D;
  82219. /**
  82220. * Clears the texture
  82221. */
  82222. clear(): void;
  82223. /**
  82224. * Updates the texture
  82225. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82226. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82227. */
  82228. update(invertY?: boolean, premulAlpha?: boolean): void;
  82229. /**
  82230. * Draws text onto the texture
  82231. * @param text defines the text to be drawn
  82232. * @param x defines the placement of the text from the left
  82233. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82234. * @param font defines the font to be used with font-style, font-size, font-name
  82235. * @param color defines the color used for the text
  82236. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82237. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82238. * @param update defines whether texture is immediately update (default is true)
  82239. */
  82240. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82241. /**
  82242. * Clones the texture
  82243. * @returns the clone of the texture.
  82244. */
  82245. clone(): DynamicTexture;
  82246. /**
  82247. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82248. * @returns a serialized dynamic texture object
  82249. */
  82250. serialize(): any;
  82251. /** @hidden */
  82252. _rebuild(): void;
  82253. }
  82254. }
  82255. declare module BABYLON {
  82256. interface AbstractScene {
  82257. /**
  82258. * The list of procedural textures added to the scene
  82259. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82260. */
  82261. proceduralTextures: Array<ProceduralTexture>;
  82262. }
  82263. /**
  82264. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82265. * in a given scene.
  82266. */
  82267. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82268. /**
  82269. * The component name helpfull to identify the component in the list of scene components.
  82270. */
  82271. readonly name: string;
  82272. /**
  82273. * The scene the component belongs to.
  82274. */
  82275. scene: Scene;
  82276. /**
  82277. * Creates a new instance of the component for the given scene
  82278. * @param scene Defines the scene to register the component in
  82279. */
  82280. constructor(scene: Scene);
  82281. /**
  82282. * Registers the component in a given scene
  82283. */
  82284. register(): void;
  82285. /**
  82286. * Rebuilds the elements related to this component in case of
  82287. * context lost for instance.
  82288. */
  82289. rebuild(): void;
  82290. /**
  82291. * Disposes the component and the associated ressources.
  82292. */
  82293. dispose(): void;
  82294. private _beforeClear;
  82295. }
  82296. }
  82297. declare module BABYLON {
  82298. interface BaseEngine {
  82299. /**
  82300. * Creates a new render target cube texture
  82301. * @param size defines the size of the texture
  82302. * @param options defines the options used to create the texture
  82303. * @returns a new render target cube texture stored in an InternalTexture
  82304. */
  82305. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82306. }
  82307. }
  82308. declare module BABYLON {
  82309. /** @hidden */
  82310. export var proceduralVertexShader: {
  82311. name: string;
  82312. shader: string;
  82313. };
  82314. }
  82315. declare module BABYLON {
  82316. /**
  82317. * 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.
  82318. * This is the base class of any Procedural texture and contains most of the shareable code.
  82319. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82320. */
  82321. export class ProceduralTexture extends Texture {
  82322. isCube: boolean;
  82323. /**
  82324. * Define if the texture is enabled or not (disabled texture will not render)
  82325. */
  82326. isEnabled: boolean;
  82327. /**
  82328. * Define if the texture must be cleared before rendering (default is true)
  82329. */
  82330. autoClear: boolean;
  82331. /**
  82332. * Callback called when the texture is generated
  82333. */
  82334. onGenerated: () => void;
  82335. /**
  82336. * Event raised when the texture is generated
  82337. */
  82338. onGeneratedObservable: Observable<ProceduralTexture>;
  82339. /** @hidden */
  82340. _generateMipMaps: boolean;
  82341. /** @hidden **/
  82342. _effect: Effect;
  82343. /** @hidden */
  82344. _textures: {
  82345. [key: string]: Texture;
  82346. };
  82347. private _size;
  82348. private _currentRefreshId;
  82349. private _refreshRate;
  82350. private _vertexBuffers;
  82351. private _indexBuffer;
  82352. private _uniforms;
  82353. private _samplers;
  82354. private _fragment;
  82355. private _floats;
  82356. private _ints;
  82357. private _floatsArrays;
  82358. private _colors3;
  82359. private _colors4;
  82360. private _vectors2;
  82361. private _vectors3;
  82362. private _matrices;
  82363. private _fallbackTexture;
  82364. private _fallbackTextureUsed;
  82365. private _engine;
  82366. private _cachedDefines;
  82367. private _contentUpdateId;
  82368. private _contentData;
  82369. /**
  82370. * Instantiates a new procedural texture.
  82371. * 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.
  82372. * This is the base class of any Procedural texture and contains most of the shareable code.
  82373. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82374. * @param name Define the name of the texture
  82375. * @param size Define the size of the texture to create
  82376. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  82377. * @param scene Define the scene the texture belongs to
  82378. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  82379. * @param generateMipMaps Define if the texture should creates mip maps or not
  82380. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  82381. */
  82382. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  82383. /**
  82384. * The effect that is created when initializing the post process.
  82385. * @returns The created effect corresponding the the postprocess.
  82386. */
  82387. getEffect(): Effect;
  82388. /**
  82389. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  82390. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  82391. */
  82392. getContent(): Nullable<ArrayBufferView>;
  82393. private _createIndexBuffer;
  82394. /** @hidden */
  82395. _rebuild(): void;
  82396. /**
  82397. * Resets the texture in order to recreate its associated resources.
  82398. * This can be called in case of context loss
  82399. */
  82400. reset(): void;
  82401. protected _getDefines(): string;
  82402. /**
  82403. * Is the texture ready to be used ? (rendered at least once)
  82404. * @returns true if ready, otherwise, false.
  82405. */
  82406. isReady(): boolean;
  82407. /**
  82408. * Resets the refresh counter of the texture and start bak from scratch.
  82409. * Could be useful to regenerate the texture if it is setup to render only once.
  82410. */
  82411. resetRefreshCounter(): void;
  82412. /**
  82413. * Set the fragment shader to use in order to render the texture.
  82414. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82415. */
  82416. setFragment(fragment: any): void;
  82417. /**
  82418. * Define the refresh rate of the texture or the rendering frequency.
  82419. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82420. */
  82421. refreshRate: number;
  82422. /** @hidden */
  82423. _shouldRender(): boolean;
  82424. /**
  82425. * Get the size the texture is rendering at.
  82426. * @returns the size (texture is always squared)
  82427. */
  82428. getRenderSize(): number;
  82429. /**
  82430. * Resize the texture to new value.
  82431. * @param size Define the new size the texture should have
  82432. * @param generateMipMaps Define whether the new texture should create mip maps
  82433. */
  82434. resize(size: number, generateMipMaps: boolean): void;
  82435. private _checkUniform;
  82436. /**
  82437. * Set a texture in the shader program used to render.
  82438. * @param name Define the name of the uniform samplers as defined in the shader
  82439. * @param texture Define the texture to bind to this sampler
  82440. * @return the texture itself allowing "fluent" like uniform updates
  82441. */
  82442. setTexture(name: string, texture: Texture): ProceduralTexture;
  82443. /**
  82444. * Set a float in the shader.
  82445. * @param name Define the name of the uniform as defined in the shader
  82446. * @param value Define the value to give to the uniform
  82447. * @return the texture itself allowing "fluent" like uniform updates
  82448. */
  82449. setFloat(name: string, value: number): ProceduralTexture;
  82450. /**
  82451. * Set a int in the shader.
  82452. * @param name Define the name of the uniform as defined in the shader
  82453. * @param value Define the value to give to the uniform
  82454. * @return the texture itself allowing "fluent" like uniform updates
  82455. */
  82456. setInt(name: string, value: number): ProceduralTexture;
  82457. /**
  82458. * Set an array of floats in the shader.
  82459. * @param name Define the name of the uniform as defined in the shader
  82460. * @param value Define the value to give to the uniform
  82461. * @return the texture itself allowing "fluent" like uniform updates
  82462. */
  82463. setFloats(name: string, value: number[]): ProceduralTexture;
  82464. /**
  82465. * Set a vec3 in the shader from a Color3.
  82466. * @param name Define the name of the uniform as defined in the shader
  82467. * @param value Define the value to give to the uniform
  82468. * @return the texture itself allowing "fluent" like uniform updates
  82469. */
  82470. setColor3(name: string, value: Color3): ProceduralTexture;
  82471. /**
  82472. * Set a vec4 in the shader from a Color4.
  82473. * @param name Define the name of the uniform as defined in the shader
  82474. * @param value Define the value to give to the uniform
  82475. * @return the texture itself allowing "fluent" like uniform updates
  82476. */
  82477. setColor4(name: string, value: Color4): ProceduralTexture;
  82478. /**
  82479. * Set a vec2 in the shader from a Vector2.
  82480. * @param name Define the name of the uniform as defined in the shader
  82481. * @param value Define the value to give to the uniform
  82482. * @return the texture itself allowing "fluent" like uniform updates
  82483. */
  82484. setVector2(name: string, value: Vector2): ProceduralTexture;
  82485. /**
  82486. * Set a vec3 in the shader from a Vector3.
  82487. * @param name Define the name of the uniform as defined in the shader
  82488. * @param value Define the value to give to the uniform
  82489. * @return the texture itself allowing "fluent" like uniform updates
  82490. */
  82491. setVector3(name: string, value: Vector3): ProceduralTexture;
  82492. /**
  82493. * Set a mat4 in the shader from a MAtrix.
  82494. * @param name Define the name of the uniform as defined in the shader
  82495. * @param value Define the value to give to the uniform
  82496. * @return the texture itself allowing "fluent" like uniform updates
  82497. */
  82498. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82499. /**
  82500. * Render the texture to its associated render target.
  82501. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82502. */
  82503. render(useCameraPostProcess?: boolean): void;
  82504. /**
  82505. * Clone the texture.
  82506. * @returns the cloned texture
  82507. */
  82508. clone(): ProceduralTexture;
  82509. /**
  82510. * Dispose the texture and release its asoociated resources.
  82511. */
  82512. dispose(): void;
  82513. }
  82514. }
  82515. declare module BABYLON {
  82516. /**
  82517. * This represents the base class for particle system in Babylon.
  82518. * 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.
  82519. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82520. * @example https://doc.babylonjs.com/babylon101/particles
  82521. */
  82522. export class BaseParticleSystem {
  82523. /**
  82524. * Source color is added to the destination color without alpha affecting the result
  82525. */
  82526. static BLENDMODE_ONEONE: number;
  82527. /**
  82528. * Blend current color and particle color using particle’s alpha
  82529. */
  82530. static BLENDMODE_STANDARD: number;
  82531. /**
  82532. * Add current color and particle color multiplied by particle’s alpha
  82533. */
  82534. static BLENDMODE_ADD: number;
  82535. /**
  82536. * Multiply current color with particle color
  82537. */
  82538. static BLENDMODE_MULTIPLY: number;
  82539. /**
  82540. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82541. */
  82542. static BLENDMODE_MULTIPLYADD: number;
  82543. /**
  82544. * List of animations used by the particle system.
  82545. */
  82546. animations: Animation[];
  82547. /**
  82548. * The id of the Particle system.
  82549. */
  82550. id: string;
  82551. /**
  82552. * The friendly name of the Particle system.
  82553. */
  82554. name: string;
  82555. /**
  82556. * The rendering group used by the Particle system to chose when to render.
  82557. */
  82558. renderingGroupId: number;
  82559. /**
  82560. * The emitter represents the Mesh or position we are attaching the particle system to.
  82561. */
  82562. emitter: Nullable<AbstractMesh | Vector3>;
  82563. /**
  82564. * The maximum number of particles to emit per frame
  82565. */
  82566. emitRate: number;
  82567. /**
  82568. * If you want to launch only a few particles at once, that can be done, as well.
  82569. */
  82570. manualEmitCount: number;
  82571. /**
  82572. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82573. */
  82574. updateSpeed: number;
  82575. /**
  82576. * The amount of time the particle system is running (depends of the overall update speed).
  82577. */
  82578. targetStopDuration: number;
  82579. /**
  82580. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82581. */
  82582. disposeOnStop: boolean;
  82583. /**
  82584. * Minimum power of emitting particles.
  82585. */
  82586. minEmitPower: number;
  82587. /**
  82588. * Maximum power of emitting particles.
  82589. */
  82590. maxEmitPower: number;
  82591. /**
  82592. * Minimum life time of emitting particles.
  82593. */
  82594. minLifeTime: number;
  82595. /**
  82596. * Maximum life time of emitting particles.
  82597. */
  82598. maxLifeTime: number;
  82599. /**
  82600. * Minimum Size of emitting particles.
  82601. */
  82602. minSize: number;
  82603. /**
  82604. * Maximum Size of emitting particles.
  82605. */
  82606. maxSize: number;
  82607. /**
  82608. * Minimum scale of emitting particles on X axis.
  82609. */
  82610. minScaleX: number;
  82611. /**
  82612. * Maximum scale of emitting particles on X axis.
  82613. */
  82614. maxScaleX: number;
  82615. /**
  82616. * Minimum scale of emitting particles on Y axis.
  82617. */
  82618. minScaleY: number;
  82619. /**
  82620. * Maximum scale of emitting particles on Y axis.
  82621. */
  82622. maxScaleY: number;
  82623. /**
  82624. * Gets or sets the minimal initial rotation in radians.
  82625. */
  82626. minInitialRotation: number;
  82627. /**
  82628. * Gets or sets the maximal initial rotation in radians.
  82629. */
  82630. maxInitialRotation: number;
  82631. /**
  82632. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82633. */
  82634. minAngularSpeed: number;
  82635. /**
  82636. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82637. */
  82638. maxAngularSpeed: number;
  82639. /**
  82640. * The texture used to render each particle. (this can be a spritesheet)
  82641. */
  82642. particleTexture: Nullable<Texture>;
  82643. /**
  82644. * The layer mask we are rendering the particles through.
  82645. */
  82646. layerMask: number;
  82647. /**
  82648. * This can help using your own shader to render the particle system.
  82649. * The according effect will be created
  82650. */
  82651. customShader: any;
  82652. /**
  82653. * By default particle system starts as soon as they are created. This prevents the
  82654. * automatic start to happen and let you decide when to start emitting particles.
  82655. */
  82656. preventAutoStart: boolean;
  82657. private _noiseTexture;
  82658. /**
  82659. * Gets or sets a texture used to add random noise to particle positions
  82660. */
  82661. noiseTexture: Nullable<ProceduralTexture>;
  82662. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82663. noiseStrength: Vector3;
  82664. /**
  82665. * Callback triggered when the particle animation is ending.
  82666. */
  82667. onAnimationEnd: Nullable<() => void>;
  82668. /**
  82669. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82670. */
  82671. blendMode: number;
  82672. /**
  82673. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82674. * to override the particles.
  82675. */
  82676. forceDepthWrite: boolean;
  82677. /** 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 */
  82678. preWarmCycles: number;
  82679. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82680. preWarmStepOffset: number;
  82681. /**
  82682. * 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)
  82683. */
  82684. spriteCellChangeSpeed: number;
  82685. /**
  82686. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82687. */
  82688. startSpriteCellID: number;
  82689. /**
  82690. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82691. */
  82692. endSpriteCellID: number;
  82693. /**
  82694. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82695. */
  82696. spriteCellWidth: number;
  82697. /**
  82698. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82699. */
  82700. spriteCellHeight: number;
  82701. /**
  82702. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82703. */
  82704. spriteRandomStartCell: boolean;
  82705. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82706. translationPivot: Vector2;
  82707. /** @hidden */
  82708. protected _isAnimationSheetEnabled: boolean;
  82709. /**
  82710. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82711. */
  82712. beginAnimationOnStart: boolean;
  82713. /**
  82714. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82715. */
  82716. beginAnimationFrom: number;
  82717. /**
  82718. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82719. */
  82720. beginAnimationTo: number;
  82721. /**
  82722. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82723. */
  82724. beginAnimationLoop: boolean;
  82725. /**
  82726. * Gets or sets a world offset applied to all particles
  82727. */
  82728. worldOffset: Vector3;
  82729. /**
  82730. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82731. */
  82732. isAnimationSheetEnabled: boolean;
  82733. /**
  82734. * Get hosting scene
  82735. * @returns the scene
  82736. */
  82737. getScene(): Scene;
  82738. /**
  82739. * You can use gravity if you want to give an orientation to your particles.
  82740. */
  82741. gravity: Vector3;
  82742. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82743. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82744. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82745. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82746. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82747. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82748. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82749. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82750. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82751. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82752. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82753. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82754. protected _hasTargetStopDurationDependantGradient(): Nullable<boolean>;
  82755. /**
  82756. * Defines the delay in milliseconds before starting the system (0 by default)
  82757. */
  82758. startDelay: number;
  82759. /**
  82760. * Gets the current list of drag gradients.
  82761. * You must use addDragGradient and removeDragGradient to udpate this list
  82762. * @returns the list of drag gradients
  82763. */
  82764. getDragGradients(): Nullable<Array<FactorGradient>>;
  82765. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82766. limitVelocityDamping: number;
  82767. /**
  82768. * Gets the current list of limit velocity gradients.
  82769. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82770. * @returns the list of limit velocity gradients
  82771. */
  82772. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82773. /**
  82774. * Gets the current list of color gradients.
  82775. * You must use addColorGradient and removeColorGradient to udpate this list
  82776. * @returns the list of color gradients
  82777. */
  82778. getColorGradients(): Nullable<Array<ColorGradient>>;
  82779. /**
  82780. * Gets the current list of size gradients.
  82781. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82782. * @returns the list of size gradients
  82783. */
  82784. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82785. /**
  82786. * Gets the current list of color remap gradients.
  82787. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82788. * @returns the list of color remap gradients
  82789. */
  82790. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82791. /**
  82792. * Gets the current list of alpha remap gradients.
  82793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82794. * @returns the list of alpha remap gradients
  82795. */
  82796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82797. /**
  82798. * Gets the current list of life time gradients.
  82799. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82800. * @returns the list of life time gradients
  82801. */
  82802. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82803. /**
  82804. * Gets the current list of angular speed gradients.
  82805. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82806. * @returns the list of angular speed gradients
  82807. */
  82808. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82809. /**
  82810. * Gets the current list of velocity gradients.
  82811. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82812. * @returns the list of velocity gradients
  82813. */
  82814. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82815. /**
  82816. * Gets the current list of start size gradients.
  82817. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82818. * @returns the list of start size gradients
  82819. */
  82820. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82821. /**
  82822. * Gets the current list of emit rate gradients.
  82823. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82824. * @returns the list of emit rate gradients
  82825. */
  82826. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82827. /**
  82828. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82829. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82830. */
  82831. direction1: Vector3;
  82832. /**
  82833. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82834. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82835. */
  82836. direction2: Vector3;
  82837. /**
  82838. * 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.
  82839. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82840. */
  82841. minEmitBox: Vector3;
  82842. /**
  82843. * 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.
  82844. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82845. */
  82846. maxEmitBox: Vector3;
  82847. /**
  82848. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82849. */
  82850. color1: Color4;
  82851. /**
  82852. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82853. */
  82854. color2: Color4;
  82855. /**
  82856. * Color the particle will have at the end of its lifetime
  82857. */
  82858. colorDead: Color4;
  82859. /**
  82860. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82861. */
  82862. textureMask: Color4;
  82863. /**
  82864. * The particle emitter type defines the emitter used by the particle system.
  82865. * It can be for example box, sphere, or cone...
  82866. */
  82867. particleEmitterType: IParticleEmitterType;
  82868. /** @hidden */
  82869. _isSubEmitter: boolean;
  82870. /**
  82871. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82872. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82873. */
  82874. billboardMode: number;
  82875. protected _isBillboardBased: boolean;
  82876. /**
  82877. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82878. */
  82879. isBillboardBased: boolean;
  82880. /**
  82881. * The scene the particle system belongs to.
  82882. */
  82883. protected _scene: Scene;
  82884. /**
  82885. * Local cache of defines for image processing.
  82886. */
  82887. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82888. /**
  82889. * Default configuration related to image processing available in the standard Material.
  82890. */
  82891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82892. /**
  82893. * Gets the image processing configuration used either in this material.
  82894. */
  82895. /**
  82896. * Sets the Default image processing configuration used either in the this material.
  82897. *
  82898. * If sets to null, the scene one is in use.
  82899. */
  82900. imageProcessingConfiguration: ImageProcessingConfiguration;
  82901. /**
  82902. * Attaches a new image processing configuration to the Standard Material.
  82903. * @param configuration
  82904. */
  82905. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82906. /** @hidden */
  82907. protected _reset(): void;
  82908. /** @hidden */
  82909. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82910. /**
  82911. * Instantiates a particle system.
  82912. * 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.
  82913. * @param name The name of the particle system
  82914. */
  82915. constructor(name: string);
  82916. /**
  82917. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82918. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82919. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82920. * @returns the emitter
  82921. */
  82922. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82923. /**
  82924. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82925. * @param radius The radius of the hemisphere to emit from
  82926. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82927. * @returns the emitter
  82928. */
  82929. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82930. /**
  82931. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82932. * @param radius The radius of the sphere to emit from
  82933. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82934. * @returns the emitter
  82935. */
  82936. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82937. /**
  82938. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82939. * @param radius The radius of the sphere to emit from
  82940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82942. * @returns the emitter
  82943. */
  82944. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82945. /**
  82946. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82947. * @param radius The radius of the emission cylinder
  82948. * @param height The height of the emission cylinder
  82949. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82950. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82951. * @returns the emitter
  82952. */
  82953. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82954. /**
  82955. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82956. * @param radius The radius of the cylinder to emit from
  82957. * @param height The height of the emission cylinder
  82958. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82961. * @returns the emitter
  82962. */
  82963. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82964. /**
  82965. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82966. * @param radius The radius of the cone to emit from
  82967. * @param angle The base angle of the cone
  82968. * @returns the emitter
  82969. */
  82970. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82971. /**
  82972. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82973. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82974. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82975. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82976. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82977. * @returns the emitter
  82978. */
  82979. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82980. }
  82981. }
  82982. declare module BABYLON {
  82983. /**
  82984. * Type of sub emitter
  82985. */
  82986. export enum SubEmitterType {
  82987. /**
  82988. * Attached to the particle over it's lifetime
  82989. */
  82990. ATTACHED = 0,
  82991. /**
  82992. * Created when the particle dies
  82993. */
  82994. END = 1
  82995. }
  82996. /**
  82997. * Sub emitter class used to emit particles from an existing particle
  82998. */
  82999. export class SubEmitter {
  83000. /**
  83001. * the particle system to be used by the sub emitter
  83002. */
  83003. particleSystem: ParticleSystem;
  83004. /**
  83005. * Type of the submitter (Default: END)
  83006. */
  83007. type: SubEmitterType;
  83008. /**
  83009. * 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)
  83010. * Note: This only is supported when using an emitter of type Mesh
  83011. */
  83012. inheritDirection: boolean;
  83013. /**
  83014. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83015. */
  83016. inheritedVelocityAmount: number;
  83017. /**
  83018. * Creates a sub emitter
  83019. * @param particleSystem the particle system to be used by the sub emitter
  83020. */
  83021. constructor(
  83022. /**
  83023. * the particle system to be used by the sub emitter
  83024. */
  83025. particleSystem: ParticleSystem);
  83026. /**
  83027. * Clones the sub emitter
  83028. * @returns the cloned sub emitter
  83029. */
  83030. clone(): SubEmitter;
  83031. /**
  83032. * Serialize current object to a JSON object
  83033. * @returns the serialized object
  83034. */
  83035. serialize(): any;
  83036. /** @hidden */
  83037. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83038. /**
  83039. * Creates a new SubEmitter from a serialized JSON version
  83040. * @param serializationObject defines the JSON object to read from
  83041. * @param scene defines the hosting scene
  83042. * @param rootUrl defines the rootUrl for data loading
  83043. * @returns a new SubEmitter
  83044. */
  83045. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83046. /** Release associated resources */
  83047. dispose(): void;
  83048. }
  83049. }
  83050. declare module BABYLON {
  83051. /** @hidden */
  83052. export var clipPlaneFragmentDeclaration: {
  83053. name: string;
  83054. shader: string;
  83055. };
  83056. }
  83057. declare module BABYLON {
  83058. /** @hidden */
  83059. export var imageProcessingDeclaration: {
  83060. name: string;
  83061. shader: string;
  83062. };
  83063. }
  83064. declare module BABYLON {
  83065. /** @hidden */
  83066. export var imageProcessingFunctions: {
  83067. name: string;
  83068. shader: string;
  83069. };
  83070. }
  83071. declare module BABYLON {
  83072. /** @hidden */
  83073. export var clipPlaneFragment: {
  83074. name: string;
  83075. shader: string;
  83076. };
  83077. }
  83078. declare module BABYLON {
  83079. /** @hidden */
  83080. export var particlesPixelShader: {
  83081. name: string;
  83082. shader: string;
  83083. };
  83084. }
  83085. declare module BABYLON {
  83086. /** @hidden */
  83087. export var clipPlaneVertexDeclaration: {
  83088. name: string;
  83089. shader: string;
  83090. };
  83091. }
  83092. declare module BABYLON {
  83093. /** @hidden */
  83094. export var clipPlaneVertex: {
  83095. name: string;
  83096. shader: string;
  83097. };
  83098. }
  83099. declare module BABYLON {
  83100. /** @hidden */
  83101. export var particlesVertexShader: {
  83102. name: string;
  83103. shader: string;
  83104. };
  83105. }
  83106. declare module BABYLON {
  83107. /**
  83108. * This represents a particle system in Babylon.
  83109. * 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.
  83110. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83111. * @example https://doc.babylonjs.com/babylon101/particles
  83112. */
  83113. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83114. /**
  83115. * Billboard mode will only apply to Y axis
  83116. */
  83117. static readonly BILLBOARDMODE_Y: number;
  83118. /**
  83119. * Billboard mode will apply to all axes
  83120. */
  83121. static readonly BILLBOARDMODE_ALL: number;
  83122. /**
  83123. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83124. */
  83125. static readonly BILLBOARDMODE_STRETCHED: number;
  83126. /**
  83127. * This function can be defined to provide custom update for active particles.
  83128. * This function will be called instead of regular update (age, position, color, etc.).
  83129. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83130. */
  83131. updateFunction: (particles: Particle[]) => void;
  83132. private _emitterWorldMatrix;
  83133. /**
  83134. * This function can be defined to specify initial direction for every new particle.
  83135. * It by default use the emitterType defined function
  83136. */
  83137. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83138. /**
  83139. * This function can be defined to specify initial position for every new particle.
  83140. * It by default use the emitterType defined function
  83141. */
  83142. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83143. /**
  83144. * @hidden
  83145. */
  83146. _inheritedVelocityOffset: Vector3;
  83147. /**
  83148. * An event triggered when the system is disposed
  83149. */
  83150. onDisposeObservable: Observable<ParticleSystem>;
  83151. private _onDisposeObserver;
  83152. /**
  83153. * Sets a callback that will be triggered when the system is disposed
  83154. */
  83155. onDispose: () => void;
  83156. private _particles;
  83157. private _epsilon;
  83158. private _capacity;
  83159. private _stockParticles;
  83160. private _newPartsExcess;
  83161. private _vertexData;
  83162. private _vertexBuffer;
  83163. private _vertexBuffers;
  83164. private _spriteBuffer;
  83165. private _indexBuffer;
  83166. private _effect;
  83167. private _customEffect;
  83168. private _cachedDefines;
  83169. private _scaledColorStep;
  83170. private _colorDiff;
  83171. private _scaledDirection;
  83172. private _scaledGravity;
  83173. private _currentRenderId;
  83174. private _alive;
  83175. private _useInstancing;
  83176. private _started;
  83177. private _stopped;
  83178. private _actualFrame;
  83179. private _scaledUpdateSpeed;
  83180. private _vertexBufferSize;
  83181. /** @hidden */
  83182. _currentEmitRateGradient: Nullable<FactorGradient>;
  83183. /** @hidden */
  83184. _currentEmitRate1: number;
  83185. /** @hidden */
  83186. _currentEmitRate2: number;
  83187. /** @hidden */
  83188. _currentStartSizeGradient: Nullable<FactorGradient>;
  83189. /** @hidden */
  83190. _currentStartSize1: number;
  83191. /** @hidden */
  83192. _currentStartSize2: number;
  83193. private readonly _rawTextureWidth;
  83194. private _rampGradientsTexture;
  83195. private _useRampGradients;
  83196. /** Gets or sets a boolean indicating that ramp gradients must be used
  83197. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83198. */
  83199. useRampGradients: boolean;
  83200. /**
  83201. * 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.
  83202. * 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: [])
  83203. */
  83204. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83205. private _subEmitters;
  83206. /**
  83207. * @hidden
  83208. * If the particle systems emitter should be disposed when the particle system is disposed
  83209. */
  83210. _disposeEmitterOnDispose: boolean;
  83211. /**
  83212. * The current active Sub-systems, this property is used by the root particle system only.
  83213. */
  83214. activeSubSystems: Array<ParticleSystem>;
  83215. private _rootParticleSystem;
  83216. /**
  83217. * Gets the current list of active particles
  83218. */
  83219. readonly particles: Particle[];
  83220. /**
  83221. * Returns the string "ParticleSystem"
  83222. * @returns a string containing the class name
  83223. */
  83224. getClassName(): string;
  83225. /**
  83226. * Instantiates a particle system.
  83227. * 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.
  83228. * @param name The name of the particle system
  83229. * @param capacity The max number of particles alive at the same time
  83230. * @param scene The scene the particle system belongs to
  83231. * @param customEffect a custom effect used to change the way particles are rendered by default
  83232. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83233. * @param epsilon Offset used to render the particles
  83234. */
  83235. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83236. private _addFactorGradient;
  83237. private _removeFactorGradient;
  83238. /**
  83239. * Adds a new life time gradient
  83240. * @param gradient defines the gradient to use (between 0 and 1)
  83241. * @param factor defines the life time factor to affect to the specified gradient
  83242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83243. * @returns the current particle system
  83244. */
  83245. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83246. /**
  83247. * Remove a specific life time gradient
  83248. * @param gradient defines the gradient to remove
  83249. * @returns the current particle system
  83250. */
  83251. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83252. /**
  83253. * Adds a new size gradient
  83254. * @param gradient defines the gradient to use (between 0 and 1)
  83255. * @param factor defines the size factor to affect to the specified gradient
  83256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83257. * @returns the current particle system
  83258. */
  83259. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83260. /**
  83261. * Remove a specific size gradient
  83262. * @param gradient defines the gradient to remove
  83263. * @returns the current particle system
  83264. */
  83265. removeSizeGradient(gradient: number): IParticleSystem;
  83266. /**
  83267. * Adds a new color remap gradient
  83268. * @param gradient defines the gradient to use (between 0 and 1)
  83269. * @param min defines the color remap minimal range
  83270. * @param max defines the color remap maximal range
  83271. * @returns the current particle system
  83272. */
  83273. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83274. /**
  83275. * Remove a specific color remap gradient
  83276. * @param gradient defines the gradient to remove
  83277. * @returns the current particle system
  83278. */
  83279. removeColorRemapGradient(gradient: number): IParticleSystem;
  83280. /**
  83281. * Adds a new alpha remap gradient
  83282. * @param gradient defines the gradient to use (between 0 and 1)
  83283. * @param min defines the alpha remap minimal range
  83284. * @param max defines the alpha remap maximal range
  83285. * @returns the current particle system
  83286. */
  83287. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83288. /**
  83289. * Remove a specific alpha remap gradient
  83290. * @param gradient defines the gradient to remove
  83291. * @returns the current particle system
  83292. */
  83293. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83294. /**
  83295. * Adds a new angular speed gradient
  83296. * @param gradient defines the gradient to use (between 0 and 1)
  83297. * @param factor defines the angular speed to affect to the specified gradient
  83298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83299. * @returns the current particle system
  83300. */
  83301. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83302. /**
  83303. * Remove a specific angular speed gradient
  83304. * @param gradient defines the gradient to remove
  83305. * @returns the current particle system
  83306. */
  83307. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83308. /**
  83309. * Adds a new velocity gradient
  83310. * @param gradient defines the gradient to use (between 0 and 1)
  83311. * @param factor defines the velocity to affect to the specified gradient
  83312. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83313. * @returns the current particle system
  83314. */
  83315. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83316. /**
  83317. * Remove a specific velocity gradient
  83318. * @param gradient defines the gradient to remove
  83319. * @returns the current particle system
  83320. */
  83321. removeVelocityGradient(gradient: number): IParticleSystem;
  83322. /**
  83323. * Adds a new limit velocity gradient
  83324. * @param gradient defines the gradient to use (between 0 and 1)
  83325. * @param factor defines the limit velocity value to affect to the specified gradient
  83326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83327. * @returns the current particle system
  83328. */
  83329. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83330. /**
  83331. * Remove a specific limit velocity gradient
  83332. * @param gradient defines the gradient to remove
  83333. * @returns the current particle system
  83334. */
  83335. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83336. /**
  83337. * Adds a new drag gradient
  83338. * @param gradient defines the gradient to use (between 0 and 1)
  83339. * @param factor defines the drag value to affect to the specified gradient
  83340. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83341. * @returns the current particle system
  83342. */
  83343. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83344. /**
  83345. * Remove a specific drag gradient
  83346. * @param gradient defines the gradient to remove
  83347. * @returns the current particle system
  83348. */
  83349. removeDragGradient(gradient: number): IParticleSystem;
  83350. /**
  83351. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83352. * @param gradient defines the gradient to use (between 0 and 1)
  83353. * @param factor defines the emit rate value to affect to the specified gradient
  83354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83355. * @returns the current particle system
  83356. */
  83357. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83358. /**
  83359. * Remove a specific emit rate gradient
  83360. * @param gradient defines the gradient to remove
  83361. * @returns the current particle system
  83362. */
  83363. removeEmitRateGradient(gradient: number): IParticleSystem;
  83364. /**
  83365. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83366. * @param gradient defines the gradient to use (between 0 and 1)
  83367. * @param factor defines the start size value to affect to the specified gradient
  83368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83369. * @returns the current particle system
  83370. */
  83371. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83372. /**
  83373. * Remove a specific start size gradient
  83374. * @param gradient defines the gradient to remove
  83375. * @returns the current particle system
  83376. */
  83377. removeStartSizeGradient(gradient: number): IParticleSystem;
  83378. private _createRampGradientTexture;
  83379. /**
  83380. * Gets the current list of ramp gradients.
  83381. * You must use addRampGradient and removeRampGradient to udpate this list
  83382. * @returns the list of ramp gradients
  83383. */
  83384. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83385. /**
  83386. * Adds a new ramp gradient used to remap particle colors
  83387. * @param gradient defines the gradient to use (between 0 and 1)
  83388. * @param color defines the color to affect to the specified gradient
  83389. * @returns the current particle system
  83390. */
  83391. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  83392. /**
  83393. * Remove a specific ramp gradient
  83394. * @param gradient defines the gradient to remove
  83395. * @returns the current particle system
  83396. */
  83397. removeRampGradient(gradient: number): ParticleSystem;
  83398. /**
  83399. * Adds a new color gradient
  83400. * @param gradient defines the gradient to use (between 0 and 1)
  83401. * @param color1 defines the color to affect to the specified gradient
  83402. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83403. * @returns this particle system
  83404. */
  83405. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83406. /**
  83407. * Remove a specific color gradient
  83408. * @param gradient defines the gradient to remove
  83409. * @returns this particle system
  83410. */
  83411. removeColorGradient(gradient: number): IParticleSystem;
  83412. private _fetchR;
  83413. protected _reset(): void;
  83414. private _resetEffect;
  83415. private _createVertexBuffers;
  83416. private _createIndexBuffer;
  83417. /**
  83418. * Gets the maximum number of particles active at the same time.
  83419. * @returns The max number of active particles.
  83420. */
  83421. getCapacity(): number;
  83422. /**
  83423. * Gets whether there are still active particles in the system.
  83424. * @returns True if it is alive, otherwise false.
  83425. */
  83426. isAlive(): boolean;
  83427. /**
  83428. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83429. * @returns True if it has been started, otherwise false.
  83430. */
  83431. isStarted(): boolean;
  83432. private _prepareSubEmitterInternalArray;
  83433. /**
  83434. * Starts the particle system and begins to emit
  83435. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83436. */
  83437. start(delay?: number): void;
  83438. /**
  83439. * Stops the particle system.
  83440. * @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.
  83441. */
  83442. stop(stopSubEmitters?: boolean): void;
  83443. /**
  83444. * Remove all active particles
  83445. */
  83446. reset(): void;
  83447. /**
  83448. * @hidden (for internal use only)
  83449. */
  83450. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83451. /**
  83452. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83453. * Its lifetime will start back at 0.
  83454. */
  83455. recycleParticle: (particle: Particle) => void;
  83456. private _stopSubEmitters;
  83457. private _createParticle;
  83458. private _removeFromRoot;
  83459. private _emitFromParticle;
  83460. private _update;
  83461. /** @hidden */
  83462. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83463. /** @hidden */
  83464. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83465. /** @hidden */
  83466. private _getEffect;
  83467. /**
  83468. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83469. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83470. */
  83471. animate(preWarmOnly?: boolean): void;
  83472. private _appendParticleVertices;
  83473. /**
  83474. * Rebuilds the particle system.
  83475. */
  83476. rebuild(): void;
  83477. /**
  83478. * Is this system ready to be used/rendered
  83479. * @return true if the system is ready
  83480. */
  83481. isReady(): boolean;
  83482. private _render;
  83483. /**
  83484. * Renders the particle system in its current state.
  83485. * @returns the current number of particles
  83486. */
  83487. render(): number;
  83488. /**
  83489. * Disposes the particle system and free the associated resources
  83490. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83491. */
  83492. dispose(disposeTexture?: boolean): void;
  83493. /**
  83494. * Clones the particle system.
  83495. * @param name The name of the cloned object
  83496. * @param newEmitter The new emitter to use
  83497. * @returns the cloned particle system
  83498. */
  83499. clone(name: string, newEmitter: any): ParticleSystem;
  83500. /**
  83501. * Serializes the particle system to a JSON object.
  83502. * @returns the JSON object
  83503. */
  83504. serialize(): any;
  83505. /** @hidden */
  83506. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83507. /** @hidden */
  83508. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83509. /**
  83510. * Parses a JSON object to create a particle system.
  83511. * @param parsedParticleSystem The JSON object to parse
  83512. * @param scene The scene to create the particle system in
  83513. * @param rootUrl The root url to use to load external dependencies like texture
  83514. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83515. * @returns the Parsed particle system
  83516. */
  83517. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83518. }
  83519. }
  83520. declare module BABYLON {
  83521. /**
  83522. * A particle represents one of the element emitted by a particle system.
  83523. * This is mainly define by its coordinates, direction, velocity and age.
  83524. */
  83525. export class Particle {
  83526. /**
  83527. * The particle system the particle belongs to.
  83528. */
  83529. particleSystem: ParticleSystem;
  83530. private static _Count;
  83531. /**
  83532. * Unique ID of the particle
  83533. */
  83534. id: number;
  83535. /**
  83536. * The world position of the particle in the scene.
  83537. */
  83538. position: Vector3;
  83539. /**
  83540. * The world direction of the particle in the scene.
  83541. */
  83542. direction: Vector3;
  83543. /**
  83544. * The color of the particle.
  83545. */
  83546. color: Color4;
  83547. /**
  83548. * The color change of the particle per step.
  83549. */
  83550. colorStep: Color4;
  83551. /**
  83552. * Defines how long will the life of the particle be.
  83553. */
  83554. lifeTime: number;
  83555. /**
  83556. * The current age of the particle.
  83557. */
  83558. age: number;
  83559. /**
  83560. * The current size of the particle.
  83561. */
  83562. size: number;
  83563. /**
  83564. * The current scale of the particle.
  83565. */
  83566. scale: Vector2;
  83567. /**
  83568. * The current angle of the particle.
  83569. */
  83570. angle: number;
  83571. /**
  83572. * Defines how fast is the angle changing.
  83573. */
  83574. angularSpeed: number;
  83575. /**
  83576. * Defines the cell index used by the particle to be rendered from a sprite.
  83577. */
  83578. cellIndex: number;
  83579. /**
  83580. * The information required to support color remapping
  83581. */
  83582. remapData: Vector4;
  83583. /** @hidden */
  83584. _randomCellOffset?: number;
  83585. /** @hidden */
  83586. _initialDirection: Nullable<Vector3>;
  83587. /** @hidden */
  83588. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83589. /** @hidden */
  83590. _initialStartSpriteCellID: number;
  83591. /** @hidden */
  83592. _initialEndSpriteCellID: number;
  83593. /** @hidden */
  83594. _currentColorGradient: Nullable<ColorGradient>;
  83595. /** @hidden */
  83596. _currentColor1: Color4;
  83597. /** @hidden */
  83598. _currentColor2: Color4;
  83599. /** @hidden */
  83600. _currentSizeGradient: Nullable<FactorGradient>;
  83601. /** @hidden */
  83602. _currentSize1: number;
  83603. /** @hidden */
  83604. _currentSize2: number;
  83605. /** @hidden */
  83606. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83607. /** @hidden */
  83608. _currentAngularSpeed1: number;
  83609. /** @hidden */
  83610. _currentAngularSpeed2: number;
  83611. /** @hidden */
  83612. _currentVelocityGradient: Nullable<FactorGradient>;
  83613. /** @hidden */
  83614. _currentVelocity1: number;
  83615. /** @hidden */
  83616. _currentVelocity2: number;
  83617. /** @hidden */
  83618. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83619. /** @hidden */
  83620. _currentLimitVelocity1: number;
  83621. /** @hidden */
  83622. _currentLimitVelocity2: number;
  83623. /** @hidden */
  83624. _currentDragGradient: Nullable<FactorGradient>;
  83625. /** @hidden */
  83626. _currentDrag1: number;
  83627. /** @hidden */
  83628. _currentDrag2: number;
  83629. /** @hidden */
  83630. _randomNoiseCoordinates1: Vector3;
  83631. /** @hidden */
  83632. _randomNoiseCoordinates2: Vector3;
  83633. /**
  83634. * Creates a new instance Particle
  83635. * @param particleSystem the particle system the particle belongs to
  83636. */
  83637. constructor(
  83638. /**
  83639. * The particle system the particle belongs to.
  83640. */
  83641. particleSystem: ParticleSystem);
  83642. private updateCellInfoFromSystem;
  83643. /**
  83644. * Defines how the sprite cell index is updated for the particle
  83645. */
  83646. updateCellIndex(): void;
  83647. /** @hidden */
  83648. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83649. /** @hidden */
  83650. _inheritParticleInfoToSubEmitters(): void;
  83651. /** @hidden */
  83652. _reset(): void;
  83653. /**
  83654. * Copy the properties of particle to another one.
  83655. * @param other the particle to copy the information to.
  83656. */
  83657. copyTo(other: Particle): void;
  83658. }
  83659. }
  83660. declare module BABYLON {
  83661. /**
  83662. * Particle emitter represents a volume emitting particles.
  83663. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83664. */
  83665. export interface IParticleEmitterType {
  83666. /**
  83667. * Called by the particle System when the direction is computed for the created particle.
  83668. * @param worldMatrix is the world matrix of the particle system
  83669. * @param directionToUpdate is the direction vector to update with the result
  83670. * @param particle is the particle we are computed the direction for
  83671. */
  83672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83673. /**
  83674. * Called by the particle System when the position is computed for the created particle.
  83675. * @param worldMatrix is the world matrix of the particle system
  83676. * @param positionToUpdate is the position vector to update with the result
  83677. * @param particle is the particle we are computed the position for
  83678. */
  83679. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83680. /**
  83681. * Clones the current emitter and returns a copy of it
  83682. * @returns the new emitter
  83683. */
  83684. clone(): IParticleEmitterType;
  83685. /**
  83686. * Called by the GPUParticleSystem to setup the update shader
  83687. * @param effect defines the update shader
  83688. */
  83689. applyToShader(effect: Effect): void;
  83690. /**
  83691. * Returns a string to use to update the GPU particles update shader
  83692. * @returns the effect defines string
  83693. */
  83694. getEffectDefines(): string;
  83695. /**
  83696. * Returns a string representing the class name
  83697. * @returns a string containing the class name
  83698. */
  83699. getClassName(): string;
  83700. /**
  83701. * Serializes the particle system to a JSON object.
  83702. * @returns the JSON object
  83703. */
  83704. serialize(): any;
  83705. /**
  83706. * Parse properties from a JSON object
  83707. * @param serializationObject defines the JSON object
  83708. */
  83709. parse(serializationObject: any): void;
  83710. }
  83711. }
  83712. declare module BABYLON {
  83713. /**
  83714. * Particle emitter emitting particles from the inside of a box.
  83715. * It emits the particles randomly between 2 given directions.
  83716. */
  83717. export class BoxParticleEmitter implements IParticleEmitterType {
  83718. /**
  83719. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83720. */
  83721. direction1: Vector3;
  83722. /**
  83723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83724. */
  83725. direction2: Vector3;
  83726. /**
  83727. * 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.
  83728. */
  83729. minEmitBox: Vector3;
  83730. /**
  83731. * 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.
  83732. */
  83733. maxEmitBox: Vector3;
  83734. /**
  83735. * Creates a new instance BoxParticleEmitter
  83736. */
  83737. constructor();
  83738. /**
  83739. * Called by the particle System when the direction is computed for the created particle.
  83740. * @param worldMatrix is the world matrix of the particle system
  83741. * @param directionToUpdate is the direction vector to update with the result
  83742. * @param particle is the particle we are computed the direction for
  83743. */
  83744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83745. /**
  83746. * Called by the particle System when the position is computed for the created particle.
  83747. * @param worldMatrix is the world matrix of the particle system
  83748. * @param positionToUpdate is the position vector to update with the result
  83749. * @param particle is the particle we are computed the position for
  83750. */
  83751. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83752. /**
  83753. * Clones the current emitter and returns a copy of it
  83754. * @returns the new emitter
  83755. */
  83756. clone(): BoxParticleEmitter;
  83757. /**
  83758. * Called by the GPUParticleSystem to setup the update shader
  83759. * @param effect defines the update shader
  83760. */
  83761. applyToShader(effect: Effect): void;
  83762. /**
  83763. * Returns a string to use to update the GPU particles update shader
  83764. * @returns a string containng the defines string
  83765. */
  83766. getEffectDefines(): string;
  83767. /**
  83768. * Returns the string "BoxParticleEmitter"
  83769. * @returns a string containing the class name
  83770. */
  83771. getClassName(): string;
  83772. /**
  83773. * Serializes the particle system to a JSON object.
  83774. * @returns the JSON object
  83775. */
  83776. serialize(): any;
  83777. /**
  83778. * Parse properties from a JSON object
  83779. * @param serializationObject defines the JSON object
  83780. */
  83781. parse(serializationObject: any): void;
  83782. }
  83783. }
  83784. declare module BABYLON {
  83785. /**
  83786. * Particle emitter emitting particles from the inside of a cone.
  83787. * It emits the particles alongside the cone volume from the base to the particle.
  83788. * The emission direction might be randomized.
  83789. */
  83790. export class ConeParticleEmitter implements IParticleEmitterType {
  83791. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83792. directionRandomizer: number;
  83793. private _radius;
  83794. private _angle;
  83795. private _height;
  83796. /**
  83797. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83798. */
  83799. radiusRange: number;
  83800. /**
  83801. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83802. */
  83803. heightRange: number;
  83804. /**
  83805. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83806. */
  83807. emitFromSpawnPointOnly: boolean;
  83808. /**
  83809. * Gets or sets the radius of the emission cone
  83810. */
  83811. radius: number;
  83812. /**
  83813. * Gets or sets the angle of the emission cone
  83814. */
  83815. angle: number;
  83816. private _buildHeight;
  83817. /**
  83818. * Creates a new instance ConeParticleEmitter
  83819. * @param radius the radius of the emission cone (1 by default)
  83820. * @param angle the cone base angle (PI by default)
  83821. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83822. */
  83823. constructor(radius?: number, angle?: number,
  83824. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83825. directionRandomizer?: number);
  83826. /**
  83827. * Called by the particle System when the direction is computed for the created particle.
  83828. * @param worldMatrix is the world matrix of the particle system
  83829. * @param directionToUpdate is the direction vector to update with the result
  83830. * @param particle is the particle we are computed the direction for
  83831. */
  83832. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83833. /**
  83834. * Called by the particle System when the position is computed for the created particle.
  83835. * @param worldMatrix is the world matrix of the particle system
  83836. * @param positionToUpdate is the position vector to update with the result
  83837. * @param particle is the particle we are computed the position for
  83838. */
  83839. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83840. /**
  83841. * Clones the current emitter and returns a copy of it
  83842. * @returns the new emitter
  83843. */
  83844. clone(): ConeParticleEmitter;
  83845. /**
  83846. * Called by the GPUParticleSystem to setup the update shader
  83847. * @param effect defines the update shader
  83848. */
  83849. applyToShader(effect: Effect): void;
  83850. /**
  83851. * Returns a string to use to update the GPU particles update shader
  83852. * @returns a string containng the defines string
  83853. */
  83854. getEffectDefines(): string;
  83855. /**
  83856. * Returns the string "ConeParticleEmitter"
  83857. * @returns a string containing the class name
  83858. */
  83859. getClassName(): string;
  83860. /**
  83861. * Serializes the particle system to a JSON object.
  83862. * @returns the JSON object
  83863. */
  83864. serialize(): any;
  83865. /**
  83866. * Parse properties from a JSON object
  83867. * @param serializationObject defines the JSON object
  83868. */
  83869. parse(serializationObject: any): void;
  83870. }
  83871. }
  83872. declare module BABYLON {
  83873. /**
  83874. * Particle emitter emitting particles from the inside of a cylinder.
  83875. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83876. */
  83877. export class CylinderParticleEmitter implements IParticleEmitterType {
  83878. /**
  83879. * The radius of the emission cylinder.
  83880. */
  83881. radius: number;
  83882. /**
  83883. * The height of the emission cylinder.
  83884. */
  83885. height: number;
  83886. /**
  83887. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83888. */
  83889. radiusRange: number;
  83890. /**
  83891. * How much to randomize the particle direction [0-1].
  83892. */
  83893. directionRandomizer: number;
  83894. /**
  83895. * Creates a new instance CylinderParticleEmitter
  83896. * @param radius the radius of the emission cylinder (1 by default)
  83897. * @param height the height of the emission cylinder (1 by default)
  83898. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83899. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83900. */
  83901. constructor(
  83902. /**
  83903. * The radius of the emission cylinder.
  83904. */
  83905. radius?: number,
  83906. /**
  83907. * The height of the emission cylinder.
  83908. */
  83909. height?: number,
  83910. /**
  83911. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83912. */
  83913. radiusRange?: number,
  83914. /**
  83915. * How much to randomize the particle direction [0-1].
  83916. */
  83917. directionRandomizer?: number);
  83918. /**
  83919. * Called by the particle System when the direction is computed for the created particle.
  83920. * @param worldMatrix is the world matrix of the particle system
  83921. * @param directionToUpdate is the direction vector to update with the result
  83922. * @param particle is the particle we are computed the direction for
  83923. */
  83924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83925. /**
  83926. * Called by the particle System when the position is computed for the created particle.
  83927. * @param worldMatrix is the world matrix of the particle system
  83928. * @param positionToUpdate is the position vector to update with the result
  83929. * @param particle is the particle we are computed the position for
  83930. */
  83931. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83932. /**
  83933. * Clones the current emitter and returns a copy of it
  83934. * @returns the new emitter
  83935. */
  83936. clone(): CylinderParticleEmitter;
  83937. /**
  83938. * Called by the GPUParticleSystem to setup the update shader
  83939. * @param effect defines the update shader
  83940. */
  83941. applyToShader(effect: Effect): void;
  83942. /**
  83943. * Returns a string to use to update the GPU particles update shader
  83944. * @returns a string containng the defines string
  83945. */
  83946. getEffectDefines(): string;
  83947. /**
  83948. * Returns the string "CylinderParticleEmitter"
  83949. * @returns a string containing the class name
  83950. */
  83951. getClassName(): string;
  83952. /**
  83953. * Serializes the particle system to a JSON object.
  83954. * @returns the JSON object
  83955. */
  83956. serialize(): any;
  83957. /**
  83958. * Parse properties from a JSON object
  83959. * @param serializationObject defines the JSON object
  83960. */
  83961. parse(serializationObject: any): void;
  83962. }
  83963. /**
  83964. * Particle emitter emitting particles from the inside of a cylinder.
  83965. * It emits the particles randomly between two vectors.
  83966. */
  83967. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83968. /**
  83969. * The min limit of the emission direction.
  83970. */
  83971. direction1: Vector3;
  83972. /**
  83973. * The max limit of the emission direction.
  83974. */
  83975. direction2: Vector3;
  83976. /**
  83977. * Creates a new instance CylinderDirectedParticleEmitter
  83978. * @param radius the radius of the emission cylinder (1 by default)
  83979. * @param height the height of the emission cylinder (1 by default)
  83980. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83981. * @param direction1 the min limit of the emission direction (up vector by default)
  83982. * @param direction2 the max limit of the emission direction (up vector by default)
  83983. */
  83984. constructor(radius?: number, height?: number, radiusRange?: number,
  83985. /**
  83986. * The min limit of the emission direction.
  83987. */
  83988. direction1?: Vector3,
  83989. /**
  83990. * The max limit of the emission direction.
  83991. */
  83992. direction2?: Vector3);
  83993. /**
  83994. * Called by the particle System when the direction is computed for the created particle.
  83995. * @param worldMatrix is the world matrix of the particle system
  83996. * @param directionToUpdate is the direction vector to update with the result
  83997. * @param particle is the particle we are computed the direction for
  83998. */
  83999. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84000. /**
  84001. * Clones the current emitter and returns a copy of it
  84002. * @returns the new emitter
  84003. */
  84004. clone(): CylinderDirectedParticleEmitter;
  84005. /**
  84006. * Called by the GPUParticleSystem to setup the update shader
  84007. * @param effect defines the update shader
  84008. */
  84009. applyToShader(effect: Effect): void;
  84010. /**
  84011. * Returns a string to use to update the GPU particles update shader
  84012. * @returns a string containng the defines string
  84013. */
  84014. getEffectDefines(): string;
  84015. /**
  84016. * Returns the string "CylinderDirectedParticleEmitter"
  84017. * @returns a string containing the class name
  84018. */
  84019. getClassName(): string;
  84020. /**
  84021. * Serializes the particle system to a JSON object.
  84022. * @returns the JSON object
  84023. */
  84024. serialize(): any;
  84025. /**
  84026. * Parse properties from a JSON object
  84027. * @param serializationObject defines the JSON object
  84028. */
  84029. parse(serializationObject: any): void;
  84030. }
  84031. }
  84032. declare module BABYLON {
  84033. /**
  84034. * Particle emitter emitting particles from the inside of a hemisphere.
  84035. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84036. */
  84037. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84038. /**
  84039. * The radius of the emission hemisphere.
  84040. */
  84041. radius: number;
  84042. /**
  84043. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84044. */
  84045. radiusRange: number;
  84046. /**
  84047. * How much to randomize the particle direction [0-1].
  84048. */
  84049. directionRandomizer: number;
  84050. /**
  84051. * Creates a new instance HemisphericParticleEmitter
  84052. * @param radius the radius of the emission hemisphere (1 by default)
  84053. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84054. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84055. */
  84056. constructor(
  84057. /**
  84058. * The radius of the emission hemisphere.
  84059. */
  84060. radius?: number,
  84061. /**
  84062. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84063. */
  84064. radiusRange?: number,
  84065. /**
  84066. * How much to randomize the particle direction [0-1].
  84067. */
  84068. directionRandomizer?: number);
  84069. /**
  84070. * Called by the particle System when the direction is computed for the created particle.
  84071. * @param worldMatrix is the world matrix of the particle system
  84072. * @param directionToUpdate is the direction vector to update with the result
  84073. * @param particle is the particle we are computed the direction for
  84074. */
  84075. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84076. /**
  84077. * Called by the particle System when the position is computed for the created particle.
  84078. * @param worldMatrix is the world matrix of the particle system
  84079. * @param positionToUpdate is the position vector to update with the result
  84080. * @param particle is the particle we are computed the position for
  84081. */
  84082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84083. /**
  84084. * Clones the current emitter and returns a copy of it
  84085. * @returns the new emitter
  84086. */
  84087. clone(): HemisphericParticleEmitter;
  84088. /**
  84089. * Called by the GPUParticleSystem to setup the update shader
  84090. * @param effect defines the update shader
  84091. */
  84092. applyToShader(effect: Effect): void;
  84093. /**
  84094. * Returns a string to use to update the GPU particles update shader
  84095. * @returns a string containng the defines string
  84096. */
  84097. getEffectDefines(): string;
  84098. /**
  84099. * Returns the string "HemisphericParticleEmitter"
  84100. * @returns a string containing the class name
  84101. */
  84102. getClassName(): string;
  84103. /**
  84104. * Serializes the particle system to a JSON object.
  84105. * @returns the JSON object
  84106. */
  84107. serialize(): any;
  84108. /**
  84109. * Parse properties from a JSON object
  84110. * @param serializationObject defines the JSON object
  84111. */
  84112. parse(serializationObject: any): void;
  84113. }
  84114. }
  84115. declare module BABYLON {
  84116. /**
  84117. * Particle emitter emitting particles from a point.
  84118. * It emits the particles randomly between 2 given directions.
  84119. */
  84120. export class PointParticleEmitter implements IParticleEmitterType {
  84121. /**
  84122. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84123. */
  84124. direction1: Vector3;
  84125. /**
  84126. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84127. */
  84128. direction2: Vector3;
  84129. /**
  84130. * Creates a new instance PointParticleEmitter
  84131. */
  84132. constructor();
  84133. /**
  84134. * Called by the particle System when the direction is computed for the created particle.
  84135. * @param worldMatrix is the world matrix of the particle system
  84136. * @param directionToUpdate is the direction vector to update with the result
  84137. * @param particle is the particle we are computed the direction for
  84138. */
  84139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84140. /**
  84141. * Called by the particle System when the position is computed for the created particle.
  84142. * @param worldMatrix is the world matrix of the particle system
  84143. * @param positionToUpdate is the position vector to update with the result
  84144. * @param particle is the particle we are computed the position for
  84145. */
  84146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84147. /**
  84148. * Clones the current emitter and returns a copy of it
  84149. * @returns the new emitter
  84150. */
  84151. clone(): PointParticleEmitter;
  84152. /**
  84153. * Called by the GPUParticleSystem to setup the update shader
  84154. * @param effect defines the update shader
  84155. */
  84156. applyToShader(effect: Effect): void;
  84157. /**
  84158. * Returns a string to use to update the GPU particles update shader
  84159. * @returns a string containng the defines string
  84160. */
  84161. getEffectDefines(): string;
  84162. /**
  84163. * Returns the string "PointParticleEmitter"
  84164. * @returns a string containing the class name
  84165. */
  84166. getClassName(): string;
  84167. /**
  84168. * Serializes the particle system to a JSON object.
  84169. * @returns the JSON object
  84170. */
  84171. serialize(): any;
  84172. /**
  84173. * Parse properties from a JSON object
  84174. * @param serializationObject defines the JSON object
  84175. */
  84176. parse(serializationObject: any): void;
  84177. }
  84178. }
  84179. declare module BABYLON {
  84180. /**
  84181. * Particle emitter emitting particles from the inside of a sphere.
  84182. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84183. */
  84184. export class SphereParticleEmitter implements IParticleEmitterType {
  84185. /**
  84186. * The radius of the emission sphere.
  84187. */
  84188. radius: number;
  84189. /**
  84190. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84191. */
  84192. radiusRange: number;
  84193. /**
  84194. * How much to randomize the particle direction [0-1].
  84195. */
  84196. directionRandomizer: number;
  84197. /**
  84198. * Creates a new instance SphereParticleEmitter
  84199. * @param radius the radius of the emission sphere (1 by default)
  84200. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84201. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84202. */
  84203. constructor(
  84204. /**
  84205. * The radius of the emission sphere.
  84206. */
  84207. radius?: number,
  84208. /**
  84209. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84210. */
  84211. radiusRange?: number,
  84212. /**
  84213. * How much to randomize the particle direction [0-1].
  84214. */
  84215. directionRandomizer?: number);
  84216. /**
  84217. * Called by the particle System when the direction is computed for the created particle.
  84218. * @param worldMatrix is the world matrix of the particle system
  84219. * @param directionToUpdate is the direction vector to update with the result
  84220. * @param particle is the particle we are computed the direction for
  84221. */
  84222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84223. /**
  84224. * Called by the particle System when the position is computed for the created particle.
  84225. * @param worldMatrix is the world matrix of the particle system
  84226. * @param positionToUpdate is the position vector to update with the result
  84227. * @param particle is the particle we are computed the position for
  84228. */
  84229. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84230. /**
  84231. * Clones the current emitter and returns a copy of it
  84232. * @returns the new emitter
  84233. */
  84234. clone(): SphereParticleEmitter;
  84235. /**
  84236. * Called by the GPUParticleSystem to setup the update shader
  84237. * @param effect defines the update shader
  84238. */
  84239. applyToShader(effect: Effect): void;
  84240. /**
  84241. * Returns a string to use to update the GPU particles update shader
  84242. * @returns a string containng the defines string
  84243. */
  84244. getEffectDefines(): string;
  84245. /**
  84246. * Returns the string "SphereParticleEmitter"
  84247. * @returns a string containing the class name
  84248. */
  84249. getClassName(): string;
  84250. /**
  84251. * Serializes the particle system to a JSON object.
  84252. * @returns the JSON object
  84253. */
  84254. serialize(): any;
  84255. /**
  84256. * Parse properties from a JSON object
  84257. * @param serializationObject defines the JSON object
  84258. */
  84259. parse(serializationObject: any): void;
  84260. }
  84261. /**
  84262. * Particle emitter emitting particles from the inside of a sphere.
  84263. * It emits the particles randomly between two vectors.
  84264. */
  84265. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84266. /**
  84267. * The min limit of the emission direction.
  84268. */
  84269. direction1: Vector3;
  84270. /**
  84271. * The max limit of the emission direction.
  84272. */
  84273. direction2: Vector3;
  84274. /**
  84275. * Creates a new instance SphereDirectedParticleEmitter
  84276. * @param radius the radius of the emission sphere (1 by default)
  84277. * @param direction1 the min limit of the emission direction (up vector by default)
  84278. * @param direction2 the max limit of the emission direction (up vector by default)
  84279. */
  84280. constructor(radius?: number,
  84281. /**
  84282. * The min limit of the emission direction.
  84283. */
  84284. direction1?: Vector3,
  84285. /**
  84286. * The max limit of the emission direction.
  84287. */
  84288. direction2?: Vector3);
  84289. /**
  84290. * Called by the particle System when the direction is computed for the created particle.
  84291. * @param worldMatrix is the world matrix of the particle system
  84292. * @param directionToUpdate is the direction vector to update with the result
  84293. * @param particle is the particle we are computed the direction for
  84294. */
  84295. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84296. /**
  84297. * Clones the current emitter and returns a copy of it
  84298. * @returns the new emitter
  84299. */
  84300. clone(): SphereDirectedParticleEmitter;
  84301. /**
  84302. * Called by the GPUParticleSystem to setup the update shader
  84303. * @param effect defines the update shader
  84304. */
  84305. applyToShader(effect: Effect): void;
  84306. /**
  84307. * Returns a string to use to update the GPU particles update shader
  84308. * @returns a string containng the defines string
  84309. */
  84310. getEffectDefines(): string;
  84311. /**
  84312. * Returns the string "SphereDirectedParticleEmitter"
  84313. * @returns a string containing the class name
  84314. */
  84315. getClassName(): string;
  84316. /**
  84317. * Serializes the particle system to a JSON object.
  84318. * @returns the JSON object
  84319. */
  84320. serialize(): any;
  84321. /**
  84322. * Parse properties from a JSON object
  84323. * @param serializationObject defines the JSON object
  84324. */
  84325. parse(serializationObject: any): void;
  84326. }
  84327. }
  84328. declare module BABYLON {
  84329. /**
  84330. * Interface representing a particle system in Babylon.js.
  84331. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84332. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84333. */
  84334. export interface IParticleSystem {
  84335. /**
  84336. * List of animations used by the particle system.
  84337. */
  84338. animations: Animation[];
  84339. /**
  84340. * The id of the Particle system.
  84341. */
  84342. id: string;
  84343. /**
  84344. * The name of the Particle system.
  84345. */
  84346. name: string;
  84347. /**
  84348. * The emitter represents the Mesh or position we are attaching the particle system to.
  84349. */
  84350. emitter: Nullable<AbstractMesh | Vector3>;
  84351. /**
  84352. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84353. */
  84354. isBillboardBased: boolean;
  84355. /**
  84356. * The rendering group used by the Particle system to chose when to render.
  84357. */
  84358. renderingGroupId: number;
  84359. /**
  84360. * The layer mask we are rendering the particles through.
  84361. */
  84362. layerMask: number;
  84363. /**
  84364. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84365. */
  84366. updateSpeed: number;
  84367. /**
  84368. * The amount of time the particle system is running (depends of the overall update speed).
  84369. */
  84370. targetStopDuration: number;
  84371. /**
  84372. * The texture used to render each particle. (this can be a spritesheet)
  84373. */
  84374. particleTexture: Nullable<Texture>;
  84375. /**
  84376. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  84377. */
  84378. blendMode: number;
  84379. /**
  84380. * Minimum life time of emitting particles.
  84381. */
  84382. minLifeTime: number;
  84383. /**
  84384. * Maximum life time of emitting particles.
  84385. */
  84386. maxLifeTime: number;
  84387. /**
  84388. * Minimum Size of emitting particles.
  84389. */
  84390. minSize: number;
  84391. /**
  84392. * Maximum Size of emitting particles.
  84393. */
  84394. maxSize: number;
  84395. /**
  84396. * Minimum scale of emitting particles on X axis.
  84397. */
  84398. minScaleX: number;
  84399. /**
  84400. * Maximum scale of emitting particles on X axis.
  84401. */
  84402. maxScaleX: number;
  84403. /**
  84404. * Minimum scale of emitting particles on Y axis.
  84405. */
  84406. minScaleY: number;
  84407. /**
  84408. * Maximum scale of emitting particles on Y axis.
  84409. */
  84410. maxScaleY: number;
  84411. /**
  84412. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84413. */
  84414. color1: Color4;
  84415. /**
  84416. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84417. */
  84418. color2: Color4;
  84419. /**
  84420. * Color the particle will have at the end of its lifetime.
  84421. */
  84422. colorDead: Color4;
  84423. /**
  84424. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84425. */
  84426. emitRate: number;
  84427. /**
  84428. * You can use gravity if you want to give an orientation to your particles.
  84429. */
  84430. gravity: Vector3;
  84431. /**
  84432. * Minimum power of emitting particles.
  84433. */
  84434. minEmitPower: number;
  84435. /**
  84436. * Maximum power of emitting particles.
  84437. */
  84438. maxEmitPower: number;
  84439. /**
  84440. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84441. */
  84442. minAngularSpeed: number;
  84443. /**
  84444. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84445. */
  84446. maxAngularSpeed: number;
  84447. /**
  84448. * Gets or sets the minimal initial rotation in radians.
  84449. */
  84450. minInitialRotation: number;
  84451. /**
  84452. * Gets or sets the maximal initial rotation in radians.
  84453. */
  84454. maxInitialRotation: number;
  84455. /**
  84456. * The particle emitter type defines the emitter used by the particle system.
  84457. * It can be for example box, sphere, or cone...
  84458. */
  84459. particleEmitterType: Nullable<IParticleEmitterType>;
  84460. /**
  84461. * Defines the delay in milliseconds before starting the system (0 by default)
  84462. */
  84463. startDelay: number;
  84464. /**
  84465. * 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
  84466. */
  84467. preWarmCycles: number;
  84468. /**
  84469. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84470. */
  84471. preWarmStepOffset: number;
  84472. /**
  84473. * 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)
  84474. */
  84475. spriteCellChangeSpeed: number;
  84476. /**
  84477. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84478. */
  84479. startSpriteCellID: number;
  84480. /**
  84481. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84482. */
  84483. endSpriteCellID: number;
  84484. /**
  84485. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84486. */
  84487. spriteCellWidth: number;
  84488. /**
  84489. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84490. */
  84491. spriteCellHeight: number;
  84492. /**
  84493. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84494. */
  84495. spriteRandomStartCell: boolean;
  84496. /**
  84497. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84498. */
  84499. isAnimationSheetEnabled: boolean;
  84500. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84501. translationPivot: Vector2;
  84502. /**
  84503. * Gets or sets a texture used to add random noise to particle positions
  84504. */
  84505. noiseTexture: Nullable<BaseTexture>;
  84506. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84507. noiseStrength: Vector3;
  84508. /**
  84509. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84510. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84511. */
  84512. billboardMode: number;
  84513. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84514. limitVelocityDamping: number;
  84515. /**
  84516. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84517. */
  84518. beginAnimationOnStart: boolean;
  84519. /**
  84520. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84521. */
  84522. beginAnimationFrom: number;
  84523. /**
  84524. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84525. */
  84526. beginAnimationTo: number;
  84527. /**
  84528. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84529. */
  84530. beginAnimationLoop: boolean;
  84531. /**
  84532. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84533. */
  84534. disposeOnStop: boolean;
  84535. /**
  84536. * Gets the maximum number of particles active at the same time.
  84537. * @returns The max number of active particles.
  84538. */
  84539. getCapacity(): number;
  84540. /**
  84541. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84542. * @returns True if it has been started, otherwise false.
  84543. */
  84544. isStarted(): boolean;
  84545. /**
  84546. * Animates the particle system for this frame.
  84547. */
  84548. animate(): void;
  84549. /**
  84550. * Renders the particle system in its current state.
  84551. * @returns the current number of particles
  84552. */
  84553. render(): number;
  84554. /**
  84555. * Dispose the particle system and frees its associated resources.
  84556. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84557. */
  84558. dispose(disposeTexture?: boolean): void;
  84559. /**
  84560. * Clones the particle system.
  84561. * @param name The name of the cloned object
  84562. * @param newEmitter The new emitter to use
  84563. * @returns the cloned particle system
  84564. */
  84565. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84566. /**
  84567. * Serializes the particle system to a JSON object.
  84568. * @returns the JSON object
  84569. */
  84570. serialize(): any;
  84571. /**
  84572. * Rebuild the particle system
  84573. */
  84574. rebuild(): void;
  84575. /**
  84576. * Starts the particle system and begins to emit
  84577. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84578. */
  84579. start(delay?: number): void;
  84580. /**
  84581. * Stops the particle system.
  84582. */
  84583. stop(): void;
  84584. /**
  84585. * Remove all active particles
  84586. */
  84587. reset(): void;
  84588. /**
  84589. * Is this system ready to be used/rendered
  84590. * @return true if the system is ready
  84591. */
  84592. isReady(): boolean;
  84593. /**
  84594. * Adds a new color gradient
  84595. * @param gradient defines the gradient to use (between 0 and 1)
  84596. * @param color1 defines the color to affect to the specified gradient
  84597. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84598. * @returns the current particle system
  84599. */
  84600. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84601. /**
  84602. * Remove a specific color gradient
  84603. * @param gradient defines the gradient to remove
  84604. * @returns the current particle system
  84605. */
  84606. removeColorGradient(gradient: number): IParticleSystem;
  84607. /**
  84608. * Adds a new size gradient
  84609. * @param gradient defines the gradient to use (between 0 and 1)
  84610. * @param factor defines the size factor to affect to the specified gradient
  84611. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84612. * @returns the current particle system
  84613. */
  84614. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84615. /**
  84616. * Remove a specific size gradient
  84617. * @param gradient defines the gradient to remove
  84618. * @returns the current particle system
  84619. */
  84620. removeSizeGradient(gradient: number): IParticleSystem;
  84621. /**
  84622. * Gets the current list of color gradients.
  84623. * You must use addColorGradient and removeColorGradient to udpate this list
  84624. * @returns the list of color gradients
  84625. */
  84626. getColorGradients(): Nullable<Array<ColorGradient>>;
  84627. /**
  84628. * Gets the current list of size gradients.
  84629. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84630. * @returns the list of size gradients
  84631. */
  84632. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84633. /**
  84634. * Gets the current list of angular speed gradients.
  84635. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84636. * @returns the list of angular speed gradients
  84637. */
  84638. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84639. /**
  84640. * Adds a new angular speed gradient
  84641. * @param gradient defines the gradient to use (between 0 and 1)
  84642. * @param factor defines the angular speed to affect to the specified gradient
  84643. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84644. * @returns the current particle system
  84645. */
  84646. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84647. /**
  84648. * Remove a specific angular speed gradient
  84649. * @param gradient defines the gradient to remove
  84650. * @returns the current particle system
  84651. */
  84652. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84653. /**
  84654. * Gets the current list of velocity gradients.
  84655. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84656. * @returns the list of velocity gradients
  84657. */
  84658. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84659. /**
  84660. * Adds a new velocity gradient
  84661. * @param gradient defines the gradient to use (between 0 and 1)
  84662. * @param factor defines the velocity to affect to the specified gradient
  84663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84664. * @returns the current particle system
  84665. */
  84666. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84667. /**
  84668. * Remove a specific velocity gradient
  84669. * @param gradient defines the gradient to remove
  84670. * @returns the current particle system
  84671. */
  84672. removeVelocityGradient(gradient: number): IParticleSystem;
  84673. /**
  84674. * Gets the current list of limit velocity gradients.
  84675. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84676. * @returns the list of limit velocity gradients
  84677. */
  84678. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84679. /**
  84680. * Adds a new limit velocity gradient
  84681. * @param gradient defines the gradient to use (between 0 and 1)
  84682. * @param factor defines the limit velocity to affect to the specified gradient
  84683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84684. * @returns the current particle system
  84685. */
  84686. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84687. /**
  84688. * Remove a specific limit velocity gradient
  84689. * @param gradient defines the gradient to remove
  84690. * @returns the current particle system
  84691. */
  84692. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84693. /**
  84694. * Adds a new drag gradient
  84695. * @param gradient defines the gradient to use (between 0 and 1)
  84696. * @param factor defines the drag to affect to the specified gradient
  84697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84698. * @returns the current particle system
  84699. */
  84700. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84701. /**
  84702. * Remove a specific drag gradient
  84703. * @param gradient defines the gradient to remove
  84704. * @returns the current particle system
  84705. */
  84706. removeDragGradient(gradient: number): IParticleSystem;
  84707. /**
  84708. * Gets the current list of drag gradients.
  84709. * You must use addDragGradient and removeDragGradient to udpate this list
  84710. * @returns the list of drag gradients
  84711. */
  84712. getDragGradients(): Nullable<Array<FactorGradient>>;
  84713. /**
  84714. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84715. * @param gradient defines the gradient to use (between 0 and 1)
  84716. * @param factor defines the emit rate to affect to the specified gradient
  84717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84718. * @returns the current particle system
  84719. */
  84720. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84721. /**
  84722. * Remove a specific emit rate gradient
  84723. * @param gradient defines the gradient to remove
  84724. * @returns the current particle system
  84725. */
  84726. removeEmitRateGradient(gradient: number): IParticleSystem;
  84727. /**
  84728. * Gets the current list of emit rate gradients.
  84729. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84730. * @returns the list of emit rate gradients
  84731. */
  84732. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84733. /**
  84734. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84735. * @param gradient defines the gradient to use (between 0 and 1)
  84736. * @param factor defines the start size to affect to the specified gradient
  84737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84738. * @returns the current particle system
  84739. */
  84740. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84741. /**
  84742. * Remove a specific start size gradient
  84743. * @param gradient defines the gradient to remove
  84744. * @returns the current particle system
  84745. */
  84746. removeStartSizeGradient(gradient: number): IParticleSystem;
  84747. /**
  84748. * Gets the current list of start size gradients.
  84749. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84750. * @returns the list of start size gradients
  84751. */
  84752. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84753. /**
  84754. * Adds a new life time gradient
  84755. * @param gradient defines the gradient to use (between 0 and 1)
  84756. * @param factor defines the life time factor to affect to the specified gradient
  84757. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84758. * @returns the current particle system
  84759. */
  84760. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84761. /**
  84762. * Remove a specific life time gradient
  84763. * @param gradient defines the gradient to remove
  84764. * @returns the current particle system
  84765. */
  84766. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84767. /**
  84768. * Gets the current list of life time gradients.
  84769. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84770. * @returns the list of life time gradients
  84771. */
  84772. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84773. /**
  84774. * Gets the current list of color gradients.
  84775. * You must use addColorGradient and removeColorGradient to udpate this list
  84776. * @returns the list of color gradients
  84777. */
  84778. getColorGradients(): Nullable<Array<ColorGradient>>;
  84779. /**
  84780. * Adds a new ramp gradient used to remap particle colors
  84781. * @param gradient defines the gradient to use (between 0 and 1)
  84782. * @param color defines the color to affect to the specified gradient
  84783. * @returns the current particle system
  84784. */
  84785. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84786. /**
  84787. * Gets the current list of ramp gradients.
  84788. * You must use addRampGradient and removeRampGradient to udpate this list
  84789. * @returns the list of ramp gradients
  84790. */
  84791. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84792. /** Gets or sets a boolean indicating that ramp gradients must be used
  84793. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84794. */
  84795. useRampGradients: boolean;
  84796. /**
  84797. * Adds a new color remap gradient
  84798. * @param gradient defines the gradient to use (between 0 and 1)
  84799. * @param min defines the color remap minimal range
  84800. * @param max defines the color remap maximal range
  84801. * @returns the current particle system
  84802. */
  84803. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84804. /**
  84805. * Gets the current list of color remap gradients.
  84806. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84807. * @returns the list of color remap gradients
  84808. */
  84809. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84810. /**
  84811. * Adds a new alpha remap gradient
  84812. * @param gradient defines the gradient to use (between 0 and 1)
  84813. * @param min defines the alpha remap minimal range
  84814. * @param max defines the alpha remap maximal range
  84815. * @returns the current particle system
  84816. */
  84817. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84818. /**
  84819. * Gets the current list of alpha remap gradients.
  84820. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84821. * @returns the list of alpha remap gradients
  84822. */
  84823. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84824. /**
  84825. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84826. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84827. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84828. * @returns the emitter
  84829. */
  84830. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84831. /**
  84832. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84833. * @param radius The radius of the hemisphere to emit from
  84834. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84835. * @returns the emitter
  84836. */
  84837. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84838. /**
  84839. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84840. * @param radius The radius of the sphere to emit from
  84841. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84842. * @returns the emitter
  84843. */
  84844. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84845. /**
  84846. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84847. * @param radius The radius of the sphere to emit from
  84848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84850. * @returns the emitter
  84851. */
  84852. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84853. /**
  84854. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84855. * @param radius The radius of the emission cylinder
  84856. * @param height The height of the emission cylinder
  84857. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84858. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84859. * @returns the emitter
  84860. */
  84861. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84862. /**
  84863. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84864. * @param radius The radius of the cylinder to emit from
  84865. * @param height The height of the emission cylinder
  84866. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84867. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84868. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84869. * @returns the emitter
  84870. */
  84871. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84872. /**
  84873. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84874. * @param radius The radius of the cone to emit from
  84875. * @param angle The base angle of the cone
  84876. * @returns the emitter
  84877. */
  84878. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84879. /**
  84880. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84881. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84882. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84883. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84884. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84885. * @returns the emitter
  84886. */
  84887. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84888. /**
  84889. * Get hosting scene
  84890. * @returns the scene
  84891. */
  84892. getScene(): Scene;
  84893. }
  84894. }
  84895. declare module BABYLON {
  84896. /**
  84897. * Creates an instance based on a source mesh.
  84898. */
  84899. export class InstancedMesh extends AbstractMesh {
  84900. private _sourceMesh;
  84901. private _currentLOD;
  84902. /** @hidden */
  84903. _indexInSourceMeshInstanceArray: number;
  84904. constructor(name: string, source: Mesh);
  84905. /**
  84906. * Returns the string "InstancedMesh".
  84907. */
  84908. getClassName(): string;
  84909. /** Gets the list of lights affecting that mesh */
  84910. readonly lightSources: Light[];
  84911. _resyncLightSources(): void;
  84912. _resyncLighSource(light: Light): void;
  84913. _removeLightSource(light: Light, dispose: boolean): void;
  84914. /**
  84915. * If the source mesh receives shadows
  84916. */
  84917. readonly receiveShadows: boolean;
  84918. /**
  84919. * The material of the source mesh
  84920. */
  84921. readonly material: Nullable<Material>;
  84922. /**
  84923. * Visibility of the source mesh
  84924. */
  84925. readonly visibility: number;
  84926. /**
  84927. * Skeleton of the source mesh
  84928. */
  84929. readonly skeleton: Nullable<Skeleton>;
  84930. /**
  84931. * Rendering ground id of the source mesh
  84932. */
  84933. renderingGroupId: number;
  84934. /**
  84935. * Returns the total number of vertices (integer).
  84936. */
  84937. getTotalVertices(): number;
  84938. /**
  84939. * Returns a positive integer : the total number of indices in this mesh geometry.
  84940. * @returns the numner of indices or zero if the mesh has no geometry.
  84941. */
  84942. getTotalIndices(): number;
  84943. /**
  84944. * The source mesh of the instance
  84945. */
  84946. readonly sourceMesh: Mesh;
  84947. /**
  84948. * Is this node ready to be used/rendered
  84949. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84950. * @return {boolean} is it ready
  84951. */
  84952. isReady(completeCheck?: boolean): boolean;
  84953. /**
  84954. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84955. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84956. * @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.
  84957. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84958. */
  84959. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84960. /**
  84961. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84962. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84963. * The `data` are either a numeric array either a Float32Array.
  84964. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84965. * 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).
  84966. * Note that a new underlying VertexBuffer object is created each call.
  84967. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84968. *
  84969. * Possible `kind` values :
  84970. * - VertexBuffer.PositionKind
  84971. * - VertexBuffer.UVKind
  84972. * - VertexBuffer.UV2Kind
  84973. * - VertexBuffer.UV3Kind
  84974. * - VertexBuffer.UV4Kind
  84975. * - VertexBuffer.UV5Kind
  84976. * - VertexBuffer.UV6Kind
  84977. * - VertexBuffer.ColorKind
  84978. * - VertexBuffer.MatricesIndicesKind
  84979. * - VertexBuffer.MatricesIndicesExtraKind
  84980. * - VertexBuffer.MatricesWeightsKind
  84981. * - VertexBuffer.MatricesWeightsExtraKind
  84982. *
  84983. * Returns the Mesh.
  84984. */
  84985. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84986. /**
  84987. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84988. * If the mesh has no geometry, it is simply returned as it is.
  84989. * The `data` are either a numeric array either a Float32Array.
  84990. * No new underlying VertexBuffer object is created.
  84991. * 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.
  84992. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84993. *
  84994. * Possible `kind` values :
  84995. * - VertexBuffer.PositionKind
  84996. * - VertexBuffer.UVKind
  84997. * - VertexBuffer.UV2Kind
  84998. * - VertexBuffer.UV3Kind
  84999. * - VertexBuffer.UV4Kind
  85000. * - VertexBuffer.UV5Kind
  85001. * - VertexBuffer.UV6Kind
  85002. * - VertexBuffer.ColorKind
  85003. * - VertexBuffer.MatricesIndicesKind
  85004. * - VertexBuffer.MatricesIndicesExtraKind
  85005. * - VertexBuffer.MatricesWeightsKind
  85006. * - VertexBuffer.MatricesWeightsExtraKind
  85007. *
  85008. * Returns the Mesh.
  85009. */
  85010. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85011. /**
  85012. * Sets the mesh indices.
  85013. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85014. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85015. * This method creates a new index buffer each call.
  85016. * Returns the Mesh.
  85017. */
  85018. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85019. /**
  85020. * Boolean : True if the mesh owns the requested kind of data.
  85021. */
  85022. isVerticesDataPresent(kind: string): boolean;
  85023. /**
  85024. * Returns an array of indices (IndicesArray).
  85025. */
  85026. getIndices(): Nullable<IndicesArray>;
  85027. readonly _positions: Nullable<Vector3[]>;
  85028. /**
  85029. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85030. * This means the mesh underlying bounding box and sphere are recomputed.
  85031. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85032. * @returns the current mesh
  85033. */
  85034. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85035. /** @hidden */
  85036. _preActivate(): InstancedMesh;
  85037. /** @hidden */
  85038. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85039. /** @hidden */
  85040. _postActivate(): void;
  85041. getWorldMatrix(): Matrix;
  85042. readonly isAnInstance: boolean;
  85043. /**
  85044. * Returns the current associated LOD AbstractMesh.
  85045. */
  85046. getLOD(camera: Camera): AbstractMesh;
  85047. /** @hidden */
  85048. _syncSubMeshes(): InstancedMesh;
  85049. /** @hidden */
  85050. _generatePointsArray(): boolean;
  85051. /**
  85052. * Creates a new InstancedMesh from the current mesh.
  85053. * - name (string) : the cloned mesh name
  85054. * - newParent (optional Node) : the optional Node to parent the clone to.
  85055. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85056. *
  85057. * Returns the clone.
  85058. */
  85059. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85060. /**
  85061. * Disposes the InstancedMesh.
  85062. * Returns nothing.
  85063. */
  85064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85065. }
  85066. }
  85067. declare module BABYLON {
  85068. /**
  85069. * Defines the options associated with the creation of a shader material.
  85070. */
  85071. export interface IShaderMaterialOptions {
  85072. /**
  85073. * Does the material work in alpha blend mode
  85074. */
  85075. needAlphaBlending: boolean;
  85076. /**
  85077. * Does the material work in alpha test mode
  85078. */
  85079. needAlphaTesting: boolean;
  85080. /**
  85081. * The list of attribute names used in the shader
  85082. */
  85083. attributes: string[];
  85084. /**
  85085. * The list of unifrom names used in the shader
  85086. */
  85087. uniforms: string[];
  85088. /**
  85089. * The list of UBO names used in the shader
  85090. */
  85091. uniformBuffers: string[];
  85092. /**
  85093. * The list of sampler names used in the shader
  85094. */
  85095. samplers: string[];
  85096. /**
  85097. * The list of defines used in the shader
  85098. */
  85099. defines: string[];
  85100. }
  85101. /**
  85102. * 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.
  85103. *
  85104. * This returned material effects how the mesh will look based on the code in the shaders.
  85105. *
  85106. * @see http://doc.babylonjs.com/how_to/shader_material
  85107. */
  85108. export class ShaderMaterial extends Material {
  85109. private _shaderPath;
  85110. private _options;
  85111. private _textures;
  85112. private _textureArrays;
  85113. private _floats;
  85114. private _ints;
  85115. private _floatsArrays;
  85116. private _colors3;
  85117. private _colors3Arrays;
  85118. private _colors4;
  85119. private _colors4Arrays;
  85120. private _vectors2;
  85121. private _vectors3;
  85122. private _vectors4;
  85123. private _matrices;
  85124. private _matrices3x3;
  85125. private _matrices2x2;
  85126. private _vectors2Arrays;
  85127. private _vectors3Arrays;
  85128. private _vectors4Arrays;
  85129. private _cachedWorldViewMatrix;
  85130. private _cachedWorldViewProjectionMatrix;
  85131. private _renderId;
  85132. /**
  85133. * Instantiate a new shader material.
  85134. * 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.
  85135. * This returned material effects how the mesh will look based on the code in the shaders.
  85136. * @see http://doc.babylonjs.com/how_to/shader_material
  85137. * @param name Define the name of the material in the scene
  85138. * @param scene Define the scene the material belongs to
  85139. * @param shaderPath Defines the route to the shader code in one of three ways:
  85140. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85141. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85142. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85143. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85144. * @param options Define the options used to create the shader
  85145. */
  85146. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85147. /**
  85148. * Gets the options used to compile the shader.
  85149. * They can be modified to trigger a new compilation
  85150. */
  85151. readonly options: IShaderMaterialOptions;
  85152. /**
  85153. * Gets the current class name of the material e.g. "ShaderMaterial"
  85154. * Mainly use in serialization.
  85155. * @returns the class name
  85156. */
  85157. getClassName(): string;
  85158. /**
  85159. * Specifies if the material will require alpha blending
  85160. * @returns a boolean specifying if alpha blending is needed
  85161. */
  85162. needAlphaBlending(): boolean;
  85163. /**
  85164. * Specifies if this material should be rendered in alpha test mode
  85165. * @returns a boolean specifying if an alpha test is needed.
  85166. */
  85167. needAlphaTesting(): boolean;
  85168. private _checkUniform;
  85169. /**
  85170. * Set a texture in the shader.
  85171. * @param name Define the name of the uniform samplers as defined in the shader
  85172. * @param texture Define the texture to bind to this sampler
  85173. * @return the material itself allowing "fluent" like uniform updates
  85174. */
  85175. setTexture(name: string, texture: Texture): ShaderMaterial;
  85176. /**
  85177. * Set a texture array in the shader.
  85178. * @param name Define the name of the uniform sampler array as defined in the shader
  85179. * @param textures Define the list of textures to bind to this sampler
  85180. * @return the material itself allowing "fluent" like uniform updates
  85181. */
  85182. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85183. /**
  85184. * Set a float in the shader.
  85185. * @param name Define the name of the uniform as defined in the shader
  85186. * @param value Define the value to give to the uniform
  85187. * @return the material itself allowing "fluent" like uniform updates
  85188. */
  85189. setFloat(name: string, value: number): ShaderMaterial;
  85190. /**
  85191. * Set a int in the shader.
  85192. * @param name Define the name of the uniform as defined in the shader
  85193. * @param value Define the value to give to the uniform
  85194. * @return the material itself allowing "fluent" like uniform updates
  85195. */
  85196. setInt(name: string, value: number): ShaderMaterial;
  85197. /**
  85198. * Set an array of floats in the shader.
  85199. * @param name Define the name of the uniform as defined in the shader
  85200. * @param value Define the value to give to the uniform
  85201. * @return the material itself allowing "fluent" like uniform updates
  85202. */
  85203. setFloats(name: string, value: number[]): ShaderMaterial;
  85204. /**
  85205. * Set a vec3 in the shader from a Color3.
  85206. * @param name Define the name of the uniform as defined in the shader
  85207. * @param value Define the value to give to the uniform
  85208. * @return the material itself allowing "fluent" like uniform updates
  85209. */
  85210. setColor3(name: string, value: Color3): ShaderMaterial;
  85211. /**
  85212. * Set a vec3 array in the shader from a Color3 array.
  85213. * @param name Define the name of the uniform as defined in the shader
  85214. * @param value Define the value to give to the uniform
  85215. * @return the material itself allowing "fluent" like uniform updates
  85216. */
  85217. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85218. /**
  85219. * Set a vec4 in the shader from a Color4.
  85220. * @param name Define the name of the uniform as defined in the shader
  85221. * @param value Define the value to give to the uniform
  85222. * @return the material itself allowing "fluent" like uniform updates
  85223. */
  85224. setColor4(name: string, value: Color4): ShaderMaterial;
  85225. /**
  85226. * Set a vec4 array in the shader from a Color4 array.
  85227. * @param name Define the name of the uniform as defined in the shader
  85228. * @param value Define the value to give to the uniform
  85229. * @return the material itself allowing "fluent" like uniform updates
  85230. */
  85231. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85232. /**
  85233. * Set a vec2 in the shader from a Vector2.
  85234. * @param name Define the name of the uniform as defined in the shader
  85235. * @param value Define the value to give to the uniform
  85236. * @return the material itself allowing "fluent" like uniform updates
  85237. */
  85238. setVector2(name: string, value: Vector2): ShaderMaterial;
  85239. /**
  85240. * Set a vec3 in the shader from a Vector3.
  85241. * @param name Define the name of the uniform as defined in the shader
  85242. * @param value Define the value to give to the uniform
  85243. * @return the material itself allowing "fluent" like uniform updates
  85244. */
  85245. setVector3(name: string, value: Vector3): ShaderMaterial;
  85246. /**
  85247. * Set a vec4 in the shader from a Vector4.
  85248. * @param name Define the name of the uniform as defined in the shader
  85249. * @param value Define the value to give to the uniform
  85250. * @return the material itself allowing "fluent" like uniform updates
  85251. */
  85252. setVector4(name: string, value: Vector4): ShaderMaterial;
  85253. /**
  85254. * Set a mat4 in the shader from a Matrix.
  85255. * @param name Define the name of the uniform as defined in the shader
  85256. * @param value Define the value to give to the uniform
  85257. * @return the material itself allowing "fluent" like uniform updates
  85258. */
  85259. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85260. /**
  85261. * Set a mat3 in the shader from a Float32Array.
  85262. * @param name Define the name of the uniform as defined in the shader
  85263. * @param value Define the value to give to the uniform
  85264. * @return the material itself allowing "fluent" like uniform updates
  85265. */
  85266. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85267. /**
  85268. * Set a mat2 in the shader from a Float32Array.
  85269. * @param name Define the name of the uniform as defined in the shader
  85270. * @param value Define the value to give to the uniform
  85271. * @return the material itself allowing "fluent" like uniform updates
  85272. */
  85273. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85274. /**
  85275. * Set a vec2 array in the shader from a number array.
  85276. * @param name Define the name of the uniform as defined in the shader
  85277. * @param value Define the value to give to the uniform
  85278. * @return the material itself allowing "fluent" like uniform updates
  85279. */
  85280. setArray2(name: string, value: number[]): ShaderMaterial;
  85281. /**
  85282. * Set a vec3 array in the shader from a number array.
  85283. * @param name Define the name of the uniform as defined in the shader
  85284. * @param value Define the value to give to the uniform
  85285. * @return the material itself allowing "fluent" like uniform updates
  85286. */
  85287. setArray3(name: string, value: number[]): ShaderMaterial;
  85288. /**
  85289. * Set a vec4 array in the shader from a number array.
  85290. * @param name Define the name of the uniform as defined in the shader
  85291. * @param value Define the value to give to the uniform
  85292. * @return the material itself allowing "fluent" like uniform updates
  85293. */
  85294. setArray4(name: string, value: number[]): ShaderMaterial;
  85295. private _checkCache;
  85296. /**
  85297. * Specifies that the submesh is ready to be used
  85298. * @param mesh defines the mesh to check
  85299. * @param subMesh defines which submesh to check
  85300. * @param useInstances specifies that instances should be used
  85301. * @returns a boolean indicating that the submesh is ready or not
  85302. */
  85303. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85304. /**
  85305. * Checks if the material is ready to render the requested mesh
  85306. * @param mesh Define the mesh to render
  85307. * @param useInstances Define whether or not the material is used with instances
  85308. * @returns true if ready, otherwise false
  85309. */
  85310. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85311. /**
  85312. * Binds the world matrix to the material
  85313. * @param world defines the world transformation matrix
  85314. */
  85315. bindOnlyWorldMatrix(world: Matrix): void;
  85316. /**
  85317. * Binds the material to the mesh
  85318. * @param world defines the world transformation matrix
  85319. * @param mesh defines the mesh to bind the material to
  85320. */
  85321. bind(world: Matrix, mesh?: Mesh): void;
  85322. /**
  85323. * Gets the active textures from the material
  85324. * @returns an array of textures
  85325. */
  85326. getActiveTextures(): BaseTexture[];
  85327. /**
  85328. * Specifies if the material uses a texture
  85329. * @param texture defines the texture to check against the material
  85330. * @returns a boolean specifying if the material uses the texture
  85331. */
  85332. hasTexture(texture: BaseTexture): boolean;
  85333. /**
  85334. * Makes a duplicate of the material, and gives it a new name
  85335. * @param name defines the new name for the duplicated material
  85336. * @returns the cloned material
  85337. */
  85338. clone(name: string): ShaderMaterial;
  85339. /**
  85340. * Disposes the material
  85341. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85342. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85343. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85344. */
  85345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85346. /**
  85347. * Serializes this material in a JSON representation
  85348. * @returns the serialized material object
  85349. */
  85350. serialize(): any;
  85351. /**
  85352. * Creates a shader material from parsed shader material data
  85353. * @param source defines the JSON represnetation of the material
  85354. * @param scene defines the hosting scene
  85355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85356. * @returns a new material
  85357. */
  85358. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85359. }
  85360. }
  85361. declare module BABYLON {
  85362. /** @hidden */
  85363. export var colorPixelShader: {
  85364. name: string;
  85365. shader: string;
  85366. };
  85367. }
  85368. declare module BABYLON {
  85369. /** @hidden */
  85370. export var colorVertexShader: {
  85371. name: string;
  85372. shader: string;
  85373. };
  85374. }
  85375. declare module BABYLON {
  85376. /**
  85377. * Line mesh
  85378. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85379. */
  85380. export class LinesMesh extends Mesh {
  85381. /**
  85382. * If vertex color should be applied to the mesh
  85383. */
  85384. readonly useVertexColor?: boolean | undefined;
  85385. /**
  85386. * If vertex alpha should be applied to the mesh
  85387. */
  85388. readonly useVertexAlpha?: boolean | undefined;
  85389. /**
  85390. * Color of the line (Default: White)
  85391. */
  85392. color: Color3;
  85393. /**
  85394. * Alpha of the line (Default: 1)
  85395. */
  85396. alpha: number;
  85397. /**
  85398. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85399. * This margin is expressed in world space coordinates, so its value may vary.
  85400. * Default value is 0.1
  85401. */
  85402. intersectionThreshold: number;
  85403. private _colorShader;
  85404. private color4;
  85405. /**
  85406. * Creates a new LinesMesh
  85407. * @param name defines the name
  85408. * @param scene defines the hosting scene
  85409. * @param parent defines the parent mesh if any
  85410. * @param source defines the optional source LinesMesh used to clone data from
  85411. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85412. * When false, achieved by calling a clone(), also passing False.
  85413. * This will make creation of children, recursive.
  85414. * @param useVertexColor defines if this LinesMesh supports vertex color
  85415. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85416. */
  85417. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85418. /**
  85419. * If vertex color should be applied to the mesh
  85420. */
  85421. useVertexColor?: boolean | undefined,
  85422. /**
  85423. * If vertex alpha should be applied to the mesh
  85424. */
  85425. useVertexAlpha?: boolean | undefined);
  85426. private _addClipPlaneDefine;
  85427. private _removeClipPlaneDefine;
  85428. isReady(): boolean;
  85429. /**
  85430. * Returns the string "LineMesh"
  85431. */
  85432. getClassName(): string;
  85433. /**
  85434. * @hidden
  85435. */
  85436. /**
  85437. * @hidden
  85438. */
  85439. material: Material;
  85440. /**
  85441. * @hidden
  85442. */
  85443. readonly checkCollisions: boolean;
  85444. /** @hidden */
  85445. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85446. /** @hidden */
  85447. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85448. /**
  85449. * Disposes of the line mesh
  85450. * @param doNotRecurse If children should be disposed
  85451. */
  85452. dispose(doNotRecurse?: boolean): void;
  85453. /**
  85454. * Returns a new LineMesh object cloned from the current one.
  85455. */
  85456. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85457. /**
  85458. * Creates a new InstancedLinesMesh object from the mesh model.
  85459. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85460. * @param name defines the name of the new instance
  85461. * @returns a new InstancedLinesMesh
  85462. */
  85463. createInstance(name: string): InstancedLinesMesh;
  85464. }
  85465. /**
  85466. * Creates an instance based on a source LinesMesh
  85467. */
  85468. export class InstancedLinesMesh extends InstancedMesh {
  85469. /**
  85470. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85471. * This margin is expressed in world space coordinates, so its value may vary.
  85472. * Initilized with the intersectionThreshold value of the source LinesMesh
  85473. */
  85474. intersectionThreshold: number;
  85475. constructor(name: string, source: LinesMesh);
  85476. /**
  85477. * Returns the string "InstancedLinesMesh".
  85478. */
  85479. getClassName(): string;
  85480. }
  85481. }
  85482. declare module BABYLON {
  85483. /** @hidden */
  85484. export var linePixelShader: {
  85485. name: string;
  85486. shader: string;
  85487. };
  85488. }
  85489. declare module BABYLON {
  85490. /** @hidden */
  85491. export var lineVertexShader: {
  85492. name: string;
  85493. shader: string;
  85494. };
  85495. }
  85496. declare module BABYLON {
  85497. interface AbstractMesh {
  85498. /**
  85499. * Gets the edgesRenderer associated with the mesh
  85500. */
  85501. edgesRenderer: Nullable<EdgesRenderer>;
  85502. }
  85503. interface LinesMesh {
  85504. /**
  85505. * Enables the edge rendering mode on the mesh.
  85506. * This mode makes the mesh edges visible
  85507. * @param epsilon defines the maximal distance between two angles to detect a face
  85508. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85509. * @returns the currentAbstractMesh
  85510. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85511. */
  85512. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85513. }
  85514. interface InstancedLinesMesh {
  85515. /**
  85516. * Enables the edge rendering mode on the mesh.
  85517. * This mode makes the mesh edges visible
  85518. * @param epsilon defines the maximal distance between two angles to detect a face
  85519. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85520. * @returns the current InstancedLinesMesh
  85521. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85522. */
  85523. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85524. }
  85525. /**
  85526. * Defines the minimum contract an Edges renderer should follow.
  85527. */
  85528. export interface IEdgesRenderer extends IDisposable {
  85529. /**
  85530. * Gets or sets a boolean indicating if the edgesRenderer is active
  85531. */
  85532. isEnabled: boolean;
  85533. /**
  85534. * Renders the edges of the attached mesh,
  85535. */
  85536. render(): void;
  85537. /**
  85538. * Checks wether or not the edges renderer is ready to render.
  85539. * @return true if ready, otherwise false.
  85540. */
  85541. isReady(): boolean;
  85542. }
  85543. /**
  85544. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85545. */
  85546. export class EdgesRenderer implements IEdgesRenderer {
  85547. /**
  85548. * Define the size of the edges with an orthographic camera
  85549. */
  85550. edgesWidthScalerForOrthographic: number;
  85551. /**
  85552. * Define the size of the edges with a perspective camera
  85553. */
  85554. edgesWidthScalerForPerspective: number;
  85555. protected _source: AbstractMesh;
  85556. protected _linesPositions: number[];
  85557. protected _linesNormals: number[];
  85558. protected _linesIndices: number[];
  85559. protected _epsilon: number;
  85560. protected _indicesCount: number;
  85561. protected _lineShader: ShaderMaterial;
  85562. protected _ib: DataBuffer;
  85563. protected _buffers: {
  85564. [key: string]: Nullable<VertexBuffer>;
  85565. };
  85566. protected _checkVerticesInsteadOfIndices: boolean;
  85567. private _meshRebuildObserver;
  85568. private _meshDisposeObserver;
  85569. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85570. isEnabled: boolean;
  85571. /**
  85572. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85573. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85574. * @param source Mesh used to create edges
  85575. * @param epsilon sum of angles in adjacency to check for edge
  85576. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85577. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85578. */
  85579. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85580. protected _prepareRessources(): void;
  85581. /** @hidden */
  85582. _rebuild(): void;
  85583. /**
  85584. * Releases the required resources for the edges renderer
  85585. */
  85586. dispose(): void;
  85587. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85588. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85589. /**
  85590. * Checks if the pair of p0 and p1 is en edge
  85591. * @param faceIndex
  85592. * @param edge
  85593. * @param faceNormals
  85594. * @param p0
  85595. * @param p1
  85596. * @private
  85597. */
  85598. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85599. /**
  85600. * push line into the position, normal and index buffer
  85601. * @protected
  85602. */
  85603. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85604. /**
  85605. * Generates lines edges from adjacencjes
  85606. * @private
  85607. */
  85608. _generateEdgesLines(): void;
  85609. /**
  85610. * Checks wether or not the edges renderer is ready to render.
  85611. * @return true if ready, otherwise false.
  85612. */
  85613. isReady(): boolean;
  85614. /**
  85615. * Renders the edges of the attached mesh,
  85616. */
  85617. render(): void;
  85618. }
  85619. /**
  85620. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85621. */
  85622. export class LineEdgesRenderer extends EdgesRenderer {
  85623. /**
  85624. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85625. * @param source LineMesh used to generate edges
  85626. * @param epsilon not important (specified angle for edge detection)
  85627. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85628. */
  85629. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85630. /**
  85631. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85632. */
  85633. _generateEdgesLines(): void;
  85634. }
  85635. }
  85636. declare module BABYLON {
  85637. /**
  85638. * This represents the object necessary to create a rendering group.
  85639. * This is exclusively used and created by the rendering manager.
  85640. * To modify the behavior, you use the available helpers in your scene or meshes.
  85641. * @hidden
  85642. */
  85643. export class RenderingGroup {
  85644. index: number;
  85645. private static _zeroVector;
  85646. private _scene;
  85647. private _opaqueSubMeshes;
  85648. private _transparentSubMeshes;
  85649. private _alphaTestSubMeshes;
  85650. private _depthOnlySubMeshes;
  85651. private _particleSystems;
  85652. private _spriteManagers;
  85653. private _opaqueSortCompareFn;
  85654. private _alphaTestSortCompareFn;
  85655. private _transparentSortCompareFn;
  85656. private _renderOpaque;
  85657. private _renderAlphaTest;
  85658. private _renderTransparent;
  85659. /** @hidden */
  85660. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85661. onBeforeTransparentRendering: () => void;
  85662. /**
  85663. * Set the opaque sort comparison function.
  85664. * If null the sub meshes will be render in the order they were created
  85665. */
  85666. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85667. /**
  85668. * Set the alpha test sort comparison function.
  85669. * If null the sub meshes will be render in the order they were created
  85670. */
  85671. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85672. /**
  85673. * Set the transparent sort comparison function.
  85674. * If null the sub meshes will be render in the order they were created
  85675. */
  85676. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85677. /**
  85678. * Creates a new rendering group.
  85679. * @param index The rendering group index
  85680. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85681. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85682. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85683. */
  85684. 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>);
  85685. /**
  85686. * Render all the sub meshes contained in the group.
  85687. * @param customRenderFunction Used to override the default render behaviour of the group.
  85688. * @returns true if rendered some submeshes.
  85689. */
  85690. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85691. /**
  85692. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85693. * @param subMeshes The submeshes to render
  85694. */
  85695. private renderOpaqueSorted;
  85696. /**
  85697. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85698. * @param subMeshes The submeshes to render
  85699. */
  85700. private renderAlphaTestSorted;
  85701. /**
  85702. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85703. * @param subMeshes The submeshes to render
  85704. */
  85705. private renderTransparentSorted;
  85706. /**
  85707. * Renders the submeshes in a specified order.
  85708. * @param subMeshes The submeshes to sort before render
  85709. * @param sortCompareFn The comparison function use to sort
  85710. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85711. * @param transparent Specifies to activate blending if true
  85712. */
  85713. private static renderSorted;
  85714. /**
  85715. * Renders the submeshes in the order they were dispatched (no sort applied).
  85716. * @param subMeshes The submeshes to render
  85717. */
  85718. private static renderUnsorted;
  85719. /**
  85720. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85721. * are rendered back to front if in the same alpha index.
  85722. *
  85723. * @param a The first submesh
  85724. * @param b The second submesh
  85725. * @returns The result of the comparison
  85726. */
  85727. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85728. /**
  85729. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85730. * are rendered back to front.
  85731. *
  85732. * @param a The first submesh
  85733. * @param b The second submesh
  85734. * @returns The result of the comparison
  85735. */
  85736. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85737. /**
  85738. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85739. * are rendered front to back (prevent overdraw).
  85740. *
  85741. * @param a The first submesh
  85742. * @param b The second submesh
  85743. * @returns The result of the comparison
  85744. */
  85745. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85746. /**
  85747. * Resets the different lists of submeshes to prepare a new frame.
  85748. */
  85749. prepare(): void;
  85750. dispose(): void;
  85751. /**
  85752. * Inserts the submesh in its correct queue depending on its material.
  85753. * @param subMesh The submesh to dispatch
  85754. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85755. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85756. */
  85757. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85758. dispatchSprites(spriteManager: ISpriteManager): void;
  85759. dispatchParticles(particleSystem: IParticleSystem): void;
  85760. private _renderParticles;
  85761. private _renderSprites;
  85762. }
  85763. }
  85764. declare module BABYLON {
  85765. /**
  85766. * Interface describing the different options available in the rendering manager
  85767. * regarding Auto Clear between groups.
  85768. */
  85769. export interface IRenderingManagerAutoClearSetup {
  85770. /**
  85771. * Defines whether or not autoclear is enable.
  85772. */
  85773. autoClear: boolean;
  85774. /**
  85775. * Defines whether or not to autoclear the depth buffer.
  85776. */
  85777. depth: boolean;
  85778. /**
  85779. * Defines whether or not to autoclear the stencil buffer.
  85780. */
  85781. stencil: boolean;
  85782. }
  85783. /**
  85784. * This class is used by the onRenderingGroupObservable
  85785. */
  85786. export class RenderingGroupInfo {
  85787. /**
  85788. * The Scene that being rendered
  85789. */
  85790. scene: Scene;
  85791. /**
  85792. * The camera currently used for the rendering pass
  85793. */
  85794. camera: Nullable<Camera>;
  85795. /**
  85796. * The ID of the renderingGroup being processed
  85797. */
  85798. renderingGroupId: number;
  85799. }
  85800. /**
  85801. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85802. * It is enable to manage the different groups as well as the different necessary sort functions.
  85803. * This should not be used directly aside of the few static configurations
  85804. */
  85805. export class RenderingManager {
  85806. /**
  85807. * The max id used for rendering groups (not included)
  85808. */
  85809. static MAX_RENDERINGGROUPS: number;
  85810. /**
  85811. * The min id used for rendering groups (included)
  85812. */
  85813. static MIN_RENDERINGGROUPS: number;
  85814. /**
  85815. * Used to globally prevent autoclearing scenes.
  85816. */
  85817. static AUTOCLEAR: boolean;
  85818. /**
  85819. * @hidden
  85820. */
  85821. _useSceneAutoClearSetup: boolean;
  85822. private _scene;
  85823. private _renderingGroups;
  85824. private _depthStencilBufferAlreadyCleaned;
  85825. private _autoClearDepthStencil;
  85826. private _customOpaqueSortCompareFn;
  85827. private _customAlphaTestSortCompareFn;
  85828. private _customTransparentSortCompareFn;
  85829. private _renderingGroupInfo;
  85830. /**
  85831. * Instantiates a new rendering group for a particular scene
  85832. * @param scene Defines the scene the groups belongs to
  85833. */
  85834. constructor(scene: Scene);
  85835. private _clearDepthStencilBuffer;
  85836. /**
  85837. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85838. * @hidden
  85839. */
  85840. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85841. /**
  85842. * Resets the different information of the group to prepare a new frame
  85843. * @hidden
  85844. */
  85845. reset(): void;
  85846. /**
  85847. * Dispose and release the group and its associated resources.
  85848. * @hidden
  85849. */
  85850. dispose(): void;
  85851. /**
  85852. * Clear the info related to rendering groups preventing retention points during dispose.
  85853. */
  85854. freeRenderingGroups(): void;
  85855. private _prepareRenderingGroup;
  85856. /**
  85857. * Add a sprite manager to the rendering manager in order to render it this frame.
  85858. * @param spriteManager Define the sprite manager to render
  85859. */
  85860. dispatchSprites(spriteManager: ISpriteManager): void;
  85861. /**
  85862. * Add a particle system to the rendering manager in order to render it this frame.
  85863. * @param particleSystem Define the particle system to render
  85864. */
  85865. dispatchParticles(particleSystem: IParticleSystem): void;
  85866. /**
  85867. * Add a submesh to the manager in order to render it this frame
  85868. * @param subMesh The submesh to dispatch
  85869. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85870. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85871. */
  85872. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85873. /**
  85874. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85875. * This allowed control for front to back rendering or reversly depending of the special needs.
  85876. *
  85877. * @param renderingGroupId The rendering group id corresponding to its index
  85878. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85879. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85880. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85881. */
  85882. 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;
  85883. /**
  85884. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85885. *
  85886. * @param renderingGroupId The rendering group id corresponding to its index
  85887. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85888. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85889. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85890. */
  85891. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85892. /**
  85893. * Gets the current auto clear configuration for one rendering group of the rendering
  85894. * manager.
  85895. * @param index the rendering group index to get the information for
  85896. * @returns The auto clear setup for the requested rendering group
  85897. */
  85898. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85899. }
  85900. }
  85901. declare module BABYLON {
  85902. /**
  85903. * This Helps creating a texture that will be created from a camera in your scene.
  85904. * It is basically a dynamic texture that could be used to create special effects for instance.
  85905. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85906. */
  85907. export class RenderTargetTexture extends Texture {
  85908. isCube: boolean;
  85909. /**
  85910. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85911. */
  85912. static readonly REFRESHRATE_RENDER_ONCE: number;
  85913. /**
  85914. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85915. */
  85916. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85917. /**
  85918. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85919. * the central point of your effect and can save a lot of performances.
  85920. */
  85921. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85922. /**
  85923. * Use this predicate to dynamically define the list of mesh you want to render.
  85924. * If set, the renderList property will be overwritten.
  85925. */
  85926. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85927. private _renderList;
  85928. /**
  85929. * Use this list to define the list of mesh you want to render.
  85930. */
  85931. renderList: Nullable<Array<AbstractMesh>>;
  85932. private _hookArray;
  85933. /**
  85934. * Define if particles should be rendered in your texture.
  85935. */
  85936. renderParticles: boolean;
  85937. /**
  85938. * Define if sprites should be rendered in your texture.
  85939. */
  85940. renderSprites: boolean;
  85941. /**
  85942. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85943. */
  85944. coordinatesMode: number;
  85945. /**
  85946. * Define the camera used to render the texture.
  85947. */
  85948. activeCamera: Nullable<Camera>;
  85949. /**
  85950. * Override the render function of the texture with your own one.
  85951. */
  85952. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85953. /**
  85954. * Define if camera post processes should be use while rendering the texture.
  85955. */
  85956. useCameraPostProcesses: boolean;
  85957. /**
  85958. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85959. */
  85960. ignoreCameraViewport: boolean;
  85961. private _postProcessManager;
  85962. private _postProcesses;
  85963. private _resizeObserver;
  85964. /**
  85965. * An event triggered when the texture is unbind.
  85966. */
  85967. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85968. /**
  85969. * An event triggered when the texture is unbind.
  85970. */
  85971. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85972. private _onAfterUnbindObserver;
  85973. /**
  85974. * Set a after unbind callback in the texture.
  85975. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85976. */
  85977. onAfterUnbind: () => void;
  85978. /**
  85979. * An event triggered before rendering the texture
  85980. */
  85981. onBeforeRenderObservable: Observable<number>;
  85982. private _onBeforeRenderObserver;
  85983. /**
  85984. * Set a before render callback in the texture.
  85985. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85986. */
  85987. onBeforeRender: (faceIndex: number) => void;
  85988. /**
  85989. * An event triggered after rendering the texture
  85990. */
  85991. onAfterRenderObservable: Observable<number>;
  85992. private _onAfterRenderObserver;
  85993. /**
  85994. * Set a after render callback in the texture.
  85995. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85996. */
  85997. onAfterRender: (faceIndex: number) => void;
  85998. /**
  85999. * An event triggered after the texture clear
  86000. */
  86001. onClearObservable: Observable<Engine>;
  86002. private _onClearObserver;
  86003. /**
  86004. * Set a clear callback in the texture.
  86005. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86006. */
  86007. onClear: (Engine: Engine) => void;
  86008. /**
  86009. * An event triggered when the texture is resized.
  86010. */
  86011. onResizeObservable: Observable<RenderTargetTexture>;
  86012. /**
  86013. * Define the clear color of the Render Target if it should be different from the scene.
  86014. */
  86015. clearColor: Color4;
  86016. protected _size: number | {
  86017. width: number;
  86018. height: number;
  86019. };
  86020. protected _initialSizeParameter: number | {
  86021. width: number;
  86022. height: number;
  86023. } | {
  86024. ratio: number;
  86025. };
  86026. protected _sizeRatio: Nullable<number>;
  86027. /** @hidden */
  86028. _generateMipMaps: boolean;
  86029. protected _renderingManager: RenderingManager;
  86030. /** @hidden */
  86031. _waitingRenderList: string[];
  86032. protected _doNotChangeAspectRatio: boolean;
  86033. protected _currentRefreshId: number;
  86034. protected _refreshRate: number;
  86035. protected _textureMatrix: Matrix;
  86036. protected _samples: number;
  86037. protected _renderTargetOptions: RenderTargetCreationOptions;
  86038. /**
  86039. * Gets render target creation options that were used.
  86040. */
  86041. readonly renderTargetOptions: RenderTargetCreationOptions;
  86042. protected _engine: Engine;
  86043. protected _onRatioRescale(): void;
  86044. /**
  86045. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86046. * It must define where the camera used to render the texture is set
  86047. */
  86048. boundingBoxPosition: Vector3;
  86049. private _boundingBoxSize;
  86050. /**
  86051. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86052. * When defined, the cubemap will switch to local mode
  86053. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86054. * @example https://www.babylonjs-playground.com/#RNASML
  86055. */
  86056. boundingBoxSize: Vector3;
  86057. /**
  86058. * In case the RTT has been created with a depth texture, get the associated
  86059. * depth texture.
  86060. * Otherwise, return null.
  86061. */
  86062. depthStencilTexture: Nullable<InternalTexture>;
  86063. /**
  86064. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86065. * or used a shadow, depth texture...
  86066. * @param name The friendly name of the texture
  86067. * @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)
  86068. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86069. * @param generateMipMaps True if mip maps need to be generated after render.
  86070. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86071. * @param type The type of the buffer in the RTT (int, half float, float...)
  86072. * @param isCube True if a cube texture needs to be created
  86073. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86074. * @param generateDepthBuffer True to generate a depth buffer
  86075. * @param generateStencilBuffer True to generate a stencil buffer
  86076. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86077. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86078. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86079. */
  86080. constructor(name: string, size: number | {
  86081. width: number;
  86082. height: number;
  86083. } | {
  86084. ratio: number;
  86085. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86086. /**
  86087. * Creates a depth stencil texture.
  86088. * This is only available in WebGL 2 or with the depth texture extension available.
  86089. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86090. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86091. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86092. */
  86093. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86094. private _processSizeParameter;
  86095. /**
  86096. * Define the number of samples to use in case of MSAA.
  86097. * It defaults to one meaning no MSAA has been enabled.
  86098. */
  86099. samples: number;
  86100. /**
  86101. * Resets the refresh counter of the texture and start bak from scratch.
  86102. * Could be useful to regenerate the texture if it is setup to render only once.
  86103. */
  86104. resetRefreshCounter(): void;
  86105. /**
  86106. * Define the refresh rate of the texture or the rendering frequency.
  86107. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86108. */
  86109. refreshRate: number;
  86110. /**
  86111. * Adds a post process to the render target rendering passes.
  86112. * @param postProcess define the post process to add
  86113. */
  86114. addPostProcess(postProcess: PostProcess): void;
  86115. /**
  86116. * Clear all the post processes attached to the render target
  86117. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86118. */
  86119. clearPostProcesses(dispose?: boolean): void;
  86120. /**
  86121. * Remove one of the post process from the list of attached post processes to the texture
  86122. * @param postProcess define the post process to remove from the list
  86123. */
  86124. removePostProcess(postProcess: PostProcess): void;
  86125. /** @hidden */
  86126. _shouldRender(): boolean;
  86127. /**
  86128. * Gets the actual render size of the texture.
  86129. * @returns the width of the render size
  86130. */
  86131. getRenderSize(): number;
  86132. /**
  86133. * Gets the actual render width of the texture.
  86134. * @returns the width of the render size
  86135. */
  86136. getRenderWidth(): number;
  86137. /**
  86138. * Gets the actual render height of the texture.
  86139. * @returns the height of the render size
  86140. */
  86141. getRenderHeight(): number;
  86142. /**
  86143. * Get if the texture can be rescaled or not.
  86144. */
  86145. readonly canRescale: boolean;
  86146. /**
  86147. * Resize the texture using a ratio.
  86148. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86149. */
  86150. scale(ratio: number): void;
  86151. /**
  86152. * Get the texture reflection matrix used to rotate/transform the reflection.
  86153. * @returns the reflection matrix
  86154. */
  86155. getReflectionTextureMatrix(): Matrix;
  86156. /**
  86157. * Resize the texture to a new desired size.
  86158. * Be carrefull as it will recreate all the data in the new texture.
  86159. * @param size Define the new size. It can be:
  86160. * - a number for squared texture,
  86161. * - an object containing { width: number, height: number }
  86162. * - or an object containing a ratio { ratio: number }
  86163. */
  86164. resize(size: number | {
  86165. width: number;
  86166. height: number;
  86167. } | {
  86168. ratio: number;
  86169. }): void;
  86170. /**
  86171. * Renders all the objects from the render list into the texture.
  86172. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86173. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86174. */
  86175. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86176. private _bestReflectionRenderTargetDimension;
  86177. /**
  86178. * @hidden
  86179. * @param faceIndex face index to bind to if this is a cubetexture
  86180. */
  86181. _bindFrameBuffer(faceIndex?: number): void;
  86182. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86183. private renderToTarget;
  86184. /**
  86185. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86186. * This allowed control for front to back rendering or reversly depending of the special needs.
  86187. *
  86188. * @param renderingGroupId The rendering group id corresponding to its index
  86189. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86190. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86191. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86192. */
  86193. 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;
  86194. /**
  86195. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86196. *
  86197. * @param renderingGroupId The rendering group id corresponding to its index
  86198. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86199. */
  86200. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86201. /**
  86202. * Clones the texture.
  86203. * @returns the cloned texture
  86204. */
  86205. clone(): RenderTargetTexture;
  86206. /**
  86207. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86208. * @returns The JSON representation of the texture
  86209. */
  86210. serialize(): any;
  86211. /**
  86212. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86213. */
  86214. disposeFramebufferObjects(): void;
  86215. /**
  86216. * Dispose the texture and release its associated resources.
  86217. */
  86218. dispose(): void;
  86219. /** @hidden */
  86220. _rebuild(): void;
  86221. /**
  86222. * Clear the info related to rendering groups preventing retention point in material dispose.
  86223. */
  86224. freeRenderingGroups(): void;
  86225. /**
  86226. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86227. * @returns the view count
  86228. */
  86229. getViewCount(): number;
  86230. }
  86231. }
  86232. declare module BABYLON {
  86233. /**
  86234. * Base class for the main features of a material in Babylon.js
  86235. */
  86236. export class Material implements IAnimatable {
  86237. /**
  86238. * Returns the triangle fill mode
  86239. */
  86240. static readonly TriangleFillMode: number;
  86241. /**
  86242. * Returns the wireframe mode
  86243. */
  86244. static readonly WireFrameFillMode: number;
  86245. /**
  86246. * Returns the point fill mode
  86247. */
  86248. static readonly PointFillMode: number;
  86249. /**
  86250. * Returns the point list draw mode
  86251. */
  86252. static readonly PointListDrawMode: number;
  86253. /**
  86254. * Returns the line list draw mode
  86255. */
  86256. static readonly LineListDrawMode: number;
  86257. /**
  86258. * Returns the line loop draw mode
  86259. */
  86260. static readonly LineLoopDrawMode: number;
  86261. /**
  86262. * Returns the line strip draw mode
  86263. */
  86264. static readonly LineStripDrawMode: number;
  86265. /**
  86266. * Returns the triangle strip draw mode
  86267. */
  86268. static readonly TriangleStripDrawMode: number;
  86269. /**
  86270. * Returns the triangle fan draw mode
  86271. */
  86272. static readonly TriangleFanDrawMode: number;
  86273. /**
  86274. * Stores the clock-wise side orientation
  86275. */
  86276. static readonly ClockWiseSideOrientation: number;
  86277. /**
  86278. * Stores the counter clock-wise side orientation
  86279. */
  86280. static readonly CounterClockWiseSideOrientation: number;
  86281. /**
  86282. * The dirty texture flag value
  86283. */
  86284. static readonly TextureDirtyFlag: number;
  86285. /**
  86286. * The dirty light flag value
  86287. */
  86288. static readonly LightDirtyFlag: number;
  86289. /**
  86290. * The dirty fresnel flag value
  86291. */
  86292. static readonly FresnelDirtyFlag: number;
  86293. /**
  86294. * The dirty attribute flag value
  86295. */
  86296. static readonly AttributesDirtyFlag: number;
  86297. /**
  86298. * The dirty misc flag value
  86299. */
  86300. static readonly MiscDirtyFlag: number;
  86301. /**
  86302. * The all dirty flag value
  86303. */
  86304. static readonly AllDirtyFlag: number;
  86305. /**
  86306. * The ID of the material
  86307. */
  86308. id: string;
  86309. /**
  86310. * Gets or sets the unique id of the material
  86311. */
  86312. uniqueId: number;
  86313. /**
  86314. * The name of the material
  86315. */
  86316. name: string;
  86317. /**
  86318. * Gets or sets user defined metadata
  86319. */
  86320. metadata: any;
  86321. /**
  86322. * For internal use only. Please do not use.
  86323. */
  86324. reservedDataStore: any;
  86325. /**
  86326. * Specifies if the ready state should be checked on each call
  86327. */
  86328. checkReadyOnEveryCall: boolean;
  86329. /**
  86330. * Specifies if the ready state should be checked once
  86331. */
  86332. checkReadyOnlyOnce: boolean;
  86333. /**
  86334. * The state of the material
  86335. */
  86336. state: string;
  86337. /**
  86338. * The alpha value of the material
  86339. */
  86340. protected _alpha: number;
  86341. /**
  86342. * List of inspectable custom properties (used by the Inspector)
  86343. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86344. */
  86345. inspectableCustomProperties: IInspectable[];
  86346. /**
  86347. * Sets the alpha value of the material
  86348. */
  86349. /**
  86350. * Gets the alpha value of the material
  86351. */
  86352. alpha: number;
  86353. /**
  86354. * Specifies if back face culling is enabled
  86355. */
  86356. protected _backFaceCulling: boolean;
  86357. /**
  86358. * Sets the back-face culling state
  86359. */
  86360. /**
  86361. * Gets the back-face culling state
  86362. */
  86363. backFaceCulling: boolean;
  86364. /**
  86365. * Stores the value for side orientation
  86366. */
  86367. sideOrientation: number;
  86368. /**
  86369. * Callback triggered when the material is compiled
  86370. */
  86371. onCompiled: Nullable<(effect: Effect) => void>;
  86372. /**
  86373. * Callback triggered when an error occurs
  86374. */
  86375. onError: Nullable<(effect: Effect, errors: string) => void>;
  86376. /**
  86377. * Callback triggered to get the render target textures
  86378. */
  86379. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86380. /**
  86381. * Gets a boolean indicating that current material needs to register RTT
  86382. */
  86383. readonly hasRenderTargetTextures: boolean;
  86384. /**
  86385. * Specifies if the material should be serialized
  86386. */
  86387. doNotSerialize: boolean;
  86388. /**
  86389. * @hidden
  86390. */
  86391. _storeEffectOnSubMeshes: boolean;
  86392. /**
  86393. * Stores the animations for the material
  86394. */
  86395. animations: Nullable<Array<Animation>>;
  86396. /**
  86397. * An event triggered when the material is disposed
  86398. */
  86399. onDisposeObservable: Observable<Material>;
  86400. /**
  86401. * An observer which watches for dispose events
  86402. */
  86403. private _onDisposeObserver;
  86404. private _onUnBindObservable;
  86405. /**
  86406. * Called during a dispose event
  86407. */
  86408. onDispose: () => void;
  86409. private _onBindObservable;
  86410. /**
  86411. * An event triggered when the material is bound
  86412. */
  86413. readonly onBindObservable: Observable<AbstractMesh>;
  86414. /**
  86415. * An observer which watches for bind events
  86416. */
  86417. private _onBindObserver;
  86418. /**
  86419. * Called during a bind event
  86420. */
  86421. onBind: (Mesh: AbstractMesh) => void;
  86422. /**
  86423. * An event triggered when the material is unbound
  86424. */
  86425. readonly onUnBindObservable: Observable<Material>;
  86426. /**
  86427. * Stores the value of the alpha mode
  86428. */
  86429. private _alphaMode;
  86430. /**
  86431. * Sets the value of the alpha mode.
  86432. *
  86433. * | Value | Type | Description |
  86434. * | --- | --- | --- |
  86435. * | 0 | ALPHA_DISABLE | |
  86436. * | 1 | ALPHA_ADD | |
  86437. * | 2 | ALPHA_COMBINE | |
  86438. * | 3 | ALPHA_SUBTRACT | |
  86439. * | 4 | ALPHA_MULTIPLY | |
  86440. * | 5 | ALPHA_MAXIMIZED | |
  86441. * | 6 | ALPHA_ONEONE | |
  86442. * | 7 | ALPHA_PREMULTIPLIED | |
  86443. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86444. * | 9 | ALPHA_INTERPOLATE | |
  86445. * | 10 | ALPHA_SCREENMODE | |
  86446. *
  86447. */
  86448. /**
  86449. * Gets the value of the alpha mode
  86450. */
  86451. alphaMode: number;
  86452. /**
  86453. * Stores the state of the need depth pre-pass value
  86454. */
  86455. private _needDepthPrePass;
  86456. /**
  86457. * Sets the need depth pre-pass value
  86458. */
  86459. /**
  86460. * Gets the depth pre-pass value
  86461. */
  86462. needDepthPrePass: boolean;
  86463. /**
  86464. * Specifies if depth writing should be disabled
  86465. */
  86466. disableDepthWrite: boolean;
  86467. /**
  86468. * Specifies if depth writing should be forced
  86469. */
  86470. forceDepthWrite: boolean;
  86471. /**
  86472. * Specifies if there should be a separate pass for culling
  86473. */
  86474. separateCullingPass: boolean;
  86475. /**
  86476. * Stores the state specifing if fog should be enabled
  86477. */
  86478. private _fogEnabled;
  86479. /**
  86480. * Sets the state for enabling fog
  86481. */
  86482. /**
  86483. * Gets the value of the fog enabled state
  86484. */
  86485. fogEnabled: boolean;
  86486. /**
  86487. * Stores the size of points
  86488. */
  86489. pointSize: number;
  86490. /**
  86491. * Stores the z offset value
  86492. */
  86493. zOffset: number;
  86494. /**
  86495. * Gets a value specifying if wireframe mode is enabled
  86496. */
  86497. /**
  86498. * Sets the state of wireframe mode
  86499. */
  86500. wireframe: boolean;
  86501. /**
  86502. * Gets the value specifying if point clouds are enabled
  86503. */
  86504. /**
  86505. * Sets the state of point cloud mode
  86506. */
  86507. pointsCloud: boolean;
  86508. /**
  86509. * Gets the material fill mode
  86510. */
  86511. /**
  86512. * Sets the material fill mode
  86513. */
  86514. fillMode: number;
  86515. /**
  86516. * @hidden
  86517. * Stores the effects for the material
  86518. */
  86519. _effect: Nullable<Effect>;
  86520. /**
  86521. * @hidden
  86522. * Specifies if the material was previously ready
  86523. */
  86524. _wasPreviouslyReady: boolean;
  86525. /**
  86526. * Specifies if uniform buffers should be used
  86527. */
  86528. private _useUBO;
  86529. /**
  86530. * Stores a reference to the scene
  86531. */
  86532. private _scene;
  86533. /**
  86534. * Stores the fill mode state
  86535. */
  86536. private _fillMode;
  86537. /**
  86538. * Specifies if the depth write state should be cached
  86539. */
  86540. private _cachedDepthWriteState;
  86541. /**
  86542. * Stores the uniform buffer
  86543. */
  86544. protected _uniformBuffer: UniformBuffer;
  86545. /** @hidden */
  86546. _indexInSceneMaterialArray: number;
  86547. /** @hidden */
  86548. meshMap: Nullable<{
  86549. [id: string]: AbstractMesh | undefined;
  86550. }>;
  86551. /**
  86552. * Creates a material instance
  86553. * @param name defines the name of the material
  86554. * @param scene defines the scene to reference
  86555. * @param doNotAdd specifies if the material should be added to the scene
  86556. */
  86557. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86558. /**
  86559. * Returns a string representation of the current material
  86560. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86561. * @returns a string with material information
  86562. */
  86563. toString(fullDetails?: boolean): string;
  86564. /**
  86565. * Gets the class name of the material
  86566. * @returns a string with the class name of the material
  86567. */
  86568. getClassName(): string;
  86569. /**
  86570. * Specifies if updates for the material been locked
  86571. */
  86572. readonly isFrozen: boolean;
  86573. /**
  86574. * Locks updates for the material
  86575. */
  86576. freeze(): void;
  86577. /**
  86578. * Unlocks updates for the material
  86579. */
  86580. unfreeze(): void;
  86581. /**
  86582. * Specifies if the material is ready to be used
  86583. * @param mesh defines the mesh to check
  86584. * @param useInstances specifies if instances should be used
  86585. * @returns a boolean indicating if the material is ready to be used
  86586. */
  86587. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86588. /**
  86589. * Specifies that the submesh is ready to be used
  86590. * @param mesh defines the mesh to check
  86591. * @param subMesh defines which submesh to check
  86592. * @param useInstances specifies that instances should be used
  86593. * @returns a boolean indicating that the submesh is ready or not
  86594. */
  86595. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86596. /**
  86597. * Returns the material effect
  86598. * @returns the effect associated with the material
  86599. */
  86600. getEffect(): Nullable<Effect>;
  86601. /**
  86602. * Returns the current scene
  86603. * @returns a Scene
  86604. */
  86605. getScene(): Scene;
  86606. /**
  86607. * Specifies if the material will require alpha blending
  86608. * @returns a boolean specifying if alpha blending is needed
  86609. */
  86610. needAlphaBlending(): boolean;
  86611. /**
  86612. * Specifies if the mesh will require alpha blending
  86613. * @param mesh defines the mesh to check
  86614. * @returns a boolean specifying if alpha blending is needed for the mesh
  86615. */
  86616. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86617. /**
  86618. * Specifies if this material should be rendered in alpha test mode
  86619. * @returns a boolean specifying if an alpha test is needed.
  86620. */
  86621. needAlphaTesting(): boolean;
  86622. /**
  86623. * Gets the texture used for the alpha test
  86624. * @returns the texture to use for alpha testing
  86625. */
  86626. getAlphaTestTexture(): Nullable<BaseTexture>;
  86627. /**
  86628. * Marks the material to indicate that it needs to be re-calculated
  86629. */
  86630. markDirty(): void;
  86631. /** @hidden */
  86632. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86633. /**
  86634. * Binds the material to the mesh
  86635. * @param world defines the world transformation matrix
  86636. * @param mesh defines the mesh to bind the material to
  86637. */
  86638. bind(world: Matrix, mesh?: Mesh): void;
  86639. /**
  86640. * Binds the submesh to the material
  86641. * @param world defines the world transformation matrix
  86642. * @param mesh defines the mesh containing the submesh
  86643. * @param subMesh defines the submesh to bind the material to
  86644. */
  86645. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86646. /**
  86647. * Binds the world matrix to the material
  86648. * @param world defines the world transformation matrix
  86649. */
  86650. bindOnlyWorldMatrix(world: Matrix): void;
  86651. /**
  86652. * Binds the scene's uniform buffer to the effect.
  86653. * @param effect defines the effect to bind to the scene uniform buffer
  86654. * @param sceneUbo defines the uniform buffer storing scene data
  86655. */
  86656. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86657. /**
  86658. * Binds the view matrix to the effect
  86659. * @param effect defines the effect to bind the view matrix to
  86660. */
  86661. bindView(effect: Effect): void;
  86662. /**
  86663. * Binds the view projection matrix to the effect
  86664. * @param effect defines the effect to bind the view projection matrix to
  86665. */
  86666. bindViewProjection(effect: Effect): void;
  86667. /**
  86668. * Specifies if material alpha testing should be turned on for the mesh
  86669. * @param mesh defines the mesh to check
  86670. */
  86671. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86672. /**
  86673. * Processes to execute after binding the material to a mesh
  86674. * @param mesh defines the rendered mesh
  86675. */
  86676. protected _afterBind(mesh?: Mesh): void;
  86677. /**
  86678. * Unbinds the material from the mesh
  86679. */
  86680. unbind(): void;
  86681. /**
  86682. * Gets the active textures from the material
  86683. * @returns an array of textures
  86684. */
  86685. getActiveTextures(): BaseTexture[];
  86686. /**
  86687. * Specifies if the material uses a texture
  86688. * @param texture defines the texture to check against the material
  86689. * @returns a boolean specifying if the material uses the texture
  86690. */
  86691. hasTexture(texture: BaseTexture): boolean;
  86692. /**
  86693. * Makes a duplicate of the material, and gives it a new name
  86694. * @param name defines the new name for the duplicated material
  86695. * @returns the cloned material
  86696. */
  86697. clone(name: string): Nullable<Material>;
  86698. /**
  86699. * Gets the meshes bound to the material
  86700. * @returns an array of meshes bound to the material
  86701. */
  86702. getBindedMeshes(): AbstractMesh[];
  86703. /**
  86704. * Force shader compilation
  86705. * @param mesh defines the mesh associated with this material
  86706. * @param onCompiled defines a function to execute once the material is compiled
  86707. * @param options defines the options to configure the compilation
  86708. */
  86709. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86710. clipPlane: boolean;
  86711. }>): void;
  86712. /**
  86713. * Force shader compilation
  86714. * @param mesh defines the mesh that will use this material
  86715. * @param options defines additional options for compiling the shaders
  86716. * @returns a promise that resolves when the compilation completes
  86717. */
  86718. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86719. clipPlane: boolean;
  86720. }>): Promise<void>;
  86721. private static readonly _AllDirtyCallBack;
  86722. private static readonly _ImageProcessingDirtyCallBack;
  86723. private static readonly _TextureDirtyCallBack;
  86724. private static readonly _FresnelDirtyCallBack;
  86725. private static readonly _MiscDirtyCallBack;
  86726. private static readonly _LightsDirtyCallBack;
  86727. private static readonly _AttributeDirtyCallBack;
  86728. private static _FresnelAndMiscDirtyCallBack;
  86729. private static _TextureAndMiscDirtyCallBack;
  86730. private static readonly _DirtyCallbackArray;
  86731. private static readonly _RunDirtyCallBacks;
  86732. /**
  86733. * Marks a define in the material to indicate that it needs to be re-computed
  86734. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86735. */
  86736. markAsDirty(flag: number): void;
  86737. /**
  86738. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86739. * @param func defines a function which checks material defines against the submeshes
  86740. */
  86741. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86742. /**
  86743. * Indicates that we need to re-calculated for all submeshes
  86744. */
  86745. protected _markAllSubMeshesAsAllDirty(): void;
  86746. /**
  86747. * Indicates that image processing needs to be re-calculated for all submeshes
  86748. */
  86749. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86750. /**
  86751. * Indicates that textures need to be re-calculated for all submeshes
  86752. */
  86753. protected _markAllSubMeshesAsTexturesDirty(): void;
  86754. /**
  86755. * Indicates that fresnel needs to be re-calculated for all submeshes
  86756. */
  86757. protected _markAllSubMeshesAsFresnelDirty(): void;
  86758. /**
  86759. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86760. */
  86761. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86762. /**
  86763. * Indicates that lights need to be re-calculated for all submeshes
  86764. */
  86765. protected _markAllSubMeshesAsLightsDirty(): void;
  86766. /**
  86767. * Indicates that attributes need to be re-calculated for all submeshes
  86768. */
  86769. protected _markAllSubMeshesAsAttributesDirty(): void;
  86770. /**
  86771. * Indicates that misc needs to be re-calculated for all submeshes
  86772. */
  86773. protected _markAllSubMeshesAsMiscDirty(): void;
  86774. /**
  86775. * Indicates that textures and misc need to be re-calculated for all submeshes
  86776. */
  86777. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86778. /**
  86779. * Disposes the material
  86780. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86781. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86782. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86783. */
  86784. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86785. /** @hidden */
  86786. private releaseVertexArrayObject;
  86787. /**
  86788. * Serializes this material
  86789. * @returns the serialized material object
  86790. */
  86791. serialize(): any;
  86792. /**
  86793. * Creates a material from parsed material data
  86794. * @param parsedMaterial defines parsed material data
  86795. * @param scene defines the hosting scene
  86796. * @param rootUrl defines the root URL to use to load textures
  86797. * @returns a new material
  86798. */
  86799. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86800. }
  86801. }
  86802. declare module BABYLON {
  86803. /**
  86804. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86805. * separate meshes. This can be use to improve performances.
  86806. * @see http://doc.babylonjs.com/how_to/multi_materials
  86807. */
  86808. export class MultiMaterial extends Material {
  86809. private _subMaterials;
  86810. /**
  86811. * Gets or Sets the list of Materials used within the multi material.
  86812. * They need to be ordered according to the submeshes order in the associated mesh
  86813. */
  86814. subMaterials: Nullable<Material>[];
  86815. /**
  86816. * Function used to align with Node.getChildren()
  86817. * @returns the list of Materials used within the multi material
  86818. */
  86819. getChildren(): Nullable<Material>[];
  86820. /**
  86821. * Instantiates a new Multi Material
  86822. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86823. * separate meshes. This can be use to improve performances.
  86824. * @see http://doc.babylonjs.com/how_to/multi_materials
  86825. * @param name Define the name in the scene
  86826. * @param scene Define the scene the material belongs to
  86827. */
  86828. constructor(name: string, scene: Scene);
  86829. private _hookArray;
  86830. /**
  86831. * Get one of the submaterial by its index in the submaterials array
  86832. * @param index The index to look the sub material at
  86833. * @returns The Material if the index has been defined
  86834. */
  86835. getSubMaterial(index: number): Nullable<Material>;
  86836. /**
  86837. * Get the list of active textures for the whole sub materials list.
  86838. * @returns All the textures that will be used during the rendering
  86839. */
  86840. getActiveTextures(): BaseTexture[];
  86841. /**
  86842. * Gets the current class name of the material e.g. "MultiMaterial"
  86843. * Mainly use in serialization.
  86844. * @returns the class name
  86845. */
  86846. getClassName(): string;
  86847. /**
  86848. * Checks if the material is ready to render the requested sub mesh
  86849. * @param mesh Define the mesh the submesh belongs to
  86850. * @param subMesh Define the sub mesh to look readyness for
  86851. * @param useInstances Define whether or not the material is used with instances
  86852. * @returns true if ready, otherwise false
  86853. */
  86854. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86855. /**
  86856. * Clones the current material and its related sub materials
  86857. * @param name Define the name of the newly cloned material
  86858. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86859. * @returns the cloned material
  86860. */
  86861. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86862. /**
  86863. * Serializes the materials into a JSON representation.
  86864. * @returns the JSON representation
  86865. */
  86866. serialize(): any;
  86867. /**
  86868. * Dispose the material and release its associated resources
  86869. * @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)
  86870. * @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)
  86871. * @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)
  86872. */
  86873. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86874. /**
  86875. * Creates a MultiMaterial from parsed MultiMaterial data.
  86876. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86877. * @param scene defines the hosting scene
  86878. * @returns a new MultiMaterial
  86879. */
  86880. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86881. }
  86882. }
  86883. declare module BABYLON {
  86884. /**
  86885. * Base class for submeshes
  86886. */
  86887. export class BaseSubMesh {
  86888. /** @hidden */
  86889. _materialDefines: Nullable<MaterialDefines>;
  86890. /** @hidden */
  86891. _materialEffect: Nullable<Effect>;
  86892. /**
  86893. * Gets associated effect
  86894. */
  86895. readonly effect: Nullable<Effect>;
  86896. /**
  86897. * Sets associated effect (effect used to render this submesh)
  86898. * @param effect defines the effect to associate with
  86899. * @param defines defines the set of defines used to compile this effect
  86900. */
  86901. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86902. }
  86903. /**
  86904. * Defines a subdivision inside a mesh
  86905. */
  86906. export class SubMesh extends BaseSubMesh implements ICullable {
  86907. /** the material index to use */
  86908. materialIndex: number;
  86909. /** vertex index start */
  86910. verticesStart: number;
  86911. /** vertices count */
  86912. verticesCount: number;
  86913. /** index start */
  86914. indexStart: number;
  86915. /** indices count */
  86916. indexCount: number;
  86917. /** @hidden */
  86918. _linesIndexCount: number;
  86919. private _mesh;
  86920. private _renderingMesh;
  86921. private _boundingInfo;
  86922. private _linesIndexBuffer;
  86923. /** @hidden */
  86924. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86925. /** @hidden */
  86926. _trianglePlanes: Plane[];
  86927. /** @hidden */
  86928. _lastColliderTransformMatrix: Nullable<Matrix>;
  86929. /** @hidden */
  86930. _renderId: number;
  86931. /** @hidden */
  86932. _alphaIndex: number;
  86933. /** @hidden */
  86934. _distanceToCamera: number;
  86935. /** @hidden */
  86936. _id: number;
  86937. private _currentMaterial;
  86938. /**
  86939. * Add a new submesh to a mesh
  86940. * @param materialIndex defines the material index to use
  86941. * @param verticesStart defines vertex index start
  86942. * @param verticesCount defines vertices count
  86943. * @param indexStart defines index start
  86944. * @param indexCount defines indices count
  86945. * @param mesh defines the parent mesh
  86946. * @param renderingMesh defines an optional rendering mesh
  86947. * @param createBoundingBox defines if bounding box should be created for this submesh
  86948. * @returns the new submesh
  86949. */
  86950. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86951. /**
  86952. * Creates a new submesh
  86953. * @param materialIndex defines the material index to use
  86954. * @param verticesStart defines vertex index start
  86955. * @param verticesCount defines vertices count
  86956. * @param indexStart defines index start
  86957. * @param indexCount defines indices count
  86958. * @param mesh defines the parent mesh
  86959. * @param renderingMesh defines an optional rendering mesh
  86960. * @param createBoundingBox defines if bounding box should be created for this submesh
  86961. */
  86962. constructor(
  86963. /** the material index to use */
  86964. materialIndex: number,
  86965. /** vertex index start */
  86966. verticesStart: number,
  86967. /** vertices count */
  86968. verticesCount: number,
  86969. /** index start */
  86970. indexStart: number,
  86971. /** indices count */
  86972. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86973. /**
  86974. * Returns true if this submesh covers the entire parent mesh
  86975. * @ignorenaming
  86976. */
  86977. readonly IsGlobal: boolean;
  86978. /**
  86979. * Returns the submesh BoudingInfo object
  86980. * @returns current bounding info (or mesh's one if the submesh is global)
  86981. */
  86982. getBoundingInfo(): BoundingInfo;
  86983. /**
  86984. * Sets the submesh BoundingInfo
  86985. * @param boundingInfo defines the new bounding info to use
  86986. * @returns the SubMesh
  86987. */
  86988. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86989. /**
  86990. * Returns the mesh of the current submesh
  86991. * @return the parent mesh
  86992. */
  86993. getMesh(): AbstractMesh;
  86994. /**
  86995. * Returns the rendering mesh of the submesh
  86996. * @returns the rendering mesh (could be different from parent mesh)
  86997. */
  86998. getRenderingMesh(): Mesh;
  86999. /**
  87000. * Returns the submesh material
  87001. * @returns null or the current material
  87002. */
  87003. getMaterial(): Nullable<Material>;
  87004. /**
  87005. * Sets a new updated BoundingInfo object to the submesh
  87006. * @param data defines an optional position array to use to determine the bounding info
  87007. * @returns the SubMesh
  87008. */
  87009. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87010. /** @hidden */
  87011. _checkCollision(collider: Collider): boolean;
  87012. /**
  87013. * Updates the submesh BoundingInfo
  87014. * @param world defines the world matrix to use to update the bounding info
  87015. * @returns the submesh
  87016. */
  87017. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87018. /**
  87019. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87020. * @param frustumPlanes defines the frustum planes
  87021. * @returns true if the submesh is intersecting with the frustum
  87022. */
  87023. isInFrustum(frustumPlanes: Plane[]): boolean;
  87024. /**
  87025. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87026. * @param frustumPlanes defines the frustum planes
  87027. * @returns true if the submesh is inside the frustum
  87028. */
  87029. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87030. /**
  87031. * Renders the submesh
  87032. * @param enableAlphaMode defines if alpha needs to be used
  87033. * @returns the submesh
  87034. */
  87035. render(enableAlphaMode: boolean): SubMesh;
  87036. /**
  87037. * @hidden
  87038. */
  87039. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87040. /**
  87041. * Checks if the submesh intersects with a ray
  87042. * @param ray defines the ray to test
  87043. * @returns true is the passed ray intersects the submesh bounding box
  87044. */
  87045. canIntersects(ray: Ray): boolean;
  87046. /**
  87047. * Intersects current submesh with a ray
  87048. * @param ray defines the ray to test
  87049. * @param positions defines mesh's positions array
  87050. * @param indices defines mesh's indices array
  87051. * @param fastCheck defines if only bounding info should be used
  87052. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87053. * @returns intersection info or null if no intersection
  87054. */
  87055. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87056. /** @hidden */
  87057. private _intersectLines;
  87058. /** @hidden */
  87059. private _intersectUnIndexedLines;
  87060. /** @hidden */
  87061. private _intersectTriangles;
  87062. /** @hidden */
  87063. private _intersectUnIndexedTriangles;
  87064. /** @hidden */
  87065. _rebuild(): void;
  87066. /**
  87067. * Creates a new submesh from the passed mesh
  87068. * @param newMesh defines the new hosting mesh
  87069. * @param newRenderingMesh defines an optional rendering mesh
  87070. * @returns the new submesh
  87071. */
  87072. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87073. /**
  87074. * Release associated resources
  87075. */
  87076. dispose(): void;
  87077. /**
  87078. * Gets the class name
  87079. * @returns the string "SubMesh".
  87080. */
  87081. getClassName(): string;
  87082. /**
  87083. * Creates a new submesh from indices data
  87084. * @param materialIndex the index of the main mesh material
  87085. * @param startIndex the index where to start the copy in the mesh indices array
  87086. * @param indexCount the number of indices to copy then from the startIndex
  87087. * @param mesh the main mesh to create the submesh from
  87088. * @param renderingMesh the optional rendering mesh
  87089. * @returns a new submesh
  87090. */
  87091. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87092. }
  87093. }
  87094. declare module BABYLON {
  87095. /**
  87096. * Class used to represent data loading progression
  87097. */
  87098. export class SceneLoaderFlags {
  87099. private static _ForceFullSceneLoadingForIncremental;
  87100. private static _ShowLoadingScreen;
  87101. private static _CleanBoneMatrixWeights;
  87102. private static _loggingLevel;
  87103. /**
  87104. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87105. */
  87106. static ForceFullSceneLoadingForIncremental: boolean;
  87107. /**
  87108. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87109. */
  87110. static ShowLoadingScreen: boolean;
  87111. /**
  87112. * Defines the current logging level (while loading the scene)
  87113. * @ignorenaming
  87114. */
  87115. static loggingLevel: number;
  87116. /**
  87117. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87118. */
  87119. static CleanBoneMatrixWeights: boolean;
  87120. }
  87121. }
  87122. declare module BABYLON {
  87123. /**
  87124. * Class used to store geometry data (vertex buffers + index buffer)
  87125. */
  87126. export class Geometry implements IGetSetVerticesData {
  87127. /**
  87128. * Gets or sets the ID of the geometry
  87129. */
  87130. id: string;
  87131. /**
  87132. * Gets or sets the unique ID of the geometry
  87133. */
  87134. uniqueId: number;
  87135. /**
  87136. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87137. */
  87138. delayLoadState: number;
  87139. /**
  87140. * Gets the file containing the data to load when running in delay load state
  87141. */
  87142. delayLoadingFile: Nullable<string>;
  87143. /**
  87144. * Callback called when the geometry is updated
  87145. */
  87146. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87147. private _scene;
  87148. private _engine;
  87149. private _meshes;
  87150. private _totalVertices;
  87151. /** @hidden */
  87152. _indices: IndicesArray;
  87153. /** @hidden */
  87154. _vertexBuffers: {
  87155. [key: string]: VertexBuffer;
  87156. };
  87157. private _isDisposed;
  87158. private _extend;
  87159. private _boundingBias;
  87160. /** @hidden */
  87161. _delayInfo: Array<string>;
  87162. private _indexBuffer;
  87163. private _indexBufferIsUpdatable;
  87164. /** @hidden */
  87165. _boundingInfo: Nullable<BoundingInfo>;
  87166. /** @hidden */
  87167. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87168. /** @hidden */
  87169. _softwareSkinningFrameId: number;
  87170. private _vertexArrayObjects;
  87171. private _updatable;
  87172. /** @hidden */
  87173. _positions: Nullable<Vector3[]>;
  87174. /**
  87175. * 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
  87176. */
  87177. /**
  87178. * 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
  87179. */
  87180. boundingBias: Vector2;
  87181. /**
  87182. * Static function used to attach a new empty geometry to a mesh
  87183. * @param mesh defines the mesh to attach the geometry to
  87184. * @returns the new Geometry
  87185. */
  87186. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87187. /**
  87188. * Creates a new geometry
  87189. * @param id defines the unique ID
  87190. * @param scene defines the hosting scene
  87191. * @param vertexData defines the VertexData used to get geometry data
  87192. * @param updatable defines if geometry must be updatable (false by default)
  87193. * @param mesh defines the mesh that will be associated with the geometry
  87194. */
  87195. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87196. /**
  87197. * Gets the current extend of the geometry
  87198. */
  87199. readonly extend: {
  87200. minimum: Vector3;
  87201. maximum: Vector3;
  87202. };
  87203. /**
  87204. * Gets the hosting scene
  87205. * @returns the hosting Scene
  87206. */
  87207. getScene(): Scene;
  87208. /**
  87209. * Gets the hosting engine
  87210. * @returns the hosting Engine
  87211. */
  87212. getEngine(): Engine;
  87213. /**
  87214. * Defines if the geometry is ready to use
  87215. * @returns true if the geometry is ready to be used
  87216. */
  87217. isReady(): boolean;
  87218. /**
  87219. * Gets a value indicating that the geometry should not be serialized
  87220. */
  87221. readonly doNotSerialize: boolean;
  87222. /** @hidden */
  87223. _rebuild(): void;
  87224. /**
  87225. * Affects all geometry data in one call
  87226. * @param vertexData defines the geometry data
  87227. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87228. */
  87229. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87230. /**
  87231. * Set specific vertex data
  87232. * @param kind defines the data kind (Position, normal, etc...)
  87233. * @param data defines the vertex data to use
  87234. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87235. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87236. */
  87237. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87238. /**
  87239. * Removes a specific vertex data
  87240. * @param kind defines the data kind (Position, normal, etc...)
  87241. */
  87242. removeVerticesData(kind: string): void;
  87243. /**
  87244. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87245. * @param buffer defines the vertex buffer to use
  87246. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87247. */
  87248. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87249. /**
  87250. * Update a specific vertex buffer
  87251. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87252. * It will do nothing if the buffer is not updatable
  87253. * @param kind defines the data kind (Position, normal, etc...)
  87254. * @param data defines the data to use
  87255. * @param offset defines the offset in the target buffer where to store the data
  87256. * @param useBytes set to true if the offset is in bytes
  87257. */
  87258. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87259. /**
  87260. * Update a specific vertex buffer
  87261. * This function will create a new buffer if the current one is not updatable
  87262. * @param kind defines the data kind (Position, normal, etc...)
  87263. * @param data defines the data to use
  87264. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87265. */
  87266. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87267. private _updateBoundingInfo;
  87268. /** @hidden */
  87269. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87270. /**
  87271. * Gets total number of vertices
  87272. * @returns the total number of vertices
  87273. */
  87274. getTotalVertices(): number;
  87275. /**
  87276. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87277. * @param kind defines the data kind (Position, normal, etc...)
  87278. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87279. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87280. * @returns a float array containing vertex data
  87281. */
  87282. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87283. /**
  87284. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87285. * @param kind defines the data kind (Position, normal, etc...)
  87286. * @returns true if the vertex buffer with the specified kind is updatable
  87287. */
  87288. isVertexBufferUpdatable(kind: string): boolean;
  87289. /**
  87290. * Gets a specific vertex buffer
  87291. * @param kind defines the data kind (Position, normal, etc...)
  87292. * @returns a VertexBuffer
  87293. */
  87294. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87295. /**
  87296. * Returns all vertex buffers
  87297. * @return an object holding all vertex buffers indexed by kind
  87298. */
  87299. getVertexBuffers(): Nullable<{
  87300. [key: string]: VertexBuffer;
  87301. }>;
  87302. /**
  87303. * Gets a boolean indicating if specific vertex buffer is present
  87304. * @param kind defines the data kind (Position, normal, etc...)
  87305. * @returns true if data is present
  87306. */
  87307. isVerticesDataPresent(kind: string): boolean;
  87308. /**
  87309. * Gets a list of all attached data kinds (Position, normal, etc...)
  87310. * @returns a list of string containing all kinds
  87311. */
  87312. getVerticesDataKinds(): string[];
  87313. /**
  87314. * Update index buffer
  87315. * @param indices defines the indices to store in the index buffer
  87316. * @param offset defines the offset in the target buffer where to store the data
  87317. * @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)
  87318. */
  87319. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87320. /**
  87321. * Creates a new index buffer
  87322. * @param indices defines the indices to store in the index buffer
  87323. * @param totalVertices defines the total number of vertices (could be null)
  87324. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87325. */
  87326. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87327. /**
  87328. * Return the total number of indices
  87329. * @returns the total number of indices
  87330. */
  87331. getTotalIndices(): number;
  87332. /**
  87333. * Gets the index buffer array
  87334. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87335. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87336. * @returns the index buffer array
  87337. */
  87338. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87339. /**
  87340. * Gets the index buffer
  87341. * @return the index buffer
  87342. */
  87343. getIndexBuffer(): Nullable<DataBuffer>;
  87344. /** @hidden */
  87345. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87346. /**
  87347. * Release the associated resources for a specific mesh
  87348. * @param mesh defines the source mesh
  87349. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87350. */
  87351. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87352. /**
  87353. * Apply current geometry to a given mesh
  87354. * @param mesh defines the mesh to apply geometry to
  87355. */
  87356. applyToMesh(mesh: Mesh): void;
  87357. private _updateExtend;
  87358. private _applyToMesh;
  87359. private notifyUpdate;
  87360. /**
  87361. * Load the geometry if it was flagged as delay loaded
  87362. * @param scene defines the hosting scene
  87363. * @param onLoaded defines a callback called when the geometry is loaded
  87364. */
  87365. load(scene: Scene, onLoaded?: () => void): void;
  87366. private _queueLoad;
  87367. /**
  87368. * Invert the geometry to move from a right handed system to a left handed one.
  87369. */
  87370. toLeftHanded(): void;
  87371. /** @hidden */
  87372. _resetPointsArrayCache(): void;
  87373. /** @hidden */
  87374. _generatePointsArray(): boolean;
  87375. /**
  87376. * Gets a value indicating if the geometry is disposed
  87377. * @returns true if the geometry was disposed
  87378. */
  87379. isDisposed(): boolean;
  87380. private _disposeVertexArrayObjects;
  87381. /**
  87382. * Free all associated resources
  87383. */
  87384. dispose(): void;
  87385. /**
  87386. * Clone the current geometry into a new geometry
  87387. * @param id defines the unique ID of the new geometry
  87388. * @returns a new geometry object
  87389. */
  87390. copy(id: string): Geometry;
  87391. /**
  87392. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87393. * @return a JSON representation of the current geometry data (without the vertices data)
  87394. */
  87395. serialize(): any;
  87396. private toNumberArray;
  87397. /**
  87398. * Serialize all vertices data into a JSON oject
  87399. * @returns a JSON representation of the current geometry data
  87400. */
  87401. serializeVerticeData(): any;
  87402. /**
  87403. * Extracts a clone of a mesh geometry
  87404. * @param mesh defines the source mesh
  87405. * @param id defines the unique ID of the new geometry object
  87406. * @returns the new geometry object
  87407. */
  87408. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  87409. /**
  87410. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87411. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87412. * Be aware Math.random() could cause collisions, but:
  87413. * "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"
  87414. * @returns a string containing a new GUID
  87415. */
  87416. static RandomId(): string;
  87417. /** @hidden */
  87418. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87419. private static _CleanMatricesWeights;
  87420. /**
  87421. * Create a new geometry from persisted data (Using .babylon file format)
  87422. * @param parsedVertexData defines the persisted data
  87423. * @param scene defines the hosting scene
  87424. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87425. * @returns the new geometry object
  87426. */
  87427. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87428. }
  87429. }
  87430. declare module BABYLON {
  87431. /**
  87432. * Define an interface for all classes that will get and set the data on vertices
  87433. */
  87434. export interface IGetSetVerticesData {
  87435. /**
  87436. * Gets a boolean indicating if specific vertex data is present
  87437. * @param kind defines the vertex data kind to use
  87438. * @returns true is data kind is present
  87439. */
  87440. isVerticesDataPresent(kind: string): boolean;
  87441. /**
  87442. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87443. * @param kind defines the data kind (Position, normal, etc...)
  87444. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87445. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87446. * @returns a float array containing vertex data
  87447. */
  87448. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87449. /**
  87450. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87451. * @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.
  87452. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87453. * @returns the indices array or an empty array if the mesh has no geometry
  87454. */
  87455. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87456. /**
  87457. * Set specific vertex data
  87458. * @param kind defines the data kind (Position, normal, etc...)
  87459. * @param data defines the vertex data to use
  87460. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87461. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87462. */
  87463. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87464. /**
  87465. * Update a specific associated vertex buffer
  87466. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87467. * - VertexBuffer.PositionKind
  87468. * - VertexBuffer.UVKind
  87469. * - VertexBuffer.UV2Kind
  87470. * - VertexBuffer.UV3Kind
  87471. * - VertexBuffer.UV4Kind
  87472. * - VertexBuffer.UV5Kind
  87473. * - VertexBuffer.UV6Kind
  87474. * - VertexBuffer.ColorKind
  87475. * - VertexBuffer.MatricesIndicesKind
  87476. * - VertexBuffer.MatricesIndicesExtraKind
  87477. * - VertexBuffer.MatricesWeightsKind
  87478. * - VertexBuffer.MatricesWeightsExtraKind
  87479. * @param data defines the data source
  87480. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87481. * @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)
  87482. */
  87483. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87484. /**
  87485. * Creates a new index buffer
  87486. * @param indices defines the indices to store in the index buffer
  87487. * @param totalVertices defines the total number of vertices (could be null)
  87488. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87489. */
  87490. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87491. }
  87492. /**
  87493. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87494. */
  87495. export class VertexData {
  87496. /**
  87497. * Mesh side orientation : usually the external or front surface
  87498. */
  87499. static readonly FRONTSIDE: number;
  87500. /**
  87501. * Mesh side orientation : usually the internal or back surface
  87502. */
  87503. static readonly BACKSIDE: number;
  87504. /**
  87505. * Mesh side orientation : both internal and external or front and back surfaces
  87506. */
  87507. static readonly DOUBLESIDE: number;
  87508. /**
  87509. * Mesh side orientation : by default, `FRONTSIDE`
  87510. */
  87511. static readonly DEFAULTSIDE: number;
  87512. /**
  87513. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87514. */
  87515. positions: Nullable<FloatArray>;
  87516. /**
  87517. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87518. */
  87519. normals: Nullable<FloatArray>;
  87520. /**
  87521. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87522. */
  87523. tangents: Nullable<FloatArray>;
  87524. /**
  87525. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87526. */
  87527. uvs: Nullable<FloatArray>;
  87528. /**
  87529. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87530. */
  87531. uvs2: Nullable<FloatArray>;
  87532. /**
  87533. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87534. */
  87535. uvs3: Nullable<FloatArray>;
  87536. /**
  87537. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87538. */
  87539. uvs4: Nullable<FloatArray>;
  87540. /**
  87541. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87542. */
  87543. uvs5: Nullable<FloatArray>;
  87544. /**
  87545. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87546. */
  87547. uvs6: Nullable<FloatArray>;
  87548. /**
  87549. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87550. */
  87551. colors: Nullable<FloatArray>;
  87552. /**
  87553. * 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).
  87554. */
  87555. matricesIndices: Nullable<FloatArray>;
  87556. /**
  87557. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87558. */
  87559. matricesWeights: Nullable<FloatArray>;
  87560. /**
  87561. * An array extending the number of possible indices
  87562. */
  87563. matricesIndicesExtra: Nullable<FloatArray>;
  87564. /**
  87565. * An array extending the number of possible weights when the number of indices is extended
  87566. */
  87567. matricesWeightsExtra: Nullable<FloatArray>;
  87568. /**
  87569. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87570. */
  87571. indices: Nullable<IndicesArray>;
  87572. /**
  87573. * Uses the passed data array to set the set the values for the specified kind of data
  87574. * @param data a linear array of floating numbers
  87575. * @param kind the type of data that is being set, eg positions, colors etc
  87576. */
  87577. set(data: FloatArray, kind: string): void;
  87578. /**
  87579. * Associates the vertexData to the passed Mesh.
  87580. * Sets it as updatable or not (default `false`)
  87581. * @param mesh the mesh the vertexData is applied to
  87582. * @param updatable when used and having the value true allows new data to update the vertexData
  87583. * @returns the VertexData
  87584. */
  87585. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87586. /**
  87587. * Associates the vertexData to the passed Geometry.
  87588. * Sets it as updatable or not (default `false`)
  87589. * @param geometry the geometry the vertexData is applied to
  87590. * @param updatable when used and having the value true allows new data to update the vertexData
  87591. * @returns VertexData
  87592. */
  87593. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87594. /**
  87595. * Updates the associated mesh
  87596. * @param mesh the mesh to be updated
  87597. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87598. * @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
  87599. * @returns VertexData
  87600. */
  87601. updateMesh(mesh: Mesh): VertexData;
  87602. /**
  87603. * Updates the associated geometry
  87604. * @param geometry the geometry to be updated
  87605. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87606. * @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
  87607. * @returns VertexData.
  87608. */
  87609. updateGeometry(geometry: Geometry): VertexData;
  87610. private _applyTo;
  87611. private _update;
  87612. /**
  87613. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87614. * @param matrix the transforming matrix
  87615. * @returns the VertexData
  87616. */
  87617. transform(matrix: Matrix): VertexData;
  87618. /**
  87619. * Merges the passed VertexData into the current one
  87620. * @param other the VertexData to be merged into the current one
  87621. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87622. * @returns the modified VertexData
  87623. */
  87624. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87625. private _mergeElement;
  87626. private _validate;
  87627. /**
  87628. * Serializes the VertexData
  87629. * @returns a serialized object
  87630. */
  87631. serialize(): any;
  87632. /**
  87633. * Extracts the vertexData from a mesh
  87634. * @param mesh the mesh from which to extract the VertexData
  87635. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87636. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87637. * @returns the object VertexData associated to the passed mesh
  87638. */
  87639. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87640. /**
  87641. * Extracts the vertexData from the geometry
  87642. * @param geometry the geometry from which to extract the VertexData
  87643. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87644. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87645. * @returns the object VertexData associated to the passed mesh
  87646. */
  87647. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87648. private static _ExtractFrom;
  87649. /**
  87650. * Creates the VertexData for a Ribbon
  87651. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87652. * * pathArray array of paths, each of which an array of successive Vector3
  87653. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87654. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87655. * * 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
  87656. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87657. * * 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)
  87658. * * 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)
  87659. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87660. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87661. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87662. * @returns the VertexData of the ribbon
  87663. */
  87664. static CreateRibbon(options: {
  87665. pathArray: Vector3[][];
  87666. closeArray?: boolean;
  87667. closePath?: boolean;
  87668. offset?: number;
  87669. sideOrientation?: number;
  87670. frontUVs?: Vector4;
  87671. backUVs?: Vector4;
  87672. invertUV?: boolean;
  87673. uvs?: Vector2[];
  87674. colors?: Color4[];
  87675. }): VertexData;
  87676. /**
  87677. * Creates the VertexData for a box
  87678. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87679. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87680. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87681. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87682. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87683. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87684. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87686. * * 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)
  87687. * * 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)
  87688. * @returns the VertexData of the box
  87689. */
  87690. static CreateBox(options: {
  87691. size?: number;
  87692. width?: number;
  87693. height?: number;
  87694. depth?: number;
  87695. faceUV?: Vector4[];
  87696. faceColors?: Color4[];
  87697. sideOrientation?: number;
  87698. frontUVs?: Vector4;
  87699. backUVs?: Vector4;
  87700. }): VertexData;
  87701. /**
  87702. * Creates the VertexData for a tiled box
  87703. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87704. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87705. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87706. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87708. * @returns the VertexData of the box
  87709. */
  87710. static CreateTiledBox(options: {
  87711. pattern?: number;
  87712. width?: number;
  87713. height?: number;
  87714. depth?: number;
  87715. tileSize?: number;
  87716. tileWidth?: number;
  87717. tileHeight?: number;
  87718. alignHorizontal?: number;
  87719. alignVertical?: number;
  87720. faceUV?: Vector4[];
  87721. faceColors?: Color4[];
  87722. sideOrientation?: number;
  87723. }): VertexData;
  87724. /**
  87725. * Creates the VertexData for a tiled plane
  87726. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87727. * * pattern a limited pattern arrangement depending on the number
  87728. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87729. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87730. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87732. * * 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)
  87733. * * 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)
  87734. * @returns the VertexData of the tiled plane
  87735. */
  87736. static CreateTiledPlane(options: {
  87737. pattern?: number;
  87738. tileSize?: number;
  87739. tileWidth?: number;
  87740. tileHeight?: number;
  87741. size?: number;
  87742. width?: number;
  87743. height?: number;
  87744. alignHorizontal?: number;
  87745. alignVertical?: number;
  87746. sideOrientation?: number;
  87747. frontUVs?: Vector4;
  87748. backUVs?: Vector4;
  87749. }): VertexData;
  87750. /**
  87751. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87752. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87753. * * segments sets the number of horizontal strips optional, default 32
  87754. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87755. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87756. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87757. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87758. * * 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
  87759. * * 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
  87760. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87761. * * 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)
  87762. * * 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)
  87763. * @returns the VertexData of the ellipsoid
  87764. */
  87765. static CreateSphere(options: {
  87766. segments?: number;
  87767. diameter?: number;
  87768. diameterX?: number;
  87769. diameterY?: number;
  87770. diameterZ?: number;
  87771. arc?: number;
  87772. slice?: number;
  87773. sideOrientation?: number;
  87774. frontUVs?: Vector4;
  87775. backUVs?: Vector4;
  87776. }): VertexData;
  87777. /**
  87778. * Creates the VertexData for a cylinder, cone or prism
  87779. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87780. * * height sets the height (y direction) of the cylinder, optional, default 2
  87781. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87782. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87783. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87784. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87785. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87786. * * 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
  87787. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87788. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87789. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87790. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87792. * * 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)
  87793. * * 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)
  87794. * @returns the VertexData of the cylinder, cone or prism
  87795. */
  87796. static CreateCylinder(options: {
  87797. height?: number;
  87798. diameterTop?: number;
  87799. diameterBottom?: number;
  87800. diameter?: number;
  87801. tessellation?: number;
  87802. subdivisions?: number;
  87803. arc?: number;
  87804. faceColors?: Color4[];
  87805. faceUV?: Vector4[];
  87806. hasRings?: boolean;
  87807. enclose?: boolean;
  87808. sideOrientation?: number;
  87809. frontUVs?: Vector4;
  87810. backUVs?: Vector4;
  87811. }): VertexData;
  87812. /**
  87813. * Creates the VertexData for a torus
  87814. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87815. * * diameter the diameter of the torus, optional default 1
  87816. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87817. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87819. * * 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)
  87820. * * 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)
  87821. * @returns the VertexData of the torus
  87822. */
  87823. static CreateTorus(options: {
  87824. diameter?: number;
  87825. thickness?: number;
  87826. tessellation?: number;
  87827. sideOrientation?: number;
  87828. frontUVs?: Vector4;
  87829. backUVs?: Vector4;
  87830. }): VertexData;
  87831. /**
  87832. * Creates the VertexData of the LineSystem
  87833. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87834. * - lines an array of lines, each line being an array of successive Vector3
  87835. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87836. * @returns the VertexData of the LineSystem
  87837. */
  87838. static CreateLineSystem(options: {
  87839. lines: Vector3[][];
  87840. colors?: Nullable<Color4[][]>;
  87841. }): VertexData;
  87842. /**
  87843. * Create the VertexData for a DashedLines
  87844. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87845. * - points an array successive Vector3
  87846. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87847. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87848. * - dashNb the intended total number of dashes, optional, default 200
  87849. * @returns the VertexData for the DashedLines
  87850. */
  87851. static CreateDashedLines(options: {
  87852. points: Vector3[];
  87853. dashSize?: number;
  87854. gapSize?: number;
  87855. dashNb?: number;
  87856. }): VertexData;
  87857. /**
  87858. * Creates the VertexData for a Ground
  87859. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87860. * - width the width (x direction) of the ground, optional, default 1
  87861. * - height the height (z direction) of the ground, optional, default 1
  87862. * - subdivisions the number of subdivisions per side, optional, default 1
  87863. * @returns the VertexData of the Ground
  87864. */
  87865. static CreateGround(options: {
  87866. width?: number;
  87867. height?: number;
  87868. subdivisions?: number;
  87869. subdivisionsX?: number;
  87870. subdivisionsY?: number;
  87871. }): VertexData;
  87872. /**
  87873. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87874. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87875. * * xmin the ground minimum X coordinate, optional, default -1
  87876. * * zmin the ground minimum Z coordinate, optional, default -1
  87877. * * xmax the ground maximum X coordinate, optional, default 1
  87878. * * zmax the ground maximum Z coordinate, optional, default 1
  87879. * * 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}
  87880. * * 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}
  87881. * @returns the VertexData of the TiledGround
  87882. */
  87883. static CreateTiledGround(options: {
  87884. xmin: number;
  87885. zmin: number;
  87886. xmax: number;
  87887. zmax: number;
  87888. subdivisions?: {
  87889. w: number;
  87890. h: number;
  87891. };
  87892. precision?: {
  87893. w: number;
  87894. h: number;
  87895. };
  87896. }): VertexData;
  87897. /**
  87898. * Creates the VertexData of the Ground designed from a heightmap
  87899. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87900. * * width the width (x direction) of the ground
  87901. * * height the height (z direction) of the ground
  87902. * * subdivisions the number of subdivisions per side
  87903. * * minHeight the minimum altitude on the ground, optional, default 0
  87904. * * maxHeight the maximum altitude on the ground, optional default 1
  87905. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87906. * * buffer the array holding the image color data
  87907. * * bufferWidth the width of image
  87908. * * bufferHeight the height of image
  87909. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87910. * @returns the VertexData of the Ground designed from a heightmap
  87911. */
  87912. static CreateGroundFromHeightMap(options: {
  87913. width: number;
  87914. height: number;
  87915. subdivisions: number;
  87916. minHeight: number;
  87917. maxHeight: number;
  87918. colorFilter: Color3;
  87919. buffer: Uint8Array;
  87920. bufferWidth: number;
  87921. bufferHeight: number;
  87922. alphaFilter: number;
  87923. }): VertexData;
  87924. /**
  87925. * Creates the VertexData for a Plane
  87926. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87927. * * size sets the width and height of the plane to the value of size, optional default 1
  87928. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87929. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87931. * * 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)
  87932. * * 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)
  87933. * @returns the VertexData of the box
  87934. */
  87935. static CreatePlane(options: {
  87936. size?: number;
  87937. width?: number;
  87938. height?: number;
  87939. sideOrientation?: number;
  87940. frontUVs?: Vector4;
  87941. backUVs?: Vector4;
  87942. }): VertexData;
  87943. /**
  87944. * Creates the VertexData of the Disc or regular Polygon
  87945. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87946. * * radius the radius of the disc, optional default 0.5
  87947. * * tessellation the number of polygon sides, optional, default 64
  87948. * * 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
  87949. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87950. * * 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)
  87951. * * 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)
  87952. * @returns the VertexData of the box
  87953. */
  87954. static CreateDisc(options: {
  87955. radius?: number;
  87956. tessellation?: number;
  87957. arc?: number;
  87958. sideOrientation?: number;
  87959. frontUVs?: Vector4;
  87960. backUVs?: Vector4;
  87961. }): VertexData;
  87962. /**
  87963. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87964. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87965. * @param polygon a mesh built from polygonTriangulation.build()
  87966. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87967. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87968. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87969. * @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)
  87970. * @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)
  87971. * @returns the VertexData of the Polygon
  87972. */
  87973. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87974. /**
  87975. * Creates the VertexData of the IcoSphere
  87976. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87977. * * radius the radius of the IcoSphere, optional default 1
  87978. * * radiusX allows stretching in the x direction, optional, default radius
  87979. * * radiusY allows stretching in the y direction, optional, default radius
  87980. * * radiusZ allows stretching in the z direction, optional, default radius
  87981. * * flat when true creates a flat shaded mesh, optional, default true
  87982. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87984. * * 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)
  87985. * * 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)
  87986. * @returns the VertexData of the IcoSphere
  87987. */
  87988. static CreateIcoSphere(options: {
  87989. radius?: number;
  87990. radiusX?: number;
  87991. radiusY?: number;
  87992. radiusZ?: number;
  87993. flat?: boolean;
  87994. subdivisions?: number;
  87995. sideOrientation?: number;
  87996. frontUVs?: Vector4;
  87997. backUVs?: Vector4;
  87998. }): VertexData;
  87999. /**
  88000. * Creates the VertexData for a Polyhedron
  88001. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88002. * * type provided types are:
  88003. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88004. * * 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)
  88005. * * size the size of the IcoSphere, optional default 1
  88006. * * sizeX allows stretching in the x direction, optional, default size
  88007. * * sizeY allows stretching in the y direction, optional, default size
  88008. * * sizeZ allows stretching in the z direction, optional, default size
  88009. * * 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
  88010. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88011. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88012. * * flat when true creates a flat shaded mesh, optional, default true
  88013. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88015. * * 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)
  88016. * * 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)
  88017. * @returns the VertexData of the Polyhedron
  88018. */
  88019. static CreatePolyhedron(options: {
  88020. type?: number;
  88021. size?: number;
  88022. sizeX?: number;
  88023. sizeY?: number;
  88024. sizeZ?: number;
  88025. custom?: any;
  88026. faceUV?: Vector4[];
  88027. faceColors?: Color4[];
  88028. flat?: boolean;
  88029. sideOrientation?: number;
  88030. frontUVs?: Vector4;
  88031. backUVs?: Vector4;
  88032. }): VertexData;
  88033. /**
  88034. * Creates the VertexData for a TorusKnot
  88035. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88036. * * radius the radius of the torus knot, optional, default 2
  88037. * * tube the thickness of the tube, optional, default 0.5
  88038. * * radialSegments the number of sides on each tube segments, optional, default 32
  88039. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88040. * * p the number of windings around the z axis, optional, default 2
  88041. * * q the number of windings around the x axis, optional, default 3
  88042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88043. * * 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)
  88044. * * 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)
  88045. * @returns the VertexData of the Torus Knot
  88046. */
  88047. static CreateTorusKnot(options: {
  88048. radius?: number;
  88049. tube?: number;
  88050. radialSegments?: number;
  88051. tubularSegments?: number;
  88052. p?: number;
  88053. q?: number;
  88054. sideOrientation?: number;
  88055. frontUVs?: Vector4;
  88056. backUVs?: Vector4;
  88057. }): VertexData;
  88058. /**
  88059. * Compute normals for given positions and indices
  88060. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88061. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88062. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88063. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88064. * * facetNormals : optional array of facet normals (vector3)
  88065. * * facetPositions : optional array of facet positions (vector3)
  88066. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88067. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88068. * * bInfo : optional bounding info, required for facetPartitioning computation
  88069. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88070. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88071. * * useRightHandedSystem: optional boolean to for right handed system computation
  88072. * * depthSort : optional boolean to enable the facet depth sort computation
  88073. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88074. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88075. */
  88076. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88077. facetNormals?: any;
  88078. facetPositions?: any;
  88079. facetPartitioning?: any;
  88080. ratio?: number;
  88081. bInfo?: any;
  88082. bbSize?: Vector3;
  88083. subDiv?: any;
  88084. useRightHandedSystem?: boolean;
  88085. depthSort?: boolean;
  88086. distanceTo?: Vector3;
  88087. depthSortedFacets?: any;
  88088. }): void;
  88089. /** @hidden */
  88090. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88091. /**
  88092. * Applies VertexData created from the imported parameters to the geometry
  88093. * @param parsedVertexData the parsed data from an imported file
  88094. * @param geometry the geometry to apply the VertexData to
  88095. */
  88096. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88097. }
  88098. }
  88099. declare module BABYLON {
  88100. /**
  88101. * Defines a target to use with MorphTargetManager
  88102. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88103. */
  88104. export class MorphTarget implements IAnimatable {
  88105. /** defines the name of the target */
  88106. name: string;
  88107. /**
  88108. * Gets or sets the list of animations
  88109. */
  88110. animations: Animation[];
  88111. private _scene;
  88112. private _positions;
  88113. private _normals;
  88114. private _tangents;
  88115. private _uvs;
  88116. private _influence;
  88117. /**
  88118. * Observable raised when the influence changes
  88119. */
  88120. onInfluenceChanged: Observable<boolean>;
  88121. /** @hidden */
  88122. _onDataLayoutChanged: Observable<void>;
  88123. /**
  88124. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88125. */
  88126. influence: number;
  88127. /**
  88128. * Gets or sets the id of the morph Target
  88129. */
  88130. id: string;
  88131. private _animationPropertiesOverride;
  88132. /**
  88133. * Gets or sets the animation properties override
  88134. */
  88135. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88136. /**
  88137. * Creates a new MorphTarget
  88138. * @param name defines the name of the target
  88139. * @param influence defines the influence to use
  88140. * @param scene defines the scene the morphtarget belongs to
  88141. */
  88142. constructor(
  88143. /** defines the name of the target */
  88144. name: string, influence?: number, scene?: Nullable<Scene>);
  88145. /**
  88146. * Gets a boolean defining if the target contains position data
  88147. */
  88148. readonly hasPositions: boolean;
  88149. /**
  88150. * Gets a boolean defining if the target contains normal data
  88151. */
  88152. readonly hasNormals: boolean;
  88153. /**
  88154. * Gets a boolean defining if the target contains tangent data
  88155. */
  88156. readonly hasTangents: boolean;
  88157. /**
  88158. * Gets a boolean defining if the target contains texture coordinates data
  88159. */
  88160. readonly hasUVs: boolean;
  88161. /**
  88162. * Affects position data to this target
  88163. * @param data defines the position data to use
  88164. */
  88165. setPositions(data: Nullable<FloatArray>): void;
  88166. /**
  88167. * Gets the position data stored in this target
  88168. * @returns a FloatArray containing the position data (or null if not present)
  88169. */
  88170. getPositions(): Nullable<FloatArray>;
  88171. /**
  88172. * Affects normal data to this target
  88173. * @param data defines the normal data to use
  88174. */
  88175. setNormals(data: Nullable<FloatArray>): void;
  88176. /**
  88177. * Gets the normal data stored in this target
  88178. * @returns a FloatArray containing the normal data (or null if not present)
  88179. */
  88180. getNormals(): Nullable<FloatArray>;
  88181. /**
  88182. * Affects tangent data to this target
  88183. * @param data defines the tangent data to use
  88184. */
  88185. setTangents(data: Nullable<FloatArray>): void;
  88186. /**
  88187. * Gets the tangent data stored in this target
  88188. * @returns a FloatArray containing the tangent data (or null if not present)
  88189. */
  88190. getTangents(): Nullable<FloatArray>;
  88191. /**
  88192. * Affects texture coordinates data to this target
  88193. * @param data defines the texture coordinates data to use
  88194. */
  88195. setUVs(data: Nullable<FloatArray>): void;
  88196. /**
  88197. * Gets the texture coordinates data stored in this target
  88198. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88199. */
  88200. getUVs(): Nullable<FloatArray>;
  88201. /**
  88202. * Serializes the current target into a Serialization object
  88203. * @returns the serialized object
  88204. */
  88205. serialize(): any;
  88206. /**
  88207. * Returns the string "MorphTarget"
  88208. * @returns "MorphTarget"
  88209. */
  88210. getClassName(): string;
  88211. /**
  88212. * Creates a new target from serialized data
  88213. * @param serializationObject defines the serialized data to use
  88214. * @returns a new MorphTarget
  88215. */
  88216. static Parse(serializationObject: any): MorphTarget;
  88217. /**
  88218. * Creates a MorphTarget from mesh data
  88219. * @param mesh defines the source mesh
  88220. * @param name defines the name to use for the new target
  88221. * @param influence defines the influence to attach to the target
  88222. * @returns a new MorphTarget
  88223. */
  88224. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88225. }
  88226. }
  88227. declare module BABYLON {
  88228. /**
  88229. * This class is used to deform meshes using morphing between different targets
  88230. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88231. */
  88232. export class MorphTargetManager {
  88233. private _targets;
  88234. private _targetInfluenceChangedObservers;
  88235. private _targetDataLayoutChangedObservers;
  88236. private _activeTargets;
  88237. private _scene;
  88238. private _influences;
  88239. private _supportsNormals;
  88240. private _supportsTangents;
  88241. private _supportsUVs;
  88242. private _vertexCount;
  88243. private _uniqueId;
  88244. private _tempInfluences;
  88245. /**
  88246. * Gets or sets a boolean indicating if normals must be morphed
  88247. */
  88248. enableNormalMorphing: boolean;
  88249. /**
  88250. * Gets or sets a boolean indicating if tangents must be morphed
  88251. */
  88252. enableTangentMorphing: boolean;
  88253. /**
  88254. * Gets or sets a boolean indicating if UV must be morphed
  88255. */
  88256. enableUVMorphing: boolean;
  88257. /**
  88258. * Creates a new MorphTargetManager
  88259. * @param scene defines the current scene
  88260. */
  88261. constructor(scene?: Nullable<Scene>);
  88262. /**
  88263. * Gets the unique ID of this manager
  88264. */
  88265. readonly uniqueId: number;
  88266. /**
  88267. * Gets the number of vertices handled by this manager
  88268. */
  88269. readonly vertexCount: number;
  88270. /**
  88271. * Gets a boolean indicating if this manager supports morphing of normals
  88272. */
  88273. readonly supportsNormals: boolean;
  88274. /**
  88275. * Gets a boolean indicating if this manager supports morphing of tangents
  88276. */
  88277. readonly supportsTangents: boolean;
  88278. /**
  88279. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88280. */
  88281. readonly supportsUVs: boolean;
  88282. /**
  88283. * Gets the number of targets stored in this manager
  88284. */
  88285. readonly numTargets: number;
  88286. /**
  88287. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88288. */
  88289. readonly numInfluencers: number;
  88290. /**
  88291. * Gets the list of influences (one per target)
  88292. */
  88293. readonly influences: Float32Array;
  88294. /**
  88295. * Gets the active target at specified index. An active target is a target with an influence > 0
  88296. * @param index defines the index to check
  88297. * @returns the requested target
  88298. */
  88299. getActiveTarget(index: number): MorphTarget;
  88300. /**
  88301. * Gets the target at specified index
  88302. * @param index defines the index to check
  88303. * @returns the requested target
  88304. */
  88305. getTarget(index: number): MorphTarget;
  88306. /**
  88307. * Add a new target to this manager
  88308. * @param target defines the target to add
  88309. */
  88310. addTarget(target: MorphTarget): void;
  88311. /**
  88312. * Removes a target from the manager
  88313. * @param target defines the target to remove
  88314. */
  88315. removeTarget(target: MorphTarget): void;
  88316. /**
  88317. * Serializes the current manager into a Serialization object
  88318. * @returns the serialized object
  88319. */
  88320. serialize(): any;
  88321. private _syncActiveTargets;
  88322. /**
  88323. * Syncrhonize the targets with all the meshes using this morph target manager
  88324. */
  88325. synchronize(): void;
  88326. /**
  88327. * Creates a new MorphTargetManager from serialized data
  88328. * @param serializationObject defines the serialized data
  88329. * @param scene defines the hosting scene
  88330. * @returns the new MorphTargetManager
  88331. */
  88332. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88333. }
  88334. }
  88335. declare module BABYLON {
  88336. /**
  88337. * Class used to represent a specific level of detail of a mesh
  88338. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88339. */
  88340. export class MeshLODLevel {
  88341. /** Defines the distance where this level should start being displayed */
  88342. distance: number;
  88343. /** Defines the mesh to use to render this level */
  88344. mesh: Nullable<Mesh>;
  88345. /**
  88346. * Creates a new LOD level
  88347. * @param distance defines the distance where this level should star being displayed
  88348. * @param mesh defines the mesh to use to render this level
  88349. */
  88350. constructor(
  88351. /** Defines the distance where this level should start being displayed */
  88352. distance: number,
  88353. /** Defines the mesh to use to render this level */
  88354. mesh: Nullable<Mesh>);
  88355. }
  88356. }
  88357. declare module BABYLON {
  88358. /**
  88359. * Mesh representing the gorund
  88360. */
  88361. export class GroundMesh extends Mesh {
  88362. /** If octree should be generated */
  88363. generateOctree: boolean;
  88364. private _heightQuads;
  88365. /** @hidden */
  88366. _subdivisionsX: number;
  88367. /** @hidden */
  88368. _subdivisionsY: number;
  88369. /** @hidden */
  88370. _width: number;
  88371. /** @hidden */
  88372. _height: number;
  88373. /** @hidden */
  88374. _minX: number;
  88375. /** @hidden */
  88376. _maxX: number;
  88377. /** @hidden */
  88378. _minZ: number;
  88379. /** @hidden */
  88380. _maxZ: number;
  88381. constructor(name: string, scene: Scene);
  88382. /**
  88383. * "GroundMesh"
  88384. * @returns "GroundMesh"
  88385. */
  88386. getClassName(): string;
  88387. /**
  88388. * The minimum of x and y subdivisions
  88389. */
  88390. readonly subdivisions: number;
  88391. /**
  88392. * X subdivisions
  88393. */
  88394. readonly subdivisionsX: number;
  88395. /**
  88396. * Y subdivisions
  88397. */
  88398. readonly subdivisionsY: number;
  88399. /**
  88400. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88401. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  88402. * @param chunksCount the number of subdivisions for x and y
  88403. * @param octreeBlocksSize (Default: 32)
  88404. */
  88405. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  88406. /**
  88407. * Returns a height (y) value in the Worl system :
  88408. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88409. * @param x x coordinate
  88410. * @param z z coordinate
  88411. * @returns the ground y position if (x, z) are outside the ground surface.
  88412. */
  88413. getHeightAtCoordinates(x: number, z: number): number;
  88414. /**
  88415. * Returns a normalized vector (Vector3) orthogonal to the ground
  88416. * at the ground coordinates (x, z) expressed in the World system.
  88417. * @param x x coordinate
  88418. * @param z z coordinate
  88419. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88420. */
  88421. getNormalAtCoordinates(x: number, z: number): Vector3;
  88422. /**
  88423. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88424. * at the ground coordinates (x, z) expressed in the World system.
  88425. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88426. * @param x x coordinate
  88427. * @param z z coordinate
  88428. * @param ref vector to store the result
  88429. * @returns the GroundMesh.
  88430. */
  88431. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88432. /**
  88433. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88434. * if the ground has been updated.
  88435. * This can be used in the render loop.
  88436. * @returns the GroundMesh.
  88437. */
  88438. updateCoordinateHeights(): GroundMesh;
  88439. private _getFacetAt;
  88440. private _initHeightQuads;
  88441. private _computeHeightQuads;
  88442. /**
  88443. * Serializes this ground mesh
  88444. * @param serializationObject object to write serialization to
  88445. */
  88446. serialize(serializationObject: any): void;
  88447. /**
  88448. * Parses a serialized ground mesh
  88449. * @param parsedMesh the serialized mesh
  88450. * @param scene the scene to create the ground mesh in
  88451. * @returns the created ground mesh
  88452. */
  88453. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88454. }
  88455. }
  88456. declare module BABYLON {
  88457. /**
  88458. * Interface for Physics-Joint data
  88459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88460. */
  88461. export interface PhysicsJointData {
  88462. /**
  88463. * The main pivot of the joint
  88464. */
  88465. mainPivot?: Vector3;
  88466. /**
  88467. * The connected pivot of the joint
  88468. */
  88469. connectedPivot?: Vector3;
  88470. /**
  88471. * The main axis of the joint
  88472. */
  88473. mainAxis?: Vector3;
  88474. /**
  88475. * The connected axis of the joint
  88476. */
  88477. connectedAxis?: Vector3;
  88478. /**
  88479. * The collision of the joint
  88480. */
  88481. collision?: boolean;
  88482. /**
  88483. * Native Oimo/Cannon/Energy data
  88484. */
  88485. nativeParams?: any;
  88486. }
  88487. /**
  88488. * This is a holder class for the physics joint created by the physics plugin
  88489. * It holds a set of functions to control the underlying joint
  88490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88491. */
  88492. export class PhysicsJoint {
  88493. /**
  88494. * The type of the physics joint
  88495. */
  88496. type: number;
  88497. /**
  88498. * The data for the physics joint
  88499. */
  88500. jointData: PhysicsJointData;
  88501. private _physicsJoint;
  88502. protected _physicsPlugin: IPhysicsEnginePlugin;
  88503. /**
  88504. * Initializes the physics joint
  88505. * @param type The type of the physics joint
  88506. * @param jointData The data for the physics joint
  88507. */
  88508. constructor(
  88509. /**
  88510. * The type of the physics joint
  88511. */
  88512. type: number,
  88513. /**
  88514. * The data for the physics joint
  88515. */
  88516. jointData: PhysicsJointData);
  88517. /**
  88518. * Gets the physics joint
  88519. */
  88520. /**
  88521. * Sets the physics joint
  88522. */
  88523. physicsJoint: any;
  88524. /**
  88525. * Sets the physics plugin
  88526. */
  88527. physicsPlugin: IPhysicsEnginePlugin;
  88528. /**
  88529. * Execute a function that is physics-plugin specific.
  88530. * @param {Function} func the function that will be executed.
  88531. * It accepts two parameters: the physics world and the physics joint
  88532. */
  88533. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88534. /**
  88535. * Distance-Joint type
  88536. */
  88537. static DistanceJoint: number;
  88538. /**
  88539. * Hinge-Joint type
  88540. */
  88541. static HingeJoint: number;
  88542. /**
  88543. * Ball-and-Socket joint type
  88544. */
  88545. static BallAndSocketJoint: number;
  88546. /**
  88547. * Wheel-Joint type
  88548. */
  88549. static WheelJoint: number;
  88550. /**
  88551. * Slider-Joint type
  88552. */
  88553. static SliderJoint: number;
  88554. /**
  88555. * Prismatic-Joint type
  88556. */
  88557. static PrismaticJoint: number;
  88558. /**
  88559. * Universal-Joint type
  88560. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88561. */
  88562. static UniversalJoint: number;
  88563. /**
  88564. * Hinge-Joint 2 type
  88565. */
  88566. static Hinge2Joint: number;
  88567. /**
  88568. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88569. */
  88570. static PointToPointJoint: number;
  88571. /**
  88572. * Spring-Joint type
  88573. */
  88574. static SpringJoint: number;
  88575. /**
  88576. * Lock-Joint type
  88577. */
  88578. static LockJoint: number;
  88579. }
  88580. /**
  88581. * A class representing a physics distance joint
  88582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88583. */
  88584. export class DistanceJoint extends PhysicsJoint {
  88585. /**
  88586. *
  88587. * @param jointData The data for the Distance-Joint
  88588. */
  88589. constructor(jointData: DistanceJointData);
  88590. /**
  88591. * Update the predefined distance.
  88592. * @param maxDistance The maximum preferred distance
  88593. * @param minDistance The minimum preferred distance
  88594. */
  88595. updateDistance(maxDistance: number, minDistance?: number): void;
  88596. }
  88597. /**
  88598. * Represents a Motor-Enabled Joint
  88599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88600. */
  88601. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88602. /**
  88603. * Initializes the Motor-Enabled Joint
  88604. * @param type The type of the joint
  88605. * @param jointData The physica joint data for the joint
  88606. */
  88607. constructor(type: number, jointData: PhysicsJointData);
  88608. /**
  88609. * Set the motor values.
  88610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88611. * @param force the force to apply
  88612. * @param maxForce max force for this motor.
  88613. */
  88614. setMotor(force?: number, maxForce?: number): void;
  88615. /**
  88616. * Set the motor's limits.
  88617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88618. * @param upperLimit The upper limit of the motor
  88619. * @param lowerLimit The lower limit of the motor
  88620. */
  88621. setLimit(upperLimit: number, lowerLimit?: number): void;
  88622. }
  88623. /**
  88624. * This class represents a single physics Hinge-Joint
  88625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88626. */
  88627. export class HingeJoint extends MotorEnabledJoint {
  88628. /**
  88629. * Initializes the Hinge-Joint
  88630. * @param jointData The joint data for the Hinge-Joint
  88631. */
  88632. constructor(jointData: PhysicsJointData);
  88633. /**
  88634. * Set the motor values.
  88635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88636. * @param {number} force the force to apply
  88637. * @param {number} maxForce max force for this motor.
  88638. */
  88639. setMotor(force?: number, maxForce?: number): void;
  88640. /**
  88641. * Set the motor's limits.
  88642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88643. * @param upperLimit The upper limit of the motor
  88644. * @param lowerLimit The lower limit of the motor
  88645. */
  88646. setLimit(upperLimit: number, lowerLimit?: number): void;
  88647. }
  88648. /**
  88649. * This class represents a dual hinge physics joint (same as wheel joint)
  88650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88651. */
  88652. export class Hinge2Joint extends MotorEnabledJoint {
  88653. /**
  88654. * Initializes the Hinge2-Joint
  88655. * @param jointData The joint data for the Hinge2-Joint
  88656. */
  88657. constructor(jointData: PhysicsJointData);
  88658. /**
  88659. * Set the motor values.
  88660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88661. * @param {number} targetSpeed the speed the motor is to reach
  88662. * @param {number} maxForce max force for this motor.
  88663. * @param {motorIndex} the motor's index, 0 or 1.
  88664. */
  88665. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88666. /**
  88667. * Set the motor limits.
  88668. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88669. * @param {number} upperLimit the upper limit
  88670. * @param {number} lowerLimit lower limit
  88671. * @param {motorIndex} the motor's index, 0 or 1.
  88672. */
  88673. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88674. }
  88675. /**
  88676. * Interface for a motor enabled joint
  88677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88678. */
  88679. export interface IMotorEnabledJoint {
  88680. /**
  88681. * Physics joint
  88682. */
  88683. physicsJoint: any;
  88684. /**
  88685. * Sets the motor of the motor-enabled joint
  88686. * @param force The force of the motor
  88687. * @param maxForce The maximum force of the motor
  88688. * @param motorIndex The index of the motor
  88689. */
  88690. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88691. /**
  88692. * Sets the limit of the motor
  88693. * @param upperLimit The upper limit of the motor
  88694. * @param lowerLimit The lower limit of the motor
  88695. * @param motorIndex The index of the motor
  88696. */
  88697. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88698. }
  88699. /**
  88700. * Joint data for a Distance-Joint
  88701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88702. */
  88703. export interface DistanceJointData extends PhysicsJointData {
  88704. /**
  88705. * Max distance the 2 joint objects can be apart
  88706. */
  88707. maxDistance: number;
  88708. }
  88709. /**
  88710. * Joint data from a spring joint
  88711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88712. */
  88713. export interface SpringJointData extends PhysicsJointData {
  88714. /**
  88715. * Length of the spring
  88716. */
  88717. length: number;
  88718. /**
  88719. * Stiffness of the spring
  88720. */
  88721. stiffness: number;
  88722. /**
  88723. * Damping of the spring
  88724. */
  88725. damping: number;
  88726. /** this callback will be called when applying the force to the impostors. */
  88727. forceApplicationCallback: () => void;
  88728. }
  88729. }
  88730. declare module BABYLON {
  88731. /**
  88732. * Holds the data for the raycast result
  88733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88734. */
  88735. export class PhysicsRaycastResult {
  88736. private _hasHit;
  88737. private _hitDistance;
  88738. private _hitNormalWorld;
  88739. private _hitPointWorld;
  88740. private _rayFromWorld;
  88741. private _rayToWorld;
  88742. /**
  88743. * Gets if there was a hit
  88744. */
  88745. readonly hasHit: boolean;
  88746. /**
  88747. * Gets the distance from the hit
  88748. */
  88749. readonly hitDistance: number;
  88750. /**
  88751. * Gets the hit normal/direction in the world
  88752. */
  88753. readonly hitNormalWorld: Vector3;
  88754. /**
  88755. * Gets the hit point in the world
  88756. */
  88757. readonly hitPointWorld: Vector3;
  88758. /**
  88759. * Gets the ray "start point" of the ray in the world
  88760. */
  88761. readonly rayFromWorld: Vector3;
  88762. /**
  88763. * Gets the ray "end point" of the ray in the world
  88764. */
  88765. readonly rayToWorld: Vector3;
  88766. /**
  88767. * Sets the hit data (normal & point in world space)
  88768. * @param hitNormalWorld defines the normal in world space
  88769. * @param hitPointWorld defines the point in world space
  88770. */
  88771. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88772. /**
  88773. * Sets the distance from the start point to the hit point
  88774. * @param distance
  88775. */
  88776. setHitDistance(distance: number): void;
  88777. /**
  88778. * Calculates the distance manually
  88779. */
  88780. calculateHitDistance(): void;
  88781. /**
  88782. * Resets all the values to default
  88783. * @param from The from point on world space
  88784. * @param to The to point on world space
  88785. */
  88786. reset(from?: Vector3, to?: Vector3): void;
  88787. }
  88788. /**
  88789. * Interface for the size containing width and height
  88790. */
  88791. interface IXYZ {
  88792. /**
  88793. * X
  88794. */
  88795. x: number;
  88796. /**
  88797. * Y
  88798. */
  88799. y: number;
  88800. /**
  88801. * Z
  88802. */
  88803. z: number;
  88804. }
  88805. }
  88806. declare module BABYLON {
  88807. /**
  88808. * Interface used to describe a physics joint
  88809. */
  88810. export interface PhysicsImpostorJoint {
  88811. /** Defines the main impostor to which the joint is linked */
  88812. mainImpostor: PhysicsImpostor;
  88813. /** Defines the impostor that is connected to the main impostor using this joint */
  88814. connectedImpostor: PhysicsImpostor;
  88815. /** Defines the joint itself */
  88816. joint: PhysicsJoint;
  88817. }
  88818. /** @hidden */
  88819. export interface IPhysicsEnginePlugin {
  88820. world: any;
  88821. name: string;
  88822. setGravity(gravity: Vector3): void;
  88823. setTimeStep(timeStep: number): void;
  88824. getTimeStep(): number;
  88825. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88826. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88827. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88828. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88829. removePhysicsBody(impostor: PhysicsImpostor): void;
  88830. generateJoint(joint: PhysicsImpostorJoint): void;
  88831. removeJoint(joint: PhysicsImpostorJoint): void;
  88832. isSupported(): boolean;
  88833. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88834. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88835. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88836. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88837. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88838. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88839. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88840. getBodyMass(impostor: PhysicsImpostor): number;
  88841. getBodyFriction(impostor: PhysicsImpostor): number;
  88842. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88843. getBodyRestitution(impostor: PhysicsImpostor): number;
  88844. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88845. getBodyPressure?(impostor: PhysicsImpostor): number;
  88846. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88847. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88848. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88849. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88850. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88851. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88852. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88853. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88854. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88855. sleepBody(impostor: PhysicsImpostor): void;
  88856. wakeUpBody(impostor: PhysicsImpostor): void;
  88857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88858. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88859. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88860. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88861. getRadius(impostor: PhysicsImpostor): number;
  88862. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88863. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88864. dispose(): void;
  88865. }
  88866. /**
  88867. * Interface used to define a physics engine
  88868. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88869. */
  88870. export interface IPhysicsEngine {
  88871. /**
  88872. * Gets the gravity vector used by the simulation
  88873. */
  88874. gravity: Vector3;
  88875. /**
  88876. * Sets the gravity vector used by the simulation
  88877. * @param gravity defines the gravity vector to use
  88878. */
  88879. setGravity(gravity: Vector3): void;
  88880. /**
  88881. * Set the time step of the physics engine.
  88882. * Default is 1/60.
  88883. * To slow it down, enter 1/600 for example.
  88884. * To speed it up, 1/30
  88885. * @param newTimeStep the new timestep to apply to this world.
  88886. */
  88887. setTimeStep(newTimeStep: number): void;
  88888. /**
  88889. * Get the time step of the physics engine.
  88890. * @returns the current time step
  88891. */
  88892. getTimeStep(): number;
  88893. /**
  88894. * Release all resources
  88895. */
  88896. dispose(): void;
  88897. /**
  88898. * Gets the name of the current physics plugin
  88899. * @returns the name of the plugin
  88900. */
  88901. getPhysicsPluginName(): string;
  88902. /**
  88903. * Adding a new impostor for the impostor tracking.
  88904. * This will be done by the impostor itself.
  88905. * @param impostor the impostor to add
  88906. */
  88907. addImpostor(impostor: PhysicsImpostor): void;
  88908. /**
  88909. * Remove an impostor from the engine.
  88910. * This impostor and its mesh will not longer be updated by the physics engine.
  88911. * @param impostor the impostor to remove
  88912. */
  88913. removeImpostor(impostor: PhysicsImpostor): void;
  88914. /**
  88915. * Add a joint to the physics engine
  88916. * @param mainImpostor defines the main impostor to which the joint is added.
  88917. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88918. * @param joint defines the joint that will connect both impostors.
  88919. */
  88920. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88921. /**
  88922. * Removes a joint from the simulation
  88923. * @param mainImpostor defines the impostor used with the joint
  88924. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88925. * @param joint defines the joint to remove
  88926. */
  88927. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88928. /**
  88929. * Gets the current plugin used to run the simulation
  88930. * @returns current plugin
  88931. */
  88932. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88933. /**
  88934. * Gets the list of physic impostors
  88935. * @returns an array of PhysicsImpostor
  88936. */
  88937. getImpostors(): Array<PhysicsImpostor>;
  88938. /**
  88939. * Gets the impostor for a physics enabled object
  88940. * @param object defines the object impersonated by the impostor
  88941. * @returns the PhysicsImpostor or null if not found
  88942. */
  88943. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88944. /**
  88945. * Gets the impostor for a physics body object
  88946. * @param body defines physics body used by the impostor
  88947. * @returns the PhysicsImpostor or null if not found
  88948. */
  88949. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88950. /**
  88951. * Does a raycast in the physics world
  88952. * @param from when should the ray start?
  88953. * @param to when should the ray end?
  88954. * @returns PhysicsRaycastResult
  88955. */
  88956. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88957. /**
  88958. * Called by the scene. No need to call it.
  88959. * @param delta defines the timespam between frames
  88960. */
  88961. _step(delta: number): void;
  88962. }
  88963. }
  88964. declare module BABYLON {
  88965. /**
  88966. * The interface for the physics imposter parameters
  88967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88968. */
  88969. export interface PhysicsImpostorParameters {
  88970. /**
  88971. * The mass of the physics imposter
  88972. */
  88973. mass: number;
  88974. /**
  88975. * The friction of the physics imposter
  88976. */
  88977. friction?: number;
  88978. /**
  88979. * The coefficient of restitution of the physics imposter
  88980. */
  88981. restitution?: number;
  88982. /**
  88983. * The native options of the physics imposter
  88984. */
  88985. nativeOptions?: any;
  88986. /**
  88987. * Specifies if the parent should be ignored
  88988. */
  88989. ignoreParent?: boolean;
  88990. /**
  88991. * Specifies if bi-directional transformations should be disabled
  88992. */
  88993. disableBidirectionalTransformation?: boolean;
  88994. /**
  88995. * The pressure inside the physics imposter, soft object only
  88996. */
  88997. pressure?: number;
  88998. /**
  88999. * The stiffness the physics imposter, soft object only
  89000. */
  89001. stiffness?: number;
  89002. /**
  89003. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89004. */
  89005. velocityIterations?: number;
  89006. /**
  89007. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89008. */
  89009. positionIterations?: number;
  89010. /**
  89011. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89012. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89013. * Add to fix multiple points
  89014. */
  89015. fixedPoints?: number;
  89016. /**
  89017. * The collision margin around a soft object
  89018. */
  89019. margin?: number;
  89020. /**
  89021. * The collision margin around a soft object
  89022. */
  89023. damping?: number;
  89024. /**
  89025. * The path for a rope based on an extrusion
  89026. */
  89027. path?: any;
  89028. /**
  89029. * The shape of an extrusion used for a rope based on an extrusion
  89030. */
  89031. shape?: any;
  89032. }
  89033. /**
  89034. * Interface for a physics-enabled object
  89035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89036. */
  89037. export interface IPhysicsEnabledObject {
  89038. /**
  89039. * The position of the physics-enabled object
  89040. */
  89041. position: Vector3;
  89042. /**
  89043. * The rotation of the physics-enabled object
  89044. */
  89045. rotationQuaternion: Nullable<Quaternion>;
  89046. /**
  89047. * The scale of the physics-enabled object
  89048. */
  89049. scaling: Vector3;
  89050. /**
  89051. * The rotation of the physics-enabled object
  89052. */
  89053. rotation?: Vector3;
  89054. /**
  89055. * The parent of the physics-enabled object
  89056. */
  89057. parent?: any;
  89058. /**
  89059. * The bounding info of the physics-enabled object
  89060. * @returns The bounding info of the physics-enabled object
  89061. */
  89062. getBoundingInfo(): BoundingInfo;
  89063. /**
  89064. * Computes the world matrix
  89065. * @param force Specifies if the world matrix should be computed by force
  89066. * @returns A world matrix
  89067. */
  89068. computeWorldMatrix(force: boolean): Matrix;
  89069. /**
  89070. * Gets the world matrix
  89071. * @returns A world matrix
  89072. */
  89073. getWorldMatrix?(): Matrix;
  89074. /**
  89075. * Gets the child meshes
  89076. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89077. * @returns An array of abstract meshes
  89078. */
  89079. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89080. /**
  89081. * Gets the vertex data
  89082. * @param kind The type of vertex data
  89083. * @returns A nullable array of numbers, or a float32 array
  89084. */
  89085. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89086. /**
  89087. * Gets the indices from the mesh
  89088. * @returns A nullable array of index arrays
  89089. */
  89090. getIndices?(): Nullable<IndicesArray>;
  89091. /**
  89092. * Gets the scene from the mesh
  89093. * @returns the indices array or null
  89094. */
  89095. getScene?(): Scene;
  89096. /**
  89097. * Gets the absolute position from the mesh
  89098. * @returns the absolute position
  89099. */
  89100. getAbsolutePosition(): Vector3;
  89101. /**
  89102. * Gets the absolute pivot point from the mesh
  89103. * @returns the absolute pivot point
  89104. */
  89105. getAbsolutePivotPoint(): Vector3;
  89106. /**
  89107. * Rotates the mesh
  89108. * @param axis The axis of rotation
  89109. * @param amount The amount of rotation
  89110. * @param space The space of the rotation
  89111. * @returns The rotation transform node
  89112. */
  89113. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89114. /**
  89115. * Translates the mesh
  89116. * @param axis The axis of translation
  89117. * @param distance The distance of translation
  89118. * @param space The space of the translation
  89119. * @returns The transform node
  89120. */
  89121. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89122. /**
  89123. * Sets the absolute position of the mesh
  89124. * @param absolutePosition The absolute position of the mesh
  89125. * @returns The transform node
  89126. */
  89127. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89128. /**
  89129. * Gets the class name of the mesh
  89130. * @returns The class name
  89131. */
  89132. getClassName(): string;
  89133. }
  89134. /**
  89135. * Represents a physics imposter
  89136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89137. */
  89138. export class PhysicsImpostor {
  89139. /**
  89140. * The physics-enabled object used as the physics imposter
  89141. */
  89142. object: IPhysicsEnabledObject;
  89143. /**
  89144. * The type of the physics imposter
  89145. */
  89146. type: number;
  89147. private _options;
  89148. private _scene?;
  89149. /**
  89150. * The default object size of the imposter
  89151. */
  89152. static DEFAULT_OBJECT_SIZE: Vector3;
  89153. /**
  89154. * The identity quaternion of the imposter
  89155. */
  89156. static IDENTITY_QUATERNION: Quaternion;
  89157. /** @hidden */
  89158. _pluginData: any;
  89159. private _physicsEngine;
  89160. private _physicsBody;
  89161. private _bodyUpdateRequired;
  89162. private _onBeforePhysicsStepCallbacks;
  89163. private _onAfterPhysicsStepCallbacks;
  89164. /** @hidden */
  89165. _onPhysicsCollideCallbacks: Array<{
  89166. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89167. otherImpostors: Array<PhysicsImpostor>;
  89168. }>;
  89169. private _deltaPosition;
  89170. private _deltaRotation;
  89171. private _deltaRotationConjugated;
  89172. /** @hidden */
  89173. _isFromLine: boolean;
  89174. private _parent;
  89175. private _isDisposed;
  89176. private static _tmpVecs;
  89177. private static _tmpQuat;
  89178. /**
  89179. * Specifies if the physics imposter is disposed
  89180. */
  89181. readonly isDisposed: boolean;
  89182. /**
  89183. * Gets the mass of the physics imposter
  89184. */
  89185. mass: number;
  89186. /**
  89187. * Gets the coefficient of friction
  89188. */
  89189. /**
  89190. * Sets the coefficient of friction
  89191. */
  89192. friction: number;
  89193. /**
  89194. * Gets the coefficient of restitution
  89195. */
  89196. /**
  89197. * Sets the coefficient of restitution
  89198. */
  89199. restitution: number;
  89200. /**
  89201. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89202. */
  89203. /**
  89204. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89205. */
  89206. pressure: number;
  89207. /**
  89208. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89209. */
  89210. /**
  89211. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89212. */
  89213. stiffness: number;
  89214. /**
  89215. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89216. */
  89217. /**
  89218. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89219. */
  89220. velocityIterations: number;
  89221. /**
  89222. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89223. */
  89224. /**
  89225. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89226. */
  89227. positionIterations: number;
  89228. /**
  89229. * The unique id of the physics imposter
  89230. * set by the physics engine when adding this impostor to the array
  89231. */
  89232. uniqueId: number;
  89233. /**
  89234. * @hidden
  89235. */
  89236. soft: boolean;
  89237. /**
  89238. * @hidden
  89239. */
  89240. segments: number;
  89241. private _joints;
  89242. /**
  89243. * Initializes the physics imposter
  89244. * @param object The physics-enabled object used as the physics imposter
  89245. * @param type The type of the physics imposter
  89246. * @param _options The options for the physics imposter
  89247. * @param _scene The Babylon scene
  89248. */
  89249. constructor(
  89250. /**
  89251. * The physics-enabled object used as the physics imposter
  89252. */
  89253. object: IPhysicsEnabledObject,
  89254. /**
  89255. * The type of the physics imposter
  89256. */
  89257. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89258. /**
  89259. * This function will completly initialize this impostor.
  89260. * It will create a new body - but only if this mesh has no parent.
  89261. * If it has, this impostor will not be used other than to define the impostor
  89262. * of the child mesh.
  89263. * @hidden
  89264. */
  89265. _init(): void;
  89266. private _getPhysicsParent;
  89267. /**
  89268. * Should a new body be generated.
  89269. * @returns boolean specifying if body initialization is required
  89270. */
  89271. isBodyInitRequired(): boolean;
  89272. /**
  89273. * Sets the updated scaling
  89274. * @param updated Specifies if the scaling is updated
  89275. */
  89276. setScalingUpdated(): void;
  89277. /**
  89278. * Force a regeneration of this or the parent's impostor's body.
  89279. * Use under cautious - This will remove all joints already implemented.
  89280. */
  89281. forceUpdate(): void;
  89282. /**
  89283. * Gets the body that holds this impostor. Either its own, or its parent.
  89284. */
  89285. /**
  89286. * Set the physics body. Used mainly by the physics engine/plugin
  89287. */
  89288. physicsBody: any;
  89289. /**
  89290. * Get the parent of the physics imposter
  89291. * @returns Physics imposter or null
  89292. */
  89293. /**
  89294. * Sets the parent of the physics imposter
  89295. */
  89296. parent: Nullable<PhysicsImpostor>;
  89297. /**
  89298. * Resets the update flags
  89299. */
  89300. resetUpdateFlags(): void;
  89301. /**
  89302. * Gets the object extend size
  89303. * @returns the object extend size
  89304. */
  89305. getObjectExtendSize(): Vector3;
  89306. /**
  89307. * Gets the object center
  89308. * @returns The object center
  89309. */
  89310. getObjectCenter(): Vector3;
  89311. /**
  89312. * Get a specific parametes from the options parameter
  89313. * @param paramName The object parameter name
  89314. * @returns The object parameter
  89315. */
  89316. getParam(paramName: string): any;
  89317. /**
  89318. * Sets a specific parameter in the options given to the physics plugin
  89319. * @param paramName The parameter name
  89320. * @param value The value of the parameter
  89321. */
  89322. setParam(paramName: string, value: number): void;
  89323. /**
  89324. * Specifically change the body's mass option. Won't recreate the physics body object
  89325. * @param mass The mass of the physics imposter
  89326. */
  89327. setMass(mass: number): void;
  89328. /**
  89329. * Gets the linear velocity
  89330. * @returns linear velocity or null
  89331. */
  89332. getLinearVelocity(): Nullable<Vector3>;
  89333. /**
  89334. * Sets the linear velocity
  89335. * @param velocity linear velocity or null
  89336. */
  89337. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89338. /**
  89339. * Gets the angular velocity
  89340. * @returns angular velocity or null
  89341. */
  89342. getAngularVelocity(): Nullable<Vector3>;
  89343. /**
  89344. * Sets the angular velocity
  89345. * @param velocity The velocity or null
  89346. */
  89347. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89348. /**
  89349. * Execute a function with the physics plugin native code
  89350. * Provide a function the will have two variables - the world object and the physics body object
  89351. * @param func The function to execute with the physics plugin native code
  89352. */
  89353. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89354. /**
  89355. * Register a function that will be executed before the physics world is stepping forward
  89356. * @param func The function to execute before the physics world is stepped forward
  89357. */
  89358. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89359. /**
  89360. * Unregister a function that will be executed before the physics world is stepping forward
  89361. * @param func The function to execute before the physics world is stepped forward
  89362. */
  89363. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89364. /**
  89365. * Register a function that will be executed after the physics step
  89366. * @param func The function to execute after physics step
  89367. */
  89368. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89369. /**
  89370. * Unregisters a function that will be executed after the physics step
  89371. * @param func The function to execute after physics step
  89372. */
  89373. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89374. /**
  89375. * register a function that will be executed when this impostor collides against a different body
  89376. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  89377. * @param func Callback that is executed on collision
  89378. */
  89379. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  89380. /**
  89381. * Unregisters the physics imposter on contact
  89382. * @param collideAgainst The physics object to collide against
  89383. * @param func Callback to execute on collision
  89384. */
  89385. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  89386. private _tmpQuat;
  89387. private _tmpQuat2;
  89388. /**
  89389. * Get the parent rotation
  89390. * @returns The parent rotation
  89391. */
  89392. getParentsRotation(): Quaternion;
  89393. /**
  89394. * this function is executed by the physics engine.
  89395. */
  89396. beforeStep: () => void;
  89397. /**
  89398. * this function is executed by the physics engine
  89399. */
  89400. afterStep: () => void;
  89401. /**
  89402. * Legacy collision detection event support
  89403. */
  89404. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  89405. /**
  89406. * event and body object due to cannon's event-based architecture.
  89407. */
  89408. onCollide: (e: {
  89409. body: any;
  89410. }) => void;
  89411. /**
  89412. * Apply a force
  89413. * @param force The force to apply
  89414. * @param contactPoint The contact point for the force
  89415. * @returns The physics imposter
  89416. */
  89417. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89418. /**
  89419. * Apply an impulse
  89420. * @param force The impulse force
  89421. * @param contactPoint The contact point for the impulse force
  89422. * @returns The physics imposter
  89423. */
  89424. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89425. /**
  89426. * A help function to create a joint
  89427. * @param otherImpostor A physics imposter used to create a joint
  89428. * @param jointType The type of joint
  89429. * @param jointData The data for the joint
  89430. * @returns The physics imposter
  89431. */
  89432. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89433. /**
  89434. * Add a joint to this impostor with a different impostor
  89435. * @param otherImpostor A physics imposter used to add a joint
  89436. * @param joint The joint to add
  89437. * @returns The physics imposter
  89438. */
  89439. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89440. /**
  89441. * Add an anchor to a cloth impostor
  89442. * @param otherImpostor rigid impostor to anchor to
  89443. * @param width ratio across width from 0 to 1
  89444. * @param height ratio up height from 0 to 1
  89445. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89446. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89447. * @returns impostor the soft imposter
  89448. */
  89449. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89450. /**
  89451. * Add a hook to a rope impostor
  89452. * @param otherImpostor rigid impostor to anchor to
  89453. * @param length ratio across rope from 0 to 1
  89454. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89455. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89456. * @returns impostor the rope imposter
  89457. */
  89458. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89459. /**
  89460. * Will keep this body still, in a sleep mode.
  89461. * @returns the physics imposter
  89462. */
  89463. sleep(): PhysicsImpostor;
  89464. /**
  89465. * Wake the body up.
  89466. * @returns The physics imposter
  89467. */
  89468. wakeUp(): PhysicsImpostor;
  89469. /**
  89470. * Clones the physics imposter
  89471. * @param newObject The physics imposter clones to this physics-enabled object
  89472. * @returns A nullable physics imposter
  89473. */
  89474. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89475. /**
  89476. * Disposes the physics imposter
  89477. */
  89478. dispose(): void;
  89479. /**
  89480. * Sets the delta position
  89481. * @param position The delta position amount
  89482. */
  89483. setDeltaPosition(position: Vector3): void;
  89484. /**
  89485. * Sets the delta rotation
  89486. * @param rotation The delta rotation amount
  89487. */
  89488. setDeltaRotation(rotation: Quaternion): void;
  89489. /**
  89490. * Gets the box size of the physics imposter and stores the result in the input parameter
  89491. * @param result Stores the box size
  89492. * @returns The physics imposter
  89493. */
  89494. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89495. /**
  89496. * Gets the radius of the physics imposter
  89497. * @returns Radius of the physics imposter
  89498. */
  89499. getRadius(): number;
  89500. /**
  89501. * Sync a bone with this impostor
  89502. * @param bone The bone to sync to the impostor.
  89503. * @param boneMesh The mesh that the bone is influencing.
  89504. * @param jointPivot The pivot of the joint / bone in local space.
  89505. * @param distToJoint Optional distance from the impostor to the joint.
  89506. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89507. */
  89508. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89509. /**
  89510. * Sync impostor to a bone
  89511. * @param bone The bone that the impostor will be synced to.
  89512. * @param boneMesh The mesh that the bone is influencing.
  89513. * @param jointPivot The pivot of the joint / bone in local space.
  89514. * @param distToJoint Optional distance from the impostor to the joint.
  89515. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89516. * @param boneAxis Optional vector3 axis the bone is aligned with
  89517. */
  89518. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89519. /**
  89520. * No-Imposter type
  89521. */
  89522. static NoImpostor: number;
  89523. /**
  89524. * Sphere-Imposter type
  89525. */
  89526. static SphereImpostor: number;
  89527. /**
  89528. * Box-Imposter type
  89529. */
  89530. static BoxImpostor: number;
  89531. /**
  89532. * Plane-Imposter type
  89533. */
  89534. static PlaneImpostor: number;
  89535. /**
  89536. * Mesh-imposter type
  89537. */
  89538. static MeshImpostor: number;
  89539. /**
  89540. * Capsule-Impostor type (Ammo.js plugin only)
  89541. */
  89542. static CapsuleImpostor: number;
  89543. /**
  89544. * Cylinder-Imposter type
  89545. */
  89546. static CylinderImpostor: number;
  89547. /**
  89548. * Particle-Imposter type
  89549. */
  89550. static ParticleImpostor: number;
  89551. /**
  89552. * Heightmap-Imposter type
  89553. */
  89554. static HeightmapImpostor: number;
  89555. /**
  89556. * ConvexHull-Impostor type (Ammo.js plugin only)
  89557. */
  89558. static ConvexHullImpostor: number;
  89559. /**
  89560. * Rope-Imposter type
  89561. */
  89562. static RopeImpostor: number;
  89563. /**
  89564. * Cloth-Imposter type
  89565. */
  89566. static ClothImpostor: number;
  89567. /**
  89568. * Softbody-Imposter type
  89569. */
  89570. static SoftbodyImpostor: number;
  89571. }
  89572. }
  89573. declare module BABYLON {
  89574. /**
  89575. * @hidden
  89576. **/
  89577. export class _CreationDataStorage {
  89578. closePath?: boolean;
  89579. closeArray?: boolean;
  89580. idx: number[];
  89581. dashSize: number;
  89582. gapSize: number;
  89583. path3D: Path3D;
  89584. pathArray: Vector3[][];
  89585. arc: number;
  89586. radius: number;
  89587. cap: number;
  89588. tessellation: number;
  89589. }
  89590. /**
  89591. * @hidden
  89592. **/
  89593. class _InstanceDataStorage {
  89594. visibleInstances: any;
  89595. batchCache: _InstancesBatch;
  89596. instancesBufferSize: number;
  89597. instancesBuffer: Nullable<Buffer>;
  89598. instancesData: Float32Array;
  89599. overridenInstanceCount: number;
  89600. isFrozen: boolean;
  89601. previousBatch: Nullable<_InstancesBatch>;
  89602. hardwareInstancedRendering: boolean;
  89603. sideOrientation: number;
  89604. }
  89605. /**
  89606. * @hidden
  89607. **/
  89608. export class _InstancesBatch {
  89609. mustReturn: boolean;
  89610. visibleInstances: Nullable<InstancedMesh[]>[];
  89611. renderSelf: boolean[];
  89612. hardwareInstancedRendering: boolean[];
  89613. }
  89614. /**
  89615. * Class used to represent renderable models
  89616. */
  89617. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89618. /**
  89619. * Mesh side orientation : usually the external or front surface
  89620. */
  89621. static readonly FRONTSIDE: number;
  89622. /**
  89623. * Mesh side orientation : usually the internal or back surface
  89624. */
  89625. static readonly BACKSIDE: number;
  89626. /**
  89627. * Mesh side orientation : both internal and external or front and back surfaces
  89628. */
  89629. static readonly DOUBLESIDE: number;
  89630. /**
  89631. * Mesh side orientation : by default, `FRONTSIDE`
  89632. */
  89633. static readonly DEFAULTSIDE: number;
  89634. /**
  89635. * Mesh cap setting : no cap
  89636. */
  89637. static readonly NO_CAP: number;
  89638. /**
  89639. * Mesh cap setting : one cap at the beginning of the mesh
  89640. */
  89641. static readonly CAP_START: number;
  89642. /**
  89643. * Mesh cap setting : one cap at the end of the mesh
  89644. */
  89645. static readonly CAP_END: number;
  89646. /**
  89647. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89648. */
  89649. static readonly CAP_ALL: number;
  89650. /**
  89651. * Mesh pattern setting : no flip or rotate
  89652. */
  89653. static readonly NO_FLIP: number;
  89654. /**
  89655. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89656. */
  89657. static readonly FLIP_TILE: number;
  89658. /**
  89659. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89660. */
  89661. static readonly ROTATE_TILE: number;
  89662. /**
  89663. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89664. */
  89665. static readonly FLIP_ROW: number;
  89666. /**
  89667. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89668. */
  89669. static readonly ROTATE_ROW: number;
  89670. /**
  89671. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89672. */
  89673. static readonly FLIP_N_ROTATE_TILE: number;
  89674. /**
  89675. * Mesh pattern setting : rotate pattern and rotate
  89676. */
  89677. static readonly FLIP_N_ROTATE_ROW: number;
  89678. /**
  89679. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89680. */
  89681. static readonly CENTER: number;
  89682. /**
  89683. * Mesh tile positioning : part tiles on left
  89684. */
  89685. static readonly LEFT: number;
  89686. /**
  89687. * Mesh tile positioning : part tiles on right
  89688. */
  89689. static readonly RIGHT: number;
  89690. /**
  89691. * Mesh tile positioning : part tiles on top
  89692. */
  89693. static readonly TOP: number;
  89694. /**
  89695. * Mesh tile positioning : part tiles on bottom
  89696. */
  89697. static readonly BOTTOM: number;
  89698. /**
  89699. * Gets the default side orientation.
  89700. * @param orientation the orientation to value to attempt to get
  89701. * @returns the default orientation
  89702. * @hidden
  89703. */
  89704. static _GetDefaultSideOrientation(orientation?: number): number;
  89705. private _internalMeshDataInfo;
  89706. /**
  89707. * An event triggered before rendering the mesh
  89708. */
  89709. readonly onBeforeRenderObservable: Observable<Mesh>;
  89710. /**
  89711. * An event triggered before binding the mesh
  89712. */
  89713. readonly onBeforeBindObservable: Observable<Mesh>;
  89714. /**
  89715. * An event triggered after rendering the mesh
  89716. */
  89717. readonly onAfterRenderObservable: Observable<Mesh>;
  89718. /**
  89719. * An event triggered before drawing the mesh
  89720. */
  89721. readonly onBeforeDrawObservable: Observable<Mesh>;
  89722. private _onBeforeDrawObserver;
  89723. /**
  89724. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89725. */
  89726. onBeforeDraw: () => void;
  89727. readonly hasInstances: boolean;
  89728. /**
  89729. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89730. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89731. */
  89732. delayLoadState: number;
  89733. /**
  89734. * Gets the list of instances created from this mesh
  89735. * it is not supposed to be modified manually.
  89736. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89737. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89738. */
  89739. instances: InstancedMesh[];
  89740. /**
  89741. * Gets the file containing delay loading data for this mesh
  89742. */
  89743. delayLoadingFile: string;
  89744. /** @hidden */
  89745. _binaryInfo: any;
  89746. /**
  89747. * User defined function used to change how LOD level selection is done
  89748. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89749. */
  89750. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89751. /**
  89752. * Gets or sets the morph target manager
  89753. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89754. */
  89755. morphTargetManager: Nullable<MorphTargetManager>;
  89756. /** @hidden */
  89757. _creationDataStorage: Nullable<_CreationDataStorage>;
  89758. /** @hidden */
  89759. _geometry: Nullable<Geometry>;
  89760. /** @hidden */
  89761. _delayInfo: Array<string>;
  89762. /** @hidden */
  89763. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89764. /** @hidden */
  89765. _instanceDataStorage: _InstanceDataStorage;
  89766. private _effectiveMaterial;
  89767. /** @hidden */
  89768. _shouldGenerateFlatShading: boolean;
  89769. /** @hidden */
  89770. _originalBuilderSideOrientation: number;
  89771. /**
  89772. * Use this property to change the original side orientation defined at construction time
  89773. */
  89774. overrideMaterialSideOrientation: Nullable<number>;
  89775. /**
  89776. * Gets the source mesh (the one used to clone this one from)
  89777. */
  89778. readonly source: Nullable<Mesh>;
  89779. /**
  89780. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89781. */
  89782. isUnIndexed: boolean;
  89783. /**
  89784. * @constructor
  89785. * @param name The value used by scene.getMeshByName() to do a lookup.
  89786. * @param scene The scene to add this mesh to.
  89787. * @param parent The parent of this mesh, if it has one
  89788. * @param source An optional Mesh from which geometry is shared, cloned.
  89789. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89790. * When false, achieved by calling a clone(), also passing False.
  89791. * This will make creation of children, recursive.
  89792. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89793. */
  89794. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89795. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89796. /**
  89797. * Gets the class name
  89798. * @returns the string "Mesh".
  89799. */
  89800. getClassName(): string;
  89801. /** @hidden */
  89802. readonly _isMesh: boolean;
  89803. /**
  89804. * Returns a description of this mesh
  89805. * @param fullDetails define if full details about this mesh must be used
  89806. * @returns a descriptive string representing this mesh
  89807. */
  89808. toString(fullDetails?: boolean): string;
  89809. /** @hidden */
  89810. _unBindEffect(): void;
  89811. /**
  89812. * Gets a boolean indicating if this mesh has LOD
  89813. */
  89814. readonly hasLODLevels: boolean;
  89815. /**
  89816. * Gets the list of MeshLODLevel associated with the current mesh
  89817. * @returns an array of MeshLODLevel
  89818. */
  89819. getLODLevels(): MeshLODLevel[];
  89820. private _sortLODLevels;
  89821. /**
  89822. * Add a mesh as LOD level triggered at the given distance.
  89823. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89824. * @param distance The distance from the center of the object to show this level
  89825. * @param mesh The mesh to be added as LOD level (can be null)
  89826. * @return This mesh (for chaining)
  89827. */
  89828. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89829. /**
  89830. * Returns the LOD level mesh at the passed distance or null if not found.
  89831. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89832. * @param distance The distance from the center of the object to show this level
  89833. * @returns a Mesh or `null`
  89834. */
  89835. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89836. /**
  89837. * Remove a mesh from the LOD array
  89838. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89839. * @param mesh defines the mesh to be removed
  89840. * @return This mesh (for chaining)
  89841. */
  89842. removeLODLevel(mesh: Mesh): Mesh;
  89843. /**
  89844. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89845. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89846. * @param camera defines the camera to use to compute distance
  89847. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89848. * @return This mesh (for chaining)
  89849. */
  89850. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89851. /**
  89852. * Gets the mesh internal Geometry object
  89853. */
  89854. readonly geometry: Nullable<Geometry>;
  89855. /**
  89856. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89857. * @returns the total number of vertices
  89858. */
  89859. getTotalVertices(): number;
  89860. /**
  89861. * Returns the content of an associated vertex buffer
  89862. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89863. * - VertexBuffer.PositionKind
  89864. * - VertexBuffer.UVKind
  89865. * - VertexBuffer.UV2Kind
  89866. * - VertexBuffer.UV3Kind
  89867. * - VertexBuffer.UV4Kind
  89868. * - VertexBuffer.UV5Kind
  89869. * - VertexBuffer.UV6Kind
  89870. * - VertexBuffer.ColorKind
  89871. * - VertexBuffer.MatricesIndicesKind
  89872. * - VertexBuffer.MatricesIndicesExtraKind
  89873. * - VertexBuffer.MatricesWeightsKind
  89874. * - VertexBuffer.MatricesWeightsExtraKind
  89875. * @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
  89876. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89877. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89878. */
  89879. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89880. /**
  89881. * Returns the mesh VertexBuffer object from the requested `kind`
  89882. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89883. * - VertexBuffer.PositionKind
  89884. * - VertexBuffer.NormalKind
  89885. * - VertexBuffer.UVKind
  89886. * - VertexBuffer.UV2Kind
  89887. * - VertexBuffer.UV3Kind
  89888. * - VertexBuffer.UV4Kind
  89889. * - VertexBuffer.UV5Kind
  89890. * - VertexBuffer.UV6Kind
  89891. * - VertexBuffer.ColorKind
  89892. * - VertexBuffer.MatricesIndicesKind
  89893. * - VertexBuffer.MatricesIndicesExtraKind
  89894. * - VertexBuffer.MatricesWeightsKind
  89895. * - VertexBuffer.MatricesWeightsExtraKind
  89896. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89897. */
  89898. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89899. /**
  89900. * Tests if a specific vertex buffer is associated with this mesh
  89901. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89902. * - VertexBuffer.PositionKind
  89903. * - VertexBuffer.NormalKind
  89904. * - VertexBuffer.UVKind
  89905. * - VertexBuffer.UV2Kind
  89906. * - VertexBuffer.UV3Kind
  89907. * - VertexBuffer.UV4Kind
  89908. * - VertexBuffer.UV5Kind
  89909. * - VertexBuffer.UV6Kind
  89910. * - VertexBuffer.ColorKind
  89911. * - VertexBuffer.MatricesIndicesKind
  89912. * - VertexBuffer.MatricesIndicesExtraKind
  89913. * - VertexBuffer.MatricesWeightsKind
  89914. * - VertexBuffer.MatricesWeightsExtraKind
  89915. * @returns a boolean
  89916. */
  89917. isVerticesDataPresent(kind: string): boolean;
  89918. /**
  89919. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89920. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89921. * - VertexBuffer.PositionKind
  89922. * - VertexBuffer.UVKind
  89923. * - VertexBuffer.UV2Kind
  89924. * - VertexBuffer.UV3Kind
  89925. * - VertexBuffer.UV4Kind
  89926. * - VertexBuffer.UV5Kind
  89927. * - VertexBuffer.UV6Kind
  89928. * - VertexBuffer.ColorKind
  89929. * - VertexBuffer.MatricesIndicesKind
  89930. * - VertexBuffer.MatricesIndicesExtraKind
  89931. * - VertexBuffer.MatricesWeightsKind
  89932. * - VertexBuffer.MatricesWeightsExtraKind
  89933. * @returns a boolean
  89934. */
  89935. isVertexBufferUpdatable(kind: string): boolean;
  89936. /**
  89937. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89938. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89939. * - VertexBuffer.PositionKind
  89940. * - VertexBuffer.NormalKind
  89941. * - VertexBuffer.UVKind
  89942. * - VertexBuffer.UV2Kind
  89943. * - VertexBuffer.UV3Kind
  89944. * - VertexBuffer.UV4Kind
  89945. * - VertexBuffer.UV5Kind
  89946. * - VertexBuffer.UV6Kind
  89947. * - VertexBuffer.ColorKind
  89948. * - VertexBuffer.MatricesIndicesKind
  89949. * - VertexBuffer.MatricesIndicesExtraKind
  89950. * - VertexBuffer.MatricesWeightsKind
  89951. * - VertexBuffer.MatricesWeightsExtraKind
  89952. * @returns an array of strings
  89953. */
  89954. getVerticesDataKinds(): string[];
  89955. /**
  89956. * Returns a positive integer : the total number of indices in this mesh geometry.
  89957. * @returns the numner of indices or zero if the mesh has no geometry.
  89958. */
  89959. getTotalIndices(): number;
  89960. /**
  89961. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89962. * @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.
  89963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89964. * @returns the indices array or an empty array if the mesh has no geometry
  89965. */
  89966. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89967. readonly isBlocked: boolean;
  89968. /**
  89969. * Determine if the current mesh is ready to be rendered
  89970. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89971. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89972. * @returns true if all associated assets are ready (material, textures, shaders)
  89973. */
  89974. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89975. /**
  89976. * 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.
  89977. */
  89978. readonly areNormalsFrozen: boolean;
  89979. /**
  89980. * 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.
  89981. * @returns the current mesh
  89982. */
  89983. freezeNormals(): Mesh;
  89984. /**
  89985. * 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
  89986. * @returns the current mesh
  89987. */
  89988. unfreezeNormals(): Mesh;
  89989. /**
  89990. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89991. */
  89992. overridenInstanceCount: number;
  89993. /** @hidden */
  89994. _preActivate(): Mesh;
  89995. /** @hidden */
  89996. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89997. /** @hidden */
  89998. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89999. /**
  90000. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90001. * This means the mesh underlying bounding box and sphere are recomputed.
  90002. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90003. * @returns the current mesh
  90004. */
  90005. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90006. /** @hidden */
  90007. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90008. /**
  90009. * This function will subdivide the mesh into multiple submeshes
  90010. * @param count defines the expected number of submeshes
  90011. */
  90012. subdivide(count: number): void;
  90013. /**
  90014. * Copy a FloatArray into a specific associated vertex buffer
  90015. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90016. * - VertexBuffer.PositionKind
  90017. * - VertexBuffer.UVKind
  90018. * - VertexBuffer.UV2Kind
  90019. * - VertexBuffer.UV3Kind
  90020. * - VertexBuffer.UV4Kind
  90021. * - VertexBuffer.UV5Kind
  90022. * - VertexBuffer.UV6Kind
  90023. * - VertexBuffer.ColorKind
  90024. * - VertexBuffer.MatricesIndicesKind
  90025. * - VertexBuffer.MatricesIndicesExtraKind
  90026. * - VertexBuffer.MatricesWeightsKind
  90027. * - VertexBuffer.MatricesWeightsExtraKind
  90028. * @param data defines the data source
  90029. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90030. * @param stride defines the data stride size (can be null)
  90031. * @returns the current mesh
  90032. */
  90033. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90034. /**
  90035. * Flags an associated vertex buffer as updatable
  90036. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90037. * - VertexBuffer.PositionKind
  90038. * - VertexBuffer.UVKind
  90039. * - VertexBuffer.UV2Kind
  90040. * - VertexBuffer.UV3Kind
  90041. * - VertexBuffer.UV4Kind
  90042. * - VertexBuffer.UV5Kind
  90043. * - VertexBuffer.UV6Kind
  90044. * - VertexBuffer.ColorKind
  90045. * - VertexBuffer.MatricesIndicesKind
  90046. * - VertexBuffer.MatricesIndicesExtraKind
  90047. * - VertexBuffer.MatricesWeightsKind
  90048. * - VertexBuffer.MatricesWeightsExtraKind
  90049. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90050. */
  90051. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90052. /**
  90053. * Sets the mesh global Vertex Buffer
  90054. * @param buffer defines the buffer to use
  90055. * @returns the current mesh
  90056. */
  90057. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90058. /**
  90059. * Update a specific associated vertex buffer
  90060. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90061. * - VertexBuffer.PositionKind
  90062. * - VertexBuffer.UVKind
  90063. * - VertexBuffer.UV2Kind
  90064. * - VertexBuffer.UV3Kind
  90065. * - VertexBuffer.UV4Kind
  90066. * - VertexBuffer.UV5Kind
  90067. * - VertexBuffer.UV6Kind
  90068. * - VertexBuffer.ColorKind
  90069. * - VertexBuffer.MatricesIndicesKind
  90070. * - VertexBuffer.MatricesIndicesExtraKind
  90071. * - VertexBuffer.MatricesWeightsKind
  90072. * - VertexBuffer.MatricesWeightsExtraKind
  90073. * @param data defines the data source
  90074. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90075. * @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)
  90076. * @returns the current mesh
  90077. */
  90078. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90079. /**
  90080. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90081. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90082. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90083. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90084. * @returns the current mesh
  90085. */
  90086. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90087. /**
  90088. * Creates a un-shared specific occurence of the geometry for the mesh.
  90089. * @returns the current mesh
  90090. */
  90091. makeGeometryUnique(): Mesh;
  90092. /**
  90093. * Set the index buffer of this mesh
  90094. * @param indices defines the source data
  90095. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90096. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90097. * @returns the current mesh
  90098. */
  90099. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90100. /**
  90101. * Update the current index buffer
  90102. * @param indices defines the source data
  90103. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90104. * @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)
  90105. * @returns the current mesh
  90106. */
  90107. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90108. /**
  90109. * Invert the geometry to move from a right handed system to a left handed one.
  90110. * @returns the current mesh
  90111. */
  90112. toLeftHanded(): Mesh;
  90113. /** @hidden */
  90114. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90115. /** @hidden */
  90116. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90117. /**
  90118. * Registers for this mesh a javascript function called just before the rendering process
  90119. * @param func defines the function to call before rendering this mesh
  90120. * @returns the current mesh
  90121. */
  90122. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90123. /**
  90124. * Disposes a previously registered javascript function called before the rendering
  90125. * @param func defines the function to remove
  90126. * @returns the current mesh
  90127. */
  90128. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90129. /**
  90130. * Registers for this mesh a javascript function called just after the rendering is complete
  90131. * @param func defines the function to call after rendering this mesh
  90132. * @returns the current mesh
  90133. */
  90134. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90135. /**
  90136. * Disposes a previously registered javascript function called after the rendering.
  90137. * @param func defines the function to remove
  90138. * @returns the current mesh
  90139. */
  90140. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90141. /** @hidden */
  90142. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90143. /** @hidden */
  90144. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90145. /** @hidden */
  90146. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90147. /** @hidden */
  90148. _rebuild(): void;
  90149. /** @hidden */
  90150. _freeze(): void;
  90151. /** @hidden */
  90152. _unFreeze(): void;
  90153. /**
  90154. * 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
  90155. * @param subMesh defines the subMesh to render
  90156. * @param enableAlphaMode defines if alpha mode can be changed
  90157. * @returns the current mesh
  90158. */
  90159. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90160. private _onBeforeDraw;
  90161. /**
  90162. * Renormalize the mesh and patch it up if there are no weights
  90163. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90164. * However in the case of zero weights then we set just a single influence to 1.
  90165. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90166. */
  90167. cleanMatrixWeights(): void;
  90168. private normalizeSkinFourWeights;
  90169. private normalizeSkinWeightsAndExtra;
  90170. /**
  90171. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90172. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90173. * the user know there was an issue with importing the mesh
  90174. * @returns a validation object with skinned, valid and report string
  90175. */
  90176. validateSkinning(): {
  90177. skinned: boolean;
  90178. valid: boolean;
  90179. report: string;
  90180. };
  90181. /** @hidden */
  90182. _checkDelayState(): Mesh;
  90183. private _queueLoad;
  90184. /**
  90185. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90186. * A mesh is in the frustum if its bounding box intersects the frustum
  90187. * @param frustumPlanes defines the frustum to test
  90188. * @returns true if the mesh is in the frustum planes
  90189. */
  90190. isInFrustum(frustumPlanes: Plane[]): boolean;
  90191. /**
  90192. * Sets the mesh material by the material or multiMaterial `id` property
  90193. * @param id is a string identifying the material or the multiMaterial
  90194. * @returns the current mesh
  90195. */
  90196. setMaterialByID(id: string): Mesh;
  90197. /**
  90198. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90199. * @returns an array of IAnimatable
  90200. */
  90201. getAnimatables(): IAnimatable[];
  90202. /**
  90203. * Modifies the mesh geometry according to the passed transformation matrix.
  90204. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90205. * The mesh normals are modified using the same transformation.
  90206. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90207. * @param transform defines the transform matrix to use
  90208. * @see http://doc.babylonjs.com/resources/baking_transformations
  90209. * @returns the current mesh
  90210. */
  90211. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90212. /**
  90213. * Modifies the mesh geometry according to its own current World Matrix.
  90214. * The mesh World Matrix is then reset.
  90215. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90216. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90217. * @see http://doc.babylonjs.com/resources/baking_transformations
  90218. * @returns the current mesh
  90219. */
  90220. bakeCurrentTransformIntoVertices(): Mesh;
  90221. /** @hidden */
  90222. readonly _positions: Nullable<Vector3[]>;
  90223. /** @hidden */
  90224. _resetPointsArrayCache(): Mesh;
  90225. /** @hidden */
  90226. _generatePointsArray(): boolean;
  90227. /**
  90228. * Returns a new Mesh object generated from the current mesh properties.
  90229. * This method must not get confused with createInstance()
  90230. * @param name is a string, the name given to the new mesh
  90231. * @param newParent can be any Node object (default `null`)
  90232. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90233. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90234. * @returns a new mesh
  90235. */
  90236. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90237. /**
  90238. * Releases resources associated with this mesh.
  90239. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90240. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90241. */
  90242. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90243. /**
  90244. * Modifies the mesh geometry according to a displacement map.
  90245. * 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.
  90246. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90247. * @param url is a string, the URL from the image file is to be downloaded.
  90248. * @param minHeight is the lower limit of the displacement.
  90249. * @param maxHeight is the upper limit of the displacement.
  90250. * @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.
  90251. * @param uvOffset is an optional vector2 used to offset UV.
  90252. * @param uvScale is an optional vector2 used to scale UV.
  90253. * @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.
  90254. * @returns the Mesh.
  90255. */
  90256. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90257. /**
  90258. * Modifies the mesh geometry according to a displacementMap buffer.
  90259. * 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.
  90260. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90261. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90262. * @param heightMapWidth is the width of the buffer image.
  90263. * @param heightMapHeight is the height of the buffer image.
  90264. * @param minHeight is the lower limit of the displacement.
  90265. * @param maxHeight is the upper limit of the displacement.
  90266. * @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.
  90267. * @param uvOffset is an optional vector2 used to offset UV.
  90268. * @param uvScale is an optional vector2 used to scale UV.
  90269. * @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.
  90270. * @returns the Mesh.
  90271. */
  90272. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90273. /**
  90274. * Modify the mesh to get a flat shading rendering.
  90275. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90276. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90277. * @returns current mesh
  90278. */
  90279. convertToFlatShadedMesh(): Mesh;
  90280. /**
  90281. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90282. * In other words, more vertices, no more indices and a single bigger VBO.
  90283. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90284. * @returns current mesh
  90285. */
  90286. convertToUnIndexedMesh(): Mesh;
  90287. /**
  90288. * Inverses facet orientations.
  90289. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90290. * @param flipNormals will also inverts the normals
  90291. * @returns current mesh
  90292. */
  90293. flipFaces(flipNormals?: boolean): Mesh;
  90294. /**
  90295. * Increase the number of facets and hence vertices in a mesh
  90296. * Vertex normals are interpolated from existing vertex normals
  90297. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90298. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90299. */
  90300. increaseVertices(numberPerEdge: number): void;
  90301. /**
  90302. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90303. * This will undo any application of covertToFlatShadedMesh
  90304. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90305. */
  90306. forceSharedVertices(): void;
  90307. /** @hidden */
  90308. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90309. /** @hidden */
  90310. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90311. /**
  90312. * Creates a new InstancedMesh object from the mesh model.
  90313. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90314. * @param name defines the name of the new instance
  90315. * @returns a new InstancedMesh
  90316. */
  90317. createInstance(name: string): InstancedMesh;
  90318. /**
  90319. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90320. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90321. * @returns the current mesh
  90322. */
  90323. synchronizeInstances(): Mesh;
  90324. /**
  90325. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90326. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90327. * This should be used together with the simplification to avoid disappearing triangles.
  90328. * @param successCallback an optional success callback to be called after the optimization finished.
  90329. * @returns the current mesh
  90330. */
  90331. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90332. /**
  90333. * Serialize current mesh
  90334. * @param serializationObject defines the object which will receive the serialization data
  90335. */
  90336. serialize(serializationObject: any): void;
  90337. /** @hidden */
  90338. _syncGeometryWithMorphTargetManager(): void;
  90339. /** @hidden */
  90340. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90341. /**
  90342. * Returns a new Mesh object parsed from the source provided.
  90343. * @param parsedMesh is the source
  90344. * @param scene defines the hosting scene
  90345. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90346. * @returns a new Mesh
  90347. */
  90348. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90349. /**
  90350. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90351. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90352. * @param name defines the name of the mesh to create
  90353. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90354. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90355. * @param closePath creates a seam between the first and the last points of each path of the path array
  90356. * @param offset is taken in account only if the `pathArray` is containing a single path
  90357. * @param scene defines the hosting scene
  90358. * @param updatable defines if the mesh must be flagged as updatable
  90359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90360. * @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)
  90361. * @returns a new Mesh
  90362. */
  90363. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90364. /**
  90365. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90366. * @param name defines the name of the mesh to create
  90367. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90368. * @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
  90369. * @param scene defines the hosting scene
  90370. * @param updatable defines if the mesh must be flagged as updatable
  90371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90372. * @returns a new Mesh
  90373. */
  90374. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90375. /**
  90376. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90377. * @param name defines the name of the mesh to create
  90378. * @param size sets the size (float) of each box side (default 1)
  90379. * @param scene defines the hosting scene
  90380. * @param updatable defines if the mesh must be flagged as updatable
  90381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90382. * @returns a new Mesh
  90383. */
  90384. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90385. /**
  90386. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90387. * @param name defines the name of the mesh to create
  90388. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90389. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90390. * @param scene defines the hosting scene
  90391. * @param updatable defines if the mesh must be flagged as updatable
  90392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90393. * @returns a new Mesh
  90394. */
  90395. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90396. /**
  90397. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90398. * @param name defines the name of the mesh to create
  90399. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90400. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90401. * @param scene defines the hosting scene
  90402. * @returns a new Mesh
  90403. */
  90404. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  90405. /**
  90406. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90407. * @param name defines the name of the mesh to create
  90408. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90409. * @param diameterTop set the top cap diameter (floats, default 1)
  90410. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90411. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90412. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90413. * @param scene defines the hosting scene
  90414. * @param updatable defines if the mesh must be flagged as updatable
  90415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90416. * @returns a new Mesh
  90417. */
  90418. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90419. /**
  90420. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90421. * @param name defines the name of the mesh to create
  90422. * @param diameter sets the diameter size (float) of the torus (default 1)
  90423. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90424. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90425. * @param scene defines the hosting scene
  90426. * @param updatable defines if the mesh must be flagged as updatable
  90427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90428. * @returns a new Mesh
  90429. */
  90430. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90431. /**
  90432. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90433. * @param name defines the name of the mesh to create
  90434. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90435. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90436. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90437. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90438. * @param p the number of windings on X axis (positive integers, default 2)
  90439. * @param q the number of windings on Y axis (positive integers, default 3)
  90440. * @param scene defines the hosting scene
  90441. * @param updatable defines if the mesh must be flagged as updatable
  90442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90443. * @returns a new Mesh
  90444. */
  90445. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90446. /**
  90447. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90448. * @param name defines the name of the mesh to create
  90449. * @param points is an array successive Vector3
  90450. * @param scene defines the hosting scene
  90451. * @param updatable defines if the mesh must be flagged as updatable
  90452. * @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).
  90453. * @returns a new Mesh
  90454. */
  90455. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90456. /**
  90457. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90458. * @param name defines the name of the mesh to create
  90459. * @param points is an array successive Vector3
  90460. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90461. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90462. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90463. * @param scene defines the hosting scene
  90464. * @param updatable defines if the mesh must be flagged as updatable
  90465. * @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)
  90466. * @returns a new Mesh
  90467. */
  90468. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90469. /**
  90470. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90471. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90472. * 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.
  90473. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90474. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90475. * Remember you can only change the shape positions, not their number when updating a polygon.
  90476. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90477. * @param name defines the name of the mesh to create
  90478. * @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
  90479. * @param scene defines the hosting scene
  90480. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90481. * @param updatable defines if the mesh must be flagged as updatable
  90482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90483. * @param earcutInjection can be used to inject your own earcut reference
  90484. * @returns a new Mesh
  90485. */
  90486. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90487. /**
  90488. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90489. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90490. * @param name defines the name of the mesh to create
  90491. * @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
  90492. * @param depth defines the height of extrusion
  90493. * @param scene defines the hosting scene
  90494. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90495. * @param updatable defines if the mesh must be flagged as updatable
  90496. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90497. * @param earcutInjection can be used to inject your own earcut reference
  90498. * @returns a new Mesh
  90499. */
  90500. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90501. /**
  90502. * Creates an extruded shape mesh.
  90503. * 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
  90504. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90505. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90506. * @param name defines the name of the mesh to create
  90507. * @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
  90508. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90509. * @param scale is the value to scale the shape
  90510. * @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
  90511. * @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
  90512. * @param scene defines the hosting scene
  90513. * @param updatable defines if the mesh must be flagged as updatable
  90514. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90515. * @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)
  90516. * @returns a new Mesh
  90517. */
  90518. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90519. /**
  90520. * Creates an custom extruded shape mesh.
  90521. * The custom extrusion is a parametric shape.
  90522. * It has no predefined shape. Its final shape will depend on the input parameters.
  90523. * Please consider using the same method from the MeshBuilder class instead
  90524. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90525. * @param name defines the name of the mesh to create
  90526. * @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
  90527. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90528. * @param scaleFunction is a custom Javascript function called on each path point
  90529. * @param rotationFunction is a custom Javascript function called on each path point
  90530. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90531. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90532. * @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
  90533. * @param scene defines the hosting scene
  90534. * @param updatable defines if the mesh must be flagged as updatable
  90535. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90536. * @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)
  90537. * @returns a new Mesh
  90538. */
  90539. 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;
  90540. /**
  90541. * Creates lathe mesh.
  90542. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90543. * Please consider using the same method from the MeshBuilder class instead
  90544. * @param name defines the name of the mesh to create
  90545. * @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
  90546. * @param radius is the radius value of the lathe
  90547. * @param tessellation is the side number of the lathe.
  90548. * @param scene defines the hosting scene
  90549. * @param updatable defines if the mesh must be flagged as updatable
  90550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90551. * @returns a new Mesh
  90552. */
  90553. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90554. /**
  90555. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90556. * @param name defines the name of the mesh to create
  90557. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90558. * @param scene defines the hosting scene
  90559. * @param updatable defines if the mesh must be flagged as updatable
  90560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90561. * @returns a new Mesh
  90562. */
  90563. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90564. /**
  90565. * Creates a ground mesh.
  90566. * Please consider using the same method from the MeshBuilder class instead
  90567. * @param name defines the name of the mesh to create
  90568. * @param width set the width of the ground
  90569. * @param height set the height of the ground
  90570. * @param subdivisions sets the number of subdivisions per side
  90571. * @param scene defines the hosting scene
  90572. * @param updatable defines if the mesh must be flagged as updatable
  90573. * @returns a new Mesh
  90574. */
  90575. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90576. /**
  90577. * Creates a tiled ground mesh.
  90578. * Please consider using the same method from the MeshBuilder class instead
  90579. * @param name defines the name of the mesh to create
  90580. * @param xmin set the ground minimum X coordinate
  90581. * @param zmin set the ground minimum Y coordinate
  90582. * @param xmax set the ground maximum X coordinate
  90583. * @param zmax set the ground maximum Z coordinate
  90584. * @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
  90585. * @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
  90586. * @param scene defines the hosting scene
  90587. * @param updatable defines if the mesh must be flagged as updatable
  90588. * @returns a new Mesh
  90589. */
  90590. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90591. w: number;
  90592. h: number;
  90593. }, precision: {
  90594. w: number;
  90595. h: number;
  90596. }, scene: Scene, updatable?: boolean): Mesh;
  90597. /**
  90598. * Creates a ground mesh from a height map.
  90599. * Please consider using the same method from the MeshBuilder class instead
  90600. * @see http://doc.babylonjs.com/babylon101/height_map
  90601. * @param name defines the name of the mesh to create
  90602. * @param url sets the URL of the height map image resource
  90603. * @param width set the ground width size
  90604. * @param height set the ground height size
  90605. * @param subdivisions sets the number of subdivision per side
  90606. * @param minHeight is the minimum altitude on the ground
  90607. * @param maxHeight is the maximum altitude on the ground
  90608. * @param scene defines the hosting scene
  90609. * @param updatable defines if the mesh must be flagged as updatable
  90610. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90611. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90612. * @returns a new Mesh
  90613. */
  90614. 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;
  90615. /**
  90616. * Creates a tube mesh.
  90617. * The tube is a parametric shape.
  90618. * It has no predefined shape. Its final shape will depend on the input parameters.
  90619. * Please consider using the same method from the MeshBuilder class instead
  90620. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90621. * @param name defines the name of the mesh to create
  90622. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90623. * @param radius sets the tube radius size
  90624. * @param tessellation is the number of sides on the tubular surface
  90625. * @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
  90626. * @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
  90627. * @param scene defines the hosting scene
  90628. * @param updatable defines if the mesh must be flagged as updatable
  90629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90630. * @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)
  90631. * @returns a new Mesh
  90632. */
  90633. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90634. (i: number, distance: number): number;
  90635. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90636. /**
  90637. * Creates a polyhedron mesh.
  90638. * Please consider using the same method from the MeshBuilder class instead.
  90639. * * 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
  90640. * * The parameter `size` (positive float, default 1) sets the polygon size
  90641. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90642. * * 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`
  90643. * * 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
  90644. * * 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)`)
  90645. * * 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
  90646. * * 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
  90647. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90648. * * If you create a double-sided mesh, you can choose what parts of 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
  90649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90650. * @param name defines the name of the mesh to create
  90651. * @param options defines the options used to create the mesh
  90652. * @param scene defines the hosting scene
  90653. * @returns a new Mesh
  90654. */
  90655. static CreatePolyhedron(name: string, options: {
  90656. type?: number;
  90657. size?: number;
  90658. sizeX?: number;
  90659. sizeY?: number;
  90660. sizeZ?: number;
  90661. custom?: any;
  90662. faceUV?: Vector4[];
  90663. faceColors?: Color4[];
  90664. updatable?: boolean;
  90665. sideOrientation?: number;
  90666. }, scene: Scene): Mesh;
  90667. /**
  90668. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90669. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90670. * * 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`)
  90671. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90672. * * 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
  90673. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90674. * * If you create a double-sided mesh, you can choose what parts of 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
  90675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90676. * @param name defines the name of the mesh
  90677. * @param options defines the options used to create the mesh
  90678. * @param scene defines the hosting scene
  90679. * @returns a new Mesh
  90680. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90681. */
  90682. static CreateIcoSphere(name: string, options: {
  90683. radius?: number;
  90684. flat?: boolean;
  90685. subdivisions?: number;
  90686. sideOrientation?: number;
  90687. updatable?: boolean;
  90688. }, scene: Scene): Mesh;
  90689. /**
  90690. * Creates a decal mesh.
  90691. * Please consider using the same method from the MeshBuilder class instead.
  90692. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90693. * @param name defines the name of the mesh
  90694. * @param sourceMesh defines the mesh receiving the decal
  90695. * @param position sets the position of the decal in world coordinates
  90696. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90697. * @param size sets the decal scaling
  90698. * @param angle sets the angle to rotate the decal
  90699. * @returns a new Mesh
  90700. */
  90701. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90702. /**
  90703. * Prepare internal position array for software CPU skinning
  90704. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90705. */
  90706. setPositionsForCPUSkinning(): Float32Array;
  90707. /**
  90708. * Prepare internal normal array for software CPU skinning
  90709. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90710. */
  90711. setNormalsForCPUSkinning(): Float32Array;
  90712. /**
  90713. * Updates the vertex buffer by applying transformation from the bones
  90714. * @param skeleton defines the skeleton to apply to current mesh
  90715. * @returns the current mesh
  90716. */
  90717. applySkeleton(skeleton: Skeleton): Mesh;
  90718. /**
  90719. * 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
  90720. * @param meshes defines the list of meshes to scan
  90721. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90722. */
  90723. static MinMax(meshes: AbstractMesh[]): {
  90724. min: Vector3;
  90725. max: Vector3;
  90726. };
  90727. /**
  90728. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90729. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90730. * @returns a vector3
  90731. */
  90732. static Center(meshesOrMinMaxVector: {
  90733. min: Vector3;
  90734. max: Vector3;
  90735. } | AbstractMesh[]): Vector3;
  90736. /**
  90737. * Merge the array of meshes into a single mesh for performance reasons.
  90738. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90739. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90740. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90741. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90742. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90743. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90744. * @returns a new mesh
  90745. */
  90746. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90747. /** @hidden */
  90748. addInstance(instance: InstancedMesh): void;
  90749. /** @hidden */
  90750. removeInstance(instance: InstancedMesh): void;
  90751. }
  90752. }
  90753. declare module BABYLON {
  90754. /**
  90755. * This is the base class of all the camera used in the application.
  90756. * @see http://doc.babylonjs.com/features/cameras
  90757. */
  90758. export class Camera extends Node {
  90759. /** @hidden */
  90760. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90761. /**
  90762. * This is the default projection mode used by the cameras.
  90763. * It helps recreating a feeling of perspective and better appreciate depth.
  90764. * This is the best way to simulate real life cameras.
  90765. */
  90766. static readonly PERSPECTIVE_CAMERA: number;
  90767. /**
  90768. * This helps creating camera with an orthographic mode.
  90769. * 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.
  90770. */
  90771. static readonly ORTHOGRAPHIC_CAMERA: number;
  90772. /**
  90773. * This is the default FOV mode for perspective cameras.
  90774. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90775. */
  90776. static readonly FOVMODE_VERTICAL_FIXED: number;
  90777. /**
  90778. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90779. */
  90780. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90781. /**
  90782. * This specifies ther is no need for a camera rig.
  90783. * Basically only one eye is rendered corresponding to the camera.
  90784. */
  90785. static readonly RIG_MODE_NONE: number;
  90786. /**
  90787. * Simulates a camera Rig with one blue eye and one red eye.
  90788. * This can be use with 3d blue and red glasses.
  90789. */
  90790. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90791. /**
  90792. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90793. */
  90794. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90795. /**
  90796. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90797. */
  90798. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90799. /**
  90800. * Defines that both eyes of the camera will be rendered over under each other.
  90801. */
  90802. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90803. /**
  90804. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90805. */
  90806. static readonly RIG_MODE_VR: number;
  90807. /**
  90808. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90809. */
  90810. static readonly RIG_MODE_WEBVR: number;
  90811. /**
  90812. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90813. */
  90814. static readonly RIG_MODE_CUSTOM: number;
  90815. /**
  90816. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90817. */
  90818. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90819. /**
  90820. * Define the input manager associated with the camera.
  90821. */
  90822. inputs: CameraInputsManager<Camera>;
  90823. /** @hidden */
  90824. _position: Vector3;
  90825. /**
  90826. * Define the current local position of the camera in the scene
  90827. */
  90828. position: Vector3;
  90829. /**
  90830. * The vector the camera should consider as up.
  90831. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90832. */
  90833. upVector: Vector3;
  90834. /**
  90835. * Define the current limit on the left side for an orthographic camera
  90836. * In scene unit
  90837. */
  90838. orthoLeft: Nullable<number>;
  90839. /**
  90840. * Define the current limit on the right side for an orthographic camera
  90841. * In scene unit
  90842. */
  90843. orthoRight: Nullable<number>;
  90844. /**
  90845. * Define the current limit on the bottom side for an orthographic camera
  90846. * In scene unit
  90847. */
  90848. orthoBottom: Nullable<number>;
  90849. /**
  90850. * Define the current limit on the top side for an orthographic camera
  90851. * In scene unit
  90852. */
  90853. orthoTop: Nullable<number>;
  90854. /**
  90855. * Field Of View is set in Radians. (default is 0.8)
  90856. */
  90857. fov: number;
  90858. /**
  90859. * Define the minimum distance the camera can see from.
  90860. * This is important to note that the depth buffer are not infinite and the closer it starts
  90861. * the more your scene might encounter depth fighting issue.
  90862. */
  90863. minZ: number;
  90864. /**
  90865. * Define the maximum distance the camera can see to.
  90866. * This is important to note that the depth buffer are not infinite and the further it end
  90867. * the more your scene might encounter depth fighting issue.
  90868. */
  90869. maxZ: number;
  90870. /**
  90871. * Define the default inertia of the camera.
  90872. * This helps giving a smooth feeling to the camera movement.
  90873. */
  90874. inertia: number;
  90875. /**
  90876. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90877. */
  90878. mode: number;
  90879. /**
  90880. * Define wether the camera is intermediate.
  90881. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90882. */
  90883. isIntermediate: boolean;
  90884. /**
  90885. * Define the viewport of the camera.
  90886. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90887. */
  90888. viewport: Viewport;
  90889. /**
  90890. * Restricts the camera to viewing objects with the same layerMask.
  90891. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90892. */
  90893. layerMask: number;
  90894. /**
  90895. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90896. */
  90897. fovMode: number;
  90898. /**
  90899. * Rig mode of the camera.
  90900. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90901. * This is normally controlled byt the camera themselves as internal use.
  90902. */
  90903. cameraRigMode: number;
  90904. /**
  90905. * Defines the distance between both "eyes" in case of a RIG
  90906. */
  90907. interaxialDistance: number;
  90908. /**
  90909. * Defines if stereoscopic rendering is done side by side or over under.
  90910. */
  90911. isStereoscopicSideBySide: boolean;
  90912. /**
  90913. * 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
  90914. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90915. * else in the scene. (Eg. security camera)
  90916. *
  90917. * 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)
  90918. */
  90919. customRenderTargets: RenderTargetTexture[];
  90920. /**
  90921. * When set, the camera will render to this render target instead of the default canvas
  90922. *
  90923. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90924. */
  90925. outputRenderTarget: Nullable<RenderTargetTexture>;
  90926. /**
  90927. * Observable triggered when the camera view matrix has changed.
  90928. */
  90929. onViewMatrixChangedObservable: Observable<Camera>;
  90930. /**
  90931. * Observable triggered when the camera Projection matrix has changed.
  90932. */
  90933. onProjectionMatrixChangedObservable: Observable<Camera>;
  90934. /**
  90935. * Observable triggered when the inputs have been processed.
  90936. */
  90937. onAfterCheckInputsObservable: Observable<Camera>;
  90938. /**
  90939. * Observable triggered when reset has been called and applied to the camera.
  90940. */
  90941. onRestoreStateObservable: Observable<Camera>;
  90942. /** @hidden */
  90943. _cameraRigParams: any;
  90944. /** @hidden */
  90945. _rigCameras: Camera[];
  90946. /** @hidden */
  90947. _rigPostProcess: Nullable<PostProcess>;
  90948. protected _webvrViewMatrix: Matrix;
  90949. /** @hidden */
  90950. _skipRendering: boolean;
  90951. /** @hidden */
  90952. _projectionMatrix: Matrix;
  90953. /** @hidden */
  90954. _postProcesses: Nullable<PostProcess>[];
  90955. /** @hidden */
  90956. _activeMeshes: SmartArray<AbstractMesh>;
  90957. protected _globalPosition: Vector3;
  90958. /** @hidden */
  90959. _computedViewMatrix: Matrix;
  90960. private _doNotComputeProjectionMatrix;
  90961. private _transformMatrix;
  90962. private _frustumPlanes;
  90963. private _refreshFrustumPlanes;
  90964. private _storedFov;
  90965. private _stateStored;
  90966. /**
  90967. * Instantiates a new camera object.
  90968. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90969. * @see http://doc.babylonjs.com/features/cameras
  90970. * @param name Defines the name of the camera in the scene
  90971. * @param position Defines the position of the camera
  90972. * @param scene Defines the scene the camera belongs too
  90973. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90974. */
  90975. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90976. /**
  90977. * Store current camera state (fov, position, etc..)
  90978. * @returns the camera
  90979. */
  90980. storeState(): Camera;
  90981. /**
  90982. * Restores the camera state values if it has been stored. You must call storeState() first
  90983. */
  90984. protected _restoreStateValues(): boolean;
  90985. /**
  90986. * Restored camera state. You must call storeState() first.
  90987. * @returns true if restored and false otherwise
  90988. */
  90989. restoreState(): boolean;
  90990. /**
  90991. * Gets the class name of the camera.
  90992. * @returns the class name
  90993. */
  90994. getClassName(): string;
  90995. /** @hidden */
  90996. readonly _isCamera: boolean;
  90997. /**
  90998. * Gets a string representation of the camera useful for debug purpose.
  90999. * @param fullDetails Defines that a more verboe level of logging is required
  91000. * @returns the string representation
  91001. */
  91002. toString(fullDetails?: boolean): string;
  91003. /**
  91004. * Gets the current world space position of the camera.
  91005. */
  91006. readonly globalPosition: Vector3;
  91007. /**
  91008. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91009. * @returns the active meshe list
  91010. */
  91011. getActiveMeshes(): SmartArray<AbstractMesh>;
  91012. /**
  91013. * Check wether a mesh is part of the current active mesh list of the camera
  91014. * @param mesh Defines the mesh to check
  91015. * @returns true if active, false otherwise
  91016. */
  91017. isActiveMesh(mesh: Mesh): boolean;
  91018. /**
  91019. * Is this camera ready to be used/rendered
  91020. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91021. * @return true if the camera is ready
  91022. */
  91023. isReady(completeCheck?: boolean): boolean;
  91024. /** @hidden */
  91025. _initCache(): void;
  91026. /** @hidden */
  91027. _updateCache(ignoreParentClass?: boolean): void;
  91028. /** @hidden */
  91029. _isSynchronized(): boolean;
  91030. /** @hidden */
  91031. _isSynchronizedViewMatrix(): boolean;
  91032. /** @hidden */
  91033. _isSynchronizedProjectionMatrix(): boolean;
  91034. /**
  91035. * Attach the input controls to a specific dom element to get the input from.
  91036. * @param element Defines the element the controls should be listened from
  91037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91038. */
  91039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91040. /**
  91041. * Detach the current controls from the specified dom element.
  91042. * @param element Defines the element to stop listening the inputs from
  91043. */
  91044. detachControl(element: HTMLElement): void;
  91045. /**
  91046. * Update the camera state according to the different inputs gathered during the frame.
  91047. */
  91048. update(): void;
  91049. /** @hidden */
  91050. _checkInputs(): void;
  91051. /** @hidden */
  91052. readonly rigCameras: Camera[];
  91053. /**
  91054. * Gets the post process used by the rig cameras
  91055. */
  91056. readonly rigPostProcess: Nullable<PostProcess>;
  91057. /**
  91058. * Internal, gets the first post proces.
  91059. * @returns the first post process to be run on this camera.
  91060. */
  91061. _getFirstPostProcess(): Nullable<PostProcess>;
  91062. private _cascadePostProcessesToRigCams;
  91063. /**
  91064. * Attach a post process to the camera.
  91065. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91066. * @param postProcess The post process to attach to the camera
  91067. * @param insertAt The position of the post process in case several of them are in use in the scene
  91068. * @returns the position the post process has been inserted at
  91069. */
  91070. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91071. /**
  91072. * Detach a post process to the camera.
  91073. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91074. * @param postProcess The post process to detach from the camera
  91075. */
  91076. detachPostProcess(postProcess: PostProcess): void;
  91077. /**
  91078. * Gets the current world matrix of the camera
  91079. */
  91080. getWorldMatrix(): Matrix;
  91081. /** @hidden */
  91082. _getViewMatrix(): Matrix;
  91083. /**
  91084. * Gets the current view matrix of the camera.
  91085. * @param force forces the camera to recompute the matrix without looking at the cached state
  91086. * @returns the view matrix
  91087. */
  91088. getViewMatrix(force?: boolean): Matrix;
  91089. /**
  91090. * Freeze the projection matrix.
  91091. * It will prevent the cache check of the camera projection compute and can speed up perf
  91092. * if no parameter of the camera are meant to change
  91093. * @param projection Defines manually a projection if necessary
  91094. */
  91095. freezeProjectionMatrix(projection?: Matrix): void;
  91096. /**
  91097. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91098. */
  91099. unfreezeProjectionMatrix(): void;
  91100. /**
  91101. * Gets the current projection matrix of the camera.
  91102. * @param force forces the camera to recompute the matrix without looking at the cached state
  91103. * @returns the projection matrix
  91104. */
  91105. getProjectionMatrix(force?: boolean): Matrix;
  91106. /**
  91107. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91108. * @returns a Matrix
  91109. */
  91110. getTransformationMatrix(): Matrix;
  91111. private _updateFrustumPlanes;
  91112. /**
  91113. * Checks if a cullable object (mesh...) is in the camera frustum
  91114. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91115. * @param target The object to check
  91116. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91117. * @returns true if the object is in frustum otherwise false
  91118. */
  91119. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91120. /**
  91121. * Checks if a cullable object (mesh...) is in the camera frustum
  91122. * Unlike isInFrustum this cheks the full bounding box
  91123. * @param target The object to check
  91124. * @returns true if the object is in frustum otherwise false
  91125. */
  91126. isCompletelyInFrustum(target: ICullable): boolean;
  91127. /**
  91128. * Gets a ray in the forward direction from the camera.
  91129. * @param length Defines the length of the ray to create
  91130. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91131. * @param origin Defines the start point of the ray which defaults to the camera position
  91132. * @returns the forward ray
  91133. */
  91134. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91135. /**
  91136. * Releases resources associated with this node.
  91137. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91138. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91139. */
  91140. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91141. /** @hidden */
  91142. _isLeftCamera: boolean;
  91143. /**
  91144. * Gets the left camera of a rig setup in case of Rigged Camera
  91145. */
  91146. readonly isLeftCamera: boolean;
  91147. /** @hidden */
  91148. _isRightCamera: boolean;
  91149. /**
  91150. * Gets the right camera of a rig setup in case of Rigged Camera
  91151. */
  91152. readonly isRightCamera: boolean;
  91153. /**
  91154. * Gets the left camera of a rig setup in case of Rigged Camera
  91155. */
  91156. readonly leftCamera: Nullable<FreeCamera>;
  91157. /**
  91158. * Gets the right camera of a rig setup in case of Rigged Camera
  91159. */
  91160. readonly rightCamera: Nullable<FreeCamera>;
  91161. /**
  91162. * Gets the left camera target of a rig setup in case of Rigged Camera
  91163. * @returns the target position
  91164. */
  91165. getLeftTarget(): Nullable<Vector3>;
  91166. /**
  91167. * Gets the right camera target of a rig setup in case of Rigged Camera
  91168. * @returns the target position
  91169. */
  91170. getRightTarget(): Nullable<Vector3>;
  91171. /**
  91172. * @hidden
  91173. */
  91174. setCameraRigMode(mode: number, rigParams: any): void;
  91175. /** @hidden */
  91176. static _setStereoscopicRigMode(camera: Camera): void;
  91177. /** @hidden */
  91178. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91179. /** @hidden */
  91180. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91181. /** @hidden */
  91182. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91183. /** @hidden */
  91184. _getVRProjectionMatrix(): Matrix;
  91185. protected _updateCameraRotationMatrix(): void;
  91186. protected _updateWebVRCameraRotationMatrix(): void;
  91187. /**
  91188. * This function MUST be overwritten by the different WebVR cameras available.
  91189. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91190. * @hidden
  91191. */
  91192. _getWebVRProjectionMatrix(): Matrix;
  91193. /**
  91194. * This function MUST be overwritten by the different WebVR cameras available.
  91195. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91196. * @hidden
  91197. */
  91198. _getWebVRViewMatrix(): Matrix;
  91199. /** @hidden */
  91200. setCameraRigParameter(name: string, value: any): void;
  91201. /**
  91202. * needs to be overridden by children so sub has required properties to be copied
  91203. * @hidden
  91204. */
  91205. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91206. /**
  91207. * May need to be overridden by children
  91208. * @hidden
  91209. */
  91210. _updateRigCameras(): void;
  91211. /** @hidden */
  91212. _setupInputs(): void;
  91213. /**
  91214. * Serialiaze the camera setup to a json represention
  91215. * @returns the JSON representation
  91216. */
  91217. serialize(): any;
  91218. /**
  91219. * Clones the current camera.
  91220. * @param name The cloned camera name
  91221. * @returns the cloned camera
  91222. */
  91223. clone(name: string): Camera;
  91224. /**
  91225. * Gets the direction of the camera relative to a given local axis.
  91226. * @param localAxis Defines the reference axis to provide a relative direction.
  91227. * @return the direction
  91228. */
  91229. getDirection(localAxis: Vector3): Vector3;
  91230. /**
  91231. * Returns the current camera absolute rotation
  91232. */
  91233. readonly absoluteRotation: Quaternion;
  91234. /**
  91235. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91236. * @param localAxis Defines the reference axis to provide a relative direction.
  91237. * @param result Defines the vector to store the result in
  91238. */
  91239. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91240. /**
  91241. * Gets a camera constructor for a given camera type
  91242. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91243. * @param name The name of the camera the result will be able to instantiate
  91244. * @param scene The scene the result will construct the camera in
  91245. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91246. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91247. * @returns a factory method to construc the camera
  91248. */
  91249. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91250. /**
  91251. * Compute the world matrix of the camera.
  91252. * @returns the camera workd matrix
  91253. */
  91254. computeWorldMatrix(): Matrix;
  91255. /**
  91256. * Parse a JSON and creates the camera from the parsed information
  91257. * @param parsedCamera The JSON to parse
  91258. * @param scene The scene to instantiate the camera in
  91259. * @returns the newly constructed camera
  91260. */
  91261. static Parse(parsedCamera: any, scene: Scene): Camera;
  91262. }
  91263. }
  91264. declare module BABYLON {
  91265. /**
  91266. * Class containing static functions to help procedurally build meshes
  91267. */
  91268. export class DiscBuilder {
  91269. /**
  91270. * Creates a plane polygonal mesh. By default, this is a disc
  91271. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91272. * * 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
  91273. * * 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
  91274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91277. * @param name defines the name of the mesh
  91278. * @param options defines the options used to create the mesh
  91279. * @param scene defines the hosting scene
  91280. * @returns the plane polygonal mesh
  91281. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91282. */
  91283. static CreateDisc(name: string, options: {
  91284. radius?: number;
  91285. tessellation?: number;
  91286. arc?: number;
  91287. updatable?: boolean;
  91288. sideOrientation?: number;
  91289. frontUVs?: Vector4;
  91290. backUVs?: Vector4;
  91291. }, scene?: Nullable<Scene>): Mesh;
  91292. }
  91293. }
  91294. declare module BABYLON {
  91295. /**
  91296. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91297. *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.
  91298. * The SPS is also a particle system. It provides some methods to manage the particles.
  91299. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91300. *
  91301. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91302. */
  91303. export class SolidParticleSystem implements IDisposable {
  91304. /**
  91305. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91306. * Example : var p = SPS.particles[i];
  91307. */
  91308. particles: SolidParticle[];
  91309. /**
  91310. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91311. */
  91312. nbParticles: number;
  91313. /**
  91314. * If the particles must ever face the camera (default false). Useful for planar particles.
  91315. */
  91316. billboard: boolean;
  91317. /**
  91318. * Recompute normals when adding a shape
  91319. */
  91320. recomputeNormals: boolean;
  91321. /**
  91322. * This a counter ofr your own usage. It's not set by any SPS functions.
  91323. */
  91324. counter: number;
  91325. /**
  91326. * The SPS name. This name is also given to the underlying mesh.
  91327. */
  91328. name: string;
  91329. /**
  91330. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91331. */
  91332. mesh: Mesh;
  91333. /**
  91334. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91335. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91336. */
  91337. vars: any;
  91338. /**
  91339. * This array is populated when the SPS is set as 'pickable'.
  91340. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91341. * Each element of this array is an object `{idx: int, faceId: int}`.
  91342. * `idx` is the picked particle index in the `SPS.particles` array
  91343. * `faceId` is the picked face index counted within this particle.
  91344. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91345. */
  91346. pickedParticles: {
  91347. idx: number;
  91348. faceId: number;
  91349. }[];
  91350. /**
  91351. * This array is populated when `enableDepthSort` is set to true.
  91352. * Each element of this array is an instance of the class DepthSortedParticle.
  91353. */
  91354. depthSortedParticles: DepthSortedParticle[];
  91355. /**
  91356. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91357. * @hidden
  91358. */
  91359. _bSphereOnly: boolean;
  91360. /**
  91361. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  91362. * @hidden
  91363. */
  91364. _bSphereRadiusFactor: number;
  91365. private _scene;
  91366. private _positions;
  91367. private _indices;
  91368. private _normals;
  91369. private _colors;
  91370. private _uvs;
  91371. private _indices32;
  91372. private _positions32;
  91373. private _normals32;
  91374. private _fixedNormal32;
  91375. private _colors32;
  91376. private _uvs32;
  91377. private _index;
  91378. private _updatable;
  91379. private _pickable;
  91380. private _isVisibilityBoxLocked;
  91381. private _alwaysVisible;
  91382. private _depthSort;
  91383. private _shapeCounter;
  91384. private _copy;
  91385. private _color;
  91386. private _computeParticleColor;
  91387. private _computeParticleTexture;
  91388. private _computeParticleRotation;
  91389. private _computeParticleVertex;
  91390. private _computeBoundingBox;
  91391. private _depthSortParticles;
  91392. private _camera;
  91393. private _mustUnrotateFixedNormals;
  91394. private _particlesIntersect;
  91395. private _needs32Bits;
  91396. /**
  91397. * Creates a SPS (Solid Particle System) object.
  91398. * @param name (String) is the SPS name, this will be the underlying mesh name.
  91399. * @param scene (Scene) is the scene in which the SPS is added.
  91400. * @param options defines the options of the sps e.g.
  91401. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  91402. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  91403. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  91404. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  91405. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  91406. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  91407. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  91408. */
  91409. constructor(name: string, scene: Scene, options?: {
  91410. updatable?: boolean;
  91411. isPickable?: boolean;
  91412. enableDepthSort?: boolean;
  91413. particleIntersection?: boolean;
  91414. boundingSphereOnly?: boolean;
  91415. bSphereRadiusFactor?: number;
  91416. });
  91417. /**
  91418. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91419. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91420. * @returns the created mesh
  91421. */
  91422. buildMesh(): Mesh;
  91423. /**
  91424. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91425. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91426. * Thus the particles generated from `digest()` have their property `position` set yet.
  91427. * @param mesh ( Mesh ) is the mesh to be digested
  91428. * @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
  91429. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91430. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91431. * @returns the current SPS
  91432. */
  91433. digest(mesh: Mesh, options?: {
  91434. facetNb?: number;
  91435. number?: number;
  91436. delta?: number;
  91437. }): SolidParticleSystem;
  91438. private _unrotateFixedNormals;
  91439. private _resetCopy;
  91440. private _meshBuilder;
  91441. private _posToShape;
  91442. private _uvsToShapeUV;
  91443. private _addParticle;
  91444. /**
  91445. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91446. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91447. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91448. * @param nb (positive integer) the number of particles to be created from this model
  91449. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91450. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91451. * @returns the number of shapes in the system
  91452. */
  91453. addShape(mesh: Mesh, nb: number, options?: {
  91454. positionFunction?: any;
  91455. vertexFunction?: any;
  91456. }): number;
  91457. private _rebuildParticle;
  91458. /**
  91459. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91460. * @returns the SPS.
  91461. */
  91462. rebuildMesh(): SolidParticleSystem;
  91463. /**
  91464. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91465. * This method calls `updateParticle()` for each particle of the SPS.
  91466. * For an animated SPS, it is usually called within the render loop.
  91467. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91468. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91469. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91470. * @returns the SPS.
  91471. */
  91472. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91473. /**
  91474. * Disposes the SPS.
  91475. */
  91476. dispose(): void;
  91477. /**
  91478. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91479. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91480. * @returns the SPS.
  91481. */
  91482. refreshVisibleSize(): SolidParticleSystem;
  91483. /**
  91484. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91485. * @param size the size (float) of the visibility box
  91486. * note : this doesn't lock the SPS mesh bounding box.
  91487. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91488. */
  91489. setVisibilityBox(size: number): void;
  91490. /**
  91491. * Gets whether the SPS as always visible or not
  91492. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91493. */
  91494. /**
  91495. * Sets the SPS as always visible or not
  91496. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91497. */
  91498. isAlwaysVisible: boolean;
  91499. /**
  91500. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91501. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91502. */
  91503. /**
  91504. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91505. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91506. */
  91507. isVisibilityBoxLocked: boolean;
  91508. /**
  91509. * Tells to `setParticles()` to compute the particle rotations or not.
  91510. * Default value : true. The SPS is faster when it's set to false.
  91511. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91512. */
  91513. /**
  91514. * Gets if `setParticles()` computes the particle rotations or not.
  91515. * Default value : true. The SPS is faster when it's set to false.
  91516. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91517. */
  91518. computeParticleRotation: boolean;
  91519. /**
  91520. * Tells to `setParticles()` to compute the particle colors or not.
  91521. * Default value : true. The SPS is faster when it's set to false.
  91522. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91523. */
  91524. /**
  91525. * Gets if `setParticles()` computes the particle colors or not.
  91526. * Default value : true. The SPS is faster when it's set to false.
  91527. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91528. */
  91529. computeParticleColor: boolean;
  91530. /**
  91531. * Gets if `setParticles()` computes the particle textures or not.
  91532. * Default value : true. The SPS is faster when it's set to false.
  91533. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91534. */
  91535. computeParticleTexture: boolean;
  91536. /**
  91537. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91538. * Default value : false. The SPS is faster when it's set to false.
  91539. * Note : the particle custom vertex positions aren't stored values.
  91540. */
  91541. /**
  91542. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91543. * Default value : false. The SPS is faster when it's set to false.
  91544. * Note : the particle custom vertex positions aren't stored values.
  91545. */
  91546. computeParticleVertex: boolean;
  91547. /**
  91548. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91549. */
  91550. /**
  91551. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91552. */
  91553. computeBoundingBox: boolean;
  91554. /**
  91555. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91556. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91557. * Default : `true`
  91558. */
  91559. /**
  91560. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91561. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91562. * Default : `true`
  91563. */
  91564. depthSortParticles: boolean;
  91565. /**
  91566. * This function does nothing. It may be overwritten to set all the particle first values.
  91567. * The SPS doesn't call this function, you may have to call it by your own.
  91568. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91569. */
  91570. initParticles(): void;
  91571. /**
  91572. * This function does nothing. It may be overwritten to recycle a particle.
  91573. * The SPS doesn't call this function, you may have to call it by your own.
  91574. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91575. * @param particle The particle to recycle
  91576. * @returns the recycled particle
  91577. */
  91578. recycleParticle(particle: SolidParticle): SolidParticle;
  91579. /**
  91580. * Updates a particle : this function should be overwritten by the user.
  91581. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91583. * @example : just set a particle position or velocity and recycle conditions
  91584. * @param particle The particle to update
  91585. * @returns the updated particle
  91586. */
  91587. updateParticle(particle: SolidParticle): SolidParticle;
  91588. /**
  91589. * Updates a vertex of a particle : it can be overwritten by the user.
  91590. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91591. * @param particle the current particle
  91592. * @param vertex the current index of the current particle
  91593. * @param pt the index of the current vertex in the particle shape
  91594. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91595. * @example : just set a vertex particle position
  91596. * @returns the updated vertex
  91597. */
  91598. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91599. /**
  91600. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91601. * This does nothing and may be overwritten by the user.
  91602. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91603. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91604. * @param update the boolean update value actually passed to setParticles()
  91605. */
  91606. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91607. /**
  91608. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91609. * This will be passed three parameters.
  91610. * This does nothing and may be overwritten by the user.
  91611. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91612. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91613. * @param update the boolean update value actually passed to setParticles()
  91614. */
  91615. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91616. }
  91617. }
  91618. declare module BABYLON {
  91619. /**
  91620. * Represents one particle of a solid particle system.
  91621. */
  91622. export class SolidParticle {
  91623. /**
  91624. * particle global index
  91625. */
  91626. idx: number;
  91627. /**
  91628. * The color of the particle
  91629. */
  91630. color: Nullable<Color4>;
  91631. /**
  91632. * The world space position of the particle.
  91633. */
  91634. position: Vector3;
  91635. /**
  91636. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91637. */
  91638. rotation: Vector3;
  91639. /**
  91640. * The world space rotation quaternion of the particle.
  91641. */
  91642. rotationQuaternion: Nullable<Quaternion>;
  91643. /**
  91644. * The scaling of the particle.
  91645. */
  91646. scaling: Vector3;
  91647. /**
  91648. * The uvs of the particle.
  91649. */
  91650. uvs: Vector4;
  91651. /**
  91652. * The current speed of the particle.
  91653. */
  91654. velocity: Vector3;
  91655. /**
  91656. * The pivot point in the particle local space.
  91657. */
  91658. pivot: Vector3;
  91659. /**
  91660. * Must the particle be translated from its pivot point in its local space ?
  91661. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91662. * Default : false
  91663. */
  91664. translateFromPivot: boolean;
  91665. /**
  91666. * Is the particle active or not ?
  91667. */
  91668. alive: boolean;
  91669. /**
  91670. * Is the particle visible or not ?
  91671. */
  91672. isVisible: boolean;
  91673. /**
  91674. * Index of this particle in the global "positions" array (Internal use)
  91675. * @hidden
  91676. */
  91677. _pos: number;
  91678. /**
  91679. * @hidden Index of this particle in the global "indices" array (Internal use)
  91680. */
  91681. _ind: number;
  91682. /**
  91683. * @hidden ModelShape of this particle (Internal use)
  91684. */
  91685. _model: ModelShape;
  91686. /**
  91687. * ModelShape id of this particle
  91688. */
  91689. shapeId: number;
  91690. /**
  91691. * Index of the particle in its shape id
  91692. */
  91693. idxInShape: number;
  91694. /**
  91695. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91696. */
  91697. _modelBoundingInfo: BoundingInfo;
  91698. /**
  91699. * @hidden Particle BoundingInfo object (Internal use)
  91700. */
  91701. _boundingInfo: BoundingInfo;
  91702. /**
  91703. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91704. */
  91705. _sps: SolidParticleSystem;
  91706. /**
  91707. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91708. */
  91709. _stillInvisible: boolean;
  91710. /**
  91711. * @hidden Last computed particle rotation matrix
  91712. */
  91713. _rotationMatrix: number[];
  91714. /**
  91715. * Parent particle Id, if any.
  91716. * Default null.
  91717. */
  91718. parentId: Nullable<number>;
  91719. /**
  91720. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91721. * The possible values are :
  91722. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91723. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91724. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91725. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91726. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91727. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91728. * */
  91729. cullingStrategy: number;
  91730. /**
  91731. * @hidden Internal global position in the SPS.
  91732. */
  91733. _globalPosition: Vector3;
  91734. /**
  91735. * Creates a Solid Particle object.
  91736. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91737. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91738. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91739. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91740. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91741. * @param shapeId (integer) is the model shape identifier in the SPS.
  91742. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91743. * @param sps defines the sps it is associated to
  91744. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91745. */
  91746. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91747. /**
  91748. * Legacy support, changed scale to scaling
  91749. */
  91750. /**
  91751. * Legacy support, changed scale to scaling
  91752. */
  91753. scale: Vector3;
  91754. /**
  91755. * Legacy support, changed quaternion to rotationQuaternion
  91756. */
  91757. /**
  91758. * Legacy support, changed quaternion to rotationQuaternion
  91759. */
  91760. quaternion: Nullable<Quaternion>;
  91761. /**
  91762. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91763. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91764. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91765. * @returns true if it intersects
  91766. */
  91767. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91768. /**
  91769. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91770. * A particle is in the frustum if its bounding box intersects the frustum
  91771. * @param frustumPlanes defines the frustum to test
  91772. * @returns true if the particle is in the frustum planes
  91773. */
  91774. isInFrustum(frustumPlanes: Plane[]): boolean;
  91775. /**
  91776. * get the rotation matrix of the particle
  91777. * @hidden
  91778. */
  91779. getRotationMatrix(m: Matrix): void;
  91780. }
  91781. /**
  91782. * Represents the shape of the model used by one particle of a solid particle system.
  91783. * SPS internal tool, don't use it manually.
  91784. */
  91785. export class ModelShape {
  91786. /**
  91787. * The shape id
  91788. * @hidden
  91789. */
  91790. shapeID: number;
  91791. /**
  91792. * flat array of model positions (internal use)
  91793. * @hidden
  91794. */
  91795. _shape: Vector3[];
  91796. /**
  91797. * flat array of model UVs (internal use)
  91798. * @hidden
  91799. */
  91800. _shapeUV: number[];
  91801. /**
  91802. * length of the shape in the model indices array (internal use)
  91803. * @hidden
  91804. */
  91805. _indicesLength: number;
  91806. /**
  91807. * Custom position function (internal use)
  91808. * @hidden
  91809. */
  91810. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91811. /**
  91812. * Custom vertex function (internal use)
  91813. * @hidden
  91814. */
  91815. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91816. /**
  91817. * 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.
  91818. * SPS internal tool, don't use it manually.
  91819. * @hidden
  91820. */
  91821. 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>);
  91822. }
  91823. /**
  91824. * Represents a Depth Sorted Particle in the solid particle system.
  91825. */
  91826. export class DepthSortedParticle {
  91827. /**
  91828. * Index of the particle in the "indices" array
  91829. */
  91830. ind: number;
  91831. /**
  91832. * Length of the particle shape in the "indices" array
  91833. */
  91834. indicesLength: number;
  91835. /**
  91836. * Squared distance from the particle to the camera
  91837. */
  91838. sqDistance: number;
  91839. }
  91840. }
  91841. declare module BABYLON {
  91842. /**
  91843. * @hidden
  91844. */
  91845. export class _MeshCollisionData {
  91846. _checkCollisions: boolean;
  91847. _collisionMask: number;
  91848. _collisionGroup: number;
  91849. _collider: Nullable<Collider>;
  91850. _oldPositionForCollisions: Vector3;
  91851. _diffPositionForCollisions: Vector3;
  91852. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91853. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91854. }
  91855. }
  91856. declare module BABYLON {
  91857. /** @hidden */
  91858. class _FacetDataStorage {
  91859. facetPositions: Vector3[];
  91860. facetNormals: Vector3[];
  91861. facetPartitioning: number[][];
  91862. facetNb: number;
  91863. partitioningSubdivisions: number;
  91864. partitioningBBoxRatio: number;
  91865. facetDataEnabled: boolean;
  91866. facetParameters: any;
  91867. bbSize: Vector3;
  91868. subDiv: {
  91869. max: number;
  91870. X: number;
  91871. Y: number;
  91872. Z: number;
  91873. };
  91874. facetDepthSort: boolean;
  91875. facetDepthSortEnabled: boolean;
  91876. depthSortedIndices: IndicesArray;
  91877. depthSortedFacets: {
  91878. ind: number;
  91879. sqDistance: number;
  91880. }[];
  91881. facetDepthSortFunction: (f1: {
  91882. ind: number;
  91883. sqDistance: number;
  91884. }, f2: {
  91885. ind: number;
  91886. sqDistance: number;
  91887. }) => number;
  91888. facetDepthSortFrom: Vector3;
  91889. facetDepthSortOrigin: Vector3;
  91890. invertedMatrix: Matrix;
  91891. }
  91892. /**
  91893. * @hidden
  91894. **/
  91895. class _InternalAbstractMeshDataInfo {
  91896. _hasVertexAlpha: boolean;
  91897. _useVertexColors: boolean;
  91898. _numBoneInfluencers: number;
  91899. _applyFog: boolean;
  91900. _receiveShadows: boolean;
  91901. _facetData: _FacetDataStorage;
  91902. _visibility: number;
  91903. _skeleton: Nullable<Skeleton>;
  91904. _layerMask: number;
  91905. _computeBonesUsingShaders: boolean;
  91906. _isActive: boolean;
  91907. _onlyForInstances: boolean;
  91908. _isActiveIntermediate: boolean;
  91909. _onlyForInstancesIntermediate: boolean;
  91910. }
  91911. /**
  91912. * Class used to store all common mesh properties
  91913. */
  91914. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91915. /** No occlusion */
  91916. static OCCLUSION_TYPE_NONE: number;
  91917. /** Occlusion set to optimisitic */
  91918. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91919. /** Occlusion set to strict */
  91920. static OCCLUSION_TYPE_STRICT: number;
  91921. /** Use an accurante occlusion algorithm */
  91922. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91923. /** Use a conservative occlusion algorithm */
  91924. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91925. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91926. * Test order :
  91927. * Is the bounding sphere outside the frustum ?
  91928. * If not, are the bounding box vertices outside the frustum ?
  91929. * It not, then the cullable object is in the frustum.
  91930. */
  91931. static readonly CULLINGSTRATEGY_STANDARD: number;
  91932. /** Culling strategy : Bounding Sphere Only.
  91933. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91934. * It's also less accurate than the standard because some not visible objects can still be selected.
  91935. * Test : is the bounding sphere outside the frustum ?
  91936. * If not, then the cullable object is in the frustum.
  91937. */
  91938. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91939. /** Culling strategy : Optimistic Inclusion.
  91940. * This in an inclusion test first, then the standard exclusion test.
  91941. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91942. * 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.
  91943. * Anyway, it's as accurate as the standard strategy.
  91944. * Test :
  91945. * Is the cullable object bounding sphere center in the frustum ?
  91946. * If not, apply the default culling strategy.
  91947. */
  91948. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91949. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91950. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91951. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91952. * 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.
  91953. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91954. * Test :
  91955. * Is the cullable object bounding sphere center in the frustum ?
  91956. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91957. */
  91958. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91959. /**
  91960. * No billboard
  91961. */
  91962. static readonly BILLBOARDMODE_NONE: number;
  91963. /** Billboard on X axis */
  91964. static readonly BILLBOARDMODE_X: number;
  91965. /** Billboard on Y axis */
  91966. static readonly BILLBOARDMODE_Y: number;
  91967. /** Billboard on Z axis */
  91968. static readonly BILLBOARDMODE_Z: number;
  91969. /** Billboard on all axes */
  91970. static readonly BILLBOARDMODE_ALL: number;
  91971. /** Billboard on using position instead of orientation */
  91972. static readonly BILLBOARDMODE_USE_POSITION: number;
  91973. /** @hidden */
  91974. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91975. /**
  91976. * The culling strategy to use to check whether the mesh must be rendered or not.
  91977. * This value can be changed at any time and will be used on the next render mesh selection.
  91978. * The possible values are :
  91979. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91980. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91981. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91982. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91983. * Please read each static variable documentation to get details about the culling process.
  91984. * */
  91985. cullingStrategy: number;
  91986. /**
  91987. * Gets the number of facets in the mesh
  91988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91989. */
  91990. readonly facetNb: number;
  91991. /**
  91992. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91994. */
  91995. partitioningSubdivisions: number;
  91996. /**
  91997. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91998. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92000. */
  92001. partitioningBBoxRatio: number;
  92002. /**
  92003. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92004. * Works only for updatable meshes.
  92005. * Doesn't work with multi-materials
  92006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92007. */
  92008. mustDepthSortFacets: boolean;
  92009. /**
  92010. * The location (Vector3) where the facet depth sort must be computed from.
  92011. * By default, the active camera position.
  92012. * Used only when facet depth sort is enabled
  92013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92014. */
  92015. facetDepthSortFrom: Vector3;
  92016. /**
  92017. * gets a boolean indicating if facetData is enabled
  92018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92019. */
  92020. readonly isFacetDataEnabled: boolean;
  92021. /** @hidden */
  92022. _updateNonUniformScalingState(value: boolean): boolean;
  92023. /**
  92024. * An event triggered when this mesh collides with another one
  92025. */
  92026. onCollideObservable: Observable<AbstractMesh>;
  92027. /** Set a function to call when this mesh collides with another one */
  92028. onCollide: () => void;
  92029. /**
  92030. * An event triggered when the collision's position changes
  92031. */
  92032. onCollisionPositionChangeObservable: Observable<Vector3>;
  92033. /** Set a function to call when the collision's position changes */
  92034. onCollisionPositionChange: () => void;
  92035. /**
  92036. * An event triggered when material is changed
  92037. */
  92038. onMaterialChangedObservable: Observable<AbstractMesh>;
  92039. /**
  92040. * Gets or sets the orientation for POV movement & rotation
  92041. */
  92042. definedFacingForward: boolean;
  92043. /** @hidden */
  92044. _occlusionQuery: Nullable<WebGLQuery>;
  92045. /** @hidden */
  92046. _renderingGroup: Nullable<RenderingGroup>;
  92047. /**
  92048. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92049. */
  92050. /**
  92051. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92052. */
  92053. visibility: number;
  92054. /** Gets or sets the alpha index used to sort transparent meshes
  92055. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92056. */
  92057. alphaIndex: number;
  92058. /**
  92059. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92060. */
  92061. isVisible: boolean;
  92062. /**
  92063. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92064. */
  92065. isPickable: boolean;
  92066. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92067. showSubMeshesBoundingBox: boolean;
  92068. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92069. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92070. */
  92071. isBlocker: boolean;
  92072. /**
  92073. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92074. */
  92075. enablePointerMoveEvents: boolean;
  92076. /**
  92077. * Specifies the rendering group id for this mesh (0 by default)
  92078. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92079. */
  92080. renderingGroupId: number;
  92081. private _material;
  92082. /** Gets or sets current material */
  92083. material: Nullable<Material>;
  92084. /**
  92085. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92086. * @see http://doc.babylonjs.com/babylon101/shadows
  92087. */
  92088. receiveShadows: boolean;
  92089. /** Defines color to use when rendering outline */
  92090. outlineColor: Color3;
  92091. /** Define width to use when rendering outline */
  92092. outlineWidth: number;
  92093. /** Defines color to use when rendering overlay */
  92094. overlayColor: Color3;
  92095. /** Defines alpha to use when rendering overlay */
  92096. overlayAlpha: number;
  92097. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92098. hasVertexAlpha: boolean;
  92099. /** 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) */
  92100. useVertexColors: boolean;
  92101. /**
  92102. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92103. */
  92104. computeBonesUsingShaders: boolean;
  92105. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92106. numBoneInfluencers: number;
  92107. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92108. applyFog: boolean;
  92109. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92110. useOctreeForRenderingSelection: boolean;
  92111. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92112. useOctreeForPicking: boolean;
  92113. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92114. useOctreeForCollisions: boolean;
  92115. /**
  92116. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92117. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92118. */
  92119. layerMask: number;
  92120. /**
  92121. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92122. */
  92123. alwaysSelectAsActiveMesh: boolean;
  92124. /**
  92125. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92126. */
  92127. doNotSyncBoundingInfo: boolean;
  92128. /**
  92129. * Gets or sets the current action manager
  92130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92131. */
  92132. actionManager: Nullable<AbstractActionManager>;
  92133. private _meshCollisionData;
  92134. /**
  92135. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92136. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92137. */
  92138. ellipsoid: Vector3;
  92139. /**
  92140. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92141. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92142. */
  92143. ellipsoidOffset: Vector3;
  92144. /**
  92145. * Gets or sets a collision mask used to mask collisions (default is -1).
  92146. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92147. */
  92148. collisionMask: number;
  92149. /**
  92150. * Gets or sets the current collision group mask (-1 by default).
  92151. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92152. */
  92153. collisionGroup: number;
  92154. /**
  92155. * Defines edge width used when edgesRenderer is enabled
  92156. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92157. */
  92158. edgesWidth: number;
  92159. /**
  92160. * Defines edge color used when edgesRenderer is enabled
  92161. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92162. */
  92163. edgesColor: Color4;
  92164. /** @hidden */
  92165. _edgesRenderer: Nullable<IEdgesRenderer>;
  92166. /** @hidden */
  92167. _masterMesh: Nullable<AbstractMesh>;
  92168. /** @hidden */
  92169. _boundingInfo: Nullable<BoundingInfo>;
  92170. /** @hidden */
  92171. _renderId: number;
  92172. /**
  92173. * Gets or sets the list of subMeshes
  92174. * @see http://doc.babylonjs.com/how_to/multi_materials
  92175. */
  92176. subMeshes: SubMesh[];
  92177. /** @hidden */
  92178. _intersectionsInProgress: AbstractMesh[];
  92179. /** @hidden */
  92180. _unIndexed: boolean;
  92181. /** @hidden */
  92182. _lightSources: Light[];
  92183. /** Gets the list of lights affecting that mesh */
  92184. readonly lightSources: Light[];
  92185. /** @hidden */
  92186. readonly _positions: Nullable<Vector3[]>;
  92187. /** @hidden */
  92188. _waitingData: {
  92189. lods: Nullable<any>;
  92190. actions: Nullable<any>;
  92191. freezeWorldMatrix: Nullable<boolean>;
  92192. };
  92193. /** @hidden */
  92194. _bonesTransformMatrices: Nullable<Float32Array>;
  92195. /** @hidden */
  92196. _transformMatrixTexture: Nullable<RawTexture>;
  92197. /**
  92198. * Gets or sets a skeleton to apply skining transformations
  92199. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92200. */
  92201. skeleton: Nullable<Skeleton>;
  92202. /**
  92203. * An event triggered when the mesh is rebuilt.
  92204. */
  92205. onRebuildObservable: Observable<AbstractMesh>;
  92206. /**
  92207. * Creates a new AbstractMesh
  92208. * @param name defines the name of the mesh
  92209. * @param scene defines the hosting scene
  92210. */
  92211. constructor(name: string, scene?: Nullable<Scene>);
  92212. /**
  92213. * Returns the string "AbstractMesh"
  92214. * @returns "AbstractMesh"
  92215. */
  92216. getClassName(): string;
  92217. /**
  92218. * Gets a string representation of the current mesh
  92219. * @param fullDetails defines a boolean indicating if full details must be included
  92220. * @returns a string representation of the current mesh
  92221. */
  92222. toString(fullDetails?: boolean): string;
  92223. /**
  92224. * @hidden
  92225. */
  92226. protected _getEffectiveParent(): Nullable<Node>;
  92227. /** @hidden */
  92228. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92229. /** @hidden */
  92230. _rebuild(): void;
  92231. /** @hidden */
  92232. _resyncLightSources(): void;
  92233. /** @hidden */
  92234. _resyncLighSource(light: Light): void;
  92235. /** @hidden */
  92236. _unBindEffect(): void;
  92237. /** @hidden */
  92238. _removeLightSource(light: Light, dispose: boolean): void;
  92239. private _markSubMeshesAsDirty;
  92240. /** @hidden */
  92241. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92242. /** @hidden */
  92243. _markSubMeshesAsAttributesDirty(): void;
  92244. /** @hidden */
  92245. _markSubMeshesAsMiscDirty(): void;
  92246. /**
  92247. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92248. */
  92249. scaling: Vector3;
  92250. /**
  92251. * Returns true if the mesh is blocked. Implemented by child classes
  92252. */
  92253. readonly isBlocked: boolean;
  92254. /**
  92255. * Returns the mesh itself by default. Implemented by child classes
  92256. * @param camera defines the camera to use to pick the right LOD level
  92257. * @returns the currentAbstractMesh
  92258. */
  92259. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92260. /**
  92261. * Returns 0 by default. Implemented by child classes
  92262. * @returns an integer
  92263. */
  92264. getTotalVertices(): number;
  92265. /**
  92266. * Returns a positive integer : the total number of indices in this mesh geometry.
  92267. * @returns the numner of indices or zero if the mesh has no geometry.
  92268. */
  92269. getTotalIndices(): number;
  92270. /**
  92271. * Returns null by default. Implemented by child classes
  92272. * @returns null
  92273. */
  92274. getIndices(): Nullable<IndicesArray>;
  92275. /**
  92276. * Returns the array of the requested vertex data kind. Implemented by child classes
  92277. * @param kind defines the vertex data kind to use
  92278. * @returns null
  92279. */
  92280. getVerticesData(kind: string): Nullable<FloatArray>;
  92281. /**
  92282. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92283. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92284. * Note that a new underlying VertexBuffer object is created each call.
  92285. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92286. * @param kind defines vertex data kind:
  92287. * * VertexBuffer.PositionKind
  92288. * * VertexBuffer.UVKind
  92289. * * VertexBuffer.UV2Kind
  92290. * * VertexBuffer.UV3Kind
  92291. * * VertexBuffer.UV4Kind
  92292. * * VertexBuffer.UV5Kind
  92293. * * VertexBuffer.UV6Kind
  92294. * * VertexBuffer.ColorKind
  92295. * * VertexBuffer.MatricesIndicesKind
  92296. * * VertexBuffer.MatricesIndicesExtraKind
  92297. * * VertexBuffer.MatricesWeightsKind
  92298. * * VertexBuffer.MatricesWeightsExtraKind
  92299. * @param data defines the data source
  92300. * @param updatable defines if the data must be flagged as updatable (or static)
  92301. * @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
  92302. * @returns the current mesh
  92303. */
  92304. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92305. /**
  92306. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92307. * If the mesh has no geometry, it is simply returned as it is.
  92308. * @param kind defines vertex data kind:
  92309. * * VertexBuffer.PositionKind
  92310. * * VertexBuffer.UVKind
  92311. * * VertexBuffer.UV2Kind
  92312. * * VertexBuffer.UV3Kind
  92313. * * VertexBuffer.UV4Kind
  92314. * * VertexBuffer.UV5Kind
  92315. * * VertexBuffer.UV6Kind
  92316. * * VertexBuffer.ColorKind
  92317. * * VertexBuffer.MatricesIndicesKind
  92318. * * VertexBuffer.MatricesIndicesExtraKind
  92319. * * VertexBuffer.MatricesWeightsKind
  92320. * * VertexBuffer.MatricesWeightsExtraKind
  92321. * @param data defines the data source
  92322. * @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
  92323. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92324. * @returns the current mesh
  92325. */
  92326. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92327. /**
  92328. * Sets the mesh indices,
  92329. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92330. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92331. * @param totalVertices Defines the total number of vertices
  92332. * @returns the current mesh
  92333. */
  92334. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92335. /**
  92336. * Gets a boolean indicating if specific vertex data is present
  92337. * @param kind defines the vertex data kind to use
  92338. * @returns true is data kind is present
  92339. */
  92340. isVerticesDataPresent(kind: string): boolean;
  92341. /**
  92342. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92343. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92344. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92345. * @returns a BoundingInfo
  92346. */
  92347. getBoundingInfo(): BoundingInfo;
  92348. /**
  92349. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92350. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92351. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92352. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92353. * @returns the current mesh
  92354. */
  92355. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92356. /**
  92357. * Overwrite the current bounding info
  92358. * @param boundingInfo defines the new bounding info
  92359. * @returns the current mesh
  92360. */
  92361. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  92362. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  92363. readonly useBones: boolean;
  92364. /** @hidden */
  92365. _preActivate(): void;
  92366. /** @hidden */
  92367. _preActivateForIntermediateRendering(renderId: number): void;
  92368. /** @hidden */
  92369. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92370. /** @hidden */
  92371. _postActivate(): void;
  92372. /** @hidden */
  92373. _freeze(): void;
  92374. /** @hidden */
  92375. _unFreeze(): void;
  92376. /**
  92377. * Gets the current world matrix
  92378. * @returns a Matrix
  92379. */
  92380. getWorldMatrix(): Matrix;
  92381. /** @hidden */
  92382. _getWorldMatrixDeterminant(): number;
  92383. /**
  92384. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  92385. */
  92386. readonly isAnInstance: boolean;
  92387. /**
  92388. * Gets a boolean indicating if this mesh has instances
  92389. */
  92390. readonly hasInstances: boolean;
  92391. /**
  92392. * Perform relative position change from the point of view of behind the front of the mesh.
  92393. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92394. * Supports definition of mesh facing forward or backward
  92395. * @param amountRight defines the distance on the right axis
  92396. * @param amountUp defines the distance on the up axis
  92397. * @param amountForward defines the distance on the forward axis
  92398. * @returns the current mesh
  92399. */
  92400. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  92401. /**
  92402. * Calculate relative position change from the point of view of behind the front of the mesh.
  92403. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92404. * Supports definition of mesh facing forward or backward
  92405. * @param amountRight defines the distance on the right axis
  92406. * @param amountUp defines the distance on the up axis
  92407. * @param amountForward defines the distance on the forward axis
  92408. * @returns the new displacement vector
  92409. */
  92410. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92411. /**
  92412. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92413. * Supports definition of mesh facing forward or backward
  92414. * @param flipBack defines the flip
  92415. * @param twirlClockwise defines the twirl
  92416. * @param tiltRight defines the tilt
  92417. * @returns the current mesh
  92418. */
  92419. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92420. /**
  92421. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92422. * Supports definition of mesh facing forward or backward.
  92423. * @param flipBack defines the flip
  92424. * @param twirlClockwise defines the twirl
  92425. * @param tiltRight defines the tilt
  92426. * @returns the new rotation vector
  92427. */
  92428. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92429. /**
  92430. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92431. * This means the mesh underlying bounding box and sphere are recomputed.
  92432. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92433. * @returns the current mesh
  92434. */
  92435. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92436. /** @hidden */
  92437. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92438. /** @hidden */
  92439. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92440. /** @hidden */
  92441. _updateBoundingInfo(): AbstractMesh;
  92442. /** @hidden */
  92443. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92444. /** @hidden */
  92445. protected _afterComputeWorldMatrix(): void;
  92446. /** @hidden */
  92447. readonly _effectiveMesh: AbstractMesh;
  92448. /**
  92449. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92450. * A mesh is in the frustum if its bounding box intersects the frustum
  92451. * @param frustumPlanes defines the frustum to test
  92452. * @returns true if the mesh is in the frustum planes
  92453. */
  92454. isInFrustum(frustumPlanes: Plane[]): boolean;
  92455. /**
  92456. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92457. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92458. * @param frustumPlanes defines the frustum to test
  92459. * @returns true if the mesh is completely in the frustum planes
  92460. */
  92461. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92462. /**
  92463. * True if the mesh intersects another mesh or a SolidParticle object
  92464. * @param mesh defines a target mesh or SolidParticle to test
  92465. * @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)
  92466. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92467. * @returns true if there is an intersection
  92468. */
  92469. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92470. /**
  92471. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92472. * @param point defines the point to test
  92473. * @returns true if there is an intersection
  92474. */
  92475. intersectsPoint(point: Vector3): boolean;
  92476. /**
  92477. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92478. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92479. */
  92480. checkCollisions: boolean;
  92481. /**
  92482. * Gets Collider object used to compute collisions (not physics)
  92483. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92484. */
  92485. readonly collider: Nullable<Collider>;
  92486. /**
  92487. * Move the mesh using collision engine
  92488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92489. * @param displacement defines the requested displacement vector
  92490. * @returns the current mesh
  92491. */
  92492. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92493. private _onCollisionPositionChange;
  92494. /** @hidden */
  92495. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92496. /** @hidden */
  92497. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92498. /** @hidden */
  92499. _checkCollision(collider: Collider): AbstractMesh;
  92500. /** @hidden */
  92501. _generatePointsArray(): boolean;
  92502. /**
  92503. * Checks if the passed Ray intersects with the mesh
  92504. * @param ray defines the ray to use
  92505. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92506. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92507. * @returns the picking info
  92508. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92509. */
  92510. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92511. /**
  92512. * Clones the current mesh
  92513. * @param name defines the mesh name
  92514. * @param newParent defines the new mesh parent
  92515. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92516. * @returns the new mesh
  92517. */
  92518. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92519. /**
  92520. * Disposes all the submeshes of the current meshnp
  92521. * @returns the current mesh
  92522. */
  92523. releaseSubMeshes(): AbstractMesh;
  92524. /**
  92525. * Releases resources associated with this abstract mesh.
  92526. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92527. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92528. */
  92529. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92530. /**
  92531. * Adds the passed mesh as a child to the current mesh
  92532. * @param mesh defines the child mesh
  92533. * @returns the current mesh
  92534. */
  92535. addChild(mesh: AbstractMesh): AbstractMesh;
  92536. /**
  92537. * Removes the passed mesh from the current mesh children list
  92538. * @param mesh defines the child mesh
  92539. * @returns the current mesh
  92540. */
  92541. removeChild(mesh: AbstractMesh): AbstractMesh;
  92542. /** @hidden */
  92543. private _initFacetData;
  92544. /**
  92545. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92546. * This method can be called within the render loop.
  92547. * 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
  92548. * @returns the current mesh
  92549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92550. */
  92551. updateFacetData(): AbstractMesh;
  92552. /**
  92553. * Returns the facetLocalNormals array.
  92554. * The normals are expressed in the mesh local spac
  92555. * @returns an array of Vector3
  92556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92557. */
  92558. getFacetLocalNormals(): Vector3[];
  92559. /**
  92560. * Returns the facetLocalPositions array.
  92561. * The facet positions are expressed in the mesh local space
  92562. * @returns an array of Vector3
  92563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92564. */
  92565. getFacetLocalPositions(): Vector3[];
  92566. /**
  92567. * Returns the facetLocalPartioning array
  92568. * @returns an array of array of numbers
  92569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92570. */
  92571. getFacetLocalPartitioning(): number[][];
  92572. /**
  92573. * Returns the i-th facet position in the world system.
  92574. * This method allocates a new Vector3 per call
  92575. * @param i defines the facet index
  92576. * @returns a new Vector3
  92577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92578. */
  92579. getFacetPosition(i: number): Vector3;
  92580. /**
  92581. * Sets the reference Vector3 with the i-th facet position in the world system
  92582. * @param i defines the facet index
  92583. * @param ref defines the target vector
  92584. * @returns the current mesh
  92585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92586. */
  92587. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92588. /**
  92589. * Returns the i-th facet normal in the world system.
  92590. * This method allocates a new Vector3 per call
  92591. * @param i defines the facet index
  92592. * @returns a new Vector3
  92593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92594. */
  92595. getFacetNormal(i: number): Vector3;
  92596. /**
  92597. * Sets the reference Vector3 with the i-th facet normal in the world system
  92598. * @param i defines the facet index
  92599. * @param ref defines the target vector
  92600. * @returns the current mesh
  92601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92602. */
  92603. getFacetNormalToRef(i: number, ref: Vector3): this;
  92604. /**
  92605. * 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)
  92606. * @param x defines x coordinate
  92607. * @param y defines y coordinate
  92608. * @param z defines z coordinate
  92609. * @returns the array of facet indexes
  92610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92611. */
  92612. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92613. /**
  92614. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92615. * @param projected sets as the (x,y,z) world projection on the facet
  92616. * @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
  92617. * @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
  92618. * @param x defines x coordinate
  92619. * @param y defines y coordinate
  92620. * @param z defines z coordinate
  92621. * @returns the face index if found (or null instead)
  92622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92623. */
  92624. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92625. /**
  92626. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92627. * @param projected sets as the (x,y,z) local projection on the facet
  92628. * @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
  92629. * @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
  92630. * @param x defines x coordinate
  92631. * @param y defines y coordinate
  92632. * @param z defines z coordinate
  92633. * @returns the face index if found (or null instead)
  92634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92635. */
  92636. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92637. /**
  92638. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92639. * @returns the parameters
  92640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92641. */
  92642. getFacetDataParameters(): any;
  92643. /**
  92644. * Disables the feature FacetData and frees the related memory
  92645. * @returns the current mesh
  92646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92647. */
  92648. disableFacetData(): AbstractMesh;
  92649. /**
  92650. * Updates the AbstractMesh indices array
  92651. * @param indices defines the data source
  92652. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92653. * @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)
  92654. * @returns the current mesh
  92655. */
  92656. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92657. /**
  92658. * Creates new normals data for the mesh
  92659. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92660. * @returns the current mesh
  92661. */
  92662. createNormals(updatable: boolean): AbstractMesh;
  92663. /**
  92664. * Align the mesh with a normal
  92665. * @param normal defines the normal to use
  92666. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92667. * @returns the current mesh
  92668. */
  92669. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92670. /** @hidden */
  92671. _checkOcclusionQuery(): boolean;
  92672. /**
  92673. * Disables the mesh edge rendering mode
  92674. * @returns the currentAbstractMesh
  92675. */
  92676. disableEdgesRendering(): AbstractMesh;
  92677. /**
  92678. * Enables the edge rendering mode on the mesh.
  92679. * This mode makes the mesh edges visible
  92680. * @param epsilon defines the maximal distance between two angles to detect a face
  92681. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92682. * @returns the currentAbstractMesh
  92683. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92684. */
  92685. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92686. }
  92687. }
  92688. declare module BABYLON {
  92689. /**
  92690. * Interface used to define ActionEvent
  92691. */
  92692. export interface IActionEvent {
  92693. /** The mesh or sprite that triggered the action */
  92694. source: any;
  92695. /** The X mouse cursor position at the time of the event */
  92696. pointerX: number;
  92697. /** The Y mouse cursor position at the time of the event */
  92698. pointerY: number;
  92699. /** The mesh that is currently pointed at (can be null) */
  92700. meshUnderPointer: Nullable<AbstractMesh>;
  92701. /** the original (browser) event that triggered the ActionEvent */
  92702. sourceEvent?: any;
  92703. /** additional data for the event */
  92704. additionalData?: any;
  92705. }
  92706. /**
  92707. * ActionEvent is the event being sent when an action is triggered.
  92708. */
  92709. export class ActionEvent implements IActionEvent {
  92710. /** The mesh or sprite that triggered the action */
  92711. source: any;
  92712. /** The X mouse cursor position at the time of the event */
  92713. pointerX: number;
  92714. /** The Y mouse cursor position at the time of the event */
  92715. pointerY: number;
  92716. /** The mesh that is currently pointed at (can be null) */
  92717. meshUnderPointer: Nullable<AbstractMesh>;
  92718. /** the original (browser) event that triggered the ActionEvent */
  92719. sourceEvent?: any;
  92720. /** additional data for the event */
  92721. additionalData?: any;
  92722. /**
  92723. * Creates a new ActionEvent
  92724. * @param source The mesh or sprite that triggered the action
  92725. * @param pointerX The X mouse cursor position at the time of the event
  92726. * @param pointerY The Y mouse cursor position at the time of the event
  92727. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92728. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92729. * @param additionalData additional data for the event
  92730. */
  92731. constructor(
  92732. /** The mesh or sprite that triggered the action */
  92733. source: any,
  92734. /** The X mouse cursor position at the time of the event */
  92735. pointerX: number,
  92736. /** The Y mouse cursor position at the time of the event */
  92737. pointerY: number,
  92738. /** The mesh that is currently pointed at (can be null) */
  92739. meshUnderPointer: Nullable<AbstractMesh>,
  92740. /** the original (browser) event that triggered the ActionEvent */
  92741. sourceEvent?: any,
  92742. /** additional data for the event */
  92743. additionalData?: any);
  92744. /**
  92745. * Helper function to auto-create an ActionEvent from a source mesh.
  92746. * @param source The source mesh that triggered the event
  92747. * @param evt The original (browser) event
  92748. * @param additionalData additional data for the event
  92749. * @returns the new ActionEvent
  92750. */
  92751. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92752. /**
  92753. * Helper function to auto-create an ActionEvent from a source sprite
  92754. * @param source The source sprite that triggered the event
  92755. * @param scene Scene associated with the sprite
  92756. * @param evt The original (browser) event
  92757. * @param additionalData additional data for the event
  92758. * @returns the new ActionEvent
  92759. */
  92760. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92761. /**
  92762. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92763. * @param scene the scene where the event occurred
  92764. * @param evt The original (browser) event
  92765. * @returns the new ActionEvent
  92766. */
  92767. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92768. /**
  92769. * Helper function to auto-create an ActionEvent from a primitive
  92770. * @param prim defines the target primitive
  92771. * @param pointerPos defines the pointer position
  92772. * @param evt The original (browser) event
  92773. * @param additionalData additional data for the event
  92774. * @returns the new ActionEvent
  92775. */
  92776. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92777. }
  92778. }
  92779. declare module BABYLON {
  92780. /**
  92781. * Abstract class used to decouple action Manager from scene and meshes.
  92782. * Do not instantiate.
  92783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92784. */
  92785. export abstract class AbstractActionManager implements IDisposable {
  92786. /** Gets the list of active triggers */
  92787. static Triggers: {
  92788. [key: string]: number;
  92789. };
  92790. /** Gets the cursor to use when hovering items */
  92791. hoverCursor: string;
  92792. /** Gets the list of actions */
  92793. actions: IAction[];
  92794. /**
  92795. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92796. */
  92797. isRecursive: boolean;
  92798. /**
  92799. * Releases all associated resources
  92800. */
  92801. abstract dispose(): void;
  92802. /**
  92803. * Does this action manager has pointer triggers
  92804. */
  92805. abstract readonly hasPointerTriggers: boolean;
  92806. /**
  92807. * Does this action manager has pick triggers
  92808. */
  92809. abstract readonly hasPickTriggers: boolean;
  92810. /**
  92811. * Process a specific trigger
  92812. * @param trigger defines the trigger to process
  92813. * @param evt defines the event details to be processed
  92814. */
  92815. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92816. /**
  92817. * Does this action manager handles actions of any of the given triggers
  92818. * @param triggers defines the triggers to be tested
  92819. * @return a boolean indicating whether one (or more) of the triggers is handled
  92820. */
  92821. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92822. /**
  92823. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92824. * speed.
  92825. * @param triggerA defines the trigger to be tested
  92826. * @param triggerB defines the trigger to be tested
  92827. * @return a boolean indicating whether one (or more) of the triggers is handled
  92828. */
  92829. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92830. /**
  92831. * Does this action manager handles actions of a given trigger
  92832. * @param trigger defines the trigger to be tested
  92833. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92834. * @return whether the trigger is handled
  92835. */
  92836. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92837. /**
  92838. * Serialize this manager to a JSON object
  92839. * @param name defines the property name to store this manager
  92840. * @returns a JSON representation of this manager
  92841. */
  92842. abstract serialize(name: string): any;
  92843. /**
  92844. * Registers an action to this action manager
  92845. * @param action defines the action to be registered
  92846. * @return the action amended (prepared) after registration
  92847. */
  92848. abstract registerAction(action: IAction): Nullable<IAction>;
  92849. /**
  92850. * Unregisters an action to this action manager
  92851. * @param action defines the action to be unregistered
  92852. * @return a boolean indicating whether the action has been unregistered
  92853. */
  92854. abstract unregisterAction(action: IAction): Boolean;
  92855. /**
  92856. * Does exist one action manager with at least one trigger
  92857. **/
  92858. static readonly HasTriggers: boolean;
  92859. /**
  92860. * Does exist one action manager with at least one pick trigger
  92861. **/
  92862. static readonly HasPickTriggers: boolean;
  92863. /**
  92864. * Does exist one action manager that handles actions of a given trigger
  92865. * @param trigger defines the trigger to be tested
  92866. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92867. **/
  92868. static HasSpecificTrigger(trigger: number): boolean;
  92869. }
  92870. }
  92871. declare module BABYLON {
  92872. /**
  92873. * Defines how a node can be built from a string name.
  92874. */
  92875. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92876. /**
  92877. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92878. */
  92879. export class Node implements IBehaviorAware<Node> {
  92880. /** @hidden */
  92881. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92882. private static _NodeConstructors;
  92883. /**
  92884. * Add a new node constructor
  92885. * @param type defines the type name of the node to construct
  92886. * @param constructorFunc defines the constructor function
  92887. */
  92888. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92889. /**
  92890. * Returns a node constructor based on type name
  92891. * @param type defines the type name
  92892. * @param name defines the new node name
  92893. * @param scene defines the hosting scene
  92894. * @param options defines optional options to transmit to constructors
  92895. * @returns the new constructor or null
  92896. */
  92897. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92898. /**
  92899. * Gets or sets the name of the node
  92900. */
  92901. name: string;
  92902. /**
  92903. * Gets or sets the id of the node
  92904. */
  92905. id: string;
  92906. /**
  92907. * Gets or sets the unique id of the node
  92908. */
  92909. uniqueId: number;
  92910. /**
  92911. * Gets or sets a string used to store user defined state for the node
  92912. */
  92913. state: string;
  92914. /**
  92915. * Gets or sets an object used to store user defined information for the node
  92916. */
  92917. metadata: any;
  92918. /**
  92919. * For internal use only. Please do not use.
  92920. */
  92921. reservedDataStore: any;
  92922. /**
  92923. * List of inspectable custom properties (used by the Inspector)
  92924. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92925. */
  92926. inspectableCustomProperties: IInspectable[];
  92927. /**
  92928. * Gets or sets a boolean used to define if the node must be serialized
  92929. */
  92930. doNotSerialize: boolean;
  92931. /** @hidden */
  92932. _isDisposed: boolean;
  92933. /**
  92934. * Gets a list of Animations associated with the node
  92935. */
  92936. animations: Animation[];
  92937. protected _ranges: {
  92938. [name: string]: Nullable<AnimationRange>;
  92939. };
  92940. /**
  92941. * Callback raised when the node is ready to be used
  92942. */
  92943. onReady: Nullable<(node: Node) => void>;
  92944. private _isEnabled;
  92945. private _isParentEnabled;
  92946. private _isReady;
  92947. /** @hidden */
  92948. _currentRenderId: number;
  92949. private _parentUpdateId;
  92950. /** @hidden */
  92951. _childUpdateId: number;
  92952. /** @hidden */
  92953. _waitingParentId: Nullable<string>;
  92954. /** @hidden */
  92955. _scene: Scene;
  92956. /** @hidden */
  92957. _cache: any;
  92958. private _parentNode;
  92959. private _children;
  92960. /** @hidden */
  92961. _worldMatrix: Matrix;
  92962. /** @hidden */
  92963. _worldMatrixDeterminant: number;
  92964. /** @hidden */
  92965. _worldMatrixDeterminantIsDirty: boolean;
  92966. /** @hidden */
  92967. private _sceneRootNodesIndex;
  92968. /**
  92969. * Gets a boolean indicating if the node has been disposed
  92970. * @returns true if the node was disposed
  92971. */
  92972. isDisposed(): boolean;
  92973. /**
  92974. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92975. * @see https://doc.babylonjs.com/how_to/parenting
  92976. */
  92977. parent: Nullable<Node>;
  92978. private addToSceneRootNodes;
  92979. private removeFromSceneRootNodes;
  92980. private _animationPropertiesOverride;
  92981. /**
  92982. * Gets or sets the animation properties override
  92983. */
  92984. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92985. /**
  92986. * Gets a string idenfifying the name of the class
  92987. * @returns "Node" string
  92988. */
  92989. getClassName(): string;
  92990. /** @hidden */
  92991. readonly _isNode: boolean;
  92992. /**
  92993. * An event triggered when the mesh is disposed
  92994. */
  92995. onDisposeObservable: Observable<Node>;
  92996. private _onDisposeObserver;
  92997. /**
  92998. * Sets a callback that will be raised when the node will be disposed
  92999. */
  93000. onDispose: () => void;
  93001. /**
  93002. * Creates a new Node
  93003. * @param name the name and id to be given to this node
  93004. * @param scene the scene this node will be added to
  93005. * @param addToRootNodes the node will be added to scene.rootNodes
  93006. */
  93007. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93008. /**
  93009. * Gets the scene of the node
  93010. * @returns a scene
  93011. */
  93012. getScene(): Scene;
  93013. /**
  93014. * Gets the engine of the node
  93015. * @returns a Engine
  93016. */
  93017. getEngine(): Engine;
  93018. private _behaviors;
  93019. /**
  93020. * Attach a behavior to the node
  93021. * @see http://doc.babylonjs.com/features/behaviour
  93022. * @param behavior defines the behavior to attach
  93023. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93024. * @returns the current Node
  93025. */
  93026. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93027. /**
  93028. * Remove an attached behavior
  93029. * @see http://doc.babylonjs.com/features/behaviour
  93030. * @param behavior defines the behavior to attach
  93031. * @returns the current Node
  93032. */
  93033. removeBehavior(behavior: Behavior<Node>): Node;
  93034. /**
  93035. * Gets the list of attached behaviors
  93036. * @see http://doc.babylonjs.com/features/behaviour
  93037. */
  93038. readonly behaviors: Behavior<Node>[];
  93039. /**
  93040. * Gets an attached behavior by name
  93041. * @param name defines the name of the behavior to look for
  93042. * @see http://doc.babylonjs.com/features/behaviour
  93043. * @returns null if behavior was not found else the requested behavior
  93044. */
  93045. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93046. /**
  93047. * Returns the latest update of the World matrix
  93048. * @returns a Matrix
  93049. */
  93050. getWorldMatrix(): Matrix;
  93051. /** @hidden */
  93052. _getWorldMatrixDeterminant(): number;
  93053. /**
  93054. * Returns directly the latest state of the mesh World matrix.
  93055. * A Matrix is returned.
  93056. */
  93057. readonly worldMatrixFromCache: Matrix;
  93058. /** @hidden */
  93059. _initCache(): void;
  93060. /** @hidden */
  93061. updateCache(force?: boolean): void;
  93062. /** @hidden */
  93063. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93064. /** @hidden */
  93065. _updateCache(ignoreParentClass?: boolean): void;
  93066. /** @hidden */
  93067. _isSynchronized(): boolean;
  93068. /** @hidden */
  93069. _markSyncedWithParent(): void;
  93070. /** @hidden */
  93071. isSynchronizedWithParent(): boolean;
  93072. /** @hidden */
  93073. isSynchronized(): boolean;
  93074. /**
  93075. * Is this node ready to be used/rendered
  93076. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93077. * @return true if the node is ready
  93078. */
  93079. isReady(completeCheck?: boolean): boolean;
  93080. /**
  93081. * Is this node enabled?
  93082. * 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
  93083. * @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
  93084. * @return whether this node (and its parent) is enabled
  93085. */
  93086. isEnabled(checkAncestors?: boolean): boolean;
  93087. /** @hidden */
  93088. protected _syncParentEnabledState(): void;
  93089. /**
  93090. * Set the enabled state of this node
  93091. * @param value defines the new enabled state
  93092. */
  93093. setEnabled(value: boolean): void;
  93094. /**
  93095. * Is this node a descendant of the given node?
  93096. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93097. * @param ancestor defines the parent node to inspect
  93098. * @returns a boolean indicating if this node is a descendant of the given node
  93099. */
  93100. isDescendantOf(ancestor: Node): boolean;
  93101. /** @hidden */
  93102. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93103. /**
  93104. * Will return all nodes that have this node as ascendant
  93105. * @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
  93106. * @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
  93107. * @return all children nodes of all types
  93108. */
  93109. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93110. /**
  93111. * Get all child-meshes of this node
  93112. * @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)
  93113. * @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
  93114. * @returns an array of AbstractMesh
  93115. */
  93116. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93117. /**
  93118. * Get all direct children of this node
  93119. * @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
  93120. * @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)
  93121. * @returns an array of Node
  93122. */
  93123. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93124. /** @hidden */
  93125. _setReady(state: boolean): void;
  93126. /**
  93127. * Get an animation by name
  93128. * @param name defines the name of the animation to look for
  93129. * @returns null if not found else the requested animation
  93130. */
  93131. getAnimationByName(name: string): Nullable<Animation>;
  93132. /**
  93133. * Creates an animation range for this node
  93134. * @param name defines the name of the range
  93135. * @param from defines the starting key
  93136. * @param to defines the end key
  93137. */
  93138. createAnimationRange(name: string, from: number, to: number): void;
  93139. /**
  93140. * Delete a specific animation range
  93141. * @param name defines the name of the range to delete
  93142. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93143. */
  93144. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93145. /**
  93146. * Get an animation range by name
  93147. * @param name defines the name of the animation range to look for
  93148. * @returns null if not found else the requested animation range
  93149. */
  93150. getAnimationRange(name: string): Nullable<AnimationRange>;
  93151. /**
  93152. * Gets the list of all animation ranges defined on this node
  93153. * @returns an array
  93154. */
  93155. getAnimationRanges(): Nullable<AnimationRange>[];
  93156. /**
  93157. * Will start the animation sequence
  93158. * @param name defines the range frames for animation sequence
  93159. * @param loop defines if the animation should loop (false by default)
  93160. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93161. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93162. * @returns the object created for this animation. If range does not exist, it will return null
  93163. */
  93164. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93165. /**
  93166. * Serialize animation ranges into a JSON compatible object
  93167. * @returns serialization object
  93168. */
  93169. serializeAnimationRanges(): any;
  93170. /**
  93171. * Computes the world matrix of the node
  93172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93173. * @returns the world matrix
  93174. */
  93175. computeWorldMatrix(force?: boolean): Matrix;
  93176. /**
  93177. * Releases resources associated with this node.
  93178. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93179. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93180. */
  93181. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93182. /**
  93183. * Parse animation range data from a serialization object and store them into a given node
  93184. * @param node defines where to store the animation ranges
  93185. * @param parsedNode defines the serialization object to read data from
  93186. * @param scene defines the hosting scene
  93187. */
  93188. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93189. /**
  93190. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93191. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93192. * @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
  93193. * @returns the new bounding vectors
  93194. */
  93195. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93196. min: Vector3;
  93197. max: Vector3;
  93198. };
  93199. }
  93200. }
  93201. declare module BABYLON {
  93202. /**
  93203. * @hidden
  93204. */
  93205. export class _IAnimationState {
  93206. key: number;
  93207. repeatCount: number;
  93208. workValue?: any;
  93209. loopMode?: number;
  93210. offsetValue?: any;
  93211. highLimitValue?: any;
  93212. }
  93213. /**
  93214. * Class used to store any kind of animation
  93215. */
  93216. export class Animation {
  93217. /**Name of the animation */
  93218. name: string;
  93219. /**Property to animate */
  93220. targetProperty: string;
  93221. /**The frames per second of the animation */
  93222. framePerSecond: number;
  93223. /**The data type of the animation */
  93224. dataType: number;
  93225. /**The loop mode of the animation */
  93226. loopMode?: number | undefined;
  93227. /**Specifies if blending should be enabled */
  93228. enableBlending?: boolean | undefined;
  93229. /**
  93230. * Use matrix interpolation instead of using direct key value when animating matrices
  93231. */
  93232. static AllowMatricesInterpolation: boolean;
  93233. /**
  93234. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93235. */
  93236. static AllowMatrixDecomposeForInterpolation: boolean;
  93237. /**
  93238. * Stores the key frames of the animation
  93239. */
  93240. private _keys;
  93241. /**
  93242. * Stores the easing function of the animation
  93243. */
  93244. private _easingFunction;
  93245. /**
  93246. * @hidden Internal use only
  93247. */
  93248. _runtimeAnimations: RuntimeAnimation[];
  93249. /**
  93250. * The set of event that will be linked to this animation
  93251. */
  93252. private _events;
  93253. /**
  93254. * Stores an array of target property paths
  93255. */
  93256. targetPropertyPath: string[];
  93257. /**
  93258. * Stores the blending speed of the animation
  93259. */
  93260. blendingSpeed: number;
  93261. /**
  93262. * Stores the animation ranges for the animation
  93263. */
  93264. private _ranges;
  93265. /**
  93266. * @hidden Internal use
  93267. */
  93268. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93269. /**
  93270. * Sets up an animation
  93271. * @param property The property to animate
  93272. * @param animationType The animation type to apply
  93273. * @param framePerSecond The frames per second of the animation
  93274. * @param easingFunction The easing function used in the animation
  93275. * @returns The created animation
  93276. */
  93277. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93278. /**
  93279. * Create and start an animation on a node
  93280. * @param name defines the name of the global animation that will be run on all nodes
  93281. * @param node defines the root node where the animation will take place
  93282. * @param targetProperty defines property to animate
  93283. * @param framePerSecond defines the number of frame per second yo use
  93284. * @param totalFrame defines the number of frames in total
  93285. * @param from defines the initial value
  93286. * @param to defines the final value
  93287. * @param loopMode defines which loop mode you want to use (off by default)
  93288. * @param easingFunction defines the easing function to use (linear by default)
  93289. * @param onAnimationEnd defines the callback to call when animation end
  93290. * @returns the animatable created for this animation
  93291. */
  93292. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93293. /**
  93294. * Create and start an animation on a node and its descendants
  93295. * @param name defines the name of the global animation that will be run on all nodes
  93296. * @param node defines the root node where the animation will take place
  93297. * @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
  93298. * @param targetProperty defines property to animate
  93299. * @param framePerSecond defines the number of frame per second to use
  93300. * @param totalFrame defines the number of frames in total
  93301. * @param from defines the initial value
  93302. * @param to defines the final value
  93303. * @param loopMode defines which loop mode you want to use (off by default)
  93304. * @param easingFunction defines the easing function to use (linear by default)
  93305. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93306. * @returns the list of animatables created for all nodes
  93307. * @example https://www.babylonjs-playground.com/#MH0VLI
  93308. */
  93309. 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[]>;
  93310. /**
  93311. * Creates a new animation, merges it with the existing animations and starts it
  93312. * @param name Name of the animation
  93313. * @param node Node which contains the scene that begins the animations
  93314. * @param targetProperty Specifies which property to animate
  93315. * @param framePerSecond The frames per second of the animation
  93316. * @param totalFrame The total number of frames
  93317. * @param from The frame at the beginning of the animation
  93318. * @param to The frame at the end of the animation
  93319. * @param loopMode Specifies the loop mode of the animation
  93320. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93321. * @param onAnimationEnd Callback to run once the animation is complete
  93322. * @returns Nullable animation
  93323. */
  93324. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93325. /**
  93326. * Transition property of an host to the target Value
  93327. * @param property The property to transition
  93328. * @param targetValue The target Value of the property
  93329. * @param host The object where the property to animate belongs
  93330. * @param scene Scene used to run the animation
  93331. * @param frameRate Framerate (in frame/s) to use
  93332. * @param transition The transition type we want to use
  93333. * @param duration The duration of the animation, in milliseconds
  93334. * @param onAnimationEnd Callback trigger at the end of the animation
  93335. * @returns Nullable animation
  93336. */
  93337. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93338. /**
  93339. * Return the array of runtime animations currently using this animation
  93340. */
  93341. readonly runtimeAnimations: RuntimeAnimation[];
  93342. /**
  93343. * Specifies if any of the runtime animations are currently running
  93344. */
  93345. readonly hasRunningRuntimeAnimations: boolean;
  93346. /**
  93347. * Initializes the animation
  93348. * @param name Name of the animation
  93349. * @param targetProperty Property to animate
  93350. * @param framePerSecond The frames per second of the animation
  93351. * @param dataType The data type of the animation
  93352. * @param loopMode The loop mode of the animation
  93353. * @param enableBlending Specifies if blending should be enabled
  93354. */
  93355. constructor(
  93356. /**Name of the animation */
  93357. name: string,
  93358. /**Property to animate */
  93359. targetProperty: string,
  93360. /**The frames per second of the animation */
  93361. framePerSecond: number,
  93362. /**The data type of the animation */
  93363. dataType: number,
  93364. /**The loop mode of the animation */
  93365. loopMode?: number | undefined,
  93366. /**Specifies if blending should be enabled */
  93367. enableBlending?: boolean | undefined);
  93368. /**
  93369. * Converts the animation to a string
  93370. * @param fullDetails support for multiple levels of logging within scene loading
  93371. * @returns String form of the animation
  93372. */
  93373. toString(fullDetails?: boolean): string;
  93374. /**
  93375. * Add an event to this animation
  93376. * @param event Event to add
  93377. */
  93378. addEvent(event: AnimationEvent): void;
  93379. /**
  93380. * Remove all events found at the given frame
  93381. * @param frame The frame to remove events from
  93382. */
  93383. removeEvents(frame: number): void;
  93384. /**
  93385. * Retrieves all the events from the animation
  93386. * @returns Events from the animation
  93387. */
  93388. getEvents(): AnimationEvent[];
  93389. /**
  93390. * Creates an animation range
  93391. * @param name Name of the animation range
  93392. * @param from Starting frame of the animation range
  93393. * @param to Ending frame of the animation
  93394. */
  93395. createRange(name: string, from: number, to: number): void;
  93396. /**
  93397. * Deletes an animation range by name
  93398. * @param name Name of the animation range to delete
  93399. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  93400. */
  93401. deleteRange(name: string, deleteFrames?: boolean): void;
  93402. /**
  93403. * Gets the animation range by name, or null if not defined
  93404. * @param name Name of the animation range
  93405. * @returns Nullable animation range
  93406. */
  93407. getRange(name: string): Nullable<AnimationRange>;
  93408. /**
  93409. * Gets the key frames from the animation
  93410. * @returns The key frames of the animation
  93411. */
  93412. getKeys(): Array<IAnimationKey>;
  93413. /**
  93414. * Gets the highest frame rate of the animation
  93415. * @returns Highest frame rate of the animation
  93416. */
  93417. getHighestFrame(): number;
  93418. /**
  93419. * Gets the easing function of the animation
  93420. * @returns Easing function of the animation
  93421. */
  93422. getEasingFunction(): IEasingFunction;
  93423. /**
  93424. * Sets the easing function of the animation
  93425. * @param easingFunction A custom mathematical formula for animation
  93426. */
  93427. setEasingFunction(easingFunction: EasingFunction): void;
  93428. /**
  93429. * Interpolates a scalar linearly
  93430. * @param startValue Start value of the animation curve
  93431. * @param endValue End value of the animation curve
  93432. * @param gradient Scalar amount to interpolate
  93433. * @returns Interpolated scalar value
  93434. */
  93435. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93436. /**
  93437. * Interpolates a scalar cubically
  93438. * @param startValue Start value of the animation curve
  93439. * @param outTangent End tangent of the animation
  93440. * @param endValue End value of the animation curve
  93441. * @param inTangent Start tangent of the animation curve
  93442. * @param gradient Scalar amount to interpolate
  93443. * @returns Interpolated scalar value
  93444. */
  93445. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93446. /**
  93447. * Interpolates a quaternion using a spherical linear interpolation
  93448. * @param startValue Start value of the animation curve
  93449. * @param endValue End value of the animation curve
  93450. * @param gradient Scalar amount to interpolate
  93451. * @returns Interpolated quaternion value
  93452. */
  93453. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93454. /**
  93455. * Interpolates a quaternion cubically
  93456. * @param startValue Start value of the animation curve
  93457. * @param outTangent End tangent of the animation curve
  93458. * @param endValue End value of the animation curve
  93459. * @param inTangent Start tangent of the animation curve
  93460. * @param gradient Scalar amount to interpolate
  93461. * @returns Interpolated quaternion value
  93462. */
  93463. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93464. /**
  93465. * Interpolates a Vector3 linearl
  93466. * @param startValue Start value of the animation curve
  93467. * @param endValue End value of the animation curve
  93468. * @param gradient Scalar amount to interpolate
  93469. * @returns Interpolated scalar value
  93470. */
  93471. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93472. /**
  93473. * Interpolates a Vector3 cubically
  93474. * @param startValue Start value of the animation curve
  93475. * @param outTangent End tangent of the animation
  93476. * @param endValue End value of the animation curve
  93477. * @param inTangent Start tangent of the animation curve
  93478. * @param gradient Scalar amount to interpolate
  93479. * @returns InterpolatedVector3 value
  93480. */
  93481. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93482. /**
  93483. * Interpolates a Vector2 linearly
  93484. * @param startValue Start value of the animation curve
  93485. * @param endValue End value of the animation curve
  93486. * @param gradient Scalar amount to interpolate
  93487. * @returns Interpolated Vector2 value
  93488. */
  93489. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93490. /**
  93491. * Interpolates a Vector2 cubically
  93492. * @param startValue Start value of the animation curve
  93493. * @param outTangent End tangent of the animation
  93494. * @param endValue End value of the animation curve
  93495. * @param inTangent Start tangent of the animation curve
  93496. * @param gradient Scalar amount to interpolate
  93497. * @returns Interpolated Vector2 value
  93498. */
  93499. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93500. /**
  93501. * Interpolates a size linearly
  93502. * @param startValue Start value of the animation curve
  93503. * @param endValue End value of the animation curve
  93504. * @param gradient Scalar amount to interpolate
  93505. * @returns Interpolated Size value
  93506. */
  93507. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93508. /**
  93509. * Interpolates a Color3 linearly
  93510. * @param startValue Start value of the animation curve
  93511. * @param endValue End value of the animation curve
  93512. * @param gradient Scalar amount to interpolate
  93513. * @returns Interpolated Color3 value
  93514. */
  93515. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93516. /**
  93517. * @hidden Internal use only
  93518. */
  93519. _getKeyValue(value: any): any;
  93520. /**
  93521. * @hidden Internal use only
  93522. */
  93523. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93524. /**
  93525. * Defines the function to use to interpolate matrices
  93526. * @param startValue defines the start matrix
  93527. * @param endValue defines the end matrix
  93528. * @param gradient defines the gradient between both matrices
  93529. * @param result defines an optional target matrix where to store the interpolation
  93530. * @returns the interpolated matrix
  93531. */
  93532. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93533. /**
  93534. * Makes a copy of the animation
  93535. * @returns Cloned animation
  93536. */
  93537. clone(): Animation;
  93538. /**
  93539. * Sets the key frames of the animation
  93540. * @param values The animation key frames to set
  93541. */
  93542. setKeys(values: Array<IAnimationKey>): void;
  93543. /**
  93544. * Serializes the animation to an object
  93545. * @returns Serialized object
  93546. */
  93547. serialize(): any;
  93548. /**
  93549. * Float animation type
  93550. */
  93551. private static _ANIMATIONTYPE_FLOAT;
  93552. /**
  93553. * Vector3 animation type
  93554. */
  93555. private static _ANIMATIONTYPE_VECTOR3;
  93556. /**
  93557. * Quaternion animation type
  93558. */
  93559. private static _ANIMATIONTYPE_QUATERNION;
  93560. /**
  93561. * Matrix animation type
  93562. */
  93563. private static _ANIMATIONTYPE_MATRIX;
  93564. /**
  93565. * Color3 animation type
  93566. */
  93567. private static _ANIMATIONTYPE_COLOR3;
  93568. /**
  93569. * Vector2 animation type
  93570. */
  93571. private static _ANIMATIONTYPE_VECTOR2;
  93572. /**
  93573. * Size animation type
  93574. */
  93575. private static _ANIMATIONTYPE_SIZE;
  93576. /**
  93577. * Relative Loop Mode
  93578. */
  93579. private static _ANIMATIONLOOPMODE_RELATIVE;
  93580. /**
  93581. * Cycle Loop Mode
  93582. */
  93583. private static _ANIMATIONLOOPMODE_CYCLE;
  93584. /**
  93585. * Constant Loop Mode
  93586. */
  93587. private static _ANIMATIONLOOPMODE_CONSTANT;
  93588. /**
  93589. * Get the float animation type
  93590. */
  93591. static readonly ANIMATIONTYPE_FLOAT: number;
  93592. /**
  93593. * Get the Vector3 animation type
  93594. */
  93595. static readonly ANIMATIONTYPE_VECTOR3: number;
  93596. /**
  93597. * Get the Vector2 animation type
  93598. */
  93599. static readonly ANIMATIONTYPE_VECTOR2: number;
  93600. /**
  93601. * Get the Size animation type
  93602. */
  93603. static readonly ANIMATIONTYPE_SIZE: number;
  93604. /**
  93605. * Get the Quaternion animation type
  93606. */
  93607. static readonly ANIMATIONTYPE_QUATERNION: number;
  93608. /**
  93609. * Get the Matrix animation type
  93610. */
  93611. static readonly ANIMATIONTYPE_MATRIX: number;
  93612. /**
  93613. * Get the Color3 animation type
  93614. */
  93615. static readonly ANIMATIONTYPE_COLOR3: number;
  93616. /**
  93617. * Get the Relative Loop Mode
  93618. */
  93619. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93620. /**
  93621. * Get the Cycle Loop Mode
  93622. */
  93623. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93624. /**
  93625. * Get the Constant Loop Mode
  93626. */
  93627. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93628. /** @hidden */
  93629. static _UniversalLerp(left: any, right: any, amount: number): any;
  93630. /**
  93631. * Parses an animation object and creates an animation
  93632. * @param parsedAnimation Parsed animation object
  93633. * @returns Animation object
  93634. */
  93635. static Parse(parsedAnimation: any): Animation;
  93636. /**
  93637. * Appends the serialized animations from the source animations
  93638. * @param source Source containing the animations
  93639. * @param destination Target to store the animations
  93640. */
  93641. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93642. }
  93643. }
  93644. declare module BABYLON {
  93645. /**
  93646. * Interface containing an array of animations
  93647. */
  93648. export interface IAnimatable {
  93649. /**
  93650. * Array of animations
  93651. */
  93652. animations: Nullable<Array<Animation>>;
  93653. }
  93654. }
  93655. declare module BABYLON {
  93656. /**
  93657. * This represents all the required information to add a fresnel effect on a material:
  93658. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93659. */
  93660. export class FresnelParameters {
  93661. private _isEnabled;
  93662. /**
  93663. * Define if the fresnel effect is enable or not.
  93664. */
  93665. isEnabled: boolean;
  93666. /**
  93667. * Define the color used on edges (grazing angle)
  93668. */
  93669. leftColor: Color3;
  93670. /**
  93671. * Define the color used on center
  93672. */
  93673. rightColor: Color3;
  93674. /**
  93675. * Define bias applied to computed fresnel term
  93676. */
  93677. bias: number;
  93678. /**
  93679. * Defined the power exponent applied to fresnel term
  93680. */
  93681. power: number;
  93682. /**
  93683. * Clones the current fresnel and its valuues
  93684. * @returns a clone fresnel configuration
  93685. */
  93686. clone(): FresnelParameters;
  93687. /**
  93688. * Serializes the current fresnel parameters to a JSON representation.
  93689. * @return the JSON serialization
  93690. */
  93691. serialize(): any;
  93692. /**
  93693. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93694. * @param parsedFresnelParameters Define the JSON representation
  93695. * @returns the parsed parameters
  93696. */
  93697. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93698. }
  93699. }
  93700. declare module BABYLON {
  93701. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93702. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93703. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93704. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93705. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93706. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93707. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93708. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93709. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93710. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93711. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93712. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93713. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93714. /**
  93715. * Decorator used to define property that can be serialized as reference to a camera
  93716. * @param sourceName defines the name of the property to decorate
  93717. */
  93718. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93719. /**
  93720. * Class used to help serialization objects
  93721. */
  93722. export class SerializationHelper {
  93723. /** @hidden */
  93724. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93725. /** @hidden */
  93726. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93727. /** @hidden */
  93728. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93729. /** @hidden */
  93730. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93731. /**
  93732. * Appends the serialized animations from the source animations
  93733. * @param source Source containing the animations
  93734. * @param destination Target to store the animations
  93735. */
  93736. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93737. /**
  93738. * Static function used to serialized a specific entity
  93739. * @param entity defines the entity to serialize
  93740. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93741. * @returns a JSON compatible object representing the serialization of the entity
  93742. */
  93743. static Serialize<T>(entity: T, serializationObject?: any): any;
  93744. /**
  93745. * Creates a new entity from a serialization data object
  93746. * @param creationFunction defines a function used to instanciated the new entity
  93747. * @param source defines the source serialization data
  93748. * @param scene defines the hosting scene
  93749. * @param rootUrl defines the root url for resources
  93750. * @returns a new entity
  93751. */
  93752. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93753. /**
  93754. * Clones an object
  93755. * @param creationFunction defines the function used to instanciate the new object
  93756. * @param source defines the source object
  93757. * @returns the cloned object
  93758. */
  93759. static Clone<T>(creationFunction: () => T, source: T): T;
  93760. /**
  93761. * Instanciates a new object based on a source one (some data will be shared between both object)
  93762. * @param creationFunction defines the function used to instanciate the new object
  93763. * @param source defines the source object
  93764. * @returns the new object
  93765. */
  93766. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93767. }
  93768. }
  93769. declare module BABYLON {
  93770. /**
  93771. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93772. */
  93773. export interface CubeMapInfo {
  93774. /**
  93775. * The pixel array for the front face.
  93776. * This is stored in format, left to right, up to down format.
  93777. */
  93778. front: Nullable<ArrayBufferView>;
  93779. /**
  93780. * The pixel array for the back face.
  93781. * This is stored in format, left to right, up to down format.
  93782. */
  93783. back: Nullable<ArrayBufferView>;
  93784. /**
  93785. * The pixel array for the left face.
  93786. * This is stored in format, left to right, up to down format.
  93787. */
  93788. left: Nullable<ArrayBufferView>;
  93789. /**
  93790. * The pixel array for the right face.
  93791. * This is stored in format, left to right, up to down format.
  93792. */
  93793. right: Nullable<ArrayBufferView>;
  93794. /**
  93795. * The pixel array for the up face.
  93796. * This is stored in format, left to right, up to down format.
  93797. */
  93798. up: Nullable<ArrayBufferView>;
  93799. /**
  93800. * The pixel array for the down face.
  93801. * This is stored in format, left to right, up to down format.
  93802. */
  93803. down: Nullable<ArrayBufferView>;
  93804. /**
  93805. * The size of the cubemap stored.
  93806. *
  93807. * Each faces will be size * size pixels.
  93808. */
  93809. size: number;
  93810. /**
  93811. * The format of the texture.
  93812. *
  93813. * RGBA, RGB.
  93814. */
  93815. format: number;
  93816. /**
  93817. * The type of the texture data.
  93818. *
  93819. * UNSIGNED_INT, FLOAT.
  93820. */
  93821. type: number;
  93822. /**
  93823. * Specifies whether the texture is in gamma space.
  93824. */
  93825. gammaSpace: boolean;
  93826. }
  93827. /**
  93828. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93829. */
  93830. export class PanoramaToCubeMapTools {
  93831. private static FACE_FRONT;
  93832. private static FACE_BACK;
  93833. private static FACE_RIGHT;
  93834. private static FACE_LEFT;
  93835. private static FACE_DOWN;
  93836. private static FACE_UP;
  93837. /**
  93838. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93839. *
  93840. * @param float32Array The source data.
  93841. * @param inputWidth The width of the input panorama.
  93842. * @param inputHeight The height of the input panorama.
  93843. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93844. * @return The cubemap data
  93845. */
  93846. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93847. private static CreateCubemapTexture;
  93848. private static CalcProjectionSpherical;
  93849. }
  93850. }
  93851. declare module BABYLON {
  93852. /**
  93853. * Helper class dealing with the extraction of spherical polynomial dataArray
  93854. * from a cube map.
  93855. */
  93856. export class CubeMapToSphericalPolynomialTools {
  93857. private static FileFaces;
  93858. /**
  93859. * Converts a texture to the according Spherical Polynomial data.
  93860. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93861. *
  93862. * @param texture The texture to extract the information from.
  93863. * @return The Spherical Polynomial data.
  93864. */
  93865. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93866. /**
  93867. * Converts a cubemap to the according Spherical Polynomial data.
  93868. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93869. *
  93870. * @param cubeInfo The Cube map to extract the information from.
  93871. * @return The Spherical Polynomial data.
  93872. */
  93873. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93874. }
  93875. }
  93876. declare module BABYLON {
  93877. /**
  93878. * Class used to manipulate GUIDs
  93879. */
  93880. export class GUID {
  93881. /**
  93882. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93883. * Be aware Math.random() could cause collisions, but:
  93884. * "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"
  93885. * @returns a pseudo random id
  93886. */
  93887. static RandomId(): string;
  93888. }
  93889. }
  93890. declare module BABYLON {
  93891. /**
  93892. * Base class of all the textures in babylon.
  93893. * It groups all the common properties the materials, post process, lights... might need
  93894. * in order to make a correct use of the texture.
  93895. */
  93896. export class BaseTexture implements IAnimatable {
  93897. /**
  93898. * Default anisotropic filtering level for the application.
  93899. * It is set to 4 as a good tradeoff between perf and quality.
  93900. */
  93901. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93902. /**
  93903. * Gets or sets the unique id of the texture
  93904. */
  93905. uniqueId: number;
  93906. /**
  93907. * Define the name of the texture.
  93908. */
  93909. name: string;
  93910. /**
  93911. * Gets or sets an object used to store user defined information.
  93912. */
  93913. metadata: any;
  93914. /**
  93915. * For internal use only. Please do not use.
  93916. */
  93917. reservedDataStore: any;
  93918. private _hasAlpha;
  93919. /**
  93920. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93921. */
  93922. hasAlpha: boolean;
  93923. /**
  93924. * Defines if the alpha value should be determined via the rgb values.
  93925. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93926. */
  93927. getAlphaFromRGB: boolean;
  93928. /**
  93929. * Intensity or strength of the texture.
  93930. * It is commonly used by materials to fine tune the intensity of the texture
  93931. */
  93932. level: number;
  93933. /**
  93934. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93935. * This is part of the texture as textures usually maps to one uv set.
  93936. */
  93937. coordinatesIndex: number;
  93938. private _coordinatesMode;
  93939. /**
  93940. * How a texture is mapped.
  93941. *
  93942. * | Value | Type | Description |
  93943. * | ----- | ----------------------------------- | ----------- |
  93944. * | 0 | EXPLICIT_MODE | |
  93945. * | 1 | SPHERICAL_MODE | |
  93946. * | 2 | PLANAR_MODE | |
  93947. * | 3 | CUBIC_MODE | |
  93948. * | 4 | PROJECTION_MODE | |
  93949. * | 5 | SKYBOX_MODE | |
  93950. * | 6 | INVCUBIC_MODE | |
  93951. * | 7 | EQUIRECTANGULAR_MODE | |
  93952. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93953. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93954. */
  93955. coordinatesMode: number;
  93956. /**
  93957. * | Value | Type | Description |
  93958. * | ----- | ------------------ | ----------- |
  93959. * | 0 | CLAMP_ADDRESSMODE | |
  93960. * | 1 | WRAP_ADDRESSMODE | |
  93961. * | 2 | MIRROR_ADDRESSMODE | |
  93962. */
  93963. wrapU: number;
  93964. /**
  93965. * | Value | Type | Description |
  93966. * | ----- | ------------------ | ----------- |
  93967. * | 0 | CLAMP_ADDRESSMODE | |
  93968. * | 1 | WRAP_ADDRESSMODE | |
  93969. * | 2 | MIRROR_ADDRESSMODE | |
  93970. */
  93971. wrapV: number;
  93972. /**
  93973. * | Value | Type | Description |
  93974. * | ----- | ------------------ | ----------- |
  93975. * | 0 | CLAMP_ADDRESSMODE | |
  93976. * | 1 | WRAP_ADDRESSMODE | |
  93977. * | 2 | MIRROR_ADDRESSMODE | |
  93978. */
  93979. wrapR: number;
  93980. /**
  93981. * With compliant hardware and browser (supporting anisotropic filtering)
  93982. * this defines the level of anisotropic filtering in the texture.
  93983. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93984. */
  93985. anisotropicFilteringLevel: number;
  93986. /**
  93987. * Define if the texture is a cube texture or if false a 2d texture.
  93988. */
  93989. isCube: boolean;
  93990. /**
  93991. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93992. */
  93993. is3D: boolean;
  93994. /**
  93995. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93996. * HDR texture are usually stored in linear space.
  93997. * This only impacts the PBR and Background materials
  93998. */
  93999. gammaSpace: boolean;
  94000. /**
  94001. * Gets or sets whether or not the texture contains RGBD data.
  94002. */
  94003. isRGBD: boolean;
  94004. /**
  94005. * Is Z inverted in the texture (useful in a cube texture).
  94006. */
  94007. invertZ: boolean;
  94008. /**
  94009. * Are mip maps generated for this texture or not.
  94010. */
  94011. readonly noMipmap: boolean;
  94012. /**
  94013. * @hidden
  94014. */
  94015. lodLevelInAlpha: boolean;
  94016. /**
  94017. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94018. */
  94019. lodGenerationOffset: number;
  94020. /**
  94021. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94022. */
  94023. lodGenerationScale: number;
  94024. /**
  94025. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94026. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94027. * average roughness values.
  94028. */
  94029. linearSpecularLOD: boolean;
  94030. /**
  94031. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94032. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94033. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94034. */
  94035. irradianceTexture: Nullable<BaseTexture>;
  94036. /**
  94037. * Define if the texture is a render target.
  94038. */
  94039. isRenderTarget: boolean;
  94040. /**
  94041. * Define the unique id of the texture in the scene.
  94042. */
  94043. readonly uid: string;
  94044. /**
  94045. * Return a string representation of the texture.
  94046. * @returns the texture as a string
  94047. */
  94048. toString(): string;
  94049. /**
  94050. * Get the class name of the texture.
  94051. * @returns "BaseTexture"
  94052. */
  94053. getClassName(): string;
  94054. /**
  94055. * Define the list of animation attached to the texture.
  94056. */
  94057. animations: Animation[];
  94058. /**
  94059. * An event triggered when the texture is disposed.
  94060. */
  94061. onDisposeObservable: Observable<BaseTexture>;
  94062. private _onDisposeObserver;
  94063. /**
  94064. * Callback triggered when the texture has been disposed.
  94065. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94066. */
  94067. onDispose: () => void;
  94068. /**
  94069. * Define the current state of the loading sequence when in delayed load mode.
  94070. */
  94071. delayLoadState: number;
  94072. private _scene;
  94073. /** @hidden */
  94074. _texture: Nullable<InternalTexture>;
  94075. private _uid;
  94076. /**
  94077. * Define if the texture is preventinga material to render or not.
  94078. * If not and the texture is not ready, the engine will use a default black texture instead.
  94079. */
  94080. readonly isBlocking: boolean;
  94081. /**
  94082. * Instantiates a new BaseTexture.
  94083. * Base class of all the textures in babylon.
  94084. * It groups all the common properties the materials, post process, lights... might need
  94085. * in order to make a correct use of the texture.
  94086. * @param scene Define the scene the texture blongs to
  94087. */
  94088. constructor(scene: Nullable<Scene>);
  94089. /**
  94090. * Get the scene the texture belongs to.
  94091. * @returns the scene or null if undefined
  94092. */
  94093. getScene(): Nullable<Scene>;
  94094. /**
  94095. * Get the texture transform matrix used to offset tile the texture for istance.
  94096. * @returns the transformation matrix
  94097. */
  94098. getTextureMatrix(): Matrix;
  94099. /**
  94100. * Get the texture reflection matrix used to rotate/transform the reflection.
  94101. * @returns the reflection matrix
  94102. */
  94103. getReflectionTextureMatrix(): Matrix;
  94104. /**
  94105. * Get the underlying lower level texture from Babylon.
  94106. * @returns the insternal texture
  94107. */
  94108. getInternalTexture(): Nullable<InternalTexture>;
  94109. /**
  94110. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94111. * @returns true if ready or not blocking
  94112. */
  94113. isReadyOrNotBlocking(): boolean;
  94114. /**
  94115. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94116. * @returns true if fully ready
  94117. */
  94118. isReady(): boolean;
  94119. private _cachedSize;
  94120. /**
  94121. * Get the size of the texture.
  94122. * @returns the texture size.
  94123. */
  94124. getSize(): ISize;
  94125. /**
  94126. * Get the base size of the texture.
  94127. * It can be different from the size if the texture has been resized for POT for instance
  94128. * @returns the base size
  94129. */
  94130. getBaseSize(): ISize;
  94131. /**
  94132. * Update the sampling mode of the texture.
  94133. * Default is Trilinear mode.
  94134. *
  94135. * | Value | Type | Description |
  94136. * | ----- | ------------------ | ----------- |
  94137. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94138. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94139. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94140. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94141. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94142. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94143. * | 7 | NEAREST_LINEAR | |
  94144. * | 8 | NEAREST_NEAREST | |
  94145. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94146. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94147. * | 11 | LINEAR_LINEAR | |
  94148. * | 12 | LINEAR_NEAREST | |
  94149. *
  94150. * > _mag_: magnification filter (close to the viewer)
  94151. * > _min_: minification filter (far from the viewer)
  94152. * > _mip_: filter used between mip map levels
  94153. *@param samplingMode Define the new sampling mode of the texture
  94154. */
  94155. updateSamplingMode(samplingMode: number): void;
  94156. /**
  94157. * Scales the texture if is `canRescale()`
  94158. * @param ratio the resize factor we want to use to rescale
  94159. */
  94160. scale(ratio: number): void;
  94161. /**
  94162. * Get if the texture can rescale.
  94163. */
  94164. readonly canRescale: boolean;
  94165. /** @hidden */
  94166. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94167. /** @hidden */
  94168. _rebuild(): void;
  94169. /**
  94170. * Triggers the load sequence in delayed load mode.
  94171. */
  94172. delayLoad(): void;
  94173. /**
  94174. * Clones the texture.
  94175. * @returns the cloned texture
  94176. */
  94177. clone(): Nullable<BaseTexture>;
  94178. /**
  94179. * Get the texture underlying type (INT, FLOAT...)
  94180. */
  94181. readonly textureType: number;
  94182. /**
  94183. * Get the texture underlying format (RGB, RGBA...)
  94184. */
  94185. readonly textureFormat: number;
  94186. /**
  94187. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94188. * This will returns an RGBA array buffer containing either in values (0-255) or
  94189. * float values (0-1) depending of the underlying buffer type.
  94190. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94191. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94192. * @param buffer defines a user defined buffer to fill with data (can be null)
  94193. * @returns The Array buffer containing the pixels data.
  94194. */
  94195. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94196. /**
  94197. * Release and destroy the underlying lower level texture aka internalTexture.
  94198. */
  94199. releaseInternalTexture(): void;
  94200. /**
  94201. * Get the polynomial representation of the texture data.
  94202. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94203. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94204. */
  94205. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94206. /** @hidden */
  94207. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94208. /** @hidden */
  94209. readonly _lodTextureMid: Nullable<BaseTexture>;
  94210. /** @hidden */
  94211. readonly _lodTextureLow: Nullable<BaseTexture>;
  94212. /**
  94213. * Dispose the texture and release its associated resources.
  94214. */
  94215. dispose(): void;
  94216. /**
  94217. * Serialize the texture into a JSON representation that can be parsed later on.
  94218. * @returns the JSON representation of the texture
  94219. */
  94220. serialize(): any;
  94221. /**
  94222. * Helper function to be called back once a list of texture contains only ready textures.
  94223. * @param textures Define the list of textures to wait for
  94224. * @param callback Define the callback triggered once the entire list will be ready
  94225. */
  94226. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94227. }
  94228. }
  94229. declare module BABYLON {
  94230. /**
  94231. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94232. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94233. */
  94234. export class EffectFallbacks {
  94235. private _defines;
  94236. private _currentRank;
  94237. private _maxRank;
  94238. private _mesh;
  94239. /**
  94240. * Removes the fallback from the bound mesh.
  94241. */
  94242. unBindMesh(): void;
  94243. /**
  94244. * Adds a fallback on the specified property.
  94245. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94246. * @param define The name of the define in the shader
  94247. */
  94248. addFallback(rank: number, define: string): void;
  94249. /**
  94250. * Sets the mesh to use CPU skinning when needing to fallback.
  94251. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94252. * @param mesh The mesh to use the fallbacks.
  94253. */
  94254. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94255. /**
  94256. * Checks to see if more fallbacks are still availible.
  94257. */
  94258. readonly hasMoreFallbacks: boolean;
  94259. /**
  94260. * Removes the defines that should be removed when falling back.
  94261. * @param currentDefines defines the current define statements for the shader.
  94262. * @param effect defines the current effect we try to compile
  94263. * @returns The resulting defines with defines of the current rank removed.
  94264. */
  94265. reduce(currentDefines: string, effect: Effect): string;
  94266. }
  94267. /**
  94268. * Options to be used when creating an effect.
  94269. */
  94270. export class EffectCreationOptions {
  94271. /**
  94272. * Atrributes that will be used in the shader.
  94273. */
  94274. attributes: string[];
  94275. /**
  94276. * Uniform varible names that will be set in the shader.
  94277. */
  94278. uniformsNames: string[];
  94279. /**
  94280. * Uniform buffer varible names that will be set in the shader.
  94281. */
  94282. uniformBuffersNames: string[];
  94283. /**
  94284. * Sampler texture variable names that will be set in the shader.
  94285. */
  94286. samplers: string[];
  94287. /**
  94288. * Define statements that will be set in the shader.
  94289. */
  94290. defines: any;
  94291. /**
  94292. * Possible fallbacks for this effect to improve performance when needed.
  94293. */
  94294. fallbacks: Nullable<EffectFallbacks>;
  94295. /**
  94296. * Callback that will be called when the shader is compiled.
  94297. */
  94298. onCompiled: Nullable<(effect: Effect) => void>;
  94299. /**
  94300. * Callback that will be called if an error occurs during shader compilation.
  94301. */
  94302. onError: Nullable<(effect: Effect, errors: string) => void>;
  94303. /**
  94304. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94305. */
  94306. indexParameters: any;
  94307. /**
  94308. * Max number of lights that can be used in the shader.
  94309. */
  94310. maxSimultaneousLights: number;
  94311. /**
  94312. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94313. */
  94314. transformFeedbackVaryings: Nullable<string[]>;
  94315. }
  94316. /**
  94317. * Effect containing vertex and fragment shader that can be executed on an object.
  94318. */
  94319. export class Effect implements IDisposable {
  94320. /**
  94321. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94322. */
  94323. static ShadersRepository: string;
  94324. /**
  94325. * Name of the effect.
  94326. */
  94327. name: any;
  94328. /**
  94329. * String container all the define statements that should be set on the shader.
  94330. */
  94331. defines: string;
  94332. /**
  94333. * Callback that will be called when the shader is compiled.
  94334. */
  94335. onCompiled: Nullable<(effect: Effect) => void>;
  94336. /**
  94337. * Callback that will be called if an error occurs during shader compilation.
  94338. */
  94339. onError: Nullable<(effect: Effect, errors: string) => void>;
  94340. /**
  94341. * Callback that will be called when effect is bound.
  94342. */
  94343. onBind: Nullable<(effect: Effect) => void>;
  94344. /**
  94345. * Unique ID of the effect.
  94346. */
  94347. uniqueId: number;
  94348. /**
  94349. * Observable that will be called when the shader is compiled.
  94350. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94351. */
  94352. onCompileObservable: Observable<Effect>;
  94353. /**
  94354. * Observable that will be called if an error occurs during shader compilation.
  94355. */
  94356. onErrorObservable: Observable<Effect>;
  94357. /** @hidden */
  94358. _onBindObservable: Nullable<Observable<Effect>>;
  94359. /**
  94360. * Observable that will be called when effect is bound.
  94361. */
  94362. readonly onBindObservable: Observable<Effect>;
  94363. /** @hidden */
  94364. _bonesComputationForcedToCPU: boolean;
  94365. private static _uniqueIdSeed;
  94366. private _engine;
  94367. private _uniformBuffersNames;
  94368. private _uniformsNames;
  94369. private _samplerList;
  94370. private _samplers;
  94371. private _isReady;
  94372. private _compilationError;
  94373. private _attributesNames;
  94374. private _attributes;
  94375. private _uniforms;
  94376. /**
  94377. * Key for the effect.
  94378. * @hidden
  94379. */
  94380. _key: string;
  94381. private _indexParameters;
  94382. private _fallbacks;
  94383. private _vertexSourceCode;
  94384. private _fragmentSourceCode;
  94385. private _vertexSourceCodeOverride;
  94386. private _fragmentSourceCodeOverride;
  94387. private _transformFeedbackVaryings;
  94388. /**
  94389. * Compiled shader to webGL program.
  94390. * @hidden
  94391. */
  94392. _pipelineContext: Nullable<IPipelineContext>;
  94393. private _valueCache;
  94394. private static _baseCache;
  94395. /**
  94396. * Instantiates an effect.
  94397. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94398. * @param baseName Name of the effect.
  94399. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94400. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94401. * @param samplers List of sampler variables that will be passed to the shader.
  94402. * @param engine Engine to be used to render the effect
  94403. * @param defines Define statements to be added to the shader.
  94404. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94405. * @param onCompiled Callback that will be called when the shader is compiled.
  94406. * @param onError Callback that will be called if an error occurs during shader compilation.
  94407. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94408. */
  94409. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | BaseEngine, samplers?: Nullable<string[]>, engine?: BaseEngine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94410. private _useFinalCode;
  94411. /**
  94412. * Unique key for this effect
  94413. */
  94414. readonly key: string;
  94415. /**
  94416. * If the effect has been compiled and prepared.
  94417. * @returns if the effect is compiled and prepared.
  94418. */
  94419. isReady(): boolean;
  94420. private _isReadyInternal;
  94421. /**
  94422. * The engine the effect was initialized with.
  94423. * @returns the engine.
  94424. */
  94425. getEngine(): Engine;
  94426. /**
  94427. * The pipeline context for this effect
  94428. * @returns the associated pipeline context
  94429. */
  94430. getPipelineContext(): Nullable<IPipelineContext>;
  94431. /**
  94432. * The set of names of attribute variables for the shader.
  94433. * @returns An array of attribute names.
  94434. */
  94435. getAttributesNames(): string[];
  94436. /**
  94437. * Returns the attribute at the given index.
  94438. * @param index The index of the attribute.
  94439. * @returns The location of the attribute.
  94440. */
  94441. getAttributeLocation(index: number): number;
  94442. /**
  94443. * Returns the attribute based on the name of the variable.
  94444. * @param name of the attribute to look up.
  94445. * @returns the attribute location.
  94446. */
  94447. getAttributeLocationByName(name: string): number;
  94448. /**
  94449. * The number of attributes.
  94450. * @returns the numnber of attributes.
  94451. */
  94452. getAttributesCount(): number;
  94453. /**
  94454. * Gets the index of a uniform variable.
  94455. * @param uniformName of the uniform to look up.
  94456. * @returns the index.
  94457. */
  94458. getUniformIndex(uniformName: string): number;
  94459. /**
  94460. * Returns the attribute based on the name of the variable.
  94461. * @param uniformName of the uniform to look up.
  94462. * @returns the location of the uniform.
  94463. */
  94464. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94465. /**
  94466. * Returns an array of sampler variable names
  94467. * @returns The array of sampler variable neames.
  94468. */
  94469. getSamplers(): string[];
  94470. /**
  94471. * The error from the last compilation.
  94472. * @returns the error string.
  94473. */
  94474. getCompilationError(): string;
  94475. /**
  94476. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94477. * @param func The callback to be used.
  94478. */
  94479. executeWhenCompiled(func: (effect: Effect) => void): void;
  94480. private _checkIsReady;
  94481. /** @hidden */
  94482. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94483. /** @hidden */
  94484. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94485. /** @hidden */
  94486. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94487. /**
  94488. * Recompiles the webGL program
  94489. * @param vertexSourceCode The source code for the vertex shader.
  94490. * @param fragmentSourceCode The source code for the fragment shader.
  94491. * @param onCompiled Callback called when completed.
  94492. * @param onError Callback called on error.
  94493. * @hidden
  94494. */
  94495. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94496. /**
  94497. * Prepares the effect
  94498. * @hidden
  94499. */
  94500. _prepareEffect(): void;
  94501. private _processCompilationErrors;
  94502. /**
  94503. * Checks if the effect is supported. (Must be called after compilation)
  94504. */
  94505. readonly isSupported: boolean;
  94506. /**
  94507. * Binds a texture to the engine to be used as output of the shader.
  94508. * @param channel Name of the output variable.
  94509. * @param texture Texture to bind.
  94510. * @hidden
  94511. */
  94512. _bindTexture(channel: string, texture: InternalTexture): void;
  94513. /**
  94514. * Sets a texture on the engine to be used in the shader.
  94515. * @param channel Name of the sampler variable.
  94516. * @param texture Texture to set.
  94517. */
  94518. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94519. /**
  94520. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94521. * @param channel Name of the sampler variable.
  94522. * @param texture Texture to set.
  94523. */
  94524. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94525. /**
  94526. * Sets an array of textures on the engine to be used in the shader.
  94527. * @param channel Name of the variable.
  94528. * @param textures Textures to set.
  94529. */
  94530. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94531. /**
  94532. * 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)
  94533. * @param channel Name of the sampler variable.
  94534. * @param postProcess Post process to get the input texture from.
  94535. */
  94536. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94537. /**
  94538. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94539. * 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)
  94540. * @param channel Name of the sampler variable.
  94541. * @param postProcess Post process to get the output texture from.
  94542. */
  94543. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94544. /** @hidden */
  94545. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94546. /** @hidden */
  94547. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94548. /** @hidden */
  94549. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94550. /** @hidden */
  94551. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94552. /**
  94553. * Binds a buffer to a uniform.
  94554. * @param buffer Buffer to bind.
  94555. * @param name Name of the uniform variable to bind to.
  94556. */
  94557. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94558. /**
  94559. * Binds block to a uniform.
  94560. * @param blockName Name of the block to bind.
  94561. * @param index Index to bind.
  94562. */
  94563. bindUniformBlock(blockName: string, index: number): void;
  94564. /**
  94565. * Sets an interger value on a uniform variable.
  94566. * @param uniformName Name of the variable.
  94567. * @param value Value to be set.
  94568. * @returns this effect.
  94569. */
  94570. setInt(uniformName: string, value: number): Effect;
  94571. /**
  94572. * Sets an int array on a uniform variable.
  94573. * @param uniformName Name of the variable.
  94574. * @param array array to be set.
  94575. * @returns this effect.
  94576. */
  94577. setIntArray(uniformName: string, array: Int32Array): Effect;
  94578. /**
  94579. * 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)
  94580. * @param uniformName Name of the variable.
  94581. * @param array array to be set.
  94582. * @returns this effect.
  94583. */
  94584. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94585. /**
  94586. * 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)
  94587. * @param uniformName Name of the variable.
  94588. * @param array array to be set.
  94589. * @returns this effect.
  94590. */
  94591. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94592. /**
  94593. * 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)
  94594. * @param uniformName Name of the variable.
  94595. * @param array array to be set.
  94596. * @returns this effect.
  94597. */
  94598. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94599. /**
  94600. * Sets an float array on a uniform variable.
  94601. * @param uniformName Name of the variable.
  94602. * @param array array to be set.
  94603. * @returns this effect.
  94604. */
  94605. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94606. /**
  94607. * 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)
  94608. * @param uniformName Name of the variable.
  94609. * @param array array to be set.
  94610. * @returns this effect.
  94611. */
  94612. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94613. /**
  94614. * 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)
  94615. * @param uniformName Name of the variable.
  94616. * @param array array to be set.
  94617. * @returns this effect.
  94618. */
  94619. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94620. /**
  94621. * 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)
  94622. * @param uniformName Name of the variable.
  94623. * @param array array to be set.
  94624. * @returns this effect.
  94625. */
  94626. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94627. /**
  94628. * Sets an array on a uniform variable.
  94629. * @param uniformName Name of the variable.
  94630. * @param array array to be set.
  94631. * @returns this effect.
  94632. */
  94633. setArray(uniformName: string, array: number[]): Effect;
  94634. /**
  94635. * 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)
  94636. * @param uniformName Name of the variable.
  94637. * @param array array to be set.
  94638. * @returns this effect.
  94639. */
  94640. setArray2(uniformName: string, array: number[]): Effect;
  94641. /**
  94642. * 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)
  94643. * @param uniformName Name of the variable.
  94644. * @param array array to be set.
  94645. * @returns this effect.
  94646. */
  94647. setArray3(uniformName: string, array: number[]): Effect;
  94648. /**
  94649. * 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)
  94650. * @param uniformName Name of the variable.
  94651. * @param array array to be set.
  94652. * @returns this effect.
  94653. */
  94654. setArray4(uniformName: string, array: number[]): Effect;
  94655. /**
  94656. * Sets matrices on a uniform variable.
  94657. * @param uniformName Name of the variable.
  94658. * @param matrices matrices to be set.
  94659. * @returns this effect.
  94660. */
  94661. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94662. /**
  94663. * Sets matrix on a uniform variable.
  94664. * @param uniformName Name of the variable.
  94665. * @param matrix matrix to be set.
  94666. * @returns this effect.
  94667. */
  94668. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94669. /**
  94670. * 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)
  94671. * @param uniformName Name of the variable.
  94672. * @param matrix matrix to be set.
  94673. * @returns this effect.
  94674. */
  94675. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94676. /**
  94677. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94678. * @param uniformName Name of the variable.
  94679. * @param matrix matrix to be set.
  94680. * @returns this effect.
  94681. */
  94682. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94683. /**
  94684. * Sets a float on a uniform variable.
  94685. * @param uniformName Name of the variable.
  94686. * @param value value to be set.
  94687. * @returns this effect.
  94688. */
  94689. setFloat(uniformName: string, value: number): Effect;
  94690. /**
  94691. * Sets a boolean on a uniform variable.
  94692. * @param uniformName Name of the variable.
  94693. * @param bool value to be set.
  94694. * @returns this effect.
  94695. */
  94696. setBool(uniformName: string, bool: boolean): Effect;
  94697. /**
  94698. * Sets a Vector2 on a uniform variable.
  94699. * @param uniformName Name of the variable.
  94700. * @param vector2 vector2 to be set.
  94701. * @returns this effect.
  94702. */
  94703. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94704. /**
  94705. * Sets a float2 on a uniform variable.
  94706. * @param uniformName Name of the variable.
  94707. * @param x First float in float2.
  94708. * @param y Second float in float2.
  94709. * @returns this effect.
  94710. */
  94711. setFloat2(uniformName: string, x: number, y: number): Effect;
  94712. /**
  94713. * Sets a Vector3 on a uniform variable.
  94714. * @param uniformName Name of the variable.
  94715. * @param vector3 Value to be set.
  94716. * @returns this effect.
  94717. */
  94718. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94719. /**
  94720. * Sets a float3 on a uniform variable.
  94721. * @param uniformName Name of the variable.
  94722. * @param x First float in float3.
  94723. * @param y Second float in float3.
  94724. * @param z Third float in float3.
  94725. * @returns this effect.
  94726. */
  94727. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94728. /**
  94729. * Sets a Vector4 on a uniform variable.
  94730. * @param uniformName Name of the variable.
  94731. * @param vector4 Value to be set.
  94732. * @returns this effect.
  94733. */
  94734. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94735. /**
  94736. * Sets a float4 on a uniform variable.
  94737. * @param uniformName Name of the variable.
  94738. * @param x First float in float4.
  94739. * @param y Second float in float4.
  94740. * @param z Third float in float4.
  94741. * @param w Fourth float in float4.
  94742. * @returns this effect.
  94743. */
  94744. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94745. /**
  94746. * Sets a Color3 on a uniform variable.
  94747. * @param uniformName Name of the variable.
  94748. * @param color3 Value to be set.
  94749. * @returns this effect.
  94750. */
  94751. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94752. /**
  94753. * Sets a Color4 on a uniform variable.
  94754. * @param uniformName Name of the variable.
  94755. * @param color3 Value to be set.
  94756. * @param alpha Alpha value to be set.
  94757. * @returns this effect.
  94758. */
  94759. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94760. /**
  94761. * Sets a Color4 on a uniform variable
  94762. * @param uniformName defines the name of the variable
  94763. * @param color4 defines the value to be set
  94764. * @returns this effect.
  94765. */
  94766. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94767. /** Release all associated resources */
  94768. dispose(): void;
  94769. /**
  94770. * This function will add a new shader to the shader store
  94771. * @param name the name of the shader
  94772. * @param pixelShader optional pixel shader content
  94773. * @param vertexShader optional vertex shader content
  94774. */
  94775. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94776. /**
  94777. * Store of each shader (The can be looked up using effect.key)
  94778. */
  94779. static ShadersStore: {
  94780. [key: string]: string;
  94781. };
  94782. /**
  94783. * Store of each included file for a shader (The can be looked up using effect.key)
  94784. */
  94785. static IncludesShadersStore: {
  94786. [key: string]: string;
  94787. };
  94788. /**
  94789. * Resets the cache of effects.
  94790. */
  94791. static ResetCache(): void;
  94792. }
  94793. }
  94794. declare module BABYLON {
  94795. /**
  94796. * Class used to describe the capabilities of the engine relatively to the current browser
  94797. */
  94798. export class EngineCapabilities {
  94799. /** Maximum textures units per fragment shader */
  94800. maxTexturesImageUnits: number;
  94801. /** Maximum texture units per vertex shader */
  94802. maxVertexTextureImageUnits: number;
  94803. /** Maximum textures units in the entire pipeline */
  94804. maxCombinedTexturesImageUnits: number;
  94805. /** Maximum texture size */
  94806. maxTextureSize: number;
  94807. /** Maximum cube texture size */
  94808. maxCubemapTextureSize: number;
  94809. /** Maximum render texture size */
  94810. maxRenderTextureSize: number;
  94811. /** Maximum number of vertex attributes */
  94812. maxVertexAttribs: number;
  94813. /** Maximum number of varyings */
  94814. maxVaryingVectors: number;
  94815. /** Maximum number of uniforms per vertex shader */
  94816. maxVertexUniformVectors: number;
  94817. /** Maximum number of uniforms per fragment shader */
  94818. maxFragmentUniformVectors: number;
  94819. /** Defines if standard derivates (dx/dy) are supported */
  94820. standardDerivatives: boolean;
  94821. /** Defines if s3tc texture compression is supported */
  94822. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  94823. /** Defines if pvrtc texture compression is supported */
  94824. pvrtc: any;
  94825. /** Defines if etc1 texture compression is supported */
  94826. etc1: any;
  94827. /** Defines if etc2 texture compression is supported */
  94828. etc2: any;
  94829. /** Defines if astc texture compression is supported */
  94830. astc: any;
  94831. /** Defines if float textures are supported */
  94832. textureFloat: boolean;
  94833. /** Defines if vertex array objects are supported */
  94834. vertexArrayObject: boolean;
  94835. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  94836. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  94837. /** Gets the maximum level of anisotropy supported */
  94838. maxAnisotropy: number;
  94839. /** Defines if instancing is supported */
  94840. instancedArrays: boolean;
  94841. /** Defines if 32 bits indices are supported */
  94842. uintIndices: boolean;
  94843. /** Defines if high precision shaders are supported */
  94844. highPrecisionShaderSupported: boolean;
  94845. /** Defines if depth reading in the fragment shader is supported */
  94846. fragmentDepthSupported: boolean;
  94847. /** Defines if float texture linear filtering is supported*/
  94848. textureFloatLinearFiltering: boolean;
  94849. /** Defines if rendering to float textures is supported */
  94850. textureFloatRender: boolean;
  94851. /** Defines if half float textures are supported*/
  94852. textureHalfFloat: boolean;
  94853. /** Defines if half float texture linear filtering is supported*/
  94854. textureHalfFloatLinearFiltering: boolean;
  94855. /** Defines if rendering to half float textures is supported */
  94856. textureHalfFloatRender: boolean;
  94857. /** Defines if textureLOD shader command is supported */
  94858. textureLOD: boolean;
  94859. /** Defines if draw buffers extension is supported */
  94860. drawBuffersExtension: boolean;
  94861. /** Defines if depth textures are supported */
  94862. depthTextureExtension: boolean;
  94863. /** Defines if float color buffer are supported */
  94864. colorBufferFloat: boolean;
  94865. /** Gets disjoint timer query extension (null if not supported) */
  94866. timerQuery: EXT_disjoint_timer_query;
  94867. /** Defines if timestamp can be used with timer query */
  94868. canUseTimestampForTimerQuery: boolean;
  94869. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94870. multiview: any;
  94871. /** Function used to let the system compiles shaders in background */
  94872. parallelShaderCompile: {
  94873. COMPLETION_STATUS_KHR: number;
  94874. };
  94875. /** Max number of texture samples for MSAA */
  94876. maxMSAASamples: number;
  94877. /** Defines if the blend min max extension is supported */
  94878. blendMinMax: boolean;
  94879. }
  94880. }
  94881. declare module BABYLON {
  94882. /**
  94883. * This class is used to track a performance counter which is number based.
  94884. * The user has access to many properties which give statistics of different nature.
  94885. *
  94886. * The implementer can track two kinds of Performance Counter: time and count.
  94887. * 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.
  94888. * 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.
  94889. */
  94890. export class PerfCounter {
  94891. /**
  94892. * Gets or sets a global boolean to turn on and off all the counters
  94893. */
  94894. static Enabled: boolean;
  94895. /**
  94896. * Returns the smallest value ever
  94897. */
  94898. readonly min: number;
  94899. /**
  94900. * Returns the biggest value ever
  94901. */
  94902. readonly max: number;
  94903. /**
  94904. * Returns the average value since the performance counter is running
  94905. */
  94906. readonly average: number;
  94907. /**
  94908. * Returns the average value of the last second the counter was monitored
  94909. */
  94910. readonly lastSecAverage: number;
  94911. /**
  94912. * Returns the current value
  94913. */
  94914. readonly current: number;
  94915. /**
  94916. * Gets the accumulated total
  94917. */
  94918. readonly total: number;
  94919. /**
  94920. * Gets the total value count
  94921. */
  94922. readonly count: number;
  94923. /**
  94924. * Creates a new counter
  94925. */
  94926. constructor();
  94927. /**
  94928. * Call this method to start monitoring a new frame.
  94929. * 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.
  94930. */
  94931. fetchNewFrame(): void;
  94932. /**
  94933. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94934. * @param newCount the count value to add to the monitored count
  94935. * @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.
  94936. */
  94937. addCount(newCount: number, fetchResult: boolean): void;
  94938. /**
  94939. * Start monitoring this performance counter
  94940. */
  94941. beginMonitoring(): void;
  94942. /**
  94943. * Compute the time lapsed since the previous beginMonitoring() call.
  94944. * @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
  94945. */
  94946. endMonitoring(newFrame?: boolean): void;
  94947. private _fetchResult;
  94948. private _startMonitoringTime;
  94949. private _min;
  94950. private _max;
  94951. private _average;
  94952. private _current;
  94953. private _totalValueCount;
  94954. private _totalAccumulated;
  94955. private _lastSecAverage;
  94956. private _lastSecAccumulated;
  94957. private _lastSecTime;
  94958. private _lastSecValueCount;
  94959. }
  94960. }
  94961. declare module BABYLON {
  94962. /** @hidden */
  94963. export class WebGL2ShaderProcessor implements IShaderProcessor {
  94964. attributeProcessor(attribute: string): string;
  94965. varyingProcessor(varying: string, isFragment: boolean): string;
  94966. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  94967. }
  94968. }
  94969. declare module BABYLON {
  94970. /** @hidden */
  94971. export class WebGLDataBuffer extends DataBuffer {
  94972. private _buffer;
  94973. constructor(resource: WebGLBuffer);
  94974. readonly underlyingResource: any;
  94975. }
  94976. }
  94977. declare module BABYLON {
  94978. /** @hidden */
  94979. export class WebGLPipelineContext implements IPipelineContext {
  94980. engine: BaseEngine;
  94981. program: Nullable<WebGLProgram>;
  94982. context?: WebGLRenderingContext;
  94983. vertexShader?: WebGLShader;
  94984. fragmentShader?: WebGLShader;
  94985. isParallelCompiled: boolean;
  94986. onCompiled?: () => void;
  94987. transformFeedback?: WebGLTransformFeedback | null;
  94988. readonly isAsync: boolean;
  94989. readonly isReady: boolean;
  94990. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  94991. }
  94992. }
  94993. declare module BABYLON {
  94994. /**
  94995. * Interface for attribute information associated with buffer instanciation
  94996. */
  94997. export class InstancingAttributeInfo {
  94998. /**
  94999. * Index/offset of the attribute in the vertex shader
  95000. */
  95001. index: number;
  95002. /**
  95003. * size of the attribute, 1, 2, 3 or 4
  95004. */
  95005. attributeSize: number;
  95006. /**
  95007. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95008. * default is FLOAT
  95009. */
  95010. attribyteType: number;
  95011. /**
  95012. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95013. */
  95014. normalized: boolean;
  95015. /**
  95016. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95017. */
  95018. offset: number;
  95019. /**
  95020. * Name of the GLSL attribute, for debugging purpose only
  95021. */
  95022. attributeName: string;
  95023. }
  95024. }
  95025. declare module BABYLON {
  95026. /**
  95027. * Settings for finer control over video usage
  95028. */
  95029. export interface VideoTextureSettings {
  95030. /**
  95031. * Applies `autoplay` to video, if specified
  95032. */
  95033. autoPlay?: boolean;
  95034. /**
  95035. * Applies `loop` to video, if specified
  95036. */
  95037. loop?: boolean;
  95038. /**
  95039. * Automatically updates internal texture from video at every frame in the render loop
  95040. */
  95041. autoUpdateTexture: boolean;
  95042. /**
  95043. * Image src displayed during the video loading or until the user interacts with the video.
  95044. */
  95045. poster?: string;
  95046. }
  95047. /**
  95048. * If you want to display a video in your scene, this is the special texture for that.
  95049. * This special texture works similar to other textures, with the exception of a few parameters.
  95050. * @see https://doc.babylonjs.com/how_to/video_texture
  95051. */
  95052. export class VideoTexture extends Texture {
  95053. /**
  95054. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95055. */
  95056. readonly autoUpdateTexture: boolean;
  95057. /**
  95058. * The video instance used by the texture internally
  95059. */
  95060. readonly video: HTMLVideoElement;
  95061. private _onUserActionRequestedObservable;
  95062. /**
  95063. * Event triggerd when a dom action is required by the user to play the video.
  95064. * This happens due to recent changes in browser policies preventing video to auto start.
  95065. */
  95066. readonly onUserActionRequestedObservable: Observable<Texture>;
  95067. private _generateMipMaps;
  95068. private _engine;
  95069. private _stillImageCaptured;
  95070. private _displayingPosterTexture;
  95071. private _settings;
  95072. private _createInternalTextureOnEvent;
  95073. private _frameId;
  95074. /**
  95075. * Creates a video texture.
  95076. * If you want to display a video in your scene, this is the special texture for that.
  95077. * This special texture works similar to other textures, with the exception of a few parameters.
  95078. * @see https://doc.babylonjs.com/how_to/video_texture
  95079. * @param name optional name, will detect from video source, if not defined
  95080. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95081. * @param scene is obviously the current scene.
  95082. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95083. * @param invertY is false by default but can be used to invert video on Y axis
  95084. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95085. * @param settings allows finer control over video usage
  95086. */
  95087. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95088. private _getName;
  95089. private _getVideo;
  95090. private _createInternalTexture;
  95091. private reset;
  95092. /**
  95093. * @hidden Internal method to initiate `update`.
  95094. */
  95095. _rebuild(): void;
  95096. /**
  95097. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95098. */
  95099. update(): void;
  95100. /**
  95101. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95102. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95103. */
  95104. updateTexture(isVisible: boolean): void;
  95105. protected _updateInternalTexture: () => void;
  95106. /**
  95107. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95108. * @param url New url.
  95109. */
  95110. updateURL(url: string): void;
  95111. /**
  95112. * Dispose the texture and release its associated resources.
  95113. */
  95114. dispose(): void;
  95115. /**
  95116. * Creates a video texture straight from a stream.
  95117. * @param scene Define the scene the texture should be created in
  95118. * @param stream Define the stream the texture should be created from
  95119. * @returns The created video texture as a promise
  95120. */
  95121. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95122. /**
  95123. * Creates a video texture straight from your WebCam video feed.
  95124. * @param scene Define the scene the texture should be created in
  95125. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95126. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95127. * @returns The created video texture as a promise
  95128. */
  95129. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95130. minWidth: number;
  95131. maxWidth: number;
  95132. minHeight: number;
  95133. maxHeight: number;
  95134. deviceId: string;
  95135. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95136. /**
  95137. * Creates a video texture straight from your WebCam video feed.
  95138. * @param scene Define the scene the texture should be created in
  95139. * @param onReady Define a callback to triggered once the texture will be ready
  95140. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95141. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95142. */
  95143. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95144. minWidth: number;
  95145. maxWidth: number;
  95146. minHeight: number;
  95147. maxHeight: number;
  95148. deviceId: string;
  95149. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95150. }
  95151. }
  95152. declare module BABYLON {
  95153. /**
  95154. * Defines the interface used by objects containing a viewport (like a camera)
  95155. */
  95156. interface IViewportOwnerLike {
  95157. /**
  95158. * Gets or sets the viewport
  95159. */
  95160. viewport: IViewportLike;
  95161. }
  95162. /**
  95163. * Defines the interface used by objects working like Scene
  95164. * @hidden
  95165. */
  95166. interface ISceneLike {
  95167. _addPendingData(data: any): void;
  95168. _removePendingData(data: any): void;
  95169. offlineProvider: IOfflineProvider;
  95170. }
  95171. /** Interface defining initialization parameters for Engine class */
  95172. export interface EngineOptions extends WebGLContextAttributes {
  95173. /**
  95174. * Defines if the engine should no exceed a specified device ratio
  95175. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95176. */
  95177. limitDeviceRatio?: number;
  95178. /**
  95179. * Defines if webvr should be enabled automatically
  95180. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95181. */
  95182. autoEnableWebVR?: boolean;
  95183. /**
  95184. * Defines if webgl2 should be turned off even if supported
  95185. * @see http://doc.babylonjs.com/features/webgl2
  95186. */
  95187. disableWebGL2Support?: boolean;
  95188. /**
  95189. * Defines if webaudio should be initialized as well
  95190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95191. */
  95192. audioEngine?: boolean;
  95193. /**
  95194. * Defines if animations should run using a deterministic lock step
  95195. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95196. */
  95197. deterministicLockstep?: boolean;
  95198. /** Defines the maximum steps to use with deterministic lock step mode */
  95199. lockstepMaxSteps?: number;
  95200. /**
  95201. * Defines that engine should ignore context lost events
  95202. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95203. */
  95204. doNotHandleContextLost?: boolean;
  95205. /**
  95206. * Defines that engine should ignore modifying touch action attribute and style
  95207. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95208. */
  95209. doNotHandleTouchAction?: boolean;
  95210. /**
  95211. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95212. */
  95213. useHighPrecisionFloats?: boolean;
  95214. }
  95215. /**
  95216. * The base engine class (root of all engines)
  95217. */
  95218. export class BaseEngine {
  95219. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95220. static ExceptionList: ({
  95221. key: string;
  95222. capture: string;
  95223. captureConstraint: number;
  95224. targets: string[];
  95225. } | {
  95226. key: string;
  95227. capture: null;
  95228. captureConstraint: null;
  95229. targets: string[];
  95230. })[];
  95231. /** @hidden */
  95232. static _TextureLoaders: IInternalTextureLoader[];
  95233. /**
  95234. * Returns the current npm package of the sdk
  95235. */
  95236. static readonly NpmPackage: string;
  95237. /**
  95238. * Returns the current version of the framework
  95239. */
  95240. static readonly Version: string;
  95241. /**
  95242. * Returns a string describing the current engine
  95243. */
  95244. readonly description: string;
  95245. /**
  95246. * Gets or sets the epsilon value used by collision engine
  95247. */
  95248. static CollisionsEpsilon: number;
  95249. /**
  95250. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95251. */
  95252. static ShadersRepository: string;
  95253. /** @hidden */
  95254. _shaderProcessor: IShaderProcessor;
  95255. /**
  95256. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95257. */
  95258. forcePOTTextures: boolean;
  95259. /**
  95260. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95261. */
  95262. isFullscreen: boolean;
  95263. /**
  95264. * Gets a boolean indicating if the pointer is currently locked
  95265. */
  95266. isPointerLock: boolean;
  95267. /**
  95268. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95269. */
  95270. cullBackFaces: boolean;
  95271. /**
  95272. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95273. */
  95274. renderEvenInBackground: boolean;
  95275. /**
  95276. * Gets or sets a boolean indicating that cache can be kept between frames
  95277. */
  95278. preventCacheWipeBetweenFrames: boolean;
  95279. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95280. validateShaderPrograms: boolean;
  95281. /**
  95282. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95283. */
  95284. disableUniformBuffers: boolean;
  95285. /** @hidden */
  95286. _uniformBuffers: UniformBuffer[];
  95287. /**
  95288. * Gets a boolean indicating that the engine supports uniform buffers
  95289. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95290. */
  95291. readonly supportsUniformBuffers: boolean;
  95292. /** @hidden */
  95293. _gl: WebGLRenderingContext;
  95294. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95295. protected _windowIsBackground: boolean;
  95296. protected _webGLVersion: number;
  95297. protected _highPrecisionShadersAllowed: boolean;
  95298. /** @hidden */
  95299. readonly _shouldUseHighPrecisionShader: boolean;
  95300. /**
  95301. * Gets a boolean indicating that only power of 2 textures are supported
  95302. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95303. */
  95304. readonly needPOTTextures: boolean;
  95305. /** @hidden */
  95306. _badOS: boolean;
  95307. /** @hidden */
  95308. _badDesktopOS: boolean;
  95309. private _hardwareScalingLevel;
  95310. /** @hidden */
  95311. _caps: EngineCapabilities;
  95312. private _isStencilEnable;
  95313. protected _colorWrite: boolean;
  95314. /** @hidden */
  95315. _drawCalls: PerfCounter;
  95316. private _glVersion;
  95317. private _glRenderer;
  95318. private _glVendor;
  95319. private _videoTextureSupported;
  95320. protected _renderingQueueLaunched: boolean;
  95321. protected _activeRenderLoops: (() => void)[];
  95322. private _deterministicLockstep;
  95323. private _lockstepMaxSteps;
  95324. /**
  95325. * Observable signaled when a context lost event is raised
  95326. */
  95327. onContextLostObservable: Observable<BaseEngine>;
  95328. /**
  95329. * Observable signaled when a context restored event is raised
  95330. */
  95331. onContextRestoredObservable: Observable<BaseEngine>;
  95332. private _onContextLost;
  95333. private _onContextRestored;
  95334. protected _contextWasLost: boolean;
  95335. /** @hidden */
  95336. _doNotHandleContextLost: boolean;
  95337. /**
  95338. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95340. */
  95341. doNotHandleContextLost: boolean;
  95342. /**
  95343. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95344. */
  95345. disableVertexArrayObjects: boolean;
  95346. /** @hidden */
  95347. protected _depthCullingState: _DepthCullingState;
  95348. /** @hidden */
  95349. protected _stencilState: _StencilState;
  95350. /** @hidden */
  95351. protected _alphaState: _AlphaState;
  95352. /** @hidden */
  95353. protected _alphaMode: number;
  95354. /** @hidden */
  95355. protected _alphaEquation: number;
  95356. /** @hidden */
  95357. _internalTexturesCache: InternalTexture[];
  95358. /** @hidden */
  95359. protected _activeChannel: number;
  95360. private _currentTextureChannel;
  95361. /** @hidden */
  95362. protected _boundTexturesCache: {
  95363. [key: string]: Nullable<InternalTexture>;
  95364. };
  95365. /** @hidden */
  95366. protected _currentEffect: Nullable<Effect>;
  95367. /** @hidden */
  95368. protected _currentProgram: Nullable<WebGLProgram>;
  95369. private _compiledEffects;
  95370. private _vertexAttribArraysEnabled;
  95371. /** @hidden */
  95372. protected _cachedViewport: Nullable<IViewportLike>;
  95373. private _cachedVertexArrayObject;
  95374. /** @hidden */
  95375. protected _cachedVertexBuffers: any;
  95376. /** @hidden */
  95377. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95378. /** @hidden */
  95379. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95380. /** @hidden */
  95381. _currentRenderTarget: Nullable<InternalTexture>;
  95382. private _uintIndicesCurrentlySet;
  95383. private _currentBoundBuffer;
  95384. /** @hidden */
  95385. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95386. private _currentBufferPointers;
  95387. private _currentInstanceLocations;
  95388. private _currentInstanceBuffers;
  95389. private _textureUnits;
  95390. /** @hidden */
  95391. _workingCanvas: Nullable<HTMLCanvasElement>;
  95392. /** @hidden */
  95393. _workingContext: Nullable<CanvasRenderingContext2D>;
  95394. /** @hidden */
  95395. _bindedRenderFunction: any;
  95396. private _vaoRecordInProgress;
  95397. private _mustWipeVertexAttributes;
  95398. private _emptyTexture;
  95399. private _emptyCubeTexture;
  95400. private _emptyTexture3D;
  95401. /** @hidden */
  95402. _frameHandler: number;
  95403. private _nextFreeTextureSlots;
  95404. private _maxSimultaneousTextures;
  95405. private _activeRequests;
  95406. private _texturesSupported;
  95407. /** @hidden */
  95408. _textureFormatInUse: Nullable<string>;
  95409. protected readonly _supportsHardwareTextureRescaling: boolean;
  95410. /**
  95411. * Gets the list of texture formats supported
  95412. */
  95413. readonly texturesSupported: Array<string>;
  95414. /**
  95415. * Gets the list of texture formats in use
  95416. */
  95417. readonly textureFormatInUse: Nullable<string>;
  95418. /**
  95419. * Gets the current viewport
  95420. */
  95421. readonly currentViewport: Nullable<IViewportLike>;
  95422. /**
  95423. * Gets the default empty texture
  95424. */
  95425. readonly emptyTexture: InternalTexture;
  95426. /**
  95427. * Gets the default empty 3D texture
  95428. */
  95429. readonly emptyTexture3D: InternalTexture;
  95430. /**
  95431. * Gets the default empty cube texture
  95432. */
  95433. readonly emptyCubeTexture: InternalTexture;
  95434. /**
  95435. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95436. */
  95437. readonly premultipliedAlpha: boolean;
  95438. /**
  95439. * Creates a new engine
  95440. * @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
  95441. * @param antialias defines enable antialiasing (default: false)
  95442. * @param options defines further options to be sent to the getContext() function
  95443. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95444. */
  95445. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95446. private _disableTouchAction;
  95447. private _rebuildInternalTextures;
  95448. private _rebuildEffects;
  95449. /**
  95450. * Gets a boolean indicating if all created effects are ready
  95451. * @returns true if all effects are ready
  95452. */
  95453. areAllEffectsReady(): boolean;
  95454. protected _rebuildBuffers(): void;
  95455. private _initGLContext;
  95456. /**
  95457. * Gets version of the current webGL context
  95458. */
  95459. readonly webGLVersion: number;
  95460. /**
  95461. * Gets a string idenfifying the name of the class
  95462. * @returns "Engine" string
  95463. */
  95464. getClassName(): string;
  95465. /**
  95466. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95467. */
  95468. readonly isStencilEnable: boolean;
  95469. /** @hidden */
  95470. _prepareWorkingCanvas(): void;
  95471. /**
  95472. * Reset the texture cache to empty state
  95473. */
  95474. resetTextureCache(): void;
  95475. /**
  95476. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  95477. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95478. * @returns true if engine is in deterministic lock step mode
  95479. */
  95480. isDeterministicLockStep(): boolean;
  95481. /**
  95482. * Gets the max steps when engine is running in deterministic lock step
  95483. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95484. * @returns the max steps
  95485. */
  95486. getLockstepMaxSteps(): number;
  95487. /**
  95488. * Gets an object containing information about the current webGL context
  95489. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95490. */
  95491. getGlInfo(): {
  95492. vendor: string;
  95493. renderer: string;
  95494. version: string;
  95495. };
  95496. /**
  95497. * Gets current aspect ratio
  95498. * @param viewportOwner defines the camera to use to get the aspect ratio
  95499. * @param useScreen defines if screen size must be used (or the current render target if any)
  95500. * @returns a number defining the aspect ratio
  95501. */
  95502. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  95503. /**
  95504. * Gets current screen aspect ratio
  95505. * @returns a number defining the aspect ratio
  95506. */
  95507. getScreenAspectRatio(): number;
  95508. /**
  95509. * Gets the current render width
  95510. * @param useScreen defines if screen size must be used (or the current render target if any)
  95511. * @returns a number defining the current render width
  95512. */
  95513. getRenderWidth(useScreen?: boolean): number;
  95514. /**
  95515. * Gets the current render height
  95516. * @param useScreen defines if screen size must be used (or the current render target if any)
  95517. * @returns a number defining the current render height
  95518. */
  95519. getRenderHeight(useScreen?: boolean): number;
  95520. /**
  95521. * Gets the HTML canvas attached with the current webGL context
  95522. * @returns a HTML canvas
  95523. */
  95524. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95525. /**
  95526. * Gets host window
  95527. * @returns the host window object
  95528. */
  95529. getHostWindow(): Window;
  95530. /**
  95531. * Gets host document
  95532. * @returns the host document object
  95533. */
  95534. getHostDocument(): Document;
  95535. /**
  95536. * Gets the client rect of the HTML canvas attached with the current webGL context
  95537. * @returns a client rectanglee
  95538. */
  95539. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  95540. /**
  95541. * Defines the hardware scaling level.
  95542. * By default the hardware scaling level is computed from the window device ratio.
  95543. * 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.
  95544. * @param level defines the level to use
  95545. */
  95546. setHardwareScalingLevel(level: number): void;
  95547. /**
  95548. * Gets the current hardware scaling level.
  95549. * By default the hardware scaling level is computed from the window device ratio.
  95550. * 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.
  95551. * @returns a number indicating the current hardware scaling level
  95552. */
  95553. getHardwareScalingLevel(): number;
  95554. /**
  95555. * Gets the list of loaded textures
  95556. * @returns an array containing all loaded textures
  95557. */
  95558. getLoadedTexturesCache(): InternalTexture[];
  95559. /**
  95560. * Gets the object containing all engine capabilities
  95561. * @returns the EngineCapabilities object
  95562. */
  95563. getCaps(): EngineCapabilities;
  95564. /**
  95565. * Gets the current depth function
  95566. * @returns a number defining the depth function
  95567. */
  95568. getDepthFunction(): Nullable<number>;
  95569. /**
  95570. * Sets the current depth function
  95571. * @param depthFunc defines the function to use
  95572. */
  95573. setDepthFunction(depthFunc: number): void;
  95574. /**
  95575. * Sets the current depth function to GREATER
  95576. */
  95577. setDepthFunctionToGreater(): void;
  95578. /**
  95579. * Sets the current depth function to GEQUAL
  95580. */
  95581. setDepthFunctionToGreaterOrEqual(): void;
  95582. /**
  95583. * Sets the current depth function to LESS
  95584. */
  95585. setDepthFunctionToLess(): void;
  95586. private _cachedStencilBuffer;
  95587. private _cachedStencilFunction;
  95588. private _cachedStencilMask;
  95589. private _cachedStencilOperationPass;
  95590. private _cachedStencilOperationFail;
  95591. private _cachedStencilOperationDepthFail;
  95592. private _cachedStencilReference;
  95593. /**
  95594. * Caches the the state of the stencil buffer
  95595. */
  95596. cacheStencilState(): void;
  95597. /**
  95598. * Restores the state of the stencil buffer
  95599. */
  95600. restoreStencilState(): void;
  95601. /**
  95602. * Sets the current depth function to LEQUAL
  95603. */
  95604. setDepthFunctionToLessOrEqual(): void;
  95605. /**
  95606. * Gets a boolean indicating if stencil buffer is enabled
  95607. * @returns the current stencil buffer state
  95608. */
  95609. getStencilBuffer(): boolean;
  95610. /**
  95611. * Enable or disable the stencil buffer
  95612. * @param enable defines if the stencil buffer must be enabled or disabled
  95613. */
  95614. setStencilBuffer(enable: boolean): void;
  95615. /**
  95616. * Gets the current stencil mask
  95617. * @returns a number defining the new stencil mask to use
  95618. */
  95619. getStencilMask(): number;
  95620. /**
  95621. * Sets the current stencil mask
  95622. * @param mask defines the new stencil mask to use
  95623. */
  95624. setStencilMask(mask: number): void;
  95625. /**
  95626. * Gets the current stencil function
  95627. * @returns a number defining the stencil function to use
  95628. */
  95629. getStencilFunction(): number;
  95630. /**
  95631. * Gets the current stencil reference value
  95632. * @returns a number defining the stencil reference value to use
  95633. */
  95634. getStencilFunctionReference(): number;
  95635. /**
  95636. * Gets the current stencil mask
  95637. * @returns a number defining the stencil mask to use
  95638. */
  95639. getStencilFunctionMask(): number;
  95640. /**
  95641. * Sets the current stencil function
  95642. * @param stencilFunc defines the new stencil function to use
  95643. */
  95644. setStencilFunction(stencilFunc: number): void;
  95645. /**
  95646. * Sets the current stencil reference
  95647. * @param reference defines the new stencil reference to use
  95648. */
  95649. setStencilFunctionReference(reference: number): void;
  95650. /**
  95651. * Sets the current stencil mask
  95652. * @param mask defines the new stencil mask to use
  95653. */
  95654. setStencilFunctionMask(mask: number): void;
  95655. /**
  95656. * Gets the current stencil operation when stencil fails
  95657. * @returns a number defining stencil operation to use when stencil fails
  95658. */
  95659. getStencilOperationFail(): number;
  95660. /**
  95661. * Gets the current stencil operation when depth fails
  95662. * @returns a number defining stencil operation to use when depth fails
  95663. */
  95664. getStencilOperationDepthFail(): number;
  95665. /**
  95666. * Gets the current stencil operation when stencil passes
  95667. * @returns a number defining stencil operation to use when stencil passes
  95668. */
  95669. getStencilOperationPass(): number;
  95670. /**
  95671. * Sets the stencil operation to use when stencil fails
  95672. * @param operation defines the stencil operation to use when stencil fails
  95673. */
  95674. setStencilOperationFail(operation: number): void;
  95675. /**
  95676. * Sets the stencil operation to use when depth fails
  95677. * @param operation defines the stencil operation to use when depth fails
  95678. */
  95679. setStencilOperationDepthFail(operation: number): void;
  95680. /**
  95681. * Sets the stencil operation to use when stencil passes
  95682. * @param operation defines the stencil operation to use when stencil passes
  95683. */
  95684. setStencilOperationPass(operation: number): void;
  95685. /**
  95686. * Sets a boolean indicating if the dithering state is enabled or disabled
  95687. * @param value defines the dithering state
  95688. */
  95689. setDitheringState(value: boolean): void;
  95690. /**
  95691. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  95692. * @param value defines the rasterizer state
  95693. */
  95694. setRasterizerState(value: boolean): void;
  95695. /**
  95696. * stop executing a render loop function and remove it from the execution array
  95697. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95698. */
  95699. stopRenderLoop(renderFunction?: () => void): void;
  95700. /** @hidden */
  95701. _renderLoop(): void;
  95702. /**
  95703. * Can be used to override the current requestAnimationFrame requester.
  95704. * @hidden
  95705. */
  95706. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  95707. /**
  95708. * Register and execute a render loop. The engine can have more than one render function
  95709. * @param renderFunction defines the function to continuously execute
  95710. */
  95711. runRenderLoop(renderFunction: () => void): void;
  95712. /**
  95713. * Clear the current render buffer or the current render target (if any is set up)
  95714. * @param color defines the color to use
  95715. * @param backBuffer defines if the back buffer must be cleared
  95716. * @param depth defines if the depth buffer must be cleared
  95717. * @param stencil defines if the stencil buffer must be cleared
  95718. */
  95719. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95720. /**
  95721. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  95722. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95723. * @param y defines the y-coordinate of the corner of the clear rectangle
  95724. * @param width defines the width of the clear rectangle
  95725. * @param height defines the height of the clear rectangle
  95726. * @param clearColor defines the clear color
  95727. */
  95728. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  95729. /**
  95730. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  95731. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95732. * @param y defines the y-coordinate of the corner of the clear rectangle
  95733. * @param width defines the width of the clear rectangle
  95734. * @param height defines the height of the clear rectangle
  95735. */
  95736. enableScissor(x: number, y: number, width: number, height: number): void;
  95737. /**
  95738. * Disable previously set scissor test rectangle
  95739. */
  95740. disableScissor(): void;
  95741. private _viewportCached;
  95742. /** @hidden */
  95743. _viewport(x: number, y: number, width: number, height: number): void;
  95744. /**
  95745. * Set the WebGL's viewport
  95746. * @param viewport defines the viewport element to be used
  95747. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95748. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95749. */
  95750. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95751. /**
  95752. * Directly set the WebGL Viewport
  95753. * @param x defines the x coordinate of the viewport (in screen space)
  95754. * @param y defines the y coordinate of the viewport (in screen space)
  95755. * @param width defines the width of the viewport (in screen space)
  95756. * @param height defines the height of the viewport (in screen space)
  95757. * @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
  95758. */
  95759. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  95760. /**
  95761. * Begin a new frame
  95762. */
  95763. beginFrame(): void;
  95764. /**
  95765. * Enf the current frame
  95766. */
  95767. endFrame(): void;
  95768. /**
  95769. * Resize the view according to the canvas' size
  95770. */
  95771. resize(): void;
  95772. /**
  95773. * Force a specific size of the canvas
  95774. * @param width defines the new canvas' width
  95775. * @param height defines the new canvas' height
  95776. */
  95777. setSize(width: number, height: number): void;
  95778. /**
  95779. * Binds the frame buffer to the specified texture.
  95780. * @param texture The texture to render to or null for the default canvas
  95781. * @param faceIndex The face of the texture to render to in case of cube texture
  95782. * @param requiredWidth The width of the target to render to
  95783. * @param requiredHeight The height of the target to render to
  95784. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95785. * @param depthStencilTexture The depth stencil texture to use to render
  95786. * @param lodLevel defines le lod level to bind to the frame buffer
  95787. */
  95788. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95789. /** @hidden */
  95790. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95791. /**
  95792. * Unbind the current render target texture from the webGL context
  95793. * @param texture defines the render target texture to unbind
  95794. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95795. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95796. */
  95797. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95798. /**
  95799. * Force the mipmap generation for the given render target texture
  95800. * @param texture defines the render target texture to use
  95801. */
  95802. generateMipMapsForCubemap(texture: InternalTexture): void;
  95803. /**
  95804. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95805. */
  95806. flushFramebuffer(): void;
  95807. /**
  95808. * Unbind the current render target and bind the default framebuffer
  95809. */
  95810. restoreDefaultFramebuffer(): void;
  95811. /**
  95812. * Create an uniform buffer
  95813. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95814. * @param elements defines the content of the uniform buffer
  95815. * @returns the webGL uniform buffer
  95816. */
  95817. createUniformBuffer(elements: FloatArray): DataBuffer;
  95818. /**
  95819. * Create a dynamic uniform buffer
  95820. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95821. * @param elements defines the content of the uniform buffer
  95822. * @returns the webGL uniform buffer
  95823. */
  95824. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95825. /**
  95826. * Update an existing uniform buffer
  95827. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95828. * @param uniformBuffer defines the target uniform buffer
  95829. * @param elements defines the content to update
  95830. * @param offset defines the offset in the uniform buffer where update should start
  95831. * @param count defines the size of the data to update
  95832. */
  95833. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95834. private _resetVertexBufferBinding;
  95835. /**
  95836. * Creates a vertex buffer
  95837. * @param data the data for the vertex buffer
  95838. * @returns the new WebGL static buffer
  95839. */
  95840. createVertexBuffer(data: DataArray): DataBuffer;
  95841. private _createVertexBuffer;
  95842. /**
  95843. * Creates a dynamic vertex buffer
  95844. * @param data the data for the dynamic vertex buffer
  95845. * @returns the new WebGL dynamic buffer
  95846. */
  95847. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95848. /**
  95849. * Update a dynamic index buffer
  95850. * @param indexBuffer defines the target index buffer
  95851. * @param indices defines the data to update
  95852. * @param offset defines the offset in the target index buffer where update should start
  95853. */
  95854. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95855. /**
  95856. * Updates a dynamic vertex buffer.
  95857. * @param vertexBuffer the vertex buffer to update
  95858. * @param data the data used to update the vertex buffer
  95859. * @param byteOffset the byte offset of the data
  95860. * @param byteLength the byte length of the data
  95861. */
  95862. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95863. private _resetIndexBufferBinding;
  95864. /**
  95865. * Creates a new index buffer
  95866. * @param indices defines the content of the index buffer
  95867. * @param updatable defines if the index buffer must be updatable
  95868. * @returns a new webGL buffer
  95869. */
  95870. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95871. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  95872. /**
  95873. * Bind a webGL buffer to the webGL context
  95874. * @param buffer defines the buffer to bind
  95875. */
  95876. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95877. /**
  95878. * Bind an uniform buffer to the current webGL context
  95879. * @param buffer defines the buffer to bind
  95880. */
  95881. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95882. /**
  95883. * Bind a buffer to the current webGL context at a given location
  95884. * @param buffer defines the buffer to bind
  95885. * @param location defines the index where to bind the buffer
  95886. */
  95887. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95888. /**
  95889. * Bind a specific block at a given index in a specific shader program
  95890. * @param pipelineContext defines the pipeline context to use
  95891. * @param blockName defines the block name
  95892. * @param index defines the index where to bind the block
  95893. */
  95894. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95895. private bindIndexBuffer;
  95896. private bindBuffer;
  95897. /**
  95898. * update the bound buffer with the given data
  95899. * @param data defines the data to update
  95900. */
  95901. updateArrayBuffer(data: Float32Array): void;
  95902. private _vertexAttribPointer;
  95903. private _bindIndexBufferWithCache;
  95904. private _bindVertexBuffersAttributes;
  95905. /**
  95906. * Records a vertex array object
  95907. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95908. * @param vertexBuffers defines the list of vertex buffers to store
  95909. * @param indexBuffer defines the index buffer to store
  95910. * @param effect defines the effect to store
  95911. * @returns the new vertex array object
  95912. */
  95913. recordVertexArrayObject(vertexBuffers: {
  95914. [key: string]: VertexBuffer;
  95915. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95916. /**
  95917. * Bind a specific vertex array object
  95918. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95919. * @param vertexArrayObject defines the vertex array object to bind
  95920. * @param indexBuffer defines the index buffer to bind
  95921. */
  95922. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95923. /**
  95924. * Bind webGl buffers directly to the webGL context
  95925. * @param vertexBuffer defines the vertex buffer to bind
  95926. * @param indexBuffer defines the index buffer to bind
  95927. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95928. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95929. * @param effect defines the effect associated with the vertex buffer
  95930. */
  95931. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95932. private _unbindVertexArrayObject;
  95933. /**
  95934. * Bind a list of vertex buffers to the webGL context
  95935. * @param vertexBuffers defines the list of vertex buffers to bind
  95936. * @param indexBuffer defines the index buffer to bind
  95937. * @param effect defines the effect associated with the vertex buffers
  95938. */
  95939. bindBuffers(vertexBuffers: {
  95940. [key: string]: Nullable<VertexBuffer>;
  95941. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95942. /**
  95943. * Unbind all instance attributes
  95944. */
  95945. unbindInstanceAttributes(): void;
  95946. /**
  95947. * Release and free the memory of a vertex array object
  95948. * @param vao defines the vertex array object to delete
  95949. */
  95950. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95951. /** @hidden */
  95952. _releaseBuffer(buffer: DataBuffer): boolean;
  95953. protected _deleteBuffer(buffer: DataBuffer): void;
  95954. /**
  95955. * Creates a webGL buffer to use with instanciation
  95956. * @param capacity defines the size of the buffer
  95957. * @returns the webGL buffer
  95958. */
  95959. createInstancesBuffer(capacity: number): DataBuffer;
  95960. /**
  95961. * Delete a webGL buffer used with instanciation
  95962. * @param buffer defines the webGL buffer to delete
  95963. */
  95964. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95965. /**
  95966. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95967. * @param instancesBuffer defines the webGL buffer to update and bind
  95968. * @param data defines the data to store in the buffer
  95969. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95970. */
  95971. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95972. /**
  95973. * Apply all cached states (depth, culling, stencil and alpha)
  95974. */
  95975. applyStates(): void;
  95976. /**
  95977. * Send a draw order
  95978. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95979. * @param indexStart defines the starting index
  95980. * @param indexCount defines the number of index to draw
  95981. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95982. */
  95983. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95984. /**
  95985. * Draw a list of points
  95986. * @param verticesStart defines the index of first vertex to draw
  95987. * @param verticesCount defines the count of vertices to draw
  95988. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95989. */
  95990. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95991. /**
  95992. * Draw a list of unindexed primitives
  95993. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95994. * @param verticesStart defines the index of first vertex to draw
  95995. * @param verticesCount defines the count of vertices to draw
  95996. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95997. */
  95998. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95999. /**
  96000. * Draw a list of indexed primitives
  96001. * @param fillMode defines the primitive to use
  96002. * @param indexStart defines the starting index
  96003. * @param indexCount defines the number of index to draw
  96004. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96005. */
  96006. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96007. /**
  96008. * Draw a list of unindexed primitives
  96009. * @param fillMode defines the primitive to use
  96010. * @param verticesStart defines the index of first vertex to draw
  96011. * @param verticesCount defines the count of vertices to draw
  96012. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96013. */
  96014. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96015. private _drawMode;
  96016. /** @hidden */
  96017. _releaseEffect(effect: Effect): void;
  96018. /** @hidden */
  96019. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96020. /**
  96021. * Create a new effect (used to store vertex/fragment shaders)
  96022. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96023. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96024. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96025. * @param samplers defines an array of string used to represent textures
  96026. * @param defines defines the string containing the defines to use to compile the shaders
  96027. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96028. * @param onCompiled defines a function to call when the effect creation is successful
  96029. * @param onError defines a function to call when the effect creation has failed
  96030. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96031. * @returns the new Effect
  96032. */
  96033. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | BaseEngine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96034. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96035. private _compileShader;
  96036. private _compileRawShader;
  96037. /**
  96038. * Directly creates a webGL program
  96039. * @param pipelineContext defines the pipeline context to attach to
  96040. * @param vertexCode defines the vertex shader code to use
  96041. * @param fragmentCode defines the fragment shader code to use
  96042. * @param context defines the webGL context to use (if not set, the current one will be used)
  96043. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96044. * @returns the new webGL program
  96045. */
  96046. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96047. /**
  96048. * Creates a webGL program
  96049. * @param pipelineContext defines the pipeline context to attach to
  96050. * @param vertexCode defines the vertex shader code to use
  96051. * @param fragmentCode defines the fragment shader code to use
  96052. * @param defines defines the string containing the defines to use to compile the shaders
  96053. * @param context defines the webGL context to use (if not set, the current one will be used)
  96054. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96055. * @returns the new webGL program
  96056. */
  96057. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96058. /**
  96059. * Creates a new pipeline context
  96060. * @returns the new pipeline
  96061. */
  96062. createPipelineContext(): IPipelineContext;
  96063. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96064. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96065. /** @hidden */
  96066. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96067. /** @hidden */
  96068. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96069. /** @hidden */
  96070. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96071. /**
  96072. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96073. * @param pipelineContext defines the pipeline context to use
  96074. * @param uniformsNames defines the list of uniform names
  96075. * @returns an array of webGL uniform locations
  96076. */
  96077. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96078. /**
  96079. * Gets the lsit of active attributes for a given webGL program
  96080. * @param pipelineContext defines the pipeline context to use
  96081. * @param attributesNames defines the list of attribute names to get
  96082. * @returns an array of indices indicating the offset of each attribute
  96083. */
  96084. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96085. /**
  96086. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96087. * @param effect defines the effect to activate
  96088. */
  96089. enableEffect(effect: Nullable<Effect>): void;
  96090. /**
  96091. * Set the value of an uniform to an array of int32
  96092. * @param uniform defines the webGL uniform location where to store the value
  96093. * @param array defines the array of int32 to store
  96094. */
  96095. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96096. /**
  96097. * Set the value of an uniform to an array of int32 (stored as vec2)
  96098. * @param uniform defines the webGL uniform location where to store the value
  96099. * @param array defines the array of int32 to store
  96100. */
  96101. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96102. /**
  96103. * Set the value of an uniform to an array of int32 (stored as vec3)
  96104. * @param uniform defines the webGL uniform location where to store the value
  96105. * @param array defines the array of int32 to store
  96106. */
  96107. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96108. /**
  96109. * Set the value of an uniform to an array of int32 (stored as vec4)
  96110. * @param uniform defines the webGL uniform location where to store the value
  96111. * @param array defines the array of int32 to store
  96112. */
  96113. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96114. /**
  96115. * Set the value of an uniform to an array of float32
  96116. * @param uniform defines the webGL uniform location where to store the value
  96117. * @param array defines the array of float32 to store
  96118. */
  96119. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96120. /**
  96121. * Set the value of an uniform to an array of float32 (stored as vec2)
  96122. * @param uniform defines the webGL uniform location where to store the value
  96123. * @param array defines the array of float32 to store
  96124. */
  96125. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96126. /**
  96127. * Set the value of an uniform to an array of float32 (stored as vec3)
  96128. * @param uniform defines the webGL uniform location where to store the value
  96129. * @param array defines the array of float32 to store
  96130. */
  96131. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96132. /**
  96133. * Set the value of an uniform to an array of float32 (stored as vec4)
  96134. * @param uniform defines the webGL uniform location where to store the value
  96135. * @param array defines the array of float32 to store
  96136. */
  96137. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96138. /**
  96139. * Set the value of an uniform to an array of number
  96140. * @param uniform defines the webGL uniform location where to store the value
  96141. * @param array defines the array of number to store
  96142. */
  96143. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96144. /**
  96145. * Set the value of an uniform to an array of number (stored as vec2)
  96146. * @param uniform defines the webGL uniform location where to store the value
  96147. * @param array defines the array of number to store
  96148. */
  96149. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96150. /**
  96151. * Set the value of an uniform to an array of number (stored as vec3)
  96152. * @param uniform defines the webGL uniform location where to store the value
  96153. * @param array defines the array of number to store
  96154. */
  96155. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96156. /**
  96157. * Set the value of an uniform to an array of number (stored as vec4)
  96158. * @param uniform defines the webGL uniform location where to store the value
  96159. * @param array defines the array of number to store
  96160. */
  96161. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96162. /**
  96163. * Set the value of an uniform to an array of float32 (stored as matrices)
  96164. * @param uniform defines the webGL uniform location where to store the value
  96165. * @param matrices defines the array of float32 to store
  96166. */
  96167. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96168. /**
  96169. * Set the value of an uniform to a matrix (3x3)
  96170. * @param uniform defines the webGL uniform location where to store the value
  96171. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96172. */
  96173. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96174. /**
  96175. * Set the value of an uniform to a matrix (2x2)
  96176. * @param uniform defines the webGL uniform location where to store the value
  96177. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96178. */
  96179. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96180. /**
  96181. * Set the value of an uniform to a number (int)
  96182. * @param uniform defines the webGL uniform location where to store the value
  96183. * @param value defines the int number to store
  96184. */
  96185. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96186. /**
  96187. * Set the value of an uniform to a number (float)
  96188. * @param uniform defines the webGL uniform location where to store the value
  96189. * @param value defines the float number to store
  96190. */
  96191. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96192. /**
  96193. * Set the value of an uniform to a vec2
  96194. * @param uniform defines the webGL uniform location where to store the value
  96195. * @param x defines the 1st component of the value
  96196. * @param y defines the 2nd component of the value
  96197. */
  96198. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96199. /**
  96200. * Set the value of an uniform to a vec3
  96201. * @param uniform defines the webGL uniform location where to store the value
  96202. * @param x defines the 1st component of the value
  96203. * @param y defines the 2nd component of the value
  96204. * @param z defines the 3rd component of the value
  96205. */
  96206. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96207. /**
  96208. * Set the value of an uniform to a boolean
  96209. * @param uniform defines the webGL uniform location where to store the value
  96210. * @param bool defines the boolean to store
  96211. */
  96212. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96213. /**
  96214. * Set the value of an uniform to a vec4
  96215. * @param uniform defines the webGL uniform location where to store the value
  96216. * @param x defines the 1st component of the value
  96217. * @param y defines the 2nd component of the value
  96218. * @param z defines the 3rd component of the value
  96219. * @param w defines the 4th component of the value
  96220. */
  96221. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96222. /**
  96223. * Sets a Color4 on a uniform variable
  96224. * @param uniform defines the uniform location
  96225. * @param color4 defines the value to be set
  96226. */
  96227. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96228. /**
  96229. * Set various states to the webGL context
  96230. * @param culling defines backface culling state
  96231. * @param zOffset defines the value to apply to zOffset (0 by default)
  96232. * @param force defines if states must be applied even if cache is up to date
  96233. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96234. */
  96235. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96236. /**
  96237. * Set the z offset to apply to current rendering
  96238. * @param value defines the offset to apply
  96239. */
  96240. setZOffset(value: number): void;
  96241. /**
  96242. * Gets the current value of the zOffset
  96243. * @returns the current zOffset state
  96244. */
  96245. getZOffset(): number;
  96246. /**
  96247. * Enable or disable depth buffering
  96248. * @param enable defines the state to set
  96249. */
  96250. setDepthBuffer(enable: boolean): void;
  96251. /**
  96252. * Gets a boolean indicating if depth writing is enabled
  96253. * @returns the current depth writing state
  96254. */
  96255. getDepthWrite(): boolean;
  96256. /**
  96257. * Enable or disable depth writing
  96258. * @param enable defines the state to set
  96259. */
  96260. setDepthWrite(enable: boolean): void;
  96261. /**
  96262. * Enable or disable color writing
  96263. * @param enable defines the state to set
  96264. */
  96265. setColorWrite(enable: boolean): void;
  96266. /**
  96267. * Gets a boolean indicating if color writing is enabled
  96268. * @returns the current color writing state
  96269. */
  96270. getColorWrite(): boolean;
  96271. /**
  96272. * Sets alpha constants used by some alpha blending modes
  96273. * @param r defines the red component
  96274. * @param g defines the green component
  96275. * @param b defines the blue component
  96276. * @param a defines the alpha component
  96277. */
  96278. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96279. /**
  96280. * Sets the current alpha mode
  96281. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96282. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96283. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96284. */
  96285. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96286. /**
  96287. * Gets the current alpha mode
  96288. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96289. * @returns the current alpha mode
  96290. */
  96291. getAlphaMode(): number;
  96292. /**
  96293. * Sets the current alpha equation
  96294. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  96295. */
  96296. setAlphaEquation(equation: number): void;
  96297. /**
  96298. * Gets the current alpha equation.
  96299. * @returns the current alpha equation
  96300. */
  96301. getAlphaEquation(): number;
  96302. /**
  96303. * Clears the list of texture accessible through engine.
  96304. * This can help preventing texture load conflict due to name collision.
  96305. */
  96306. clearInternalTexturesCache(): void;
  96307. /**
  96308. * Force the entire cache to be cleared
  96309. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96310. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96311. */
  96312. wipeCaches(bruteForce?: boolean): void;
  96313. /**
  96314. * Set the compressed texture format to use, based on the formats you have, and the formats
  96315. * supported by the hardware / browser.
  96316. *
  96317. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96318. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96319. * to API arguments needed to compressed textures. This puts the burden on the container
  96320. * generator to house the arcane code for determining these for current & future formats.
  96321. *
  96322. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96323. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96324. *
  96325. * Note: The result of this call is not taken into account when a texture is base64.
  96326. *
  96327. * @param formatsAvailable defines the list of those format families you have created
  96328. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  96329. *
  96330. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  96331. * @returns The extension selected.
  96332. */
  96333. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  96334. /** @hidden */
  96335. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96336. min: number;
  96337. mag: number;
  96338. };
  96339. /** @hidden */
  96340. _createTexture(): WebGLTexture;
  96341. /**
  96342. * Usually called from Texture.ts.
  96343. * Passed information to create a WebGLTexture
  96344. * @param urlArg defines a value which contains one of the following:
  96345. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96346. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96347. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96348. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96349. * @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)
  96350. * @param scene needed for loading to the correct scene
  96351. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96352. * @param onLoad optional callback to be called upon successful completion
  96353. * @param onError optional callback to be called upon failure
  96354. * @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
  96355. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96356. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96357. * @param forcedExtension defines the extension to use to pick the right loader
  96358. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96359. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96360. */
  96361. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96362. /**
  96363. * @hidden
  96364. */
  96365. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96366. private _unpackFlipYCached;
  96367. /**
  96368. * In case you are sharing the context with other applications, it might
  96369. * be interested to not cache the unpack flip y state to ensure a consistent
  96370. * value would be set.
  96371. */
  96372. enableUnpackFlipYCached: boolean;
  96373. /** @hidden */
  96374. _unpackFlipY(value: boolean): void;
  96375. /** @hidden */
  96376. _getUnpackAlignement(): number;
  96377. /**
  96378. * Creates a dynamic texture
  96379. * @param width defines the width of the texture
  96380. * @param height defines the height of the texture
  96381. * @param generateMipMaps defines if the engine should generate the mip levels
  96382. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96383. * @returns the dynamic texture inside an InternalTexture
  96384. */
  96385. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  96386. /**
  96387. * Update the sampling mode of a given texture
  96388. * @param samplingMode defines the required sampling mode
  96389. * @param texture defines the texture to update
  96390. */
  96391. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96392. /**
  96393. * Update the content of a dynamic texture
  96394. * @param texture defines the texture to update
  96395. * @param canvas defines the canvas containing the source
  96396. * @param invertY defines if data must be stored with Y axis inverted
  96397. * @param premulAlpha defines if alpha is stored as premultiplied
  96398. * @param format defines the format of the data
  96399. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  96400. */
  96401. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  96402. /**
  96403. * Update a video texture
  96404. * @param texture defines the texture to update
  96405. * @param video defines the video element to use
  96406. * @param invertY defines if data must be stored with Y axis inverted
  96407. */
  96408. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96409. /**
  96410. * Updates a depth texture Comparison Mode and Function.
  96411. * If the comparison Function is equal to 0, the mode will be set to none.
  96412. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96413. * @param texture The texture to set the comparison function for
  96414. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96415. */
  96416. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96417. /** @hidden */
  96418. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96419. width: number;
  96420. height: number;
  96421. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96422. /**
  96423. * Creates a depth stencil texture.
  96424. * This is only available in WebGL 2 or with the depth texture extension available.
  96425. * @param size The size of face edge in the texture.
  96426. * @param options The options defining the texture.
  96427. * @returns The texture
  96428. */
  96429. createDepthStencilTexture(size: number | {
  96430. width: number;
  96431. height: number;
  96432. }, options: DepthTextureCreationOptions): InternalTexture;
  96433. /**
  96434. * Creates a depth stencil texture.
  96435. * This is only available in WebGL 2 or with the depth texture extension available.
  96436. * @param size The size of face edge in the texture.
  96437. * @param options The options defining the texture.
  96438. * @returns The texture
  96439. */
  96440. private _createDepthStencilTexture;
  96441. /**
  96442. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96443. * @param renderTarget The render target to set the frame buffer for
  96444. */
  96445. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96446. /**
  96447. * Creates a new render target texture
  96448. * @param size defines the size of the texture
  96449. * @param options defines the options used to create the texture
  96450. * @returns a new render target texture stored in an InternalTexture
  96451. */
  96452. createRenderTargetTexture(size: number | {
  96453. width: number;
  96454. height: number;
  96455. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96456. /** @hidden */
  96457. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96458. /**
  96459. * Updates the sample count of a render target texture
  96460. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  96461. * @param texture defines the texture to update
  96462. * @param samples defines the sample count to set
  96463. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  96464. */
  96465. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  96466. /** @hidden */
  96467. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96468. /** @hidden */
  96469. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96470. /** @hidden */
  96471. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96472. /** @hidden */
  96473. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96474. /**
  96475. * @hidden
  96476. */
  96477. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96478. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96479. private _prepareWebGLTexture;
  96480. /** @hidden */
  96481. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  96482. /** @hidden */
  96483. _releaseFramebufferObjects(texture: InternalTexture): void;
  96484. /** @hidden */
  96485. _releaseTexture(texture: InternalTexture): void;
  96486. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96487. protected _setProgram(program: WebGLProgram): void;
  96488. protected _boundUniforms: {
  96489. [key: number]: WebGLUniformLocation;
  96490. };
  96491. /**
  96492. * Binds an effect to the webGL context
  96493. * @param effect defines the effect to bind
  96494. */
  96495. bindSamplers(effect: Effect): void;
  96496. private _activateCurrentTexture;
  96497. /** @hidden */
  96498. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96499. /** @hidden */
  96500. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96501. /**
  96502. * Sets a texture to the webGL context from a postprocess
  96503. * @param channel defines the channel to use
  96504. * @param postProcess defines the source postprocess
  96505. */
  96506. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  96507. /**
  96508. * Binds the output of the passed in post process to the texture channel specified
  96509. * @param channel The channel the texture should be bound to
  96510. * @param postProcess The post process which's output should be bound
  96511. */
  96512. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  96513. /**
  96514. * Unbind all textures from the webGL context
  96515. */
  96516. unbindAllTextures(): void;
  96517. /**
  96518. * Sets a texture to the according uniform.
  96519. * @param channel The texture channel
  96520. * @param uniform The uniform to set
  96521. * @param texture The texture to apply
  96522. */
  96523. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96524. /**
  96525. * Sets a depth stencil texture from a render target to the according uniform.
  96526. * @param channel The texture channel
  96527. * @param uniform The uniform to set
  96528. * @param texture The render target texture containing the depth stencil texture to apply
  96529. */
  96530. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  96531. private _bindSamplerUniformToChannel;
  96532. private _getTextureWrapMode;
  96533. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96534. /**
  96535. * Sets an array of texture to the webGL context
  96536. * @param channel defines the channel where the texture array must be set
  96537. * @param uniform defines the associated uniform location
  96538. * @param textures defines the array of textures to bind
  96539. */
  96540. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96541. /** @hidden */
  96542. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96543. private _setTextureParameterFloat;
  96544. private _setTextureParameterInteger;
  96545. /**
  96546. * Reads pixels from the current frame buffer. Please note that this function can be slow
  96547. * @param x defines the x coordinate of the rectangle where pixels must be read
  96548. * @param y defines the y coordinate of the rectangle where pixels must be read
  96549. * @param width defines the width of the rectangle where pixels must be read
  96550. * @param height defines the height of the rectangle where pixels must be read
  96551. * @returns a Uint8Array containing RGBA colors
  96552. */
  96553. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  96554. /**
  96555. * Unbind all vertex attributes from the webGL context
  96556. */
  96557. unbindAllAttributes(): void;
  96558. /**
  96559. * 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
  96560. */
  96561. releaseEffects(): void;
  96562. /**
  96563. * Dispose and release all associated resources
  96564. */
  96565. dispose(): void;
  96566. /**
  96567. * Attach a new callback raised when context lost event is fired
  96568. * @param callback defines the callback to call
  96569. */
  96570. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96571. /**
  96572. * Attach a new callback raised when context restored event is fired
  96573. * @param callback defines the callback to call
  96574. */
  96575. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96576. /**
  96577. * Gets the source code of the vertex shader associated with a specific webGL program
  96578. * @param program defines the program to use
  96579. * @returns a string containing the source code of the vertex shader associated with the program
  96580. */
  96581. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  96582. /**
  96583. * Gets the source code of the fragment shader associated with a specific webGL program
  96584. * @param program defines the program to use
  96585. * @returns a string containing the source code of the fragment shader associated with the program
  96586. */
  96587. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  96588. /**
  96589. * Get the current error code of the webGL context
  96590. * @returns the error code
  96591. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96592. */
  96593. getError(): number;
  96594. private _canRenderToFloatFramebuffer;
  96595. private _canRenderToHalfFloatFramebuffer;
  96596. private _canRenderToFramebuffer;
  96597. /** @hidden */
  96598. _getWebGLTextureType(type: number): number;
  96599. /** @hidden */
  96600. _getInternalFormat(format: number): number;
  96601. /** @hidden */
  96602. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96603. /** @hidden */
  96604. _getRGBAMultiSampleBufferFormat(type: number): number;
  96605. /** @hidden */
  96606. _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;
  96607. /** @hidden */
  96608. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96609. /**
  96610. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96611. * @returns true if the engine can be created
  96612. * @ignorenaming
  96613. */
  96614. static isSupported(): boolean;
  96615. /**
  96616. * Find the next highest power of two.
  96617. * @param x Number to start search from.
  96618. * @return Next highest power of two.
  96619. */
  96620. static CeilingPOT(x: number): number;
  96621. /**
  96622. * Find the next lowest power of two.
  96623. * @param x Number to start search from.
  96624. * @return Next lowest power of two.
  96625. */
  96626. static FloorPOT(x: number): number;
  96627. /**
  96628. * Find the nearest power of two.
  96629. * @param x Number to start search from.
  96630. * @return Next nearest power of two.
  96631. */
  96632. static NearestPOT(x: number): number;
  96633. /**
  96634. * Get the closest exponent of two
  96635. * @param value defines the value to approximate
  96636. * @param max defines the maximum value to return
  96637. * @param mode defines how to define the closest value
  96638. * @returns closest exponent of two of the given value
  96639. */
  96640. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96641. /**
  96642. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96643. * @param func - the function to be called
  96644. * @param requester - the object that will request the next frame. Falls back to window.
  96645. * @returns frame number
  96646. */
  96647. static QueueNewFrame(func: () => void, requester?: any): number;
  96648. /**
  96649. * Ask the browser to promote the current element to pointerlock mode
  96650. * @param element defines the DOM element to promote
  96651. */
  96652. static _RequestPointerlock(element: HTMLElement): void;
  96653. /**
  96654. * Asks the browser to exit pointerlock mode
  96655. */
  96656. static _ExitPointerlock(): void;
  96657. /**
  96658. * Ask the browser to promote the current element to fullscreen rendering mode
  96659. * @param element defines the DOM element to promote
  96660. */
  96661. static _RequestFullscreen(element: HTMLElement): void;
  96662. /**
  96663. * Asks the browser to exit fullscreen mode
  96664. */
  96665. static _ExitFullscreen(): void;
  96666. }
  96667. }
  96668. declare module BABYLON {
  96669. /**
  96670. * Class used to store data associated with WebGL texture data for the engine
  96671. * This class should not be used directly
  96672. */
  96673. export class InternalTexture {
  96674. /** @hidden */
  96675. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  96676. /**
  96677. * The source of the texture data is unknown
  96678. */
  96679. static DATASOURCE_UNKNOWN: number;
  96680. /**
  96681. * Texture data comes from an URL
  96682. */
  96683. static DATASOURCE_URL: number;
  96684. /**
  96685. * Texture data is only used for temporary storage
  96686. */
  96687. static DATASOURCE_TEMP: number;
  96688. /**
  96689. * Texture data comes from raw data (ArrayBuffer)
  96690. */
  96691. static DATASOURCE_RAW: number;
  96692. /**
  96693. * Texture content is dynamic (video or dynamic texture)
  96694. */
  96695. static DATASOURCE_DYNAMIC: number;
  96696. /**
  96697. * Texture content is generated by rendering to it
  96698. */
  96699. static DATASOURCE_RENDERTARGET: number;
  96700. /**
  96701. * Texture content is part of a multi render target process
  96702. */
  96703. static DATASOURCE_MULTIRENDERTARGET: number;
  96704. /**
  96705. * Texture data comes from a cube data file
  96706. */
  96707. static DATASOURCE_CUBE: number;
  96708. /**
  96709. * Texture data comes from a raw cube data
  96710. */
  96711. static DATASOURCE_CUBERAW: number;
  96712. /**
  96713. * Texture data come from a prefiltered cube data file
  96714. */
  96715. static DATASOURCE_CUBEPREFILTERED: number;
  96716. /**
  96717. * Texture content is raw 3D data
  96718. */
  96719. static DATASOURCE_RAW3D: number;
  96720. /**
  96721. * Texture content is a depth texture
  96722. */
  96723. static DATASOURCE_DEPTHTEXTURE: number;
  96724. /**
  96725. * Texture data comes from a raw cube data encoded with RGBD
  96726. */
  96727. static DATASOURCE_CUBERAW_RGBD: number;
  96728. /**
  96729. * Defines if the texture is ready
  96730. */
  96731. isReady: boolean;
  96732. /**
  96733. * Defines if the texture is a cube texture
  96734. */
  96735. isCube: boolean;
  96736. /**
  96737. * Defines if the texture contains 3D data
  96738. */
  96739. is3D: boolean;
  96740. /**
  96741. * Defines if the texture contains multiview data
  96742. */
  96743. isMultiview: boolean;
  96744. /**
  96745. * Gets the URL used to load this texture
  96746. */
  96747. url: string;
  96748. /**
  96749. * Gets the sampling mode of the texture
  96750. */
  96751. samplingMode: number;
  96752. /**
  96753. * Gets a boolean indicating if the texture needs mipmaps generation
  96754. */
  96755. generateMipMaps: boolean;
  96756. /**
  96757. * Gets the number of samples used by the texture (WebGL2+ only)
  96758. */
  96759. samples: number;
  96760. /**
  96761. * Gets the type of the texture (int, float...)
  96762. */
  96763. type: number;
  96764. /**
  96765. * Gets the format of the texture (RGB, RGBA...)
  96766. */
  96767. format: number;
  96768. /**
  96769. * Observable called when the texture is loaded
  96770. */
  96771. onLoadedObservable: Observable<InternalTexture>;
  96772. /**
  96773. * Gets the width of the texture
  96774. */
  96775. width: number;
  96776. /**
  96777. * Gets the height of the texture
  96778. */
  96779. height: number;
  96780. /**
  96781. * Gets the depth of the texture
  96782. */
  96783. depth: number;
  96784. /**
  96785. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  96786. */
  96787. baseWidth: number;
  96788. /**
  96789. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  96790. */
  96791. baseHeight: number;
  96792. /**
  96793. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  96794. */
  96795. baseDepth: number;
  96796. /**
  96797. * Gets a boolean indicating if the texture is inverted on Y axis
  96798. */
  96799. invertY: boolean;
  96800. /** @hidden */
  96801. _invertVScale: boolean;
  96802. /** @hidden */
  96803. _associatedChannel: number;
  96804. /** @hidden */
  96805. _dataSource: number;
  96806. /** @hidden */
  96807. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  96808. /** @hidden */
  96809. _bufferView: Nullable<ArrayBufferView>;
  96810. /** @hidden */
  96811. _bufferViewArray: Nullable<ArrayBufferView[]>;
  96812. /** @hidden */
  96813. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  96814. /** @hidden */
  96815. _size: number;
  96816. /** @hidden */
  96817. _extension: string;
  96818. /** @hidden */
  96819. _files: Nullable<string[]>;
  96820. /** @hidden */
  96821. _workingCanvas: Nullable<HTMLCanvasElement>;
  96822. /** @hidden */
  96823. _workingContext: Nullable<CanvasRenderingContext2D>;
  96824. /** @hidden */
  96825. _framebuffer: Nullable<WebGLFramebuffer>;
  96826. /** @hidden */
  96827. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  96828. /** @hidden */
  96829. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  96830. /** @hidden */
  96831. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  96832. /** @hidden */
  96833. _attachments: Nullable<number[]>;
  96834. /** @hidden */
  96835. _cachedCoordinatesMode: Nullable<number>;
  96836. /** @hidden */
  96837. _cachedWrapU: Nullable<number>;
  96838. /** @hidden */
  96839. _cachedWrapV: Nullable<number>;
  96840. /** @hidden */
  96841. _cachedWrapR: Nullable<number>;
  96842. /** @hidden */
  96843. _cachedAnisotropicFilteringLevel: Nullable<number>;
  96844. /** @hidden */
  96845. _isDisabled: boolean;
  96846. /** @hidden */
  96847. _compression: Nullable<string>;
  96848. /** @hidden */
  96849. _generateStencilBuffer: boolean;
  96850. /** @hidden */
  96851. _generateDepthBuffer: boolean;
  96852. /** @hidden */
  96853. _comparisonFunction: number;
  96854. /** @hidden */
  96855. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  96856. /** @hidden */
  96857. _lodGenerationScale: number;
  96858. /** @hidden */
  96859. _lodGenerationOffset: number;
  96860. /** @hidden */
  96861. _colorTextureArray: Nullable<WebGLTexture>;
  96862. /** @hidden */
  96863. _depthStencilTextureArray: Nullable<WebGLTexture>;
  96864. /** @hidden */
  96865. _lodTextureHigh: Nullable<BaseTexture>;
  96866. /** @hidden */
  96867. _lodTextureMid: Nullable<BaseTexture>;
  96868. /** @hidden */
  96869. _lodTextureLow: Nullable<BaseTexture>;
  96870. /** @hidden */
  96871. _isRGBD: boolean;
  96872. /** @hidden */
  96873. _linearSpecularLOD: boolean;
  96874. /** @hidden */
  96875. _irradianceTexture: Nullable<BaseTexture>;
  96876. /** @hidden */
  96877. _webGLTexture: Nullable<WebGLTexture>;
  96878. /** @hidden */
  96879. _references: number;
  96880. private _engine;
  96881. /**
  96882. * Gets the Engine the texture belongs to.
  96883. * @returns The babylon engine
  96884. */
  96885. getEngine(): BaseEngine;
  96886. /**
  96887. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  96888. */
  96889. readonly dataSource: number;
  96890. /**
  96891. * Creates a new InternalTexture
  96892. * @param engine defines the engine to use
  96893. * @param dataSource defines the type of data that will be used
  96894. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96895. */
  96896. constructor(engine: BaseEngine, dataSource: number, delayAllocation?: boolean);
  96897. /**
  96898. * Increments the number of references (ie. the number of Texture that point to it)
  96899. */
  96900. incrementReferences(): void;
  96901. /**
  96902. * Change the size of the texture (not the size of the content)
  96903. * @param width defines the new width
  96904. * @param height defines the new height
  96905. * @param depth defines the new depth (1 by default)
  96906. */
  96907. updateSize(width: int, height: int, depth?: int): void;
  96908. /** @hidden */
  96909. _rebuild(): void;
  96910. /** @hidden */
  96911. _swapAndDie(target: InternalTexture): void;
  96912. /**
  96913. * Dispose the current allocated resources
  96914. */
  96915. dispose(): void;
  96916. }
  96917. }
  96918. declare module BABYLON {
  96919. /**
  96920. * Class used to work with sound analyzer using fast fourier transform (FFT)
  96921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96922. */
  96923. export class Analyser {
  96924. /**
  96925. * Gets or sets the smoothing
  96926. * @ignorenaming
  96927. */
  96928. SMOOTHING: number;
  96929. /**
  96930. * Gets or sets the FFT table size
  96931. * @ignorenaming
  96932. */
  96933. FFT_SIZE: number;
  96934. /**
  96935. * Gets or sets the bar graph amplitude
  96936. * @ignorenaming
  96937. */
  96938. BARGRAPHAMPLITUDE: number;
  96939. /**
  96940. * Gets or sets the position of the debug canvas
  96941. * @ignorenaming
  96942. */
  96943. DEBUGCANVASPOS: {
  96944. x: number;
  96945. y: number;
  96946. };
  96947. /**
  96948. * Gets or sets the debug canvas size
  96949. * @ignorenaming
  96950. */
  96951. DEBUGCANVASSIZE: {
  96952. width: number;
  96953. height: number;
  96954. };
  96955. private _byteFreqs;
  96956. private _byteTime;
  96957. private _floatFreqs;
  96958. private _webAudioAnalyser;
  96959. private _debugCanvas;
  96960. private _debugCanvasContext;
  96961. private _scene;
  96962. private _registerFunc;
  96963. private _audioEngine;
  96964. /**
  96965. * Creates a new analyser
  96966. * @param scene defines hosting scene
  96967. */
  96968. constructor(scene: Scene);
  96969. /**
  96970. * Get the number of data values you will have to play with for the visualization
  96971. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  96972. * @returns a number
  96973. */
  96974. getFrequencyBinCount(): number;
  96975. /**
  96976. * Gets the current frequency data as a byte array
  96977. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  96978. * @returns a Uint8Array
  96979. */
  96980. getByteFrequencyData(): Uint8Array;
  96981. /**
  96982. * Gets the current waveform as a byte array
  96983. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  96984. * @returns a Uint8Array
  96985. */
  96986. getByteTimeDomainData(): Uint8Array;
  96987. /**
  96988. * Gets the current frequency data as a float array
  96989. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  96990. * @returns a Float32Array
  96991. */
  96992. getFloatFrequencyData(): Float32Array;
  96993. /**
  96994. * Renders the debug canvas
  96995. */
  96996. drawDebugCanvas(): void;
  96997. /**
  96998. * Stops rendering the debug canvas and removes it
  96999. */
  97000. stopDebugCanvas(): void;
  97001. /**
  97002. * Connects two audio nodes
  97003. * @param inputAudioNode defines first node to connect
  97004. * @param outputAudioNode defines second node to connect
  97005. */
  97006. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97007. /**
  97008. * Releases all associated resources
  97009. */
  97010. dispose(): void;
  97011. }
  97012. }
  97013. declare module BABYLON {
  97014. /**
  97015. * This represents an audio engine and it is responsible
  97016. * to play, synchronize and analyse sounds throughout the application.
  97017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97018. */
  97019. export interface IAudioEngine extends IDisposable {
  97020. /**
  97021. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97022. */
  97023. readonly canUseWebAudio: boolean;
  97024. /**
  97025. * Gets the current AudioContext if available.
  97026. */
  97027. readonly audioContext: Nullable<AudioContext>;
  97028. /**
  97029. * The master gain node defines the global audio volume of your audio engine.
  97030. */
  97031. readonly masterGain: GainNode;
  97032. /**
  97033. * Gets whether or not mp3 are supported by your browser.
  97034. */
  97035. readonly isMP3supported: boolean;
  97036. /**
  97037. * Gets whether or not ogg are supported by your browser.
  97038. */
  97039. readonly isOGGsupported: boolean;
  97040. /**
  97041. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97042. * @ignoreNaming
  97043. */
  97044. WarnedWebAudioUnsupported: boolean;
  97045. /**
  97046. * Defines if the audio engine relies on a custom unlocked button.
  97047. * In this case, the embedded button will not be displayed.
  97048. */
  97049. useCustomUnlockedButton: boolean;
  97050. /**
  97051. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97052. */
  97053. readonly unlocked: boolean;
  97054. /**
  97055. * Event raised when audio has been unlocked on the browser.
  97056. */
  97057. onAudioUnlockedObservable: Observable<AudioEngine>;
  97058. /**
  97059. * Event raised when audio has been locked on the browser.
  97060. */
  97061. onAudioLockedObservable: Observable<AudioEngine>;
  97062. /**
  97063. * Flags the audio engine in Locked state.
  97064. * This happens due to new browser policies preventing audio to autoplay.
  97065. */
  97066. lock(): void;
  97067. /**
  97068. * Unlocks the audio engine once a user action has been done on the dom.
  97069. * This is helpful to resume play once browser policies have been satisfied.
  97070. */
  97071. unlock(): void;
  97072. }
  97073. /**
  97074. * This represents the default audio engine used in babylon.
  97075. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97077. */
  97078. export class AudioEngine implements IAudioEngine {
  97079. private _audioContext;
  97080. private _audioContextInitialized;
  97081. private _muteButton;
  97082. private _hostElement;
  97083. /**
  97084. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97085. */
  97086. canUseWebAudio: boolean;
  97087. /**
  97088. * The master gain node defines the global audio volume of your audio engine.
  97089. */
  97090. masterGain: GainNode;
  97091. /**
  97092. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97093. * @ignoreNaming
  97094. */
  97095. WarnedWebAudioUnsupported: boolean;
  97096. /**
  97097. * Gets whether or not mp3 are supported by your browser.
  97098. */
  97099. isMP3supported: boolean;
  97100. /**
  97101. * Gets whether or not ogg are supported by your browser.
  97102. */
  97103. isOGGsupported: boolean;
  97104. /**
  97105. * Gets whether audio has been unlocked on the device.
  97106. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97107. * a user interaction has happened.
  97108. */
  97109. unlocked: boolean;
  97110. /**
  97111. * Defines if the audio engine relies on a custom unlocked button.
  97112. * In this case, the embedded button will not be displayed.
  97113. */
  97114. useCustomUnlockedButton: boolean;
  97115. /**
  97116. * Event raised when audio has been unlocked on the browser.
  97117. */
  97118. onAudioUnlockedObservable: Observable<AudioEngine>;
  97119. /**
  97120. * Event raised when audio has been locked on the browser.
  97121. */
  97122. onAudioLockedObservable: Observable<AudioEngine>;
  97123. /**
  97124. * Gets the current AudioContext if available.
  97125. */
  97126. readonly audioContext: Nullable<AudioContext>;
  97127. private _connectedAnalyser;
  97128. /**
  97129. * Instantiates a new audio engine.
  97130. *
  97131. * There should be only one per page as some browsers restrict the number
  97132. * of audio contexts you can create.
  97133. * @param hostElement defines the host element where to display the mute icon if necessary
  97134. */
  97135. constructor(hostElement?: Nullable<HTMLElement>);
  97136. /**
  97137. * Flags the audio engine in Locked state.
  97138. * This happens due to new browser policies preventing audio to autoplay.
  97139. */
  97140. lock(): void;
  97141. /**
  97142. * Unlocks the audio engine once a user action has been done on the dom.
  97143. * This is helpful to resume play once browser policies have been satisfied.
  97144. */
  97145. unlock(): void;
  97146. private _resumeAudioContext;
  97147. private _initializeAudioContext;
  97148. private _tryToRun;
  97149. private _triggerRunningState;
  97150. private _triggerSuspendedState;
  97151. private _displayMuteButton;
  97152. private _moveButtonToTopLeft;
  97153. private _onResize;
  97154. private _hideMuteButton;
  97155. /**
  97156. * Destroy and release the resources associated with the audio ccontext.
  97157. */
  97158. dispose(): void;
  97159. /**
  97160. * Gets the global volume sets on the master gain.
  97161. * @returns the global volume if set or -1 otherwise
  97162. */
  97163. getGlobalVolume(): number;
  97164. /**
  97165. * Sets the global volume of your experience (sets on the master gain).
  97166. * @param newVolume Defines the new global volume of the application
  97167. */
  97168. setGlobalVolume(newVolume: number): void;
  97169. /**
  97170. * Connect the audio engine to an audio analyser allowing some amazing
  97171. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97172. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97173. * @param analyser The analyser to connect to the engine
  97174. */
  97175. connectToAnalyser(analyser: Analyser): void;
  97176. }
  97177. }
  97178. declare module BABYLON {
  97179. /**
  97180. * Interface used to present a loading screen while loading a scene
  97181. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97182. */
  97183. export interface ILoadingScreen {
  97184. /**
  97185. * Function called to display the loading screen
  97186. */
  97187. displayLoadingUI: () => void;
  97188. /**
  97189. * Function called to hide the loading screen
  97190. */
  97191. hideLoadingUI: () => void;
  97192. /**
  97193. * Gets or sets the color to use for the background
  97194. */
  97195. loadingUIBackgroundColor: string;
  97196. /**
  97197. * Gets or sets the text to display while loading
  97198. */
  97199. loadingUIText: string;
  97200. }
  97201. /**
  97202. * Class used for the default loading screen
  97203. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97204. */
  97205. export class DefaultLoadingScreen implements ILoadingScreen {
  97206. private _renderingCanvas;
  97207. private _loadingText;
  97208. private _loadingDivBackgroundColor;
  97209. private _loadingDiv;
  97210. private _loadingTextDiv;
  97211. /** Gets or sets the logo url to use for the default loading screen */
  97212. static DefaultLogoUrl: string;
  97213. /** Gets or sets the spinner url to use for the default loading screen */
  97214. static DefaultSpinnerUrl: string;
  97215. /**
  97216. * Creates a new default loading screen
  97217. * @param _renderingCanvas defines the canvas used to render the scene
  97218. * @param _loadingText defines the default text to display
  97219. * @param _loadingDivBackgroundColor defines the default background color
  97220. */
  97221. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97222. /**
  97223. * Function called to display the loading screen
  97224. */
  97225. displayLoadingUI(): void;
  97226. /**
  97227. * Function called to hide the loading screen
  97228. */
  97229. hideLoadingUI(): void;
  97230. /**
  97231. * Gets or sets the text to display while loading
  97232. */
  97233. loadingUIText: string;
  97234. /**
  97235. * Gets or sets the color to use for the background
  97236. */
  97237. loadingUIBackgroundColor: string;
  97238. private _resizeLoadingUI;
  97239. }
  97240. }
  97241. declare module BABYLON {
  97242. /**
  97243. * Interface for any object that can request an animation frame
  97244. */
  97245. export interface ICustomAnimationFrameRequester {
  97246. /**
  97247. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97248. */
  97249. renderFunction?: Function;
  97250. /**
  97251. * Called to request the next frame to render to
  97252. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97253. */
  97254. requestAnimationFrame: Function;
  97255. /**
  97256. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97257. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97258. */
  97259. requestID?: number;
  97260. }
  97261. }
  97262. declare module BABYLON {
  97263. /**
  97264. * Interface for performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97265. */
  97266. export interface IPerformanceMonitor {
  97267. /**
  97268. * Enables contributions to the sliding window sample set
  97269. */
  97270. enable(): void;
  97271. /**
  97272. * Disables contributions to the sliding window sample set
  97273. * Samples will not be interpolated over the disabled period
  97274. */
  97275. disable(): void;
  97276. /**
  97277. * Samples current frame
  97278. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97279. */
  97280. sampleFrame(timeMs?: number): void;
  97281. /**
  97282. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97283. */
  97284. averageFrameTime: number;
  97285. /**
  97286. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97287. */
  97288. averageFrameTimeVariance: number;
  97289. /**
  97290. * Returns the frame time of the most recent frame
  97291. */
  97292. instantaneousFrameTime: number;
  97293. /**
  97294. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97295. */
  97296. averageFPS: number;
  97297. /**
  97298. * Returns the average framerate in frames per second using the most recent frame time
  97299. */
  97300. instantaneousFPS: number;
  97301. }
  97302. }
  97303. declare module BABYLON {
  97304. /**
  97305. * Defines the interface used by display changed events
  97306. */
  97307. export interface IDisplayChangedEventArgs {
  97308. /** Gets the vrDisplay object (if any) */
  97309. vrDisplay: Nullable<any>;
  97310. /** Gets a boolean indicating if webVR is supported */
  97311. vrSupported: boolean;
  97312. }
  97313. /**
  97314. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97315. */
  97316. export class Engine extends BaseEngine {
  97317. /**
  97318. * Returns the current npm package of the sdk
  97319. */
  97320. static readonly NpmPackage: string;
  97321. /**
  97322. * Returns the current version of the framework
  97323. */
  97324. static readonly Version: string;
  97325. /** Gets the list of created engines */
  97326. static readonly Instances: Engine[];
  97327. /**
  97328. * Gets the latest created engine
  97329. */
  97330. static readonly LastCreatedEngine: Nullable<Engine>;
  97331. /**
  97332. * Gets the latest created scene
  97333. */
  97334. static readonly LastCreatedScene: Nullable<Scene>;
  97335. /**
  97336. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97337. * @param flag defines which part of the materials must be marked as dirty
  97338. * @param predicate defines a predicate used to filter which materials should be affected
  97339. */
  97340. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97341. /**
  97342. * Factory used to create the performance monitor
  97343. * @returns a new PerformanceMonitor
  97344. */
  97345. static DefaultPerformanceMonitorFactory(): IPerformanceMonitor;
  97346. /**
  97347. * Method called to create the default loading screen.
  97348. * This can be overriden in your own app.
  97349. * @param canvas The rendering canvas element
  97350. * @returns The loading screen
  97351. */
  97352. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97353. /**
  97354. * Method called to create the default rescale post process on each engine.
  97355. */
  97356. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97357. /**
  97358. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97359. **/
  97360. enableOfflineSupport: boolean;
  97361. /**
  97362. * 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)
  97363. **/
  97364. disableManifestCheck: boolean;
  97365. /**
  97366. * Gets the list of created scenes
  97367. */
  97368. scenes: Scene[];
  97369. /**
  97370. * Event raised when a new scene is created
  97371. */
  97372. onNewSceneAddedObservable: Observable<Scene>;
  97373. /**
  97374. * Gets the list of created postprocesses
  97375. */
  97376. postProcesses: PostProcess[];
  97377. /**
  97378. * Observable event triggered each time the rendering canvas is resized
  97379. */
  97380. onResizeObservable: Observable<Engine>;
  97381. /**
  97382. * Observable event triggered each time the canvas loses focus
  97383. */
  97384. onCanvasBlurObservable: Observable<Engine>;
  97385. /**
  97386. * Observable event triggered each time the canvas gains focus
  97387. */
  97388. onCanvasFocusObservable: Observable<Engine>;
  97389. /**
  97390. * Observable event triggered each time the canvas receives pointerout event
  97391. */
  97392. onCanvasPointerOutObservable: Observable<PointerEvent>;
  97393. /**
  97394. * Observable event triggered before each texture is initialized
  97395. */
  97396. onBeforeTextureInitObservable: Observable<Texture>;
  97397. /**
  97398. * Observable raised when the engine begins a new frame
  97399. */
  97400. onBeginFrameObservable: Observable<Engine>;
  97401. /**
  97402. * If set, will be used to request the next animation frame for the render loop
  97403. */
  97404. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  97405. /**
  97406. * Observable raised when the engine ends the current frame
  97407. */
  97408. onEndFrameObservable: Observable<Engine>;
  97409. /**
  97410. * Observable raised when the engine is about to compile a shader
  97411. */
  97412. onBeforeShaderCompilationObservable: Observable<Engine>;
  97413. /**
  97414. * Observable raised when the engine has jsut compiled a shader
  97415. */
  97416. onAfterShaderCompilationObservable: Observable<Engine>;
  97417. /**
  97418. * Gets the audio engine
  97419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97420. * @ignorenaming
  97421. */
  97422. static audioEngine: IAudioEngine;
  97423. /**
  97424. * Default AudioEngine factory responsible of creating the Audio Engine.
  97425. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  97426. */
  97427. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  97428. /**
  97429. * Default offline support factory responsible of creating a tool used to store data locally.
  97430. * By default, this will create a Database object if the workload has been embedded.
  97431. */
  97432. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  97433. private _loadingScreen;
  97434. private _pointerLockRequested;
  97435. private _dummyFramebuffer;
  97436. private _rescalePostProcess;
  97437. protected readonly _supportsHardwareTextureRescaling: boolean;
  97438. private _fps;
  97439. private _deltaTime;
  97440. /**
  97441. * Turn this value on if you want to pause FPS computation when in background
  97442. */
  97443. disablePerformanceMonitorInBackground: boolean;
  97444. private _performanceMonitor;
  97445. /**
  97446. * Gets the performance monitor attached to this engine
  97447. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  97448. */
  97449. readonly performanceMonitor: IPerformanceMonitor;
  97450. private _onFocus;
  97451. private _onBlur;
  97452. private _onCanvasPointerOut;
  97453. private _onCanvasBlur;
  97454. private _onCanvasFocus;
  97455. private _onFullscreenChange;
  97456. private _onPointerLockChange;
  97457. /**
  97458. * Creates a new engine
  97459. * @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
  97460. * @param antialias defines enable antialiasing (default: false)
  97461. * @param options defines further options to be sent to the getContext() function
  97462. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97463. */
  97464. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97465. /**
  97466. * Initializes a webVR display and starts listening to display change events
  97467. * The onVRDisplayChangedObservable will be notified upon these changes
  97468. * @returns The onVRDisplayChangedObservable
  97469. */
  97470. initWebVR(): Observable<IDisplayChangedEventArgs>;
  97471. /** @hidden */
  97472. _prepareVRComponent(): void;
  97473. /** @hidden */
  97474. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  97475. /** @hidden */
  97476. _submitVRFrame(): void;
  97477. /**
  97478. * Call this function to leave webVR mode
  97479. * Will do nothing if webVR is not supported or if there is no webVR device
  97480. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97481. */
  97482. disableVR(): void;
  97483. /**
  97484. * Gets a boolean indicating that the system is in VR mode and is presenting
  97485. * @returns true if VR mode is engaged
  97486. */
  97487. isVRPresenting(): boolean;
  97488. /** @hidden */
  97489. _requestVRFrame(): void;
  97490. protected _rebuildBuffers(): void;
  97491. _renderLoop(): void;
  97492. /**
  97493. * Toggle full screen mode
  97494. * @param requestPointerLock defines if a pointer lock should be requested from the user
  97495. */
  97496. switchFullscreen(requestPointerLock: boolean): void;
  97497. /**
  97498. * Enters full screen mode
  97499. * @param requestPointerLock defines if a pointer lock should be requested from the user
  97500. */
  97501. enterFullscreen(requestPointerLock: boolean): void;
  97502. /**
  97503. * Exits full screen mode
  97504. */
  97505. exitFullscreen(): void;
  97506. /**
  97507. * Enters Pointerlock mode
  97508. */
  97509. enterPointerlock(): void;
  97510. /**
  97511. * Exits Pointerlock mode
  97512. */
  97513. exitPointerlock(): void;
  97514. /**
  97515. * Begin a new frame
  97516. */
  97517. beginFrame(): void;
  97518. /**
  97519. * Enf the current frame
  97520. */
  97521. endFrame(): void;
  97522. resize(): void;
  97523. /**
  97524. * Force a specific size of the canvas
  97525. * @param width defines the new canvas' width
  97526. * @param height defines the new canvas' height
  97527. */
  97528. setSize(width: number, height: number): void;
  97529. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97530. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97531. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97532. _releaseTexture(texture: InternalTexture): void;
  97533. /**
  97534. * @hidden
  97535. * Rescales a texture
  97536. * @param source input texutre
  97537. * @param destination destination texture
  97538. * @param scene scene to use to render the resize
  97539. * @param internalFormat format to use when resizing
  97540. * @param onComplete callback to be called when resize has completed
  97541. */
  97542. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97543. /**
  97544. * Gets the current framerate
  97545. * @returns a number representing the framerate
  97546. */
  97547. getFps(): number;
  97548. /**
  97549. * Gets the time spent between current and previous frame
  97550. * @returns a number representing the delta time in ms
  97551. */
  97552. getDeltaTime(): number;
  97553. private _measureFps;
  97554. /** @hidden */
  97555. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97556. dispose(): void;
  97557. /**
  97558. * Display the loading screen
  97559. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97560. */
  97561. displayLoadingUI(): void;
  97562. /**
  97563. * Hide the loading screen
  97564. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97565. */
  97566. hideLoadingUI(): void;
  97567. /**
  97568. * Gets the current loading screen object
  97569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97570. */
  97571. /**
  97572. * Sets the current loading screen object
  97573. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97574. */
  97575. loadingScreen: ILoadingScreen;
  97576. /**
  97577. * Sets the current loading screen text
  97578. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97579. */
  97580. loadingUIText: string;
  97581. /**
  97582. * Sets the current loading screen background color
  97583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97584. */
  97585. loadingUIBackgroundColor: string;
  97586. }
  97587. }
  97588. declare module BABYLON {
  97589. /**
  97590. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97591. * during the life time of the application.
  97592. */
  97593. export class EngineStore {
  97594. /** Gets the list of created engines */
  97595. static Instances: Engine[];
  97596. /** @hidden */
  97597. static _LastCreatedScene: Nullable<Scene>;
  97598. /**
  97599. * Gets the latest created engine
  97600. */
  97601. static readonly LastCreatedEngine: Nullable<Engine>;
  97602. /**
  97603. * Gets the latest created scene
  97604. */
  97605. static readonly LastCreatedScene: Nullable<Scene>;
  97606. /**
  97607. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97608. * @ignorenaming
  97609. */
  97610. static UseFallbackTexture: boolean;
  97611. /**
  97612. * Texture content used if a texture cannot loaded
  97613. * @ignorenaming
  97614. */
  97615. static FallbackTexture: string;
  97616. }
  97617. }
  97618. declare module BABYLON {
  97619. /**
  97620. * Helper class that provides a small promise polyfill
  97621. */
  97622. export class PromisePolyfill {
  97623. /**
  97624. * Static function used to check if the polyfill is required
  97625. * If this is the case then the function will inject the polyfill to window.Promise
  97626. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97627. */
  97628. static Apply(force?: boolean): void;
  97629. }
  97630. }
  97631. declare module BABYLON {
  97632. /**
  97633. * Interface for screenshot methods with describe argument called `size` as object with options
  97634. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97635. */
  97636. export interface IScreenshotSize {
  97637. /**
  97638. * number in pixels for canvas height
  97639. */
  97640. height?: number;
  97641. /**
  97642. * multiplier allowing render at a higher or lower resolution
  97643. * If value is defined then height and width will be ignored and taken from camera
  97644. */
  97645. precision?: number;
  97646. /**
  97647. * number in pixels for canvas width
  97648. */
  97649. width?: number;
  97650. }
  97651. }
  97652. declare module BABYLON {
  97653. interface IColor4Like {
  97654. r: float;
  97655. g: float;
  97656. b: float;
  97657. a: float;
  97658. }
  97659. /**
  97660. * Class containing a set of static utilities functions
  97661. */
  97662. export class Tools {
  97663. /**
  97664. * Gets or sets the base URL to use to load assets
  97665. */
  97666. static BaseUrl: string;
  97667. /**
  97668. * Enable/Disable Custom HTTP Request Headers globally.
  97669. * default = false
  97670. * @see CustomRequestHeaders
  97671. */
  97672. static UseCustomRequestHeaders: boolean;
  97673. /**
  97674. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97675. * i.e. when loading files, where the server/service expects an Authorization header
  97676. */
  97677. static CustomRequestHeaders: {
  97678. [key: string]: string;
  97679. };
  97680. /**
  97681. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97682. */
  97683. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97684. /**
  97685. * Default behaviour for cors in the application.
  97686. * It can be a string if the expected behavior is identical in the entire app.
  97687. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97688. */
  97689. static CorsBehavior: string | ((url: string | string[]) => string);
  97690. /**
  97691. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97692. * @ignorenaming
  97693. */
  97694. static UseFallbackTexture: boolean;
  97695. /**
  97696. * Use this object to register external classes like custom textures or material
  97697. * to allow the laoders to instantiate them
  97698. */
  97699. static RegisteredExternalClasses: {
  97700. [key: string]: Object;
  97701. };
  97702. /**
  97703. * Texture content used if a texture cannot loaded
  97704. * @ignorenaming
  97705. */
  97706. static fallbackTexture: string;
  97707. /**
  97708. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97709. * @param u defines the coordinate on X axis
  97710. * @param v defines the coordinate on Y axis
  97711. * @param width defines the width of the source data
  97712. * @param height defines the height of the source data
  97713. * @param pixels defines the source byte array
  97714. * @param color defines the output color
  97715. */
  97716. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97717. /**
  97718. * Interpolates between a and b via alpha
  97719. * @param a The lower value (returned when alpha = 0)
  97720. * @param b The upper value (returned when alpha = 1)
  97721. * @param alpha The interpolation-factor
  97722. * @return The mixed value
  97723. */
  97724. static Mix(a: number, b: number, alpha: number): number;
  97725. /**
  97726. * Tries to instantiate a new object from a given class name
  97727. * @param className defines the class name to instantiate
  97728. * @returns the new object or null if the system was not able to do the instantiation
  97729. */
  97730. static Instantiate(className: string): any;
  97731. /**
  97732. * Provides a slice function that will work even on IE
  97733. * @param data defines the array to slice
  97734. * @param start defines the start of the data (optional)
  97735. * @param end defines the end of the data (optional)
  97736. * @returns the new sliced array
  97737. */
  97738. static Slice<T>(data: T, start?: number, end?: number): T;
  97739. /**
  97740. * Polyfill for setImmediate
  97741. * @param action defines the action to execute after the current execution block
  97742. */
  97743. static SetImmediate(action: () => void): void;
  97744. /**
  97745. * Function indicating if a number is an exponent of 2
  97746. * @param value defines the value to test
  97747. * @returns true if the value is an exponent of 2
  97748. */
  97749. static IsExponentOfTwo(value: number): boolean;
  97750. private static _tmpFloatArray;
  97751. /**
  97752. * Returns the nearest 32-bit single precision float representation of a Number
  97753. * @param value A Number. If the parameter is of a different type, it will get converted
  97754. * to a number or to NaN if it cannot be converted
  97755. * @returns number
  97756. */
  97757. static FloatRound(value: number): number;
  97758. /**
  97759. * Extracts the filename from a path
  97760. * @param path defines the path to use
  97761. * @returns the filename
  97762. */
  97763. static GetFilename(path: string): string;
  97764. /**
  97765. * Extracts the "folder" part of a path (everything before the filename).
  97766. * @param uri The URI to extract the info from
  97767. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97768. * @returns The "folder" part of the path
  97769. */
  97770. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97771. /**
  97772. * Extracts text content from a DOM element hierarchy
  97773. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97774. */
  97775. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97776. /**
  97777. * Convert an angle in radians to degrees
  97778. * @param angle defines the angle to convert
  97779. * @returns the angle in degrees
  97780. */
  97781. static ToDegrees(angle: number): number;
  97782. /**
  97783. * Convert an angle in degrees to radians
  97784. * @param angle defines the angle to convert
  97785. * @returns the angle in radians
  97786. */
  97787. static ToRadians(angle: number): number;
  97788. /**
  97789. * Encode a buffer to a base64 string
  97790. * @param buffer defines the buffer to encode
  97791. * @returns the encoded string
  97792. */
  97793. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97794. /**
  97795. * Returns an array if obj is not an array
  97796. * @param obj defines the object to evaluate as an array
  97797. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97798. * @returns either obj directly if obj is an array or a new array containing obj
  97799. */
  97800. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97801. /**
  97802. * Gets the pointer prefix to use
  97803. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97804. */
  97805. static GetPointerPrefix(): string;
  97806. /**
  97807. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97808. * @param url define the url we are trying
  97809. * @param element define the dom element where to configure the cors policy
  97810. */
  97811. static SetCorsBehavior(url: string | string[], element: {
  97812. crossOrigin: string | null;
  97813. }): void;
  97814. /**
  97815. * Removes unwanted characters from an url
  97816. * @param url defines the url to clean
  97817. * @returns the cleaned url
  97818. */
  97819. static CleanUrl(url: string): string;
  97820. /**
  97821. * Gets or sets a function used to pre-process url before using them to load assets
  97822. */
  97823. static PreprocessUrl: (url: string) => string;
  97824. /**
  97825. * Loads an image as an HTMLImageElement.
  97826. * @param input url string, ArrayBuffer, or Blob to load
  97827. * @param onLoad callback called when the image successfully loads
  97828. * @param onError callback called when the image fails to load
  97829. * @param offlineProvider offline provider for caching
  97830. * @returns the HTMLImageElement of the loaded image
  97831. */
  97832. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97833. /**
  97834. * Loads a file
  97835. * @param url url string, ArrayBuffer, or Blob to load
  97836. * @param onSuccess callback called when the file successfully loads
  97837. * @param onProgress callback called while file is loading (if the server supports this mode)
  97838. * @param offlineProvider defines the offline provider for caching
  97839. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97840. * @param onError callback called when the file fails to load
  97841. * @returns a file request object
  97842. */
  97843. 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;
  97844. /**
  97845. * Loads a file from a url
  97846. * @param url the file url to load
  97847. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97848. */
  97849. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97850. /**
  97851. * Load a script (identified by an url). When the url returns, the
  97852. * content of this file is added into a new script element, attached to the DOM (body element)
  97853. * @param scriptUrl defines the url of the script to laod
  97854. * @param onSuccess defines the callback called when the script is loaded
  97855. * @param onError defines the callback to call if an error occurs
  97856. * @param scriptId defines the id of the script element
  97857. */
  97858. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97859. /**
  97860. * Load an asynchronous script (identified by an url). When the url returns, the
  97861. * content of this file is added into a new script element, attached to the DOM (body element)
  97862. * @param scriptUrl defines the url of the script to laod
  97863. * @param scriptId defines the id of the script element
  97864. * @returns a promise request object
  97865. */
  97866. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97867. /**
  97868. * Loads a file from a blob
  97869. * @param fileToLoad defines the blob to use
  97870. * @param callback defines the callback to call when data is loaded
  97871. * @param progressCallback defines the callback to call during loading process
  97872. * @returns a file request object
  97873. */
  97874. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97875. /**
  97876. * Loads a file
  97877. * @param fileToLoad defines the file to load
  97878. * @param callback defines the callback to call when data is loaded
  97879. * @param progressCallBack defines the callback to call during loading process
  97880. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97881. * @returns a file request object
  97882. */
  97883. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97884. /**
  97885. * Creates a data url from a given string content
  97886. * @param content defines the content to convert
  97887. * @returns the new data url link
  97888. */
  97889. static FileAsURL(content: string): string;
  97890. /**
  97891. * Format the given number to a specific decimal format
  97892. * @param value defines the number to format
  97893. * @param decimals defines the number of decimals to use
  97894. * @returns the formatted string
  97895. */
  97896. static Format(value: number, decimals?: number): string;
  97897. /**
  97898. * Tries to copy an object by duplicating every property
  97899. * @param source defines the source object
  97900. * @param destination defines the target object
  97901. * @param doNotCopyList defines a list of properties to avoid
  97902. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97903. */
  97904. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97905. /**
  97906. * Gets a boolean indicating if the given object has no own property
  97907. * @param obj defines the object to test
  97908. * @returns true if object has no own property
  97909. */
  97910. static IsEmpty(obj: any): boolean;
  97911. /**
  97912. * Function used to register events at window level
  97913. * @param windowElement defines the Window object to use
  97914. * @param events defines the events to register
  97915. */
  97916. static RegisterTopRootEvents(windowElement: Window, events: {
  97917. name: string;
  97918. handler: Nullable<(e: FocusEvent) => any>;
  97919. }[]): void;
  97920. /**
  97921. * Function used to unregister events from window level
  97922. * @param windowElement defines the Window object to use
  97923. * @param events defines the events to unregister
  97924. */
  97925. static UnregisterTopRootEvents(windowElement: Window, events: {
  97926. name: string;
  97927. handler: Nullable<(e: FocusEvent) => any>;
  97928. }[]): void;
  97929. /**
  97930. * @ignore
  97931. */
  97932. static _ScreenshotCanvas: HTMLCanvasElement;
  97933. /**
  97934. * Dumps the current bound framebuffer
  97935. * @param width defines the rendering width
  97936. * @param height defines the rendering height
  97937. * @param engine defines the hosting engine
  97938. * @param successCallback defines the callback triggered once the data are available
  97939. * @param mimeType defines the mime type of the result
  97940. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97941. */
  97942. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97943. /**
  97944. * Converts the canvas data to blob.
  97945. * This acts as a polyfill for browsers not supporting the to blob function.
  97946. * @param canvas Defines the canvas to extract the data from
  97947. * @param successCallback Defines the callback triggered once the data are available
  97948. * @param mimeType Defines the mime type of the result
  97949. */
  97950. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97951. /**
  97952. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97953. * @param successCallback defines the callback triggered once the data are available
  97954. * @param mimeType defines the mime type of the result
  97955. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97956. */
  97957. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97958. /**
  97959. * Downloads a blob in the browser
  97960. * @param blob defines the blob to download
  97961. * @param fileName defines the name of the downloaded file
  97962. */
  97963. static Download(blob: Blob, fileName: string): void;
  97964. /**
  97965. * Captures a screenshot of the current rendering
  97966. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97967. * @param engine defines the rendering engine
  97968. * @param camera defines the source camera
  97969. * @param size This parameter can be set to a single number or to an object with the
  97970. * following (optional) properties: precision, width, height. If a single number is passed,
  97971. * it will be used for both width and height. If an object is passed, the screenshot size
  97972. * will be derived from the parameters. The precision property is a multiplier allowing
  97973. * rendering at a higher or lower resolution
  97974. * @param successCallback defines the callback receives a single parameter which contains the
  97975. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97976. * src parameter of an <img> to display it
  97977. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97978. * Check your browser for supported MIME types
  97979. */
  97980. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97981. /**
  97982. * Captures a screenshot of the current rendering
  97983. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97984. * @param engine defines the rendering engine
  97985. * @param camera defines the source camera
  97986. * @param size This parameter can be set to a single number or to an object with the
  97987. * following (optional) properties: precision, width, height. If a single number is passed,
  97988. * it will be used for both width and height. If an object is passed, the screenshot size
  97989. * will be derived from the parameters. The precision property is a multiplier allowing
  97990. * rendering at a higher or lower resolution
  97991. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97992. * Check your browser for supported MIME types
  97993. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97994. * to the src parameter of an <img> to display it
  97995. */
  97996. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97997. /**
  97998. * Generates an image screenshot from the specified camera.
  97999. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98000. * @param engine The engine to use for rendering
  98001. * @param camera The camera to use for rendering
  98002. * @param size This parameter can be set to a single number or to an object with the
  98003. * following (optional) properties: precision, width, height. If a single number is passed,
  98004. * it will be used for both width and height. If an object is passed, the screenshot size
  98005. * will be derived from the parameters. The precision property is a multiplier allowing
  98006. * rendering at a higher or lower resolution
  98007. * @param successCallback The callback receives a single parameter which contains the
  98008. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98009. * src parameter of an <img> to display it
  98010. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98011. * Check your browser for supported MIME types
  98012. * @param samples Texture samples (default: 1)
  98013. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98014. * @param fileName A name for for the downloaded file.
  98015. */
  98016. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98017. /**
  98018. * Generates an image screenshot from the specified camera.
  98019. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98020. * @param engine The engine to use for rendering
  98021. * @param camera The camera to use for rendering
  98022. * @param size This parameter can be set to a single number or to an object with the
  98023. * following (optional) properties: precision, width, height. If a single number is passed,
  98024. * it will be used for both width and height. If an object is passed, the screenshot size
  98025. * will be derived from the parameters. The precision property is a multiplier allowing
  98026. * rendering at a higher or lower resolution
  98027. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98028. * Check your browser for supported MIME types
  98029. * @param samples Texture samples (default: 1)
  98030. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98031. * @param fileName A name for for the downloaded file.
  98032. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98033. * to the src parameter of an <img> to display it
  98034. */
  98035. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98036. /**
  98037. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98038. * Be aware Math.random() could cause collisions, but:
  98039. * "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"
  98040. * @returns a pseudo random id
  98041. */
  98042. static RandomId(): string;
  98043. /**
  98044. * Test if the given uri is a base64 string
  98045. * @param uri The uri to test
  98046. * @return True if the uri is a base64 string or false otherwise
  98047. */
  98048. static IsBase64(uri: string): boolean;
  98049. /**
  98050. * Decode the given base64 uri.
  98051. * @param uri The uri to decode
  98052. * @return The decoded base64 data.
  98053. */
  98054. static DecodeBase64(uri: string): ArrayBuffer;
  98055. /**
  98056. * Gets the absolute url.
  98057. * @param url the input url
  98058. * @return the absolute url
  98059. */
  98060. static GetAbsoluteUrl(url: string): string;
  98061. /**
  98062. * No log
  98063. */
  98064. static readonly NoneLogLevel: number;
  98065. /**
  98066. * Only message logs
  98067. */
  98068. static readonly MessageLogLevel: number;
  98069. /**
  98070. * Only warning logs
  98071. */
  98072. static readonly WarningLogLevel: number;
  98073. /**
  98074. * Only error logs
  98075. */
  98076. static readonly ErrorLogLevel: number;
  98077. /**
  98078. * All logs
  98079. */
  98080. static readonly AllLogLevel: number;
  98081. /**
  98082. * Gets a value indicating the number of loading errors
  98083. * @ignorenaming
  98084. */
  98085. static readonly errorsCount: number;
  98086. /**
  98087. * Callback called when a new log is added
  98088. */
  98089. static OnNewCacheEntry: (entry: string) => void;
  98090. /**
  98091. * Log a message to the console
  98092. * @param message defines the message to log
  98093. */
  98094. static Log(message: string): void;
  98095. /**
  98096. * Write a warning message to the console
  98097. * @param message defines the message to log
  98098. */
  98099. static Warn(message: string): void;
  98100. /**
  98101. * Write an error message to the console
  98102. * @param message defines the message to log
  98103. */
  98104. static Error(message: string): void;
  98105. /**
  98106. * Gets current log cache (list of logs)
  98107. */
  98108. static readonly LogCache: string;
  98109. /**
  98110. * Clears the log cache
  98111. */
  98112. static ClearLogCache(): void;
  98113. /**
  98114. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98115. */
  98116. static LogLevels: number;
  98117. /**
  98118. * Checks if the window object exists
  98119. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98120. */
  98121. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98122. /**
  98123. * No performance log
  98124. */
  98125. static readonly PerformanceNoneLogLevel: number;
  98126. /**
  98127. * Use user marks to log performance
  98128. */
  98129. static readonly PerformanceUserMarkLogLevel: number;
  98130. /**
  98131. * Log performance to the console
  98132. */
  98133. static readonly PerformanceConsoleLogLevel: number;
  98134. private static _performance;
  98135. /**
  98136. * Sets the current performance log level
  98137. */
  98138. static PerformanceLogLevel: number;
  98139. private static _StartPerformanceCounterDisabled;
  98140. private static _EndPerformanceCounterDisabled;
  98141. private static _StartUserMark;
  98142. private static _EndUserMark;
  98143. private static _StartPerformanceConsole;
  98144. private static _EndPerformanceConsole;
  98145. /**
  98146. * Starts a performance counter
  98147. */
  98148. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98149. /**
  98150. * Ends a specific performance coutner
  98151. */
  98152. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98153. /**
  98154. * Gets either window.performance.now() if supported or Date.now() else
  98155. */
  98156. static readonly Now: number;
  98157. /**
  98158. * This method will return the name of the class used to create the instance of the given object.
  98159. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98160. * @param object the object to get the class name from
  98161. * @param isType defines if the object is actually a type
  98162. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98163. */
  98164. static GetClassName(object: any, isType?: boolean): string;
  98165. /**
  98166. * Gets the first element of an array satisfying a given predicate
  98167. * @param array defines the array to browse
  98168. * @param predicate defines the predicate to use
  98169. * @returns null if not found or the element
  98170. */
  98171. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98172. /**
  98173. * This method will return the name of the full name of the class, including its owning module (if any).
  98174. * 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).
  98175. * @param object the object to get the class name from
  98176. * @param isType defines if the object is actually a type
  98177. * @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.
  98178. * @ignorenaming
  98179. */
  98180. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98181. /**
  98182. * Returns a promise that resolves after the given amount of time.
  98183. * @param delay Number of milliseconds to delay
  98184. * @returns Promise that resolves after the given amount of time
  98185. */
  98186. static DelayAsync(delay: number): Promise<void>;
  98187. }
  98188. /**
  98189. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98190. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98191. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98192. * @param name The name of the class, case should be preserved
  98193. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98194. */
  98195. export function className(name: string, module?: string): (target: Object) => void;
  98196. /**
  98197. * An implementation of a loop for asynchronous functions.
  98198. */
  98199. export class AsyncLoop {
  98200. /**
  98201. * Defines the number of iterations for the loop
  98202. */
  98203. iterations: number;
  98204. /**
  98205. * Defines the current index of the loop.
  98206. */
  98207. index: number;
  98208. private _done;
  98209. private _fn;
  98210. private _successCallback;
  98211. /**
  98212. * Constructor.
  98213. * @param iterations the number of iterations.
  98214. * @param func the function to run each iteration
  98215. * @param successCallback the callback that will be called upon succesful execution
  98216. * @param offset starting offset.
  98217. */
  98218. constructor(
  98219. /**
  98220. * Defines the number of iterations for the loop
  98221. */
  98222. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98223. /**
  98224. * Execute the next iteration. Must be called after the last iteration was finished.
  98225. */
  98226. executeNext(): void;
  98227. /**
  98228. * Break the loop and run the success callback.
  98229. */
  98230. breakLoop(): void;
  98231. /**
  98232. * Create and run an async loop.
  98233. * @param iterations the number of iterations.
  98234. * @param fn the function to run each iteration
  98235. * @param successCallback the callback that will be called upon succesful execution
  98236. * @param offset starting offset.
  98237. * @returns the created async loop object
  98238. */
  98239. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98240. /**
  98241. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98242. * @param iterations total number of iterations
  98243. * @param syncedIterations number of synchronous iterations in each async iteration.
  98244. * @param fn the function to call each iteration.
  98245. * @param callback a success call back that will be called when iterating stops.
  98246. * @param breakFunction a break condition (optional)
  98247. * @param timeout timeout settings for the setTimeout function. default - 0.
  98248. * @returns the created async loop object
  98249. */
  98250. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98251. }
  98252. }
  98253. declare module BABYLON {
  98254. /**
  98255. * This class implement a typical dictionary using a string as key and the generic type T as value.
  98256. * The underlying implementation relies on an associative array to ensure the best performances.
  98257. * The value can be anything including 'null' but except 'undefined'
  98258. */
  98259. export class StringDictionary<T> {
  98260. /**
  98261. * This will clear this dictionary and copy the content from the 'source' one.
  98262. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  98263. * @param source the dictionary to take the content from and copy to this dictionary
  98264. */
  98265. copyFrom(source: StringDictionary<T>): void;
  98266. /**
  98267. * Get a value based from its key
  98268. * @param key the given key to get the matching value from
  98269. * @return the value if found, otherwise undefined is returned
  98270. */
  98271. get(key: string): T | undefined;
  98272. /**
  98273. * Get a value from its key or add it if it doesn't exist.
  98274. * This method will ensure you that a given key/data will be present in the dictionary.
  98275. * @param key the given key to get the matching value from
  98276. * @param factory the factory that will create the value if the key is not present in the dictionary.
  98277. * The factory will only be invoked if there's no data for the given key.
  98278. * @return the value corresponding to the key.
  98279. */
  98280. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  98281. /**
  98282. * Get a value from its key if present in the dictionary otherwise add it
  98283. * @param key the key to get the value from
  98284. * @param val if there's no such key/value pair in the dictionary add it with this value
  98285. * @return the value corresponding to the key
  98286. */
  98287. getOrAdd(key: string, val: T): T;
  98288. /**
  98289. * Check if there's a given key in the dictionary
  98290. * @param key the key to check for
  98291. * @return true if the key is present, false otherwise
  98292. */
  98293. contains(key: string): boolean;
  98294. /**
  98295. * Add a new key and its corresponding value
  98296. * @param key the key to add
  98297. * @param value the value corresponding to the key
  98298. * @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
  98299. */
  98300. add(key: string, value: T): boolean;
  98301. /**
  98302. * Update a specific value associated to a key
  98303. * @param key defines the key to use
  98304. * @param value defines the value to store
  98305. * @returns true if the value was updated (or false if the key was not found)
  98306. */
  98307. set(key: string, value: T): boolean;
  98308. /**
  98309. * Get the element of the given key and remove it from the dictionary
  98310. * @param key defines the key to search
  98311. * @returns the value associated with the key or null if not found
  98312. */
  98313. getAndRemove(key: string): Nullable<T>;
  98314. /**
  98315. * Remove a key/value from the dictionary.
  98316. * @param key the key to remove
  98317. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  98318. */
  98319. remove(key: string): boolean;
  98320. /**
  98321. * Clear the whole content of the dictionary
  98322. */
  98323. clear(): void;
  98324. /**
  98325. * Gets the current count
  98326. */
  98327. readonly count: number;
  98328. /**
  98329. * Execute a callback on each key/val of the dictionary.
  98330. * Note that you can remove any element in this dictionary in the callback implementation
  98331. * @param callback the callback to execute on a given key/value pair
  98332. */
  98333. forEach(callback: (key: string, val: T) => void): void;
  98334. /**
  98335. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  98336. * If the callback returns null or undefined the method will iterate to the next key/value pair
  98337. * Note that you can remove any element in this dictionary in the callback implementation
  98338. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  98339. * @returns the first item
  98340. */
  98341. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  98342. private _count;
  98343. private _data;
  98344. }
  98345. }
  98346. declare module BABYLON {
  98347. /** @hidden */
  98348. export interface ICollisionCoordinator {
  98349. createCollider(): Collider;
  98350. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98351. init(scene: Scene): void;
  98352. }
  98353. /** @hidden */
  98354. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98355. private _scene;
  98356. private _scaledPosition;
  98357. private _scaledVelocity;
  98358. private _finalPosition;
  98359. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98360. createCollider(): Collider;
  98361. init(scene: Scene): void;
  98362. private _collideWithWorld;
  98363. }
  98364. }
  98365. declare module BABYLON {
  98366. /**
  98367. * Class used to manage all inputs for the scene.
  98368. */
  98369. export class InputManager {
  98370. /** The distance in pixel that you have to move to prevent some events */
  98371. static DragMovementThreshold: number;
  98372. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98373. static LongPressDelay: number;
  98374. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98375. static DoubleClickDelay: number;
  98376. /** If you need to check double click without raising a single click at first click, enable this flag */
  98377. static ExclusiveDoubleClickMode: boolean;
  98378. private _wheelEventName;
  98379. private _onPointerMove;
  98380. private _onPointerDown;
  98381. private _onPointerUp;
  98382. private _initClickEvent;
  98383. private _initActionManager;
  98384. private _delayedSimpleClick;
  98385. private _delayedSimpleClickTimeout;
  98386. private _previousDelayedSimpleClickTimeout;
  98387. private _meshPickProceed;
  98388. private _previousButtonPressed;
  98389. private _currentPickResult;
  98390. private _previousPickResult;
  98391. private _totalPointersPressed;
  98392. private _doubleClickOccured;
  98393. private _pointerOverMesh;
  98394. private _pickedDownMesh;
  98395. private _pickedUpMesh;
  98396. private _pointerX;
  98397. private _pointerY;
  98398. private _unTranslatedPointerX;
  98399. private _unTranslatedPointerY;
  98400. private _startingPointerPosition;
  98401. private _previousStartingPointerPosition;
  98402. private _startingPointerTime;
  98403. private _previousStartingPointerTime;
  98404. private _pointerCaptures;
  98405. private _onKeyDown;
  98406. private _onKeyUp;
  98407. private _onCanvasFocusObserver;
  98408. private _onCanvasBlurObserver;
  98409. private _scene;
  98410. /**
  98411. * Creates a new InputManager
  98412. * @param scene defines the hosting scene
  98413. */
  98414. constructor(scene: Scene);
  98415. /**
  98416. * Gets the mesh that is currently under the pointer
  98417. */
  98418. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98419. /**
  98420. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98421. */
  98422. readonly unTranslatedPointer: Vector2;
  98423. /**
  98424. * Gets or sets the current on-screen X position of the pointer
  98425. */
  98426. pointerX: number;
  98427. /**
  98428. * Gets or sets the current on-screen Y position of the pointer
  98429. */
  98430. pointerY: number;
  98431. private _updatePointerPosition;
  98432. private _processPointerMove;
  98433. private _setRayOnPointerInfo;
  98434. private _checkPrePointerObservable;
  98435. /**
  98436. * Use this method to simulate a pointer move on a mesh
  98437. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98438. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98439. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98440. */
  98441. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98442. /**
  98443. * Use this method to simulate a pointer down on a mesh
  98444. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98445. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98446. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98447. */
  98448. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98449. private _processPointerDown;
  98450. /** @hidden */
  98451. _isPointerSwiping(): boolean;
  98452. /**
  98453. * Use this method to simulate a pointer up on a mesh
  98454. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98455. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98456. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98457. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98458. */
  98459. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98460. private _processPointerUp;
  98461. /**
  98462. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98463. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98464. * @returns true if the pointer was captured
  98465. */
  98466. isPointerCaptured(pointerId?: number): boolean;
  98467. /**
  98468. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98469. * @param attachUp defines if you want to attach events to pointerup
  98470. * @param attachDown defines if you want to attach events to pointerdown
  98471. * @param attachMove defines if you want to attach events to pointermove
  98472. */
  98473. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98474. /**
  98475. * Detaches all event handlers
  98476. */
  98477. detachControl(): void;
  98478. /**
  98479. * Force the value of meshUnderPointer
  98480. * @param mesh defines the mesh to use
  98481. */
  98482. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98483. /**
  98484. * Gets the mesh under the pointer
  98485. * @returns a Mesh or null if no mesh is under the pointer
  98486. */
  98487. getPointerOverMesh(): Nullable<AbstractMesh>;
  98488. }
  98489. }
  98490. declare module BABYLON {
  98491. /**
  98492. * Helper class used to generate session unique ID
  98493. */
  98494. export class UniqueIdGenerator {
  98495. private static _UniqueIdCounter;
  98496. /**
  98497. * Gets an unique (relatively to the current scene) Id
  98498. */
  98499. static readonly UniqueId: number;
  98500. }
  98501. }
  98502. declare module BABYLON {
  98503. /**
  98504. * This class defines the direct association between an animation and a target
  98505. */
  98506. export class TargetedAnimation {
  98507. /**
  98508. * Animation to perform
  98509. */
  98510. animation: Animation;
  98511. /**
  98512. * Target to animate
  98513. */
  98514. target: any;
  98515. /**
  98516. * Serialize the object
  98517. * @returns the JSON object representing the current entity
  98518. */
  98519. serialize(): any;
  98520. }
  98521. /**
  98522. * Use this class to create coordinated animations on multiple targets
  98523. */
  98524. export class AnimationGroup implements IDisposable {
  98525. /** The name of the animation group */
  98526. name: string;
  98527. private _scene;
  98528. private _targetedAnimations;
  98529. private _animatables;
  98530. private _from;
  98531. private _to;
  98532. private _isStarted;
  98533. private _isPaused;
  98534. private _speedRatio;
  98535. private _loopAnimation;
  98536. /**
  98537. * Gets or sets the unique id of the node
  98538. */
  98539. uniqueId: number;
  98540. /**
  98541. * This observable will notify when one animation have ended
  98542. */
  98543. onAnimationEndObservable: Observable<TargetedAnimation>;
  98544. /**
  98545. * Observer raised when one animation loops
  98546. */
  98547. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98548. /**
  98549. * This observable will notify when all animations have ended.
  98550. */
  98551. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98552. /**
  98553. * This observable will notify when all animations have paused.
  98554. */
  98555. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98556. /**
  98557. * This observable will notify when all animations are playing.
  98558. */
  98559. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98560. /**
  98561. * Gets the first frame
  98562. */
  98563. readonly from: number;
  98564. /**
  98565. * Gets the last frame
  98566. */
  98567. readonly to: number;
  98568. /**
  98569. * Define if the animations are started
  98570. */
  98571. readonly isStarted: boolean;
  98572. /**
  98573. * Gets a value indicating that the current group is playing
  98574. */
  98575. readonly isPlaying: boolean;
  98576. /**
  98577. * Gets or sets the speed ratio to use for all animations
  98578. */
  98579. /**
  98580. * Gets or sets the speed ratio to use for all animations
  98581. */
  98582. speedRatio: number;
  98583. /**
  98584. * Gets or sets if all animations should loop or not
  98585. */
  98586. loopAnimation: boolean;
  98587. /**
  98588. * Gets the targeted animations for this animation group
  98589. */
  98590. readonly targetedAnimations: Array<TargetedAnimation>;
  98591. /**
  98592. * returning the list of animatables controlled by this animation group.
  98593. */
  98594. readonly animatables: Array<Animatable>;
  98595. /**
  98596. * Instantiates a new Animation Group.
  98597. * This helps managing several animations at once.
  98598. * @see http://doc.babylonjs.com/how_to/group
  98599. * @param name Defines the name of the group
  98600. * @param scene Defines the scene the group belongs to
  98601. */
  98602. constructor(
  98603. /** The name of the animation group */
  98604. name: string, scene?: Nullable<Scene>);
  98605. /**
  98606. * Add an animation (with its target) in the group
  98607. * @param animation defines the animation we want to add
  98608. * @param target defines the target of the animation
  98609. * @returns the TargetedAnimation object
  98610. */
  98611. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98612. /**
  98613. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98614. * It can add constant keys at begin or end
  98615. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98616. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98617. * @returns the animation group
  98618. */
  98619. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98620. /**
  98621. * Start all animations on given targets
  98622. * @param loop defines if animations must loop
  98623. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98624. * @param from defines the from key (optional)
  98625. * @param to defines the to key (optional)
  98626. * @returns the current animation group
  98627. */
  98628. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98629. /**
  98630. * Pause all animations
  98631. * @returns the animation group
  98632. */
  98633. pause(): AnimationGroup;
  98634. /**
  98635. * Play all animations to initial state
  98636. * This function will start() the animations if they were not started or will restart() them if they were paused
  98637. * @param loop defines if animations must loop
  98638. * @returns the animation group
  98639. */
  98640. play(loop?: boolean): AnimationGroup;
  98641. /**
  98642. * Reset all animations to initial state
  98643. * @returns the animation group
  98644. */
  98645. reset(): AnimationGroup;
  98646. /**
  98647. * Restart animations from key 0
  98648. * @returns the animation group
  98649. */
  98650. restart(): AnimationGroup;
  98651. /**
  98652. * Stop all animations
  98653. * @returns the animation group
  98654. */
  98655. stop(): AnimationGroup;
  98656. /**
  98657. * Set animation weight for all animatables
  98658. * @param weight defines the weight to use
  98659. * @return the animationGroup
  98660. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98661. */
  98662. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98663. /**
  98664. * Synchronize and normalize all animatables with a source animatable
  98665. * @param root defines the root animatable to synchronize with
  98666. * @return the animationGroup
  98667. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98668. */
  98669. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98670. /**
  98671. * Goes to a specific frame in this animation group
  98672. * @param frame the frame number to go to
  98673. * @return the animationGroup
  98674. */
  98675. goToFrame(frame: number): AnimationGroup;
  98676. /**
  98677. * Dispose all associated resources
  98678. */
  98679. dispose(): void;
  98680. private _checkAnimationGroupEnded;
  98681. /**
  98682. * Clone the current animation group and returns a copy
  98683. * @param newName defines the name of the new group
  98684. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98685. * @returns the new aniamtion group
  98686. */
  98687. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98688. /**
  98689. * Serializes the animationGroup to an object
  98690. * @returns Serialized object
  98691. */
  98692. serialize(): any;
  98693. /**
  98694. * Returns a new AnimationGroup object parsed from the source provided.
  98695. * @param parsedAnimationGroup defines the source
  98696. * @param scene defines the scene that will receive the animationGroup
  98697. * @returns a new AnimationGroup
  98698. */
  98699. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98700. /**
  98701. * Returns the string "AnimationGroup"
  98702. * @returns "AnimationGroup"
  98703. */
  98704. getClassName(): string;
  98705. /**
  98706. * Creates a detailled string about the object
  98707. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98708. * @returns a string representing the object
  98709. */
  98710. toString(fullDetails?: boolean): string;
  98711. }
  98712. }
  98713. declare module BABYLON {
  98714. /**
  98715. * Define an interface for all classes that will hold resources
  98716. */
  98717. export interface IDisposable {
  98718. /**
  98719. * Releases all held resources
  98720. */
  98721. dispose(): void;
  98722. }
  98723. /** Interface defining initialization parameters for Scene class */
  98724. export interface SceneOptions {
  98725. /**
  98726. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98727. * It will improve performance when the number of geometries becomes important.
  98728. */
  98729. useGeometryUniqueIdsMap?: boolean;
  98730. /**
  98731. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98732. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98733. */
  98734. useMaterialMeshMap?: boolean;
  98735. /**
  98736. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98737. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98738. */
  98739. useClonedMeshhMap?: boolean;
  98740. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98741. virtual?: boolean;
  98742. }
  98743. /**
  98744. * Represents a scene to be rendered by the engine.
  98745. * @see http://doc.babylonjs.com/features/scene
  98746. */
  98747. export class Scene extends AbstractScene implements IAnimatable {
  98748. /** The fog is deactivated */
  98749. static readonly FOGMODE_NONE: number;
  98750. /** The fog density is following an exponential function */
  98751. static readonly FOGMODE_EXP: number;
  98752. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98753. static readonly FOGMODE_EXP2: number;
  98754. /** The fog density is following a linear function. */
  98755. static readonly FOGMODE_LINEAR: number;
  98756. /**
  98757. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98759. */
  98760. static MinDeltaTime: number;
  98761. /**
  98762. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98764. */
  98765. static MaxDeltaTime: number;
  98766. /**
  98767. * Factory used to create the default material.
  98768. * @param name The name of the material to create
  98769. * @param scene The scene to create the material for
  98770. * @returns The default material
  98771. */
  98772. static DefaultMaterialFactory(scene: Scene): Material;
  98773. /**
  98774. * Factory used to create the a collision coordinator.
  98775. * @returns The collision coordinator
  98776. */
  98777. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98778. /** @hidden */
  98779. _inputManager: InputManager;
  98780. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98781. cameraToUseForPointers: Nullable<Camera>;
  98782. /** @hidden */
  98783. readonly _isScene: boolean;
  98784. /**
  98785. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98786. */
  98787. autoClear: boolean;
  98788. /**
  98789. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98790. */
  98791. autoClearDepthAndStencil: boolean;
  98792. /**
  98793. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98794. */
  98795. clearColor: Color4;
  98796. /**
  98797. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98798. */
  98799. ambientColor: Color3;
  98800. /**
  98801. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98802. * It should only be one of the following (if not the default embedded one):
  98803. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98804. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98805. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98806. * The material properties need to be setup according to the type of texture in use.
  98807. */
  98808. environmentBRDFTexture: BaseTexture;
  98809. /** @hidden */
  98810. protected _environmentTexture: Nullable<BaseTexture>;
  98811. /**
  98812. * Texture used in all pbr material as the reflection texture.
  98813. * As in the majority of the scene they are the same (exception for multi room and so on),
  98814. * this is easier to reference from here than from all the materials.
  98815. */
  98816. /**
  98817. * Texture used in all pbr material as the reflection texture.
  98818. * As in the majority of the scene they are the same (exception for multi room and so on),
  98819. * this is easier to set here than in all the materials.
  98820. */
  98821. environmentTexture: Nullable<BaseTexture>;
  98822. /** @hidden */
  98823. protected _environmentIntensity: number;
  98824. /**
  98825. * Intensity of the environment in all pbr material.
  98826. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98827. * As in the majority of the scene they are the same (exception for multi room and so on),
  98828. * this is easier to reference from here than from all the materials.
  98829. */
  98830. /**
  98831. * Intensity of the environment in all pbr material.
  98832. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98833. * As in the majority of the scene they are the same (exception for multi room and so on),
  98834. * this is easier to set here than in all the materials.
  98835. */
  98836. environmentIntensity: number;
  98837. /** @hidden */
  98838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98839. /**
  98840. * Default image processing configuration used either in the rendering
  98841. * Forward main pass or through the imageProcessingPostProcess if present.
  98842. * As in the majority of the scene they are the same (exception for multi camera),
  98843. * this is easier to reference from here than from all the materials and post process.
  98844. *
  98845. * No setter as we it is a shared configuration, you can set the values instead.
  98846. */
  98847. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98848. private _forceWireframe;
  98849. /**
  98850. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98851. */
  98852. forceWireframe: boolean;
  98853. private _forcePointsCloud;
  98854. /**
  98855. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98856. */
  98857. forcePointsCloud: boolean;
  98858. /**
  98859. * Gets or sets the active clipplane 1
  98860. */
  98861. clipPlane: Nullable<Plane>;
  98862. /**
  98863. * Gets or sets the active clipplane 2
  98864. */
  98865. clipPlane2: Nullable<Plane>;
  98866. /**
  98867. * Gets or sets the active clipplane 3
  98868. */
  98869. clipPlane3: Nullable<Plane>;
  98870. /**
  98871. * Gets or sets the active clipplane 4
  98872. */
  98873. clipPlane4: Nullable<Plane>;
  98874. /**
  98875. * Gets or sets a boolean indicating if animations are enabled
  98876. */
  98877. animationsEnabled: boolean;
  98878. private _animationPropertiesOverride;
  98879. /**
  98880. * Gets or sets the animation properties override
  98881. */
  98882. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98883. /**
  98884. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98885. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98886. */
  98887. useConstantAnimationDeltaTime: boolean;
  98888. /**
  98889. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98890. * Please note that it requires to run a ray cast through the scene on every frame
  98891. */
  98892. constantlyUpdateMeshUnderPointer: boolean;
  98893. /**
  98894. * Defines the HTML cursor to use when hovering over interactive elements
  98895. */
  98896. hoverCursor: string;
  98897. /**
  98898. * Defines the HTML default cursor to use (empty by default)
  98899. */
  98900. defaultCursor: string;
  98901. /**
  98902. * This is used to call preventDefault() on pointer down
  98903. * in order to block unwanted artifacts like system double clicks
  98904. */
  98905. preventDefaultOnPointerDown: boolean;
  98906. /**
  98907. * This is used to call preventDefault() on pointer up
  98908. * in order to block unwanted artifacts like system double clicks
  98909. */
  98910. preventDefaultOnPointerUp: boolean;
  98911. /**
  98912. * Gets or sets user defined metadata
  98913. */
  98914. metadata: any;
  98915. /**
  98916. * For internal use only. Please do not use.
  98917. */
  98918. reservedDataStore: any;
  98919. /**
  98920. * Gets the name of the plugin used to load this scene (null by default)
  98921. */
  98922. loadingPluginName: string;
  98923. /**
  98924. * Use this array to add regular expressions used to disable offline support for specific urls
  98925. */
  98926. disableOfflineSupportExceptionRules: RegExp[];
  98927. /**
  98928. * An event triggered when the scene is disposed.
  98929. */
  98930. onDisposeObservable: Observable<Scene>;
  98931. private _onDisposeObserver;
  98932. /** Sets a function to be executed when this scene is disposed. */
  98933. onDispose: () => void;
  98934. /**
  98935. * An event triggered before rendering the scene (right after animations and physics)
  98936. */
  98937. onBeforeRenderObservable: Observable<Scene>;
  98938. private _onBeforeRenderObserver;
  98939. /** Sets a function to be executed before rendering this scene */
  98940. beforeRender: Nullable<() => void>;
  98941. /**
  98942. * An event triggered after rendering the scene
  98943. */
  98944. onAfterRenderObservable: Observable<Scene>;
  98945. /**
  98946. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98947. */
  98948. onAfterRenderCameraObservable: Observable<Camera>;
  98949. private _onAfterRenderObserver;
  98950. /** Sets a function to be executed after rendering this scene */
  98951. afterRender: Nullable<() => void>;
  98952. /**
  98953. * An event triggered before animating the scene
  98954. */
  98955. onBeforeAnimationsObservable: Observable<Scene>;
  98956. /**
  98957. * An event triggered after animations processing
  98958. */
  98959. onAfterAnimationsObservable: Observable<Scene>;
  98960. /**
  98961. * An event triggered before draw calls are ready to be sent
  98962. */
  98963. onBeforeDrawPhaseObservable: Observable<Scene>;
  98964. /**
  98965. * An event triggered after draw calls have been sent
  98966. */
  98967. onAfterDrawPhaseObservable: Observable<Scene>;
  98968. /**
  98969. * An event triggered when the scene is ready
  98970. */
  98971. onReadyObservable: Observable<Scene>;
  98972. /**
  98973. * An event triggered before rendering a camera
  98974. */
  98975. onBeforeCameraRenderObservable: Observable<Camera>;
  98976. private _onBeforeCameraRenderObserver;
  98977. /** Sets a function to be executed before rendering a camera*/
  98978. beforeCameraRender: () => void;
  98979. /**
  98980. * An event triggered after rendering a camera
  98981. */
  98982. onAfterCameraRenderObservable: Observable<Camera>;
  98983. private _onAfterCameraRenderObserver;
  98984. /** Sets a function to be executed after rendering a camera*/
  98985. afterCameraRender: () => void;
  98986. /**
  98987. * An event triggered when active meshes evaluation is about to start
  98988. */
  98989. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98990. /**
  98991. * An event triggered when active meshes evaluation is done
  98992. */
  98993. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98994. /**
  98995. * An event triggered when particles rendering is about to start
  98996. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98997. */
  98998. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98999. /**
  99000. * An event triggered when particles rendering is done
  99001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99002. */
  99003. onAfterParticlesRenderingObservable: Observable<Scene>;
  99004. /**
  99005. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99006. */
  99007. onDataLoadedObservable: Observable<Scene>;
  99008. /**
  99009. * An event triggered when a camera is created
  99010. */
  99011. onNewCameraAddedObservable: Observable<Camera>;
  99012. /**
  99013. * An event triggered when a camera is removed
  99014. */
  99015. onCameraRemovedObservable: Observable<Camera>;
  99016. /**
  99017. * An event triggered when a light is created
  99018. */
  99019. onNewLightAddedObservable: Observable<Light>;
  99020. /**
  99021. * An event triggered when a light is removed
  99022. */
  99023. onLightRemovedObservable: Observable<Light>;
  99024. /**
  99025. * An event triggered when a geometry is created
  99026. */
  99027. onNewGeometryAddedObservable: Observable<Geometry>;
  99028. /**
  99029. * An event triggered when a geometry is removed
  99030. */
  99031. onGeometryRemovedObservable: Observable<Geometry>;
  99032. /**
  99033. * An event triggered when a transform node is created
  99034. */
  99035. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99036. /**
  99037. * An event triggered when a transform node is removed
  99038. */
  99039. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99040. /**
  99041. * An event triggered when a mesh is created
  99042. */
  99043. onNewMeshAddedObservable: Observable<AbstractMesh>;
  99044. /**
  99045. * An event triggered when a mesh is removed
  99046. */
  99047. onMeshRemovedObservable: Observable<AbstractMesh>;
  99048. /**
  99049. * An event triggered when a skeleton is created
  99050. */
  99051. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99052. /**
  99053. * An event triggered when a skeleton is removed
  99054. */
  99055. onSkeletonRemovedObservable: Observable<Skeleton>;
  99056. /**
  99057. * An event triggered when a material is created
  99058. */
  99059. onNewMaterialAddedObservable: Observable<Material>;
  99060. /**
  99061. * An event triggered when a material is removed
  99062. */
  99063. onMaterialRemovedObservable: Observable<Material>;
  99064. /**
  99065. * An event triggered when a texture is created
  99066. */
  99067. onNewTextureAddedObservable: Observable<BaseTexture>;
  99068. /**
  99069. * An event triggered when a texture is removed
  99070. */
  99071. onTextureRemovedObservable: Observable<BaseTexture>;
  99072. /**
  99073. * An event triggered when render targets are about to be rendered
  99074. * Can happen multiple times per frame.
  99075. */
  99076. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99077. /**
  99078. * An event triggered when render targets were rendered.
  99079. * Can happen multiple times per frame.
  99080. */
  99081. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99082. /**
  99083. * An event triggered before calculating deterministic simulation step
  99084. */
  99085. onBeforeStepObservable: Observable<Scene>;
  99086. /**
  99087. * An event triggered after calculating deterministic simulation step
  99088. */
  99089. onAfterStepObservable: Observable<Scene>;
  99090. /**
  99091. * An event triggered when the activeCamera property is updated
  99092. */
  99093. onActiveCameraChanged: Observable<Scene>;
  99094. /**
  99095. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99096. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99097. * 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)
  99098. */
  99099. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99100. /**
  99101. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99102. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99103. * 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)
  99104. */
  99105. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99106. /**
  99107. * This Observable will when a mesh has been imported into the scene.
  99108. */
  99109. onMeshImportedObservable: Observable<AbstractMesh>;
  99110. /**
  99111. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  99112. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  99113. */
  99114. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  99115. /** @hidden */
  99116. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  99117. /**
  99118. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  99119. */
  99120. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  99121. /**
  99122. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  99123. */
  99124. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  99125. /**
  99126. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  99127. */
  99128. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  99129. /** Callback called when a pointer move is detected */
  99130. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99131. /** Callback called when a pointer down is detected */
  99132. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99133. /** Callback called when a pointer up is detected */
  99134. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99135. /** Callback called when a pointer pick is detected */
  99136. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99137. /**
  99138. * 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).
  99139. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99140. */
  99141. onPrePointerObservable: Observable<PointerInfoPre>;
  99142. /**
  99143. * Observable event triggered each time an input event is received from the rendering canvas
  99144. */
  99145. onPointerObservable: Observable<PointerInfo>;
  99146. /**
  99147. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99148. */
  99149. readonly unTranslatedPointer: Vector2;
  99150. /**
  99151. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99152. */
  99153. static DragMovementThreshold: number;
  99154. /**
  99155. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99156. */
  99157. static LongPressDelay: number;
  99158. /**
  99159. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99160. */
  99161. static DoubleClickDelay: number;
  99162. /** If you need to check double click without raising a single click at first click, enable this flag */
  99163. static ExclusiveDoubleClickMode: boolean;
  99164. /** @hidden */
  99165. _mirroredCameraPosition: Nullable<Vector3>;
  99166. /**
  99167. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99168. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99169. */
  99170. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99171. /**
  99172. * Observable event triggered each time an keyboard event is received from the hosting window
  99173. */
  99174. onKeyboardObservable: Observable<KeyboardInfo>;
  99175. private _useRightHandedSystem;
  99176. /**
  99177. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99178. */
  99179. useRightHandedSystem: boolean;
  99180. private _timeAccumulator;
  99181. private _currentStepId;
  99182. private _currentInternalStep;
  99183. /**
  99184. * Sets the step Id used by deterministic lock step
  99185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99186. * @param newStepId defines the step Id
  99187. */
  99188. setStepId(newStepId: number): void;
  99189. /**
  99190. * Gets the step Id used by deterministic lock step
  99191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99192. * @returns the step Id
  99193. */
  99194. getStepId(): number;
  99195. /**
  99196. * Gets the internal step used by deterministic lock step
  99197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99198. * @returns the internal step
  99199. */
  99200. getInternalStep(): number;
  99201. private _fogEnabled;
  99202. /**
  99203. * Gets or sets a boolean indicating if fog is enabled on this scene
  99204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99205. * (Default is true)
  99206. */
  99207. fogEnabled: boolean;
  99208. private _fogMode;
  99209. /**
  99210. * Gets or sets the fog mode to use
  99211. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99212. * | mode | value |
  99213. * | --- | --- |
  99214. * | FOGMODE_NONE | 0 |
  99215. * | FOGMODE_EXP | 1 |
  99216. * | FOGMODE_EXP2 | 2 |
  99217. * | FOGMODE_LINEAR | 3 |
  99218. */
  99219. fogMode: number;
  99220. /**
  99221. * Gets or sets the fog color to use
  99222. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99223. * (Default is Color3(0.2, 0.2, 0.3))
  99224. */
  99225. fogColor: Color3;
  99226. /**
  99227. * Gets or sets the fog density to use
  99228. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99229. * (Default is 0.1)
  99230. */
  99231. fogDensity: number;
  99232. /**
  99233. * Gets or sets the fog start distance to use
  99234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99235. * (Default is 0)
  99236. */
  99237. fogStart: number;
  99238. /**
  99239. * Gets or sets the fog end distance to use
  99240. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99241. * (Default is 1000)
  99242. */
  99243. fogEnd: number;
  99244. private _shadowsEnabled;
  99245. /**
  99246. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99247. */
  99248. shadowsEnabled: boolean;
  99249. private _lightsEnabled;
  99250. /**
  99251. * Gets or sets a boolean indicating if lights are enabled on this scene
  99252. */
  99253. lightsEnabled: boolean;
  99254. /** All of the active cameras added to this scene. */
  99255. activeCameras: Camera[];
  99256. /** @hidden */
  99257. _activeCamera: Nullable<Camera>;
  99258. /** Gets or sets the current active camera */
  99259. activeCamera: Nullable<Camera>;
  99260. private _defaultMaterial;
  99261. /** The default material used on meshes when no material is affected */
  99262. /** The default material used on meshes when no material is affected */
  99263. defaultMaterial: Material;
  99264. private _texturesEnabled;
  99265. /**
  99266. * Gets or sets a boolean indicating if textures are enabled on this scene
  99267. */
  99268. texturesEnabled: boolean;
  99269. /**
  99270. * Gets or sets a boolean indicating if particles are enabled on this scene
  99271. */
  99272. particlesEnabled: boolean;
  99273. /**
  99274. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99275. */
  99276. spritesEnabled: boolean;
  99277. private _skeletonsEnabled;
  99278. /**
  99279. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99280. */
  99281. skeletonsEnabled: boolean;
  99282. /**
  99283. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99284. */
  99285. lensFlaresEnabled: boolean;
  99286. /**
  99287. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99289. */
  99290. collisionsEnabled: boolean;
  99291. private _collisionCoordinator;
  99292. /** @hidden */
  99293. readonly collisionCoordinator: ICollisionCoordinator;
  99294. /**
  99295. * Defines the gravity applied to this scene (used only for collisions)
  99296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99297. */
  99298. gravity: Vector3;
  99299. /**
  99300. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99301. */
  99302. postProcessesEnabled: boolean;
  99303. /**
  99304. * The list of postprocesses added to the scene
  99305. */
  99306. postProcesses: PostProcess[];
  99307. /**
  99308. * Gets the current postprocess manager
  99309. */
  99310. postProcessManager: PostProcessManager;
  99311. /**
  99312. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99313. */
  99314. renderTargetsEnabled: boolean;
  99315. /**
  99316. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99317. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99318. */
  99319. dumpNextRenderTargets: boolean;
  99320. /**
  99321. * The list of user defined render targets added to the scene
  99322. */
  99323. customRenderTargets: RenderTargetTexture[];
  99324. /**
  99325. * Defines if texture loading must be delayed
  99326. * If true, textures will only be loaded when they need to be rendered
  99327. */
  99328. useDelayedTextureLoading: boolean;
  99329. /**
  99330. * Gets the list of meshes imported to the scene through SceneLoader
  99331. */
  99332. importedMeshesFiles: String[];
  99333. /**
  99334. * Gets or sets a boolean indicating if probes are enabled on this scene
  99335. */
  99336. probesEnabled: boolean;
  99337. /**
  99338. * Gets or sets the current offline provider to use to store scene data
  99339. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99340. */
  99341. offlineProvider: IOfflineProvider;
  99342. /**
  99343. * Gets or sets the action manager associated with the scene
  99344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99345. */
  99346. actionManager: AbstractActionManager;
  99347. private _meshesForIntersections;
  99348. /**
  99349. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99350. */
  99351. proceduralTexturesEnabled: boolean;
  99352. private _engine;
  99353. private _totalVertices;
  99354. /** @hidden */
  99355. _activeIndices: PerfCounter;
  99356. /** @hidden */
  99357. _activeParticles: PerfCounter;
  99358. /** @hidden */
  99359. _activeBones: PerfCounter;
  99360. private _animationRatio;
  99361. /** @hidden */
  99362. _animationTimeLast: number;
  99363. /** @hidden */
  99364. _animationTime: number;
  99365. /**
  99366. * Gets or sets a general scale for animation speed
  99367. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99368. */
  99369. animationTimeScale: number;
  99370. /** @hidden */
  99371. _cachedMaterial: Nullable<Material>;
  99372. /** @hidden */
  99373. _cachedEffect: Nullable<Effect>;
  99374. /** @hidden */
  99375. _cachedVisibility: Nullable<number>;
  99376. private _renderId;
  99377. private _frameId;
  99378. private _executeWhenReadyTimeoutId;
  99379. private _intermediateRendering;
  99380. private _viewUpdateFlag;
  99381. private _projectionUpdateFlag;
  99382. /** @hidden */
  99383. _toBeDisposed: Nullable<IDisposable>[];
  99384. private _activeRequests;
  99385. /** @hidden */
  99386. _pendingData: any[];
  99387. private _isDisposed;
  99388. /**
  99389. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99390. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99391. */
  99392. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99393. private _activeMeshes;
  99394. private _processedMaterials;
  99395. private _renderTargets;
  99396. /** @hidden */
  99397. _activeParticleSystems: SmartArray<IParticleSystem>;
  99398. private _activeSkeletons;
  99399. private _softwareSkinnedMeshes;
  99400. private _renderingManager;
  99401. /** @hidden */
  99402. _activeAnimatables: Animatable[];
  99403. private _transformMatrix;
  99404. private _sceneUbo;
  99405. /** @hidden */
  99406. _viewMatrix: Matrix;
  99407. private _projectionMatrix;
  99408. /** @hidden */
  99409. _forcedViewPosition: Nullable<Vector3>;
  99410. /** @hidden */
  99411. _frustumPlanes: Plane[];
  99412. /**
  99413. * Gets the list of frustum planes (built from the active camera)
  99414. */
  99415. readonly frustumPlanes: Plane[];
  99416. /**
  99417. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99418. * This is useful if there are more lights that the maximum simulteanous authorized
  99419. */
  99420. requireLightSorting: boolean;
  99421. /** @hidden */
  99422. readonly useMaterialMeshMap: boolean;
  99423. /** @hidden */
  99424. readonly useClonedMeshhMap: boolean;
  99425. private _externalData;
  99426. private _uid;
  99427. /**
  99428. * @hidden
  99429. * Backing store of defined scene components.
  99430. */
  99431. _components: ISceneComponent[];
  99432. /**
  99433. * @hidden
  99434. * Backing store of defined scene components.
  99435. */
  99436. _serializableComponents: ISceneSerializableComponent[];
  99437. /**
  99438. * List of components to register on the next registration step.
  99439. */
  99440. private _transientComponents;
  99441. /**
  99442. * Registers the transient components if needed.
  99443. */
  99444. private _registerTransientComponents;
  99445. /**
  99446. * @hidden
  99447. * Add a component to the scene.
  99448. * Note that the ccomponent could be registered on th next frame if this is called after
  99449. * the register component stage.
  99450. * @param component Defines the component to add to the scene
  99451. */
  99452. _addComponent(component: ISceneComponent): void;
  99453. /**
  99454. * @hidden
  99455. * Gets a component from the scene.
  99456. * @param name defines the name of the component to retrieve
  99457. * @returns the component or null if not present
  99458. */
  99459. _getComponent(name: string): Nullable<ISceneComponent>;
  99460. /**
  99461. * @hidden
  99462. * Defines the actions happening before camera updates.
  99463. */
  99464. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99465. /**
  99466. * @hidden
  99467. * Defines the actions happening before clear the canvas.
  99468. */
  99469. _beforeClearStage: Stage<SimpleStageAction>;
  99470. /**
  99471. * @hidden
  99472. * Defines the actions when collecting render targets for the frame.
  99473. */
  99474. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99475. /**
  99476. * @hidden
  99477. * Defines the actions happening for one camera in the frame.
  99478. */
  99479. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99480. /**
  99481. * @hidden
  99482. * Defines the actions happening during the per mesh ready checks.
  99483. */
  99484. _isReadyForMeshStage: Stage<MeshStageAction>;
  99485. /**
  99486. * @hidden
  99487. * Defines the actions happening before evaluate active mesh checks.
  99488. */
  99489. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99490. /**
  99491. * @hidden
  99492. * Defines the actions happening during the evaluate sub mesh checks.
  99493. */
  99494. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99495. /**
  99496. * @hidden
  99497. * Defines the actions happening during the active mesh stage.
  99498. */
  99499. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99500. /**
  99501. * @hidden
  99502. * Defines the actions happening during the per camera render target step.
  99503. */
  99504. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99505. /**
  99506. * @hidden
  99507. * Defines the actions happening just before the active camera is drawing.
  99508. */
  99509. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99510. /**
  99511. * @hidden
  99512. * Defines the actions happening just before a render target is drawing.
  99513. */
  99514. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99515. /**
  99516. * @hidden
  99517. * Defines the actions happening just before a rendering group is drawing.
  99518. */
  99519. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99520. /**
  99521. * @hidden
  99522. * Defines the actions happening just before a mesh is drawing.
  99523. */
  99524. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99525. /**
  99526. * @hidden
  99527. * Defines the actions happening just after a mesh has been drawn.
  99528. */
  99529. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99530. /**
  99531. * @hidden
  99532. * Defines the actions happening just after a rendering group has been drawn.
  99533. */
  99534. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99535. /**
  99536. * @hidden
  99537. * Defines the actions happening just after the active camera has been drawn.
  99538. */
  99539. _afterCameraDrawStage: Stage<CameraStageAction>;
  99540. /**
  99541. * @hidden
  99542. * Defines the actions happening just after a render target has been drawn.
  99543. */
  99544. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99545. /**
  99546. * @hidden
  99547. * Defines the actions happening just after rendering all cameras and computing intersections.
  99548. */
  99549. _afterRenderStage: Stage<SimpleStageAction>;
  99550. /**
  99551. * @hidden
  99552. * Defines the actions happening when a pointer move event happens.
  99553. */
  99554. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99555. /**
  99556. * @hidden
  99557. * Defines the actions happening when a pointer down event happens.
  99558. */
  99559. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99560. /**
  99561. * @hidden
  99562. * Defines the actions happening when a pointer up event happens.
  99563. */
  99564. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99565. /**
  99566. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99567. */
  99568. private geometriesByUniqueId;
  99569. /**
  99570. * Creates a new Scene
  99571. * @param engine defines the engine to use to render this scene
  99572. * @param options defines the scene options
  99573. */
  99574. constructor(engine: Engine, options?: SceneOptions);
  99575. /**
  99576. * Gets a string idenfifying the name of the class
  99577. * @returns "Scene" string
  99578. */
  99579. getClassName(): string;
  99580. private _defaultMeshCandidates;
  99581. /**
  99582. * @hidden
  99583. */
  99584. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99585. private _defaultSubMeshCandidates;
  99586. /**
  99587. * @hidden
  99588. */
  99589. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99590. /**
  99591. * Sets the default candidate providers for the scene.
  99592. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99593. * and getCollidingSubMeshCandidates to their default function
  99594. */
  99595. setDefaultCandidateProviders(): void;
  99596. /**
  99597. * Gets the mesh that is currently under the pointer
  99598. */
  99599. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99600. /**
  99601. * Gets or sets the current on-screen X position of the pointer
  99602. */
  99603. pointerX: number;
  99604. /**
  99605. * Gets or sets the current on-screen Y position of the pointer
  99606. */
  99607. pointerY: number;
  99608. /**
  99609. * Gets the cached material (ie. the latest rendered one)
  99610. * @returns the cached material
  99611. */
  99612. getCachedMaterial(): Nullable<Material>;
  99613. /**
  99614. * Gets the cached effect (ie. the latest rendered one)
  99615. * @returns the cached effect
  99616. */
  99617. getCachedEffect(): Nullable<Effect>;
  99618. /**
  99619. * Gets the cached visibility state (ie. the latest rendered one)
  99620. * @returns the cached visibility state
  99621. */
  99622. getCachedVisibility(): Nullable<number>;
  99623. /**
  99624. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99625. * @param material defines the current material
  99626. * @param effect defines the current effect
  99627. * @param visibility defines the current visibility state
  99628. * @returns true if one parameter is not cached
  99629. */
  99630. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99631. /**
  99632. * Gets the engine associated with the scene
  99633. * @returns an Engine
  99634. */
  99635. getEngine(): Engine;
  99636. /**
  99637. * Gets the total number of vertices rendered per frame
  99638. * @returns the total number of vertices rendered per frame
  99639. */
  99640. getTotalVertices(): number;
  99641. /**
  99642. * Gets the performance counter for total vertices
  99643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99644. */
  99645. readonly totalVerticesPerfCounter: PerfCounter;
  99646. /**
  99647. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99648. * @returns the total number of active indices rendered per frame
  99649. */
  99650. getActiveIndices(): number;
  99651. /**
  99652. * Gets the performance counter for active indices
  99653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99654. */
  99655. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99656. /**
  99657. * Gets the total number of active particles rendered per frame
  99658. * @returns the total number of active particles rendered per frame
  99659. */
  99660. getActiveParticles(): number;
  99661. /**
  99662. * Gets the performance counter for active particles
  99663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99664. */
  99665. readonly activeParticlesPerfCounter: PerfCounter;
  99666. /**
  99667. * Gets the total number of active bones rendered per frame
  99668. * @returns the total number of active bones rendered per frame
  99669. */
  99670. getActiveBones(): number;
  99671. /**
  99672. * Gets the performance counter for active bones
  99673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99674. */
  99675. readonly activeBonesPerfCounter: PerfCounter;
  99676. /**
  99677. * Gets the array of active meshes
  99678. * @returns an array of AbstractMesh
  99679. */
  99680. getActiveMeshes(): SmartArray<AbstractMesh>;
  99681. /**
  99682. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99683. * @returns a number
  99684. */
  99685. getAnimationRatio(): number;
  99686. /**
  99687. * Gets an unique Id for the current render phase
  99688. * @returns a number
  99689. */
  99690. getRenderId(): number;
  99691. /**
  99692. * Gets an unique Id for the current frame
  99693. * @returns a number
  99694. */
  99695. getFrameId(): number;
  99696. /** Call this function if you want to manually increment the render Id*/
  99697. incrementRenderId(): void;
  99698. private _createUbo;
  99699. /**
  99700. * Use this method to simulate a pointer move on a mesh
  99701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99704. * @returns the current scene
  99705. */
  99706. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99707. /**
  99708. * Use this method to simulate a pointer down on a mesh
  99709. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99710. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99711. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99712. * @returns the current scene
  99713. */
  99714. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99715. /**
  99716. * Use this method to simulate a pointer up on a mesh
  99717. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99718. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99719. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99720. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99721. * @returns the current scene
  99722. */
  99723. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99724. /**
  99725. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99726. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99727. * @returns true if the pointer was captured
  99728. */
  99729. isPointerCaptured(pointerId?: number): boolean;
  99730. /**
  99731. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99732. * @param attachUp defines if you want to attach events to pointerup
  99733. * @param attachDown defines if you want to attach events to pointerdown
  99734. * @param attachMove defines if you want to attach events to pointermove
  99735. */
  99736. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99737. /** Detaches all event handlers*/
  99738. detachControl(): void;
  99739. /**
  99740. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99741. * Delay loaded resources are not taking in account
  99742. * @return true if all required resources are ready
  99743. */
  99744. isReady(): boolean;
  99745. /** Resets all cached information relative to material (including effect and visibility) */
  99746. resetCachedMaterial(): void;
  99747. /**
  99748. * Registers a function to be called before every frame render
  99749. * @param func defines the function to register
  99750. */
  99751. registerBeforeRender(func: () => void): void;
  99752. /**
  99753. * Unregisters a function called before every frame render
  99754. * @param func defines the function to unregister
  99755. */
  99756. unregisterBeforeRender(func: () => void): void;
  99757. /**
  99758. * Registers a function to be called after every frame render
  99759. * @param func defines the function to register
  99760. */
  99761. registerAfterRender(func: () => void): void;
  99762. /**
  99763. * Unregisters a function called after every frame render
  99764. * @param func defines the function to unregister
  99765. */
  99766. unregisterAfterRender(func: () => void): void;
  99767. private _executeOnceBeforeRender;
  99768. /**
  99769. * The provided function will run before render once and will be disposed afterwards.
  99770. * A timeout delay can be provided so that the function will be executed in N ms.
  99771. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99772. * @param func The function to be executed.
  99773. * @param timeout optional delay in ms
  99774. */
  99775. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99776. /** @hidden */
  99777. _addPendingData(data: any): void;
  99778. /** @hidden */
  99779. _removePendingData(data: any): void;
  99780. /**
  99781. * Returns the number of items waiting to be loaded
  99782. * @returns the number of items waiting to be loaded
  99783. */
  99784. getWaitingItemsCount(): number;
  99785. /**
  99786. * Returns a boolean indicating if the scene is still loading data
  99787. */
  99788. readonly isLoading: boolean;
  99789. /**
  99790. * Registers a function to be executed when the scene is ready
  99791. * @param {Function} func - the function to be executed
  99792. */
  99793. executeWhenReady(func: () => void): void;
  99794. /**
  99795. * Returns a promise that resolves when the scene is ready
  99796. * @returns A promise that resolves when the scene is ready
  99797. */
  99798. whenReadyAsync(): Promise<void>;
  99799. /** @hidden */
  99800. _checkIsReady(): void;
  99801. /**
  99802. * Gets all animatable attached to the scene
  99803. */
  99804. readonly animatables: Animatable[];
  99805. /**
  99806. * Resets the last animation time frame.
  99807. * Useful to override when animations start running when loading a scene for the first time.
  99808. */
  99809. resetLastAnimationTimeFrame(): void;
  99810. /**
  99811. * Gets the current view matrix
  99812. * @returns a Matrix
  99813. */
  99814. getViewMatrix(): Matrix;
  99815. /**
  99816. * Gets the current projection matrix
  99817. * @returns a Matrix
  99818. */
  99819. getProjectionMatrix(): Matrix;
  99820. /**
  99821. * Gets the current transform matrix
  99822. * @returns a Matrix made of View * Projection
  99823. */
  99824. getTransformMatrix(): Matrix;
  99825. /**
  99826. * Sets the current transform matrix
  99827. * @param viewL defines the View matrix to use
  99828. * @param projectionL defines the Projection matrix to use
  99829. * @param viewR defines the right View matrix to use (if provided)
  99830. * @param projectionR defines the right Projection matrix to use (if provided)
  99831. */
  99832. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99833. /**
  99834. * Gets the uniform buffer used to store scene data
  99835. * @returns a UniformBuffer
  99836. */
  99837. getSceneUniformBuffer(): UniformBuffer;
  99838. /**
  99839. * Gets an unique (relatively to the current scene) Id
  99840. * @returns an unique number for the scene
  99841. */
  99842. getUniqueId(): number;
  99843. /**
  99844. * Add a mesh to the list of scene's meshes
  99845. * @param newMesh defines the mesh to add
  99846. * @param recursive if all child meshes should also be added to the scene
  99847. */
  99848. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99849. /**
  99850. * Remove a mesh for the list of scene's meshes
  99851. * @param toRemove defines the mesh to remove
  99852. * @param recursive if all child meshes should also be removed from the scene
  99853. * @returns the index where the mesh was in the mesh list
  99854. */
  99855. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99856. /**
  99857. * Add a transform node to the list of scene's transform nodes
  99858. * @param newTransformNode defines the transform node to add
  99859. */
  99860. addTransformNode(newTransformNode: TransformNode): void;
  99861. /**
  99862. * Remove a transform node for the list of scene's transform nodes
  99863. * @param toRemove defines the transform node to remove
  99864. * @returns the index where the transform node was in the transform node list
  99865. */
  99866. removeTransformNode(toRemove: TransformNode): number;
  99867. /**
  99868. * Remove a skeleton for the list of scene's skeletons
  99869. * @param toRemove defines the skeleton to remove
  99870. * @returns the index where the skeleton was in the skeleton list
  99871. */
  99872. removeSkeleton(toRemove: Skeleton): number;
  99873. /**
  99874. * Remove a morph target for the list of scene's morph targets
  99875. * @param toRemove defines the morph target to remove
  99876. * @returns the index where the morph target was in the morph target list
  99877. */
  99878. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99879. /**
  99880. * Remove a light for the list of scene's lights
  99881. * @param toRemove defines the light to remove
  99882. * @returns the index where the light was in the light list
  99883. */
  99884. removeLight(toRemove: Light): number;
  99885. /**
  99886. * Remove a camera for the list of scene's cameras
  99887. * @param toRemove defines the camera to remove
  99888. * @returns the index where the camera was in the camera list
  99889. */
  99890. removeCamera(toRemove: Camera): number;
  99891. /**
  99892. * Remove a particle system for the list of scene's particle systems
  99893. * @param toRemove defines the particle system to remove
  99894. * @returns the index where the particle system was in the particle system list
  99895. */
  99896. removeParticleSystem(toRemove: IParticleSystem): number;
  99897. /**
  99898. * Remove a animation for the list of scene's animations
  99899. * @param toRemove defines the animation to remove
  99900. * @returns the index where the animation was in the animation list
  99901. */
  99902. removeAnimation(toRemove: Animation): number;
  99903. /**
  99904. * Will stop the animation of the given target
  99905. * @param target - the target
  99906. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99907. * @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)
  99908. */
  99909. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99910. /**
  99911. * Removes the given animation group from this scene.
  99912. * @param toRemove The animation group to remove
  99913. * @returns The index of the removed animation group
  99914. */
  99915. removeAnimationGroup(toRemove: AnimationGroup): number;
  99916. /**
  99917. * Removes the given multi-material from this scene.
  99918. * @param toRemove The multi-material to remove
  99919. * @returns The index of the removed multi-material
  99920. */
  99921. removeMultiMaterial(toRemove: MultiMaterial): number;
  99922. /**
  99923. * Removes the given material from this scene.
  99924. * @param toRemove The material to remove
  99925. * @returns The index of the removed material
  99926. */
  99927. removeMaterial(toRemove: Material): number;
  99928. /**
  99929. * Removes the given action manager from this scene.
  99930. * @param toRemove The action manager to remove
  99931. * @returns The index of the removed action manager
  99932. */
  99933. removeActionManager(toRemove: AbstractActionManager): number;
  99934. /**
  99935. * Removes the given texture from this scene.
  99936. * @param toRemove The texture to remove
  99937. * @returns The index of the removed texture
  99938. */
  99939. removeTexture(toRemove: BaseTexture): number;
  99940. /**
  99941. * Adds the given light to this scene
  99942. * @param newLight The light to add
  99943. */
  99944. addLight(newLight: Light): void;
  99945. /**
  99946. * Sorts the list list based on light priorities
  99947. */
  99948. sortLightsByPriority(): void;
  99949. /**
  99950. * Adds the given camera to this scene
  99951. * @param newCamera The camera to add
  99952. */
  99953. addCamera(newCamera: Camera): void;
  99954. /**
  99955. * Adds the given skeleton to this scene
  99956. * @param newSkeleton The skeleton to add
  99957. */
  99958. addSkeleton(newSkeleton: Skeleton): void;
  99959. /**
  99960. * Adds the given particle system to this scene
  99961. * @param newParticleSystem The particle system to add
  99962. */
  99963. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99964. /**
  99965. * Adds the given animation to this scene
  99966. * @param newAnimation The animation to add
  99967. */
  99968. addAnimation(newAnimation: Animation): void;
  99969. /**
  99970. * Adds the given animation group to this scene.
  99971. * @param newAnimationGroup The animation group to add
  99972. */
  99973. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99974. /**
  99975. * Adds the given multi-material to this scene
  99976. * @param newMultiMaterial The multi-material to add
  99977. */
  99978. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99979. /**
  99980. * Adds the given material to this scene
  99981. * @param newMaterial The material to add
  99982. */
  99983. addMaterial(newMaterial: Material): void;
  99984. /**
  99985. * Adds the given morph target to this scene
  99986. * @param newMorphTargetManager The morph target to add
  99987. */
  99988. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99989. /**
  99990. * Adds the given geometry to this scene
  99991. * @param newGeometry The geometry to add
  99992. */
  99993. addGeometry(newGeometry: Geometry): void;
  99994. /**
  99995. * Adds the given action manager to this scene
  99996. * @param newActionManager The action manager to add
  99997. */
  99998. addActionManager(newActionManager: AbstractActionManager): void;
  99999. /**
  100000. * Adds the given texture to this scene.
  100001. * @param newTexture The texture to add
  100002. */
  100003. addTexture(newTexture: BaseTexture): void;
  100004. /**
  100005. * Switch active camera
  100006. * @param newCamera defines the new active camera
  100007. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100008. */
  100009. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100010. /**
  100011. * sets the active camera of the scene using its ID
  100012. * @param id defines the camera's ID
  100013. * @return the new active camera or null if none found.
  100014. */
  100015. setActiveCameraByID(id: string): Nullable<Camera>;
  100016. /**
  100017. * sets the active camera of the scene using its name
  100018. * @param name defines the camera's name
  100019. * @returns the new active camera or null if none found.
  100020. */
  100021. setActiveCameraByName(name: string): Nullable<Camera>;
  100022. /**
  100023. * get an animation group using its name
  100024. * @param name defines the material's name
  100025. * @return the animation group or null if none found.
  100026. */
  100027. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100028. /**
  100029. * Get a material using its unique id
  100030. * @param uniqueId defines the material's unique id
  100031. * @return the material or null if none found.
  100032. */
  100033. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100034. /**
  100035. * get a material using its id
  100036. * @param id defines the material's ID
  100037. * @return the material or null if none found.
  100038. */
  100039. getMaterialByID(id: string): Nullable<Material>;
  100040. /**
  100041. * Gets a the last added material using a given id
  100042. * @param id defines the material's ID
  100043. * @return the last material with the given id or null if none found.
  100044. */
  100045. getLastMaterialByID(id: string): Nullable<Material>;
  100046. /**
  100047. * Gets a material using its name
  100048. * @param name defines the material's name
  100049. * @return the material or null if none found.
  100050. */
  100051. getMaterialByName(name: string): Nullable<Material>;
  100052. /**
  100053. * Get a texture using its unique id
  100054. * @param uniqueId defines the texture's unique id
  100055. * @return the texture or null if none found.
  100056. */
  100057. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100058. /**
  100059. * Gets a camera using its id
  100060. * @param id defines the id to look for
  100061. * @returns the camera or null if not found
  100062. */
  100063. getCameraByID(id: string): Nullable<Camera>;
  100064. /**
  100065. * Gets a camera using its unique id
  100066. * @param uniqueId defines the unique id to look for
  100067. * @returns the camera or null if not found
  100068. */
  100069. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100070. /**
  100071. * Gets a camera using its name
  100072. * @param name defines the camera's name
  100073. * @return the camera or null if none found.
  100074. */
  100075. getCameraByName(name: string): Nullable<Camera>;
  100076. /**
  100077. * Gets a bone using its id
  100078. * @param id defines the bone's id
  100079. * @return the bone or null if not found
  100080. */
  100081. getBoneByID(id: string): Nullable<Bone>;
  100082. /**
  100083. * Gets a bone using its id
  100084. * @param name defines the bone's name
  100085. * @return the bone or null if not found
  100086. */
  100087. getBoneByName(name: string): Nullable<Bone>;
  100088. /**
  100089. * Gets a light node using its name
  100090. * @param name defines the the light's name
  100091. * @return the light or null if none found.
  100092. */
  100093. getLightByName(name: string): Nullable<Light>;
  100094. /**
  100095. * Gets a light node using its id
  100096. * @param id defines the light's id
  100097. * @return the light or null if none found.
  100098. */
  100099. getLightByID(id: string): Nullable<Light>;
  100100. /**
  100101. * Gets a light node using its scene-generated unique ID
  100102. * @param uniqueId defines the light's unique id
  100103. * @return the light or null if none found.
  100104. */
  100105. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100106. /**
  100107. * Gets a particle system by id
  100108. * @param id defines the particle system id
  100109. * @return the corresponding system or null if none found
  100110. */
  100111. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  100112. /**
  100113. * Gets a geometry using its ID
  100114. * @param id defines the geometry's id
  100115. * @return the geometry or null if none found.
  100116. */
  100117. getGeometryByID(id: string): Nullable<Geometry>;
  100118. private _getGeometryByUniqueID;
  100119. /**
  100120. * Add a new geometry to this scene
  100121. * @param geometry defines the geometry to be added to the scene.
  100122. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  100123. * @return a boolean defining if the geometry was added or not
  100124. */
  100125. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  100126. /**
  100127. * Removes an existing geometry
  100128. * @param geometry defines the geometry to be removed from the scene
  100129. * @return a boolean defining if the geometry was removed or not
  100130. */
  100131. removeGeometry(geometry: Geometry): boolean;
  100132. /**
  100133. * Gets the list of geometries attached to the scene
  100134. * @returns an array of Geometry
  100135. */
  100136. getGeometries(): Geometry[];
  100137. /**
  100138. * Gets the first added mesh found of a given ID
  100139. * @param id defines the id to search for
  100140. * @return the mesh found or null if not found at all
  100141. */
  100142. getMeshByID(id: string): Nullable<AbstractMesh>;
  100143. /**
  100144. * Gets a list of meshes using their id
  100145. * @param id defines the id to search for
  100146. * @returns a list of meshes
  100147. */
  100148. getMeshesByID(id: string): Array<AbstractMesh>;
  100149. /**
  100150. * Gets the first added transform node found of a given ID
  100151. * @param id defines the id to search for
  100152. * @return the found transform node or null if not found at all.
  100153. */
  100154. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100155. /**
  100156. * Gets a transform node with its auto-generated unique id
  100157. * @param uniqueId efines the unique id to search for
  100158. * @return the found transform node or null if not found at all.
  100159. */
  100160. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100161. /**
  100162. * Gets a list of transform nodes using their id
  100163. * @param id defines the id to search for
  100164. * @returns a list of transform nodes
  100165. */
  100166. getTransformNodesByID(id: string): Array<TransformNode>;
  100167. /**
  100168. * Gets a mesh with its auto-generated unique id
  100169. * @param uniqueId defines the unique id to search for
  100170. * @return the found mesh or null if not found at all.
  100171. */
  100172. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100173. /**
  100174. * Gets a the last added mesh using a given id
  100175. * @param id defines the id to search for
  100176. * @return the found mesh or null if not found at all.
  100177. */
  100178. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100179. /**
  100180. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100181. * @param id defines the id to search for
  100182. * @return the found node or null if not found at all
  100183. */
  100184. getLastEntryByID(id: string): Nullable<Node>;
  100185. /**
  100186. * Gets a node (Mesh, Camera, Light) using a given id
  100187. * @param id defines the id to search for
  100188. * @return the found node or null if not found at all
  100189. */
  100190. getNodeByID(id: string): Nullable<Node>;
  100191. /**
  100192. * Gets a node (Mesh, Camera, Light) using a given name
  100193. * @param name defines the name to search for
  100194. * @return the found node or null if not found at all.
  100195. */
  100196. getNodeByName(name: string): Nullable<Node>;
  100197. /**
  100198. * Gets a mesh using a given name
  100199. * @param name defines the name to search for
  100200. * @return the found mesh or null if not found at all.
  100201. */
  100202. getMeshByName(name: string): Nullable<AbstractMesh>;
  100203. /**
  100204. * Gets a transform node using a given name
  100205. * @param name defines the name to search for
  100206. * @return the found transform node or null if not found at all.
  100207. */
  100208. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100209. /**
  100210. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100211. * @param id defines the id to search for
  100212. * @return the found skeleton or null if not found at all.
  100213. */
  100214. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100215. /**
  100216. * Gets a skeleton using a given auto generated unique id
  100217. * @param uniqueId defines the unique id to search for
  100218. * @return the found skeleton or null if not found at all.
  100219. */
  100220. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100221. /**
  100222. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100223. * @param id defines the id to search for
  100224. * @return the found skeleton or null if not found at all.
  100225. */
  100226. getSkeletonById(id: string): Nullable<Skeleton>;
  100227. /**
  100228. * Gets a skeleton using a given name
  100229. * @param name defines the name to search for
  100230. * @return the found skeleton or null if not found at all.
  100231. */
  100232. getSkeletonByName(name: string): Nullable<Skeleton>;
  100233. /**
  100234. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100235. * @param id defines the id to search for
  100236. * @return the found morph target manager or null if not found at all.
  100237. */
  100238. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100239. /**
  100240. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100241. * @param id defines the id to search for
  100242. * @return the found morph target or null if not found at all.
  100243. */
  100244. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100245. /**
  100246. * Gets a boolean indicating if the given mesh is active
  100247. * @param mesh defines the mesh to look for
  100248. * @returns true if the mesh is in the active list
  100249. */
  100250. isActiveMesh(mesh: AbstractMesh): boolean;
  100251. /**
  100252. * Return a unique id as a string which can serve as an identifier for the scene
  100253. */
  100254. readonly uid: string;
  100255. /**
  100256. * Add an externaly attached data from its key.
  100257. * This method call will fail and return false, if such key already exists.
  100258. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100259. * @param key the unique key that identifies the data
  100260. * @param data the data object to associate to the key for this Engine instance
  100261. * @return true if no such key were already present and the data was added successfully, false otherwise
  100262. */
  100263. addExternalData<T>(key: string, data: T): boolean;
  100264. /**
  100265. * Get an externaly attached data from its key
  100266. * @param key the unique key that identifies the data
  100267. * @return the associated data, if present (can be null), or undefined if not present
  100268. */
  100269. getExternalData<T>(key: string): Nullable<T>;
  100270. /**
  100271. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100272. * @param key the unique key that identifies the data
  100273. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100274. * @return the associated data, can be null if the factory returned null.
  100275. */
  100276. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100277. /**
  100278. * Remove an externaly attached data from the Engine instance
  100279. * @param key the unique key that identifies the data
  100280. * @return true if the data was successfully removed, false if it doesn't exist
  100281. */
  100282. removeExternalData(key: string): boolean;
  100283. private _evaluateSubMesh;
  100284. /**
  100285. * Clear the processed materials smart array preventing retention point in material dispose.
  100286. */
  100287. freeProcessedMaterials(): void;
  100288. private _preventFreeActiveMeshesAndRenderingGroups;
  100289. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100290. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100291. * when disposing several meshes in a row or a hierarchy of meshes.
  100292. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100293. */
  100294. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100295. /**
  100296. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100297. */
  100298. freeActiveMeshes(): void;
  100299. /**
  100300. * Clear the info related to rendering groups preventing retention points during dispose.
  100301. */
  100302. freeRenderingGroups(): void;
  100303. /** @hidden */
  100304. _isInIntermediateRendering(): boolean;
  100305. /**
  100306. * Lambda returning the list of potentially active meshes.
  100307. */
  100308. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100309. /**
  100310. * Lambda returning the list of potentially active sub meshes.
  100311. */
  100312. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100313. /**
  100314. * Lambda returning the list of potentially intersecting sub meshes.
  100315. */
  100316. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100317. /**
  100318. * Lambda returning the list of potentially colliding sub meshes.
  100319. */
  100320. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100321. private _activeMeshesFrozen;
  100322. /**
  100323. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100324. * @returns the current scene
  100325. */
  100326. freezeActiveMeshes(): Scene;
  100327. /**
  100328. * Use this function to restart evaluating active meshes on every frame
  100329. * @returns the current scene
  100330. */
  100331. unfreezeActiveMeshes(): Scene;
  100332. private _evaluateActiveMeshes;
  100333. private _activeMesh;
  100334. /**
  100335. * Update the transform matrix to update from the current active camera
  100336. * @param force defines a boolean used to force the update even if cache is up to date
  100337. */
  100338. updateTransformMatrix(force?: boolean): void;
  100339. private _bindFrameBuffer;
  100340. /** @hidden */
  100341. _allowPostProcessClearColor: boolean;
  100342. /** @hidden */
  100343. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100344. private _processSubCameras;
  100345. private _checkIntersections;
  100346. /** @hidden */
  100347. _advancePhysicsEngineStep(step: number): void;
  100348. /**
  100349. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100350. */
  100351. getDeterministicFrameTime: () => number;
  100352. /** @hidden */
  100353. _animate(): void;
  100354. /** Execute all animations (for a frame) */
  100355. animate(): void;
  100356. /**
  100357. * Render the scene
  100358. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100359. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100360. */
  100361. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100362. /**
  100363. * Freeze all materials
  100364. * A frozen material will not be updatable but should be faster to render
  100365. */
  100366. freezeMaterials(): void;
  100367. /**
  100368. * Unfreeze all materials
  100369. * A frozen material will not be updatable but should be faster to render
  100370. */
  100371. unfreezeMaterials(): void;
  100372. /**
  100373. * Releases all held ressources
  100374. */
  100375. dispose(): void;
  100376. /**
  100377. * Gets if the scene is already disposed
  100378. */
  100379. readonly isDisposed: boolean;
  100380. /**
  100381. * Call this function to reduce memory footprint of the scene.
  100382. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100383. */
  100384. clearCachedVertexData(): void;
  100385. /**
  100386. * This function will remove the local cached buffer data from texture.
  100387. * It will save memory but will prevent the texture from being rebuilt
  100388. */
  100389. cleanCachedTextureBuffer(): void;
  100390. /**
  100391. * Get the world extend vectors with an optional filter
  100392. *
  100393. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100394. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100395. */
  100396. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100397. min: Vector3;
  100398. max: Vector3;
  100399. };
  100400. /**
  100401. * Creates a ray that can be used to pick in the scene
  100402. * @param x defines the x coordinate of the origin (on-screen)
  100403. * @param y defines the y coordinate of the origin (on-screen)
  100404. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100405. * @param camera defines the camera to use for the picking
  100406. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100407. * @returns a Ray
  100408. */
  100409. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100410. /**
  100411. * Creates a ray that can be used to pick in the scene
  100412. * @param x defines the x coordinate of the origin (on-screen)
  100413. * @param y defines the y coordinate of the origin (on-screen)
  100414. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100415. * @param result defines the ray where to store the picking ray
  100416. * @param camera defines the camera to use for the picking
  100417. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100418. * @returns the current scene
  100419. */
  100420. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100421. /**
  100422. * Creates a ray that can be used to pick in the scene
  100423. * @param x defines the x coordinate of the origin (on-screen)
  100424. * @param y defines the y coordinate of the origin (on-screen)
  100425. * @param camera defines the camera to use for the picking
  100426. * @returns a Ray
  100427. */
  100428. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100429. /**
  100430. * Creates a ray that can be used to pick in the scene
  100431. * @param x defines the x coordinate of the origin (on-screen)
  100432. * @param y defines the y coordinate of the origin (on-screen)
  100433. * @param result defines the ray where to store the picking ray
  100434. * @param camera defines the camera to use for the picking
  100435. * @returns the current scene
  100436. */
  100437. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100438. /** Launch a ray to try to pick a mesh in the scene
  100439. * @param x position on screen
  100440. * @param y position on screen
  100441. * @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
  100442. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100443. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100444. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100445. * @returns a PickingInfo
  100446. */
  100447. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100448. /** Use the given ray to pick a mesh in the scene
  100449. * @param ray The ray to use to pick meshes
  100450. * @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
  100451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100453. * @returns a PickingInfo
  100454. */
  100455. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100456. /**
  100457. * Launch a ray to try to pick a mesh in the scene
  100458. * @param x X position on screen
  100459. * @param y Y position on screen
  100460. * @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
  100461. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100462. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100463. * @returns an array of PickingInfo
  100464. */
  100465. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100466. /**
  100467. * Launch a ray to try to pick a mesh in the scene
  100468. * @param ray Ray to use
  100469. * @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
  100470. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100471. * @returns an array of PickingInfo
  100472. */
  100473. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100474. /**
  100475. * Force the value of meshUnderPointer
  100476. * @param mesh defines the mesh to use
  100477. */
  100478. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100479. /**
  100480. * Gets the mesh under the pointer
  100481. * @returns a Mesh or null if no mesh is under the pointer
  100482. */
  100483. getPointerOverMesh(): Nullable<AbstractMesh>;
  100484. /** @hidden */
  100485. _rebuildGeometries(): void;
  100486. /** @hidden */
  100487. _rebuildTextures(): void;
  100488. private _getByTags;
  100489. /**
  100490. * Get a list of meshes by tags
  100491. * @param tagsQuery defines the tags query to use
  100492. * @param forEach defines a predicate used to filter results
  100493. * @returns an array of Mesh
  100494. */
  100495. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100496. /**
  100497. * Get a list of cameras by tags
  100498. * @param tagsQuery defines the tags query to use
  100499. * @param forEach defines a predicate used to filter results
  100500. * @returns an array of Camera
  100501. */
  100502. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100503. /**
  100504. * Get a list of lights by tags
  100505. * @param tagsQuery defines the tags query to use
  100506. * @param forEach defines a predicate used to filter results
  100507. * @returns an array of Light
  100508. */
  100509. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100510. /**
  100511. * Get a list of materials by tags
  100512. * @param tagsQuery defines the tags query to use
  100513. * @param forEach defines a predicate used to filter results
  100514. * @returns an array of Material
  100515. */
  100516. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100517. /**
  100518. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100519. * This allowed control for front to back rendering or reversly depending of the special needs.
  100520. *
  100521. * @param renderingGroupId The rendering group id corresponding to its index
  100522. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100523. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100524. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100525. */
  100526. 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;
  100527. /**
  100528. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100529. *
  100530. * @param renderingGroupId The rendering group id corresponding to its index
  100531. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100532. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100533. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100534. */
  100535. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100536. /**
  100537. * Gets the current auto clear configuration for one rendering group of the rendering
  100538. * manager.
  100539. * @param index the rendering group index to get the information for
  100540. * @returns The auto clear setup for the requested rendering group
  100541. */
  100542. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100543. private _blockMaterialDirtyMechanism;
  100544. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100545. blockMaterialDirtyMechanism: boolean;
  100546. /**
  100547. * Will flag all materials as dirty to trigger new shader compilation
  100548. * @param flag defines the flag used to specify which material part must be marked as dirty
  100549. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100550. */
  100551. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100552. /** @hidden */
  100553. _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;
  100554. /** @hidden */
  100555. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100556. }
  100557. }
  100558. declare module BABYLON {
  100559. /**
  100560. * Set of assets to keep when moving a scene into an asset container.
  100561. */
  100562. export class KeepAssets extends AbstractScene {
  100563. }
  100564. /**
  100565. * Container with a set of assets that can be added or removed from a scene.
  100566. */
  100567. export class AssetContainer extends AbstractScene {
  100568. /**
  100569. * The scene the AssetContainer belongs to.
  100570. */
  100571. scene: Scene;
  100572. /**
  100573. * Instantiates an AssetContainer.
  100574. * @param scene The scene the AssetContainer belongs to.
  100575. */
  100576. constructor(scene: Scene);
  100577. /**
  100578. * Adds all the assets from the container to the scene.
  100579. */
  100580. addAllToScene(): void;
  100581. /**
  100582. * Removes all the assets in the container from the scene
  100583. */
  100584. removeAllFromScene(): void;
  100585. /**
  100586. * Disposes all the assets in the container
  100587. */
  100588. dispose(): void;
  100589. private _moveAssets;
  100590. /**
  100591. * Removes all the assets contained in the scene and adds them to the container.
  100592. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100593. */
  100594. moveAllFromScene(keepAssets?: KeepAssets): void;
  100595. /**
  100596. * 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.
  100597. * @returns the root mesh
  100598. */
  100599. createRootMesh(): Mesh;
  100600. }
  100601. }
  100602. declare module BABYLON {
  100603. /**
  100604. * Defines how the parser contract is defined.
  100605. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100606. */
  100607. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100608. /**
  100609. * Defines how the individual parser contract is defined.
  100610. * These parser can parse an individual asset
  100611. */
  100612. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100613. /**
  100614. * Base class of the scene acting as a container for the different elements composing a scene.
  100615. * This class is dynamically extended by the different components of the scene increasing
  100616. * flexibility and reducing coupling
  100617. */
  100618. export abstract class AbstractScene {
  100619. /**
  100620. * Stores the list of available parsers in the application.
  100621. */
  100622. private static _BabylonFileParsers;
  100623. /**
  100624. * Stores the list of available individual parsers in the application.
  100625. */
  100626. private static _IndividualBabylonFileParsers;
  100627. /**
  100628. * Adds a parser in the list of available ones
  100629. * @param name Defines the name of the parser
  100630. * @param parser Defines the parser to add
  100631. */
  100632. static AddParser(name: string, parser: BabylonFileParser): void;
  100633. /**
  100634. * Gets a general parser from the list of avaialble ones
  100635. * @param name Defines the name of the parser
  100636. * @returns the requested parser or null
  100637. */
  100638. static GetParser(name: string): Nullable<BabylonFileParser>;
  100639. /**
  100640. * Adds n individual parser in the list of available ones
  100641. * @param name Defines the name of the parser
  100642. * @param parser Defines the parser to add
  100643. */
  100644. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100645. /**
  100646. * Gets an individual parser from the list of avaialble ones
  100647. * @param name Defines the name of the parser
  100648. * @returns the requested parser or null
  100649. */
  100650. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100651. /**
  100652. * Parser json data and populate both a scene and its associated container object
  100653. * @param jsonData Defines the data to parse
  100654. * @param scene Defines the scene to parse the data for
  100655. * @param container Defines the container attached to the parsing sequence
  100656. * @param rootUrl Defines the root url of the data
  100657. */
  100658. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100659. /**
  100660. * Gets the list of root nodes (ie. nodes with no parent)
  100661. */
  100662. rootNodes: Node[];
  100663. /** All of the cameras added to this scene
  100664. * @see http://doc.babylonjs.com/babylon101/cameras
  100665. */
  100666. cameras: Camera[];
  100667. /**
  100668. * All of the lights added to this scene
  100669. * @see http://doc.babylonjs.com/babylon101/lights
  100670. */
  100671. lights: Light[];
  100672. /**
  100673. * All of the (abstract) meshes added to this scene
  100674. */
  100675. meshes: AbstractMesh[];
  100676. /**
  100677. * The list of skeletons added to the scene
  100678. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100679. */
  100680. skeletons: Skeleton[];
  100681. /**
  100682. * All of the particle systems added to this scene
  100683. * @see http://doc.babylonjs.com/babylon101/particles
  100684. */
  100685. particleSystems: IParticleSystem[];
  100686. /**
  100687. * Gets a list of Animations associated with the scene
  100688. */
  100689. animations: Animation[];
  100690. /**
  100691. * All of the animation groups added to this scene
  100692. * @see http://doc.babylonjs.com/how_to/group
  100693. */
  100694. animationGroups: AnimationGroup[];
  100695. /**
  100696. * All of the multi-materials added to this scene
  100697. * @see http://doc.babylonjs.com/how_to/multi_materials
  100698. */
  100699. multiMaterials: MultiMaterial[];
  100700. /**
  100701. * All of the materials added to this scene
  100702. * In the context of a Scene, it is not supposed to be modified manually.
  100703. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100704. * Note also that the order of the Material wihin the array is not significant and might change.
  100705. * @see http://doc.babylonjs.com/babylon101/materials
  100706. */
  100707. materials: Material[];
  100708. /**
  100709. * The list of morph target managers added to the scene
  100710. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100711. */
  100712. morphTargetManagers: MorphTargetManager[];
  100713. /**
  100714. * The list of geometries used in the scene.
  100715. */
  100716. geometries: Geometry[];
  100717. /**
  100718. * All of the tranform nodes added to this scene
  100719. * In the context of a Scene, it is not supposed to be modified manually.
  100720. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100721. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100722. * @see http://doc.babylonjs.com/how_to/transformnode
  100723. */
  100724. transformNodes: TransformNode[];
  100725. /**
  100726. * ActionManagers available on the scene.
  100727. */
  100728. actionManagers: AbstractActionManager[];
  100729. /**
  100730. * Textures to keep.
  100731. */
  100732. textures: BaseTexture[];
  100733. /**
  100734. * Environment texture for the scene
  100735. */
  100736. environmentTexture: Nullable<BaseTexture>;
  100737. }
  100738. }
  100739. declare module BABYLON {
  100740. /**
  100741. * Interface used to define options for Sound class
  100742. */
  100743. export interface ISoundOptions {
  100744. /**
  100745. * Does the sound autoplay once loaded.
  100746. */
  100747. autoplay?: boolean;
  100748. /**
  100749. * Does the sound loop after it finishes playing once.
  100750. */
  100751. loop?: boolean;
  100752. /**
  100753. * Sound's volume
  100754. */
  100755. volume?: number;
  100756. /**
  100757. * Is it a spatial sound?
  100758. */
  100759. spatialSound?: boolean;
  100760. /**
  100761. * Maximum distance to hear that sound
  100762. */
  100763. maxDistance?: number;
  100764. /**
  100765. * Uses user defined attenuation function
  100766. */
  100767. useCustomAttenuation?: boolean;
  100768. /**
  100769. * Define the roll off factor of spatial sounds.
  100770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100771. */
  100772. rolloffFactor?: number;
  100773. /**
  100774. * Define the reference distance the sound should be heard perfectly.
  100775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100776. */
  100777. refDistance?: number;
  100778. /**
  100779. * Define the distance attenuation model the sound will follow.
  100780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100781. */
  100782. distanceModel?: string;
  100783. /**
  100784. * Defines the playback speed (1 by default)
  100785. */
  100786. playbackRate?: number;
  100787. /**
  100788. * Defines if the sound is from a streaming source
  100789. */
  100790. streaming?: boolean;
  100791. /**
  100792. * Defines an optional length (in seconds) inside the sound file
  100793. */
  100794. length?: number;
  100795. /**
  100796. * Defines an optional offset (in seconds) inside the sound file
  100797. */
  100798. offset?: number;
  100799. /**
  100800. * If true, URLs will not be required to state the audio file codec to use.
  100801. */
  100802. skipCodecCheck?: boolean;
  100803. }
  100804. /**
  100805. * Defines a sound that can be played in the application.
  100806. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100808. */
  100809. export class Sound {
  100810. /**
  100811. * The name of the sound in the scene.
  100812. */
  100813. name: string;
  100814. /**
  100815. * Does the sound autoplay once loaded.
  100816. */
  100817. autoplay: boolean;
  100818. /**
  100819. * Does the sound loop after it finishes playing once.
  100820. */
  100821. loop: boolean;
  100822. /**
  100823. * Does the sound use a custom attenuation curve to simulate the falloff
  100824. * happening when the source gets further away from the camera.
  100825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100826. */
  100827. useCustomAttenuation: boolean;
  100828. /**
  100829. * The sound track id this sound belongs to.
  100830. */
  100831. soundTrackId: number;
  100832. /**
  100833. * Is this sound currently played.
  100834. */
  100835. isPlaying: boolean;
  100836. /**
  100837. * Is this sound currently paused.
  100838. */
  100839. isPaused: boolean;
  100840. /**
  100841. * Does this sound enables spatial sound.
  100842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100843. */
  100844. spatialSound: boolean;
  100845. /**
  100846. * Define the reference distance the sound should be heard perfectly.
  100847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100848. */
  100849. refDistance: number;
  100850. /**
  100851. * Define the roll off factor of spatial sounds.
  100852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100853. */
  100854. rolloffFactor: number;
  100855. /**
  100856. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100858. */
  100859. maxDistance: number;
  100860. /**
  100861. * Define the distance attenuation model the sound will follow.
  100862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100863. */
  100864. distanceModel: string;
  100865. /**
  100866. * @hidden
  100867. * Back Compat
  100868. **/
  100869. onended: () => any;
  100870. /**
  100871. * Observable event when the current playing sound finishes.
  100872. */
  100873. onEndedObservable: Observable<Sound>;
  100874. private _panningModel;
  100875. private _playbackRate;
  100876. private _streaming;
  100877. private _startTime;
  100878. private _startOffset;
  100879. private _position;
  100880. /** @hidden */
  100881. _positionInEmitterSpace: boolean;
  100882. private _localDirection;
  100883. private _volume;
  100884. private _isReadyToPlay;
  100885. private _isDirectional;
  100886. private _readyToPlayCallback;
  100887. private _audioBuffer;
  100888. private _soundSource;
  100889. private _streamingSource;
  100890. private _soundPanner;
  100891. private _soundGain;
  100892. private _inputAudioNode;
  100893. private _outputAudioNode;
  100894. private _coneInnerAngle;
  100895. private _coneOuterAngle;
  100896. private _coneOuterGain;
  100897. private _scene;
  100898. private _connectedTransformNode;
  100899. private _customAttenuationFunction;
  100900. private _registerFunc;
  100901. private _isOutputConnected;
  100902. private _htmlAudioElement;
  100903. private _urlType;
  100904. private _length?;
  100905. private _offset?;
  100906. /** @hidden */
  100907. static _SceneComponentInitialization: (scene: Scene) => void;
  100908. /**
  100909. * Create a sound and attach it to a scene
  100910. * @param name Name of your sound
  100911. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100912. * @param scene defines the scene the sound belongs to
  100913. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100914. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100915. */
  100916. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100917. /**
  100918. * Release the sound and its associated resources
  100919. */
  100920. dispose(): void;
  100921. /**
  100922. * Gets if the sounds is ready to be played or not.
  100923. * @returns true if ready, otherwise false
  100924. */
  100925. isReady(): boolean;
  100926. private _soundLoaded;
  100927. /**
  100928. * Sets the data of the sound from an audiobuffer
  100929. * @param audioBuffer The audioBuffer containing the data
  100930. */
  100931. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100932. /**
  100933. * Updates the current sounds options such as maxdistance, loop...
  100934. * @param options A JSON object containing values named as the object properties
  100935. */
  100936. updateOptions(options: ISoundOptions): void;
  100937. private _createSpatialParameters;
  100938. private _updateSpatialParameters;
  100939. /**
  100940. * Switch the panning model to HRTF:
  100941. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100943. */
  100944. switchPanningModelToHRTF(): void;
  100945. /**
  100946. * Switch the panning model to Equal Power:
  100947. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100949. */
  100950. switchPanningModelToEqualPower(): void;
  100951. private _switchPanningModel;
  100952. /**
  100953. * Connect this sound to a sound track audio node like gain...
  100954. * @param soundTrackAudioNode the sound track audio node to connect to
  100955. */
  100956. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100957. /**
  100958. * Transform this sound into a directional source
  100959. * @param coneInnerAngle Size of the inner cone in degree
  100960. * @param coneOuterAngle Size of the outer cone in degree
  100961. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100962. */
  100963. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100964. /**
  100965. * Gets or sets the inner angle for the directional cone.
  100966. */
  100967. /**
  100968. * Gets or sets the inner angle for the directional cone.
  100969. */
  100970. directionalConeInnerAngle: number;
  100971. /**
  100972. * Gets or sets the outer angle for the directional cone.
  100973. */
  100974. /**
  100975. * Gets or sets the outer angle for the directional cone.
  100976. */
  100977. directionalConeOuterAngle: number;
  100978. /**
  100979. * Sets the position of the emitter if spatial sound is enabled
  100980. * @param newPosition Defines the new posisiton
  100981. */
  100982. setPosition(newPosition: Vector3): void;
  100983. /**
  100984. * Sets the local direction of the emitter if spatial sound is enabled
  100985. * @param newLocalDirection Defines the new local direction
  100986. */
  100987. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100988. private _updateDirection;
  100989. /** @hidden */
  100990. updateDistanceFromListener(): void;
  100991. /**
  100992. * Sets a new custom attenuation function for the sound.
  100993. * @param callback Defines the function used for the attenuation
  100994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100995. */
  100996. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100997. /**
  100998. * Play the sound
  100999. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101000. * @param offset (optional) Start the sound at a specific time in seconds
  101001. * @param length (optional) Sound duration (in seconds)
  101002. */
  101003. play(time?: number, offset?: number, length?: number): void;
  101004. private _onended;
  101005. /**
  101006. * Stop the sound
  101007. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101008. */
  101009. stop(time?: number): void;
  101010. /**
  101011. * Put the sound in pause
  101012. */
  101013. pause(): void;
  101014. /**
  101015. * Sets a dedicated volume for this sounds
  101016. * @param newVolume Define the new volume of the sound
  101017. * @param time Define time for gradual change to new volume
  101018. */
  101019. setVolume(newVolume: number, time?: number): void;
  101020. /**
  101021. * Set the sound play back rate
  101022. * @param newPlaybackRate Define the playback rate the sound should be played at
  101023. */
  101024. setPlaybackRate(newPlaybackRate: number): void;
  101025. /**
  101026. * Gets the volume of the sound.
  101027. * @returns the volume of the sound
  101028. */
  101029. getVolume(): number;
  101030. /**
  101031. * Attach the sound to a dedicated mesh
  101032. * @param transformNode The transform node to connect the sound with
  101033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101034. */
  101035. attachToMesh(transformNode: TransformNode): void;
  101036. /**
  101037. * Detach the sound from the previously attached mesh
  101038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101039. */
  101040. detachFromMesh(): void;
  101041. private _onRegisterAfterWorldMatrixUpdate;
  101042. /**
  101043. * Clone the current sound in the scene.
  101044. * @returns the new sound clone
  101045. */
  101046. clone(): Nullable<Sound>;
  101047. /**
  101048. * Gets the current underlying audio buffer containing the data
  101049. * @returns the audio buffer
  101050. */
  101051. getAudioBuffer(): Nullable<AudioBuffer>;
  101052. /**
  101053. * Serializes the Sound in a JSON representation
  101054. * @returns the JSON representation of the sound
  101055. */
  101056. serialize(): any;
  101057. /**
  101058. * Parse a JSON representation of a sound to innstantiate in a given scene
  101059. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101060. * @param scene Define the scene the new parsed sound should be created in
  101061. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101062. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101063. * @returns the newly parsed sound
  101064. */
  101065. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101066. }
  101067. }
  101068. declare module BABYLON {
  101069. /**
  101070. * This defines an action helpful to play a defined sound on a triggered action.
  101071. */
  101072. export class PlaySoundAction extends Action {
  101073. private _sound;
  101074. /**
  101075. * Instantiate the action
  101076. * @param triggerOptions defines the trigger options
  101077. * @param sound defines the sound to play
  101078. * @param condition defines the trigger related conditions
  101079. */
  101080. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101081. /** @hidden */
  101082. _prepare(): void;
  101083. /**
  101084. * Execute the action and play the sound.
  101085. */
  101086. execute(): void;
  101087. /**
  101088. * Serializes the actions and its related information.
  101089. * @param parent defines the object to serialize in
  101090. * @returns the serialized object
  101091. */
  101092. serialize(parent: any): any;
  101093. }
  101094. /**
  101095. * This defines an action helpful to stop a defined sound on a triggered action.
  101096. */
  101097. export class StopSoundAction extends Action {
  101098. private _sound;
  101099. /**
  101100. * Instantiate the action
  101101. * @param triggerOptions defines the trigger options
  101102. * @param sound defines the sound to stop
  101103. * @param condition defines the trigger related conditions
  101104. */
  101105. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101106. /** @hidden */
  101107. _prepare(): void;
  101108. /**
  101109. * Execute the action and stop the sound.
  101110. */
  101111. execute(): void;
  101112. /**
  101113. * Serializes the actions and its related information.
  101114. * @param parent defines the object to serialize in
  101115. * @returns the serialized object
  101116. */
  101117. serialize(parent: any): any;
  101118. }
  101119. }
  101120. declare module BABYLON {
  101121. /**
  101122. * This defines an action responsible to change the value of a property
  101123. * by interpolating between its current value and the newly set one once triggered.
  101124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101125. */
  101126. export class InterpolateValueAction extends Action {
  101127. /**
  101128. * Defines the path of the property where the value should be interpolated
  101129. */
  101130. propertyPath: string;
  101131. /**
  101132. * Defines the target value at the end of the interpolation.
  101133. */
  101134. value: any;
  101135. /**
  101136. * Defines the time it will take for the property to interpolate to the value.
  101137. */
  101138. duration: number;
  101139. /**
  101140. * Defines if the other scene animations should be stopped when the action has been triggered
  101141. */
  101142. stopOtherAnimations?: boolean;
  101143. /**
  101144. * Defines a callback raised once the interpolation animation has been done.
  101145. */
  101146. onInterpolationDone?: () => void;
  101147. /**
  101148. * Observable triggered once the interpolation animation has been done.
  101149. */
  101150. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101151. private _target;
  101152. private _effectiveTarget;
  101153. private _property;
  101154. /**
  101155. * Instantiate the action
  101156. * @param triggerOptions defines the trigger options
  101157. * @param target defines the object containing the value to interpolate
  101158. * @param propertyPath defines the path to the property in the target object
  101159. * @param value defines the target value at the end of the interpolation
  101160. * @param duration deines the time it will take for the property to interpolate to the value.
  101161. * @param condition defines the trigger related conditions
  101162. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101163. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101164. */
  101165. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101166. /** @hidden */
  101167. _prepare(): void;
  101168. /**
  101169. * Execute the action starts the value interpolation.
  101170. */
  101171. execute(): void;
  101172. /**
  101173. * Serializes the actions and its related information.
  101174. * @param parent defines the object to serialize in
  101175. * @returns the serialized object
  101176. */
  101177. serialize(parent: any): any;
  101178. }
  101179. }
  101180. declare module BABYLON {
  101181. /**
  101182. * Options allowed during the creation of a sound track.
  101183. */
  101184. export interface ISoundTrackOptions {
  101185. /**
  101186. * The volume the sound track should take during creation
  101187. */
  101188. volume?: number;
  101189. /**
  101190. * Define if the sound track is the main sound track of the scene
  101191. */
  101192. mainTrack?: boolean;
  101193. }
  101194. /**
  101195. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101196. * It will be also used in a future release to apply effects on a specific track.
  101197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101198. */
  101199. export class SoundTrack {
  101200. /**
  101201. * The unique identifier of the sound track in the scene.
  101202. */
  101203. id: number;
  101204. /**
  101205. * The list of sounds included in the sound track.
  101206. */
  101207. soundCollection: Array<Sound>;
  101208. private _outputAudioNode;
  101209. private _scene;
  101210. private _isMainTrack;
  101211. private _connectedAnalyser;
  101212. private _options;
  101213. private _isInitialized;
  101214. /**
  101215. * Creates a new sound track.
  101216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101217. * @param scene Define the scene the sound track belongs to
  101218. * @param options
  101219. */
  101220. constructor(scene: Scene, options?: ISoundTrackOptions);
  101221. private _initializeSoundTrackAudioGraph;
  101222. /**
  101223. * Release the sound track and its associated resources
  101224. */
  101225. dispose(): void;
  101226. /**
  101227. * Adds a sound to this sound track
  101228. * @param sound define the cound to add
  101229. * @ignoreNaming
  101230. */
  101231. AddSound(sound: Sound): void;
  101232. /**
  101233. * Removes a sound to this sound track
  101234. * @param sound define the cound to remove
  101235. * @ignoreNaming
  101236. */
  101237. RemoveSound(sound: Sound): void;
  101238. /**
  101239. * Set a global volume for the full sound track.
  101240. * @param newVolume Define the new volume of the sound track
  101241. */
  101242. setVolume(newVolume: number): void;
  101243. /**
  101244. * Switch the panning model to HRTF:
  101245. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101247. */
  101248. switchPanningModelToHRTF(): void;
  101249. /**
  101250. * Switch the panning model to Equal Power:
  101251. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101253. */
  101254. switchPanningModelToEqualPower(): void;
  101255. /**
  101256. * Connect the sound track to an audio analyser allowing some amazing
  101257. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101259. * @param analyser The analyser to connect to the engine
  101260. */
  101261. connectToAnalyser(analyser: Analyser): void;
  101262. }
  101263. }
  101264. declare module BABYLON {
  101265. interface AbstractScene {
  101266. /**
  101267. * The list of sounds used in the scene.
  101268. */
  101269. sounds: Nullable<Array<Sound>>;
  101270. }
  101271. interface Scene {
  101272. /**
  101273. * @hidden
  101274. * Backing field
  101275. */
  101276. _mainSoundTrack: SoundTrack;
  101277. /**
  101278. * The main sound track played by the scene.
  101279. * It cotains your primary collection of sounds.
  101280. */
  101281. mainSoundTrack: SoundTrack;
  101282. /**
  101283. * The list of sound tracks added to the scene
  101284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101285. */
  101286. soundTracks: Nullable<Array<SoundTrack>>;
  101287. /**
  101288. * Gets a sound using a given name
  101289. * @param name defines the name to search for
  101290. * @return the found sound or null if not found at all.
  101291. */
  101292. getSoundByName(name: string): Nullable<Sound>;
  101293. /**
  101294. * Gets or sets if audio support is enabled
  101295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101296. */
  101297. audioEnabled: boolean;
  101298. /**
  101299. * Gets or sets if audio will be output to headphones
  101300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101301. */
  101302. headphone: boolean;
  101303. /**
  101304. * Gets or sets custom audio listener position provider
  101305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101306. */
  101307. audioListenerPositionProvider: Nullable<() => Vector3>;
  101308. }
  101309. /**
  101310. * Defines the sound scene component responsible to manage any sounds
  101311. * in a given scene.
  101312. */
  101313. export class AudioSceneComponent implements ISceneSerializableComponent {
  101314. /**
  101315. * The component name helpfull to identify the component in the list of scene components.
  101316. */
  101317. readonly name: string;
  101318. /**
  101319. * The scene the component belongs to.
  101320. */
  101321. scene: Scene;
  101322. private _audioEnabled;
  101323. /**
  101324. * Gets whether audio is enabled or not.
  101325. * Please use related enable/disable method to switch state.
  101326. */
  101327. readonly audioEnabled: boolean;
  101328. private _headphone;
  101329. /**
  101330. * Gets whether audio is outputing to headphone or not.
  101331. * Please use the according Switch methods to change output.
  101332. */
  101333. readonly headphone: boolean;
  101334. private _audioListenerPositionProvider;
  101335. /**
  101336. * Gets the current audio listener position provider
  101337. */
  101338. /**
  101339. * Sets a custom listener position for all sounds in the scene
  101340. * By default, this is the position of the first active camera
  101341. */
  101342. audioListenerPositionProvider: Nullable<() => Vector3>;
  101343. /**
  101344. * Creates a new instance of the component for the given scene
  101345. * @param scene Defines the scene to register the component in
  101346. */
  101347. constructor(scene: Scene);
  101348. /**
  101349. * Registers the component in a given scene
  101350. */
  101351. register(): void;
  101352. /**
  101353. * Rebuilds the elements related to this component in case of
  101354. * context lost for instance.
  101355. */
  101356. rebuild(): void;
  101357. /**
  101358. * Serializes the component data to the specified json object
  101359. * @param serializationObject The object to serialize to
  101360. */
  101361. serialize(serializationObject: any): void;
  101362. /**
  101363. * Adds all the elements from the container to the scene
  101364. * @param container the container holding the elements
  101365. */
  101366. addFromContainer(container: AbstractScene): void;
  101367. /**
  101368. * Removes all the elements in the container from the scene
  101369. * @param container contains the elements to remove
  101370. * @param dispose if the removed element should be disposed (default: false)
  101371. */
  101372. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101373. /**
  101374. * Disposes the component and the associated ressources.
  101375. */
  101376. dispose(): void;
  101377. /**
  101378. * Disables audio in the associated scene.
  101379. */
  101380. disableAudio(): void;
  101381. /**
  101382. * Enables audio in the associated scene.
  101383. */
  101384. enableAudio(): void;
  101385. /**
  101386. * Switch audio to headphone output.
  101387. */
  101388. switchAudioModeForHeadphones(): void;
  101389. /**
  101390. * Switch audio to normal speakers.
  101391. */
  101392. switchAudioModeForNormalSpeakers(): void;
  101393. private _afterRender;
  101394. }
  101395. }
  101396. declare module BABYLON {
  101397. /**
  101398. * Wraps one or more Sound objects and selects one with random weight for playback.
  101399. */
  101400. export class WeightedSound {
  101401. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101402. loop: boolean;
  101403. private _coneInnerAngle;
  101404. private _coneOuterAngle;
  101405. private _volume;
  101406. /** A Sound is currently playing. */
  101407. isPlaying: boolean;
  101408. /** A Sound is currently paused. */
  101409. isPaused: boolean;
  101410. private _sounds;
  101411. private _weights;
  101412. private _currentIndex?;
  101413. /**
  101414. * Creates a new WeightedSound from the list of sounds given.
  101415. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101416. * @param sounds Array of Sounds that will be selected from.
  101417. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101418. */
  101419. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101420. /**
  101421. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101422. */
  101423. /**
  101424. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101425. */
  101426. directionalConeInnerAngle: number;
  101427. /**
  101428. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101429. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101430. */
  101431. /**
  101432. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101433. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101434. */
  101435. directionalConeOuterAngle: number;
  101436. /**
  101437. * Playback volume.
  101438. */
  101439. /**
  101440. * Playback volume.
  101441. */
  101442. volume: number;
  101443. private _onended;
  101444. /**
  101445. * Suspend playback
  101446. */
  101447. pause(): void;
  101448. /**
  101449. * Stop playback
  101450. */
  101451. stop(): void;
  101452. /**
  101453. * Start playback.
  101454. * @param startOffset Position the clip head at a specific time in seconds.
  101455. */
  101456. play(startOffset?: number): void;
  101457. }
  101458. }
  101459. declare module BABYLON {
  101460. /**
  101461. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101462. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101463. */
  101464. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101465. /**
  101466. * Gets the name of the behavior.
  101467. */
  101468. readonly name: string;
  101469. /**
  101470. * The easing function used by animations
  101471. */
  101472. static EasingFunction: BackEase;
  101473. /**
  101474. * The easing mode used by animations
  101475. */
  101476. static EasingMode: number;
  101477. /**
  101478. * The duration of the animation, in milliseconds
  101479. */
  101480. transitionDuration: number;
  101481. /**
  101482. * Length of the distance animated by the transition when lower radius is reached
  101483. */
  101484. lowerRadiusTransitionRange: number;
  101485. /**
  101486. * Length of the distance animated by the transition when upper radius is reached
  101487. */
  101488. upperRadiusTransitionRange: number;
  101489. private _autoTransitionRange;
  101490. /**
  101491. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101492. */
  101493. /**
  101494. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101495. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101496. */
  101497. autoTransitionRange: boolean;
  101498. private _attachedCamera;
  101499. private _onAfterCheckInputsObserver;
  101500. private _onMeshTargetChangedObserver;
  101501. /**
  101502. * Initializes the behavior.
  101503. */
  101504. init(): void;
  101505. /**
  101506. * Attaches the behavior to its arc rotate camera.
  101507. * @param camera Defines the camera to attach the behavior to
  101508. */
  101509. attach(camera: ArcRotateCamera): void;
  101510. /**
  101511. * Detaches the behavior from its current arc rotate camera.
  101512. */
  101513. detach(): void;
  101514. private _radiusIsAnimating;
  101515. private _radiusBounceTransition;
  101516. private _animatables;
  101517. private _cachedWheelPrecision;
  101518. /**
  101519. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101520. * @param radiusLimit The limit to check against.
  101521. * @return Bool to indicate if at limit.
  101522. */
  101523. private _isRadiusAtLimit;
  101524. /**
  101525. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101526. * @param radiusDelta The delta by which to animate to. Can be negative.
  101527. */
  101528. private _applyBoundRadiusAnimation;
  101529. /**
  101530. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101531. */
  101532. protected _clearAnimationLocks(): void;
  101533. /**
  101534. * Stops and removes all animations that have been applied to the camera
  101535. */
  101536. stopAllAnimations(): void;
  101537. }
  101538. }
  101539. declare module BABYLON {
  101540. /**
  101541. * 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.
  101542. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101543. */
  101544. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101545. /**
  101546. * Gets the name of the behavior.
  101547. */
  101548. readonly name: string;
  101549. private _mode;
  101550. private _radiusScale;
  101551. private _positionScale;
  101552. private _defaultElevation;
  101553. private _elevationReturnTime;
  101554. private _elevationReturnWaitTime;
  101555. private _zoomStopsAnimation;
  101556. private _framingTime;
  101557. /**
  101558. * The easing function used by animations
  101559. */
  101560. static EasingFunction: ExponentialEase;
  101561. /**
  101562. * The easing mode used by animations
  101563. */
  101564. static EasingMode: number;
  101565. /**
  101566. * Sets the current mode used by the behavior
  101567. */
  101568. /**
  101569. * Gets current mode used by the behavior.
  101570. */
  101571. mode: number;
  101572. /**
  101573. * Sets the scale applied to the radius (1 by default)
  101574. */
  101575. /**
  101576. * Gets the scale applied to the radius
  101577. */
  101578. radiusScale: number;
  101579. /**
  101580. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101581. */
  101582. /**
  101583. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101584. */
  101585. positionScale: number;
  101586. /**
  101587. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101588. * behaviour is triggered, in radians.
  101589. */
  101590. /**
  101591. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101592. * behaviour is triggered, in radians.
  101593. */
  101594. defaultElevation: number;
  101595. /**
  101596. * Sets the time (in milliseconds) taken to return to the default beta position.
  101597. * Negative value indicates camera should not return to default.
  101598. */
  101599. /**
  101600. * Gets the time (in milliseconds) taken to return to the default beta position.
  101601. * Negative value indicates camera should not return to default.
  101602. */
  101603. elevationReturnTime: number;
  101604. /**
  101605. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101606. */
  101607. /**
  101608. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101609. */
  101610. elevationReturnWaitTime: number;
  101611. /**
  101612. * Sets the flag that indicates if user zooming should stop animation.
  101613. */
  101614. /**
  101615. * Gets the flag that indicates if user zooming should stop animation.
  101616. */
  101617. zoomStopsAnimation: boolean;
  101618. /**
  101619. * Sets the transition time when framing the mesh, in milliseconds
  101620. */
  101621. /**
  101622. * Gets the transition time when framing the mesh, in milliseconds
  101623. */
  101624. framingTime: number;
  101625. /**
  101626. * Define if the behavior should automatically change the configured
  101627. * camera limits and sensibilities.
  101628. */
  101629. autoCorrectCameraLimitsAndSensibility: boolean;
  101630. private _onPrePointerObservableObserver;
  101631. private _onAfterCheckInputsObserver;
  101632. private _onMeshTargetChangedObserver;
  101633. private _attachedCamera;
  101634. private _isPointerDown;
  101635. private _lastInteractionTime;
  101636. /**
  101637. * Initializes the behavior.
  101638. */
  101639. init(): void;
  101640. /**
  101641. * Attaches the behavior to its arc rotate camera.
  101642. * @param camera Defines the camera to attach the behavior to
  101643. */
  101644. attach(camera: ArcRotateCamera): void;
  101645. /**
  101646. * Detaches the behavior from its current arc rotate camera.
  101647. */
  101648. detach(): void;
  101649. private _animatables;
  101650. private _betaIsAnimating;
  101651. private _betaTransition;
  101652. private _radiusTransition;
  101653. private _vectorTransition;
  101654. /**
  101655. * Targets the given mesh and updates zoom level accordingly.
  101656. * @param mesh The mesh to target.
  101657. * @param radius Optional. If a cached radius position already exists, overrides default.
  101658. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101661. */
  101662. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101663. /**
  101664. * Targets the given mesh with its children and updates zoom level accordingly.
  101665. * @param mesh The mesh to target.
  101666. * @param radius Optional. If a cached radius position already exists, overrides default.
  101667. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101668. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101669. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101670. */
  101671. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101672. /**
  101673. * Targets the given meshes with their children and updates zoom level accordingly.
  101674. * @param meshes The mesh to target.
  101675. * @param radius Optional. If a cached radius position already exists, overrides default.
  101676. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101677. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101678. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101679. */
  101680. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101681. /**
  101682. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101683. * @param minimumWorld Determines the smaller position of the bounding box extend
  101684. * @param maximumWorld Determines the bigger position of the bounding box extend
  101685. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101686. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101687. */
  101688. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101689. /**
  101690. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101691. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101692. * frustum width.
  101693. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101694. * to fully enclose the mesh in the viewing frustum.
  101695. */
  101696. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101697. /**
  101698. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101699. * is automatically returned to its default position (expected to be above ground plane).
  101700. */
  101701. private _maintainCameraAboveGround;
  101702. /**
  101703. * Returns the frustum slope based on the canvas ratio and camera FOV
  101704. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101705. */
  101706. private _getFrustumSlope;
  101707. /**
  101708. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101709. */
  101710. private _clearAnimationLocks;
  101711. /**
  101712. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101713. */
  101714. private _applyUserInteraction;
  101715. /**
  101716. * Stops and removes all animations that have been applied to the camera
  101717. */
  101718. stopAllAnimations(): void;
  101719. /**
  101720. * Gets a value indicating if the user is moving the camera
  101721. */
  101722. readonly isUserIsMoving: boolean;
  101723. /**
  101724. * The camera can move all the way towards the mesh.
  101725. */
  101726. static IgnoreBoundsSizeMode: number;
  101727. /**
  101728. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101729. */
  101730. static FitFrustumSidesMode: number;
  101731. }
  101732. }
  101733. declare module BABYLON {
  101734. /**
  101735. * Base class for Camera Pointer Inputs.
  101736. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101737. * for example usage.
  101738. */
  101739. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101740. /**
  101741. * Defines the camera the input is attached to.
  101742. */
  101743. abstract camera: Camera;
  101744. /**
  101745. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101746. */
  101747. protected _altKey: boolean;
  101748. protected _ctrlKey: boolean;
  101749. protected _metaKey: boolean;
  101750. protected _shiftKey: boolean;
  101751. /**
  101752. * Which mouse buttons were pressed at time of last mouse event.
  101753. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101754. */
  101755. protected _buttonsPressed: number;
  101756. /**
  101757. * Defines the buttons associated with the input to handle camera move.
  101758. */
  101759. buttons: number[];
  101760. /**
  101761. * Attach the input controls to a specific dom element to get the input from.
  101762. * @param element Defines the element the controls should be listened from
  101763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101764. */
  101765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101766. /**
  101767. * Detach the current controls from the specified dom element.
  101768. * @param element Defines the element to stop listening the inputs from
  101769. */
  101770. detachControl(element: Nullable<HTMLElement>): void;
  101771. /**
  101772. * Gets the class name of the current input.
  101773. * @returns the class name
  101774. */
  101775. getClassName(): string;
  101776. /**
  101777. * Get the friendly name associated with the input class.
  101778. * @returns the input friendly name
  101779. */
  101780. getSimpleName(): string;
  101781. /**
  101782. * Called on pointer POINTERDOUBLETAP event.
  101783. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101784. */
  101785. protected onDoubleTap(type: string): void;
  101786. /**
  101787. * Called on pointer POINTERMOVE event if only a single touch is active.
  101788. * Override this method to provide functionality.
  101789. */
  101790. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101791. /**
  101792. * Called on pointer POINTERMOVE event if multiple touches are active.
  101793. * Override this method to provide functionality.
  101794. */
  101795. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101796. /**
  101797. * Called on JS contextmenu event.
  101798. * Override this method to provide functionality.
  101799. */
  101800. protected onContextMenu(evt: PointerEvent): void;
  101801. /**
  101802. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101803. * press.
  101804. * Override this method to provide functionality.
  101805. */
  101806. protected onButtonDown(evt: PointerEvent): void;
  101807. /**
  101808. * Called each time a new POINTERUP event occurs. Ie, for each button
  101809. * release.
  101810. * Override this method to provide functionality.
  101811. */
  101812. protected onButtonUp(evt: PointerEvent): void;
  101813. /**
  101814. * Called when window becomes inactive.
  101815. * Override this method to provide functionality.
  101816. */
  101817. protected onLostFocus(): void;
  101818. private _pointerInput;
  101819. private _observer;
  101820. private _onLostFocus;
  101821. private pointA;
  101822. private pointB;
  101823. }
  101824. }
  101825. declare module BABYLON {
  101826. /**
  101827. * Manage the pointers inputs to control an arc rotate camera.
  101828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101829. */
  101830. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101831. /**
  101832. * Defines the camera the input is attached to.
  101833. */
  101834. camera: ArcRotateCamera;
  101835. /**
  101836. * Gets the class name of the current input.
  101837. * @returns the class name
  101838. */
  101839. getClassName(): string;
  101840. /**
  101841. * Defines the buttons associated with the input to handle camera move.
  101842. */
  101843. buttons: number[];
  101844. /**
  101845. * Defines the pointer angular sensibility along the X axis or how fast is
  101846. * the camera rotating.
  101847. */
  101848. angularSensibilityX: number;
  101849. /**
  101850. * Defines the pointer angular sensibility along the Y axis or how fast is
  101851. * the camera rotating.
  101852. */
  101853. angularSensibilityY: number;
  101854. /**
  101855. * Defines the pointer pinch precision or how fast is the camera zooming.
  101856. */
  101857. pinchPrecision: number;
  101858. /**
  101859. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101860. * from 0.
  101861. * It defines the percentage of current camera.radius to use as delta when
  101862. * pinch zoom is used.
  101863. */
  101864. pinchDeltaPercentage: number;
  101865. /**
  101866. * Defines the pointer panning sensibility or how fast is the camera moving.
  101867. */
  101868. panningSensibility: number;
  101869. /**
  101870. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101871. */
  101872. multiTouchPanning: boolean;
  101873. /**
  101874. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101875. * zoom (pinch) through multitouch.
  101876. */
  101877. multiTouchPanAndZoom: boolean;
  101878. /**
  101879. * Revers pinch action direction.
  101880. */
  101881. pinchInwards: boolean;
  101882. private _isPanClick;
  101883. private _twoFingerActivityCount;
  101884. private _isPinching;
  101885. /**
  101886. * Called on pointer POINTERMOVE event if only a single touch is active.
  101887. */
  101888. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101889. /**
  101890. * Called on pointer POINTERDOUBLETAP event.
  101891. */
  101892. protected onDoubleTap(type: string): void;
  101893. /**
  101894. * Called on pointer POINTERMOVE event if multiple touches are active.
  101895. */
  101896. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101897. /**
  101898. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101899. * press.
  101900. */
  101901. protected onButtonDown(evt: PointerEvent): void;
  101902. /**
  101903. * Called each time a new POINTERUP event occurs. Ie, for each button
  101904. * release.
  101905. */
  101906. protected onButtonUp(evt: PointerEvent): void;
  101907. /**
  101908. * Called when window becomes inactive.
  101909. */
  101910. protected onLostFocus(): void;
  101911. }
  101912. }
  101913. declare module BABYLON {
  101914. /**
  101915. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101917. */
  101918. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101919. /**
  101920. * Defines the camera the input is attached to.
  101921. */
  101922. camera: ArcRotateCamera;
  101923. /**
  101924. * Defines the list of key codes associated with the up action (increase alpha)
  101925. */
  101926. keysUp: number[];
  101927. /**
  101928. * Defines the list of key codes associated with the down action (decrease alpha)
  101929. */
  101930. keysDown: number[];
  101931. /**
  101932. * Defines the list of key codes associated with the left action (increase beta)
  101933. */
  101934. keysLeft: number[];
  101935. /**
  101936. * Defines the list of key codes associated with the right action (decrease beta)
  101937. */
  101938. keysRight: number[];
  101939. /**
  101940. * Defines the list of key codes associated with the reset action.
  101941. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101942. */
  101943. keysReset: number[];
  101944. /**
  101945. * Defines the panning sensibility of the inputs.
  101946. * (How fast is the camera paning)
  101947. */
  101948. panningSensibility: number;
  101949. /**
  101950. * Defines the zooming sensibility of the inputs.
  101951. * (How fast is the camera zooming)
  101952. */
  101953. zoomingSensibility: number;
  101954. /**
  101955. * Defines wether maintaining the alt key down switch the movement mode from
  101956. * orientation to zoom.
  101957. */
  101958. useAltToZoom: boolean;
  101959. /**
  101960. * Rotation speed of the camera
  101961. */
  101962. angularSpeed: number;
  101963. private _keys;
  101964. private _ctrlPressed;
  101965. private _altPressed;
  101966. private _onCanvasBlurObserver;
  101967. private _onKeyboardObserver;
  101968. private _engine;
  101969. private _scene;
  101970. /**
  101971. * Attach the input controls to a specific dom element to get the input from.
  101972. * @param element Defines the element the controls should be listened from
  101973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101974. */
  101975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101976. /**
  101977. * Detach the current controls from the specified dom element.
  101978. * @param element Defines the element to stop listening the inputs from
  101979. */
  101980. detachControl(element: Nullable<HTMLElement>): void;
  101981. /**
  101982. * Update the current camera state depending on the inputs that have been used this frame.
  101983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101984. */
  101985. checkInputs(): void;
  101986. /**
  101987. * Gets the class name of the current intput.
  101988. * @returns the class name
  101989. */
  101990. getClassName(): string;
  101991. /**
  101992. * Get the friendly name associated with the input class.
  101993. * @returns the input friendly name
  101994. */
  101995. getSimpleName(): string;
  101996. }
  101997. }
  101998. declare module BABYLON {
  101999. /**
  102000. * Manage the mouse wheel inputs to control an arc rotate camera.
  102001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102002. */
  102003. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102004. /**
  102005. * Defines the camera the input is attached to.
  102006. */
  102007. camera: ArcRotateCamera;
  102008. /**
  102009. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102010. */
  102011. wheelPrecision: number;
  102012. /**
  102013. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102014. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102015. */
  102016. wheelDeltaPercentage: number;
  102017. private _wheel;
  102018. private _observer;
  102019. private computeDeltaFromMouseWheelLegacyEvent;
  102020. /**
  102021. * Attach the input controls to a specific dom element to get the input from.
  102022. * @param element Defines the element the controls should be listened from
  102023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102024. */
  102025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102026. /**
  102027. * Detach the current controls from the specified dom element.
  102028. * @param element Defines the element to stop listening the inputs from
  102029. */
  102030. detachControl(element: Nullable<HTMLElement>): void;
  102031. /**
  102032. * Gets the class name of the current intput.
  102033. * @returns the class name
  102034. */
  102035. getClassName(): string;
  102036. /**
  102037. * Get the friendly name associated with the input class.
  102038. * @returns the input friendly name
  102039. */
  102040. getSimpleName(): string;
  102041. }
  102042. }
  102043. declare module BABYLON {
  102044. /**
  102045. * Default Inputs manager for the ArcRotateCamera.
  102046. * It groups all the default supported inputs for ease of use.
  102047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102048. */
  102049. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102050. /**
  102051. * Instantiates a new ArcRotateCameraInputsManager.
  102052. * @param camera Defines the camera the inputs belong to
  102053. */
  102054. constructor(camera: ArcRotateCamera);
  102055. /**
  102056. * Add mouse wheel input support to the input manager.
  102057. * @returns the current input manager
  102058. */
  102059. addMouseWheel(): ArcRotateCameraInputsManager;
  102060. /**
  102061. * Add pointers input support to the input manager.
  102062. * @returns the current input manager
  102063. */
  102064. addPointers(): ArcRotateCameraInputsManager;
  102065. /**
  102066. * Add keyboard input support to the input manager.
  102067. * @returns the current input manager
  102068. */
  102069. addKeyboard(): ArcRotateCameraInputsManager;
  102070. }
  102071. }
  102072. declare module BABYLON {
  102073. /**
  102074. * This represents an orbital type of camera.
  102075. *
  102076. * 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.
  102077. * 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.
  102078. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102079. */
  102080. export class ArcRotateCamera extends TargetCamera {
  102081. /**
  102082. * Defines the rotation angle of the camera along the longitudinal axis.
  102083. */
  102084. alpha: number;
  102085. /**
  102086. * Defines the rotation angle of the camera along the latitudinal axis.
  102087. */
  102088. beta: number;
  102089. /**
  102090. * Defines the radius of the camera from it s target point.
  102091. */
  102092. radius: number;
  102093. protected _target: Vector3;
  102094. protected _targetHost: Nullable<AbstractMesh>;
  102095. /**
  102096. * Defines the target point of the camera.
  102097. * The camera looks towards it form the radius distance.
  102098. */
  102099. target: Vector3;
  102100. /**
  102101. * Define the current local position of the camera in the scene
  102102. */
  102103. position: Vector3;
  102104. protected _upVector: Vector3;
  102105. protected _upToYMatrix: Matrix;
  102106. protected _YToUpMatrix: Matrix;
  102107. /**
  102108. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  102109. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  102110. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  102111. */
  102112. upVector: Vector3;
  102113. /**
  102114. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  102115. */
  102116. setMatUp(): void;
  102117. /**
  102118. * Current inertia value on the longitudinal axis.
  102119. * The bigger this number the longer it will take for the camera to stop.
  102120. */
  102121. inertialAlphaOffset: number;
  102122. /**
  102123. * Current inertia value on the latitudinal axis.
  102124. * The bigger this number the longer it will take for the camera to stop.
  102125. */
  102126. inertialBetaOffset: number;
  102127. /**
  102128. * Current inertia value on the radius axis.
  102129. * The bigger this number the longer it will take for the camera to stop.
  102130. */
  102131. inertialRadiusOffset: number;
  102132. /**
  102133. * Minimum allowed angle on the longitudinal axis.
  102134. * This can help limiting how the Camera is able to move in the scene.
  102135. */
  102136. lowerAlphaLimit: Nullable<number>;
  102137. /**
  102138. * Maximum allowed angle on the longitudinal axis.
  102139. * This can help limiting how the Camera is able to move in the scene.
  102140. */
  102141. upperAlphaLimit: Nullable<number>;
  102142. /**
  102143. * Minimum allowed angle on the latitudinal axis.
  102144. * This can help limiting how the Camera is able to move in the scene.
  102145. */
  102146. lowerBetaLimit: number;
  102147. /**
  102148. * Maximum allowed angle on the latitudinal axis.
  102149. * This can help limiting how the Camera is able to move in the scene.
  102150. */
  102151. upperBetaLimit: number;
  102152. /**
  102153. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102154. * This can help limiting how the Camera is able to move in the scene.
  102155. */
  102156. lowerRadiusLimit: Nullable<number>;
  102157. /**
  102158. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102159. * This can help limiting how the Camera is able to move in the scene.
  102160. */
  102161. upperRadiusLimit: Nullable<number>;
  102162. /**
  102163. * Defines the current inertia value used during panning of the camera along the X axis.
  102164. */
  102165. inertialPanningX: number;
  102166. /**
  102167. * Defines the current inertia value used during panning of the camera along the Y axis.
  102168. */
  102169. inertialPanningY: number;
  102170. /**
  102171. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102172. * Basically if your fingers moves away from more than this distance you will be considered
  102173. * in pinch mode.
  102174. */
  102175. pinchToPanMaxDistance: number;
  102176. /**
  102177. * Defines the maximum distance the camera can pan.
  102178. * This could help keeping the cammera always in your scene.
  102179. */
  102180. panningDistanceLimit: Nullable<number>;
  102181. /**
  102182. * Defines the target of the camera before paning.
  102183. */
  102184. panningOriginTarget: Vector3;
  102185. /**
  102186. * Defines the value of the inertia used during panning.
  102187. * 0 would mean stop inertia and one would mean no decelleration at all.
  102188. */
  102189. panningInertia: number;
  102190. /**
  102191. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102192. */
  102193. angularSensibilityX: number;
  102194. /**
  102195. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102196. */
  102197. angularSensibilityY: number;
  102198. /**
  102199. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102200. */
  102201. pinchPrecision: number;
  102202. /**
  102203. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102204. * It will be used instead of pinchDeltaPrecision if different from 0.
  102205. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102206. */
  102207. pinchDeltaPercentage: number;
  102208. /**
  102209. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102210. */
  102211. panningSensibility: number;
  102212. /**
  102213. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102214. */
  102215. keysUp: number[];
  102216. /**
  102217. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102218. */
  102219. keysDown: number[];
  102220. /**
  102221. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102222. */
  102223. keysLeft: number[];
  102224. /**
  102225. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102226. */
  102227. keysRight: number[];
  102228. /**
  102229. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102230. */
  102231. wheelPrecision: number;
  102232. /**
  102233. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102234. * It will be used instead of pinchDeltaPrecision if different from 0.
  102235. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102236. */
  102237. wheelDeltaPercentage: number;
  102238. /**
  102239. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102240. */
  102241. zoomOnFactor: number;
  102242. /**
  102243. * Defines a screen offset for the camera position.
  102244. */
  102245. targetScreenOffset: Vector2;
  102246. /**
  102247. * Allows the camera to be completely reversed.
  102248. * If false the camera can not arrive upside down.
  102249. */
  102250. allowUpsideDown: boolean;
  102251. /**
  102252. * Define if double tap/click is used to restore the previously saved state of the camera.
  102253. */
  102254. useInputToRestoreState: boolean;
  102255. /** @hidden */
  102256. _viewMatrix: Matrix;
  102257. /** @hidden */
  102258. _useCtrlForPanning: boolean;
  102259. /** @hidden */
  102260. _panningMouseButton: number;
  102261. /**
  102262. * Defines the input associated to the camera.
  102263. */
  102264. inputs: ArcRotateCameraInputsManager;
  102265. /** @hidden */
  102266. _reset: () => void;
  102267. /**
  102268. * Defines the allowed panning axis.
  102269. */
  102270. panningAxis: Vector3;
  102271. protected _localDirection: Vector3;
  102272. protected _transformedDirection: Vector3;
  102273. private _bouncingBehavior;
  102274. /**
  102275. * Gets the bouncing behavior of the camera if it has been enabled.
  102276. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102277. */
  102278. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102279. /**
  102280. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102281. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102282. */
  102283. useBouncingBehavior: boolean;
  102284. private _framingBehavior;
  102285. /**
  102286. * Gets the framing behavior of the camera if it has been enabled.
  102287. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102288. */
  102289. readonly framingBehavior: Nullable<FramingBehavior>;
  102290. /**
  102291. * Defines if the framing behavior of the camera is enabled on the camera.
  102292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102293. */
  102294. useFramingBehavior: boolean;
  102295. private _autoRotationBehavior;
  102296. /**
  102297. * Gets the auto rotation behavior of the camera if it has been enabled.
  102298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102299. */
  102300. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102301. /**
  102302. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102304. */
  102305. useAutoRotationBehavior: boolean;
  102306. /**
  102307. * Observable triggered when the mesh target has been changed on the camera.
  102308. */
  102309. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102310. /**
  102311. * Event raised when the camera is colliding with a mesh.
  102312. */
  102313. onCollide: (collidedMesh: AbstractMesh) => void;
  102314. /**
  102315. * Defines whether the camera should check collision with the objects oh the scene.
  102316. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102317. */
  102318. checkCollisions: boolean;
  102319. /**
  102320. * Defines the collision radius of the camera.
  102321. * This simulates a sphere around the camera.
  102322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102323. */
  102324. collisionRadius: Vector3;
  102325. protected _collider: Collider;
  102326. protected _previousPosition: Vector3;
  102327. protected _collisionVelocity: Vector3;
  102328. protected _newPosition: Vector3;
  102329. protected _previousAlpha: number;
  102330. protected _previousBeta: number;
  102331. protected _previousRadius: number;
  102332. protected _collisionTriggered: boolean;
  102333. protected _targetBoundingCenter: Nullable<Vector3>;
  102334. private _computationVector;
  102335. /**
  102336. * Instantiates a new ArcRotateCamera in a given scene
  102337. * @param name Defines the name of the camera
  102338. * @param alpha Defines the camera rotation along the logitudinal axis
  102339. * @param beta Defines the camera rotation along the latitudinal axis
  102340. * @param radius Defines the camera distance from its target
  102341. * @param target Defines the camera target
  102342. * @param scene Defines the scene the camera belongs to
  102343. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102344. */
  102345. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102346. /** @hidden */
  102347. _initCache(): void;
  102348. /** @hidden */
  102349. _updateCache(ignoreParentClass?: boolean): void;
  102350. protected _getTargetPosition(): Vector3;
  102351. private _storedAlpha;
  102352. private _storedBeta;
  102353. private _storedRadius;
  102354. private _storedTarget;
  102355. private _storedTargetScreenOffset;
  102356. /**
  102357. * Stores the current state of the camera (alpha, beta, radius and target)
  102358. * @returns the camera itself
  102359. */
  102360. storeState(): Camera;
  102361. /**
  102362. * @hidden
  102363. * Restored camera state. You must call storeState() first
  102364. */
  102365. _restoreStateValues(): boolean;
  102366. /** @hidden */
  102367. _isSynchronizedViewMatrix(): boolean;
  102368. /**
  102369. * Attached controls to the current camera.
  102370. * @param element Defines the element the controls should be listened from
  102371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102372. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102373. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102374. */
  102375. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102376. /**
  102377. * Detach the current controls from the camera.
  102378. * The camera will stop reacting to inputs.
  102379. * @param element Defines the element to stop listening the inputs from
  102380. */
  102381. detachControl(element: HTMLElement): void;
  102382. /** @hidden */
  102383. _checkInputs(): void;
  102384. protected _checkLimits(): void;
  102385. /**
  102386. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102387. */
  102388. rebuildAnglesAndRadius(): void;
  102389. /**
  102390. * Use a position to define the current camera related information like aplha, beta and radius
  102391. * @param position Defines the position to set the camera at
  102392. */
  102393. setPosition(position: Vector3): void;
  102394. /**
  102395. * Defines the target the camera should look at.
  102396. * This will automatically adapt alpha beta and radius to fit within the new target.
  102397. * @param target Defines the new target as a Vector or a mesh
  102398. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102399. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102400. */
  102401. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102402. /** @hidden */
  102403. _getViewMatrix(): Matrix;
  102404. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102405. /**
  102406. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102407. * @param meshes Defines the mesh to zoom on
  102408. * @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)
  102409. */
  102410. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102411. /**
  102412. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102413. * The target will be changed but the radius
  102414. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102415. * @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)
  102416. */
  102417. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102418. min: Vector3;
  102419. max: Vector3;
  102420. distance: number;
  102421. }, doNotUpdateMaxZ?: boolean): void;
  102422. /**
  102423. * @override
  102424. * Override Camera.createRigCamera
  102425. */
  102426. createRigCamera(name: string, cameraIndex: number): Camera;
  102427. /**
  102428. * @hidden
  102429. * @override
  102430. * Override Camera._updateRigCameras
  102431. */
  102432. _updateRigCameras(): void;
  102433. /**
  102434. * Destroy the camera and release the current resources hold by it.
  102435. */
  102436. dispose(): void;
  102437. /**
  102438. * Gets the current object class name.
  102439. * @return the class name
  102440. */
  102441. getClassName(): string;
  102442. }
  102443. }
  102444. declare module BABYLON {
  102445. /**
  102446. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102447. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102448. */
  102449. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102450. /**
  102451. * Gets the name of the behavior.
  102452. */
  102453. readonly name: string;
  102454. private _zoomStopsAnimation;
  102455. private _idleRotationSpeed;
  102456. private _idleRotationWaitTime;
  102457. private _idleRotationSpinupTime;
  102458. /**
  102459. * Sets the flag that indicates if user zooming should stop animation.
  102460. */
  102461. /**
  102462. * Gets the flag that indicates if user zooming should stop animation.
  102463. */
  102464. zoomStopsAnimation: boolean;
  102465. /**
  102466. * Sets the default speed at which the camera rotates around the model.
  102467. */
  102468. /**
  102469. * Gets the default speed at which the camera rotates around the model.
  102470. */
  102471. idleRotationSpeed: number;
  102472. /**
  102473. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102474. */
  102475. /**
  102476. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102477. */
  102478. idleRotationWaitTime: number;
  102479. /**
  102480. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102481. */
  102482. /**
  102483. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102484. */
  102485. idleRotationSpinupTime: number;
  102486. /**
  102487. * Gets a value indicating if the camera is currently rotating because of this behavior
  102488. */
  102489. readonly rotationInProgress: boolean;
  102490. private _onPrePointerObservableObserver;
  102491. private _onAfterCheckInputsObserver;
  102492. private _attachedCamera;
  102493. private _isPointerDown;
  102494. private _lastFrameTime;
  102495. private _lastInteractionTime;
  102496. private _cameraRotationSpeed;
  102497. /**
  102498. * Initializes the behavior.
  102499. */
  102500. init(): void;
  102501. /**
  102502. * Attaches the behavior to its arc rotate camera.
  102503. * @param camera Defines the camera to attach the behavior to
  102504. */
  102505. attach(camera: ArcRotateCamera): void;
  102506. /**
  102507. * Detaches the behavior from its current arc rotate camera.
  102508. */
  102509. detach(): void;
  102510. /**
  102511. * Returns true if user is scrolling.
  102512. * @return true if user is scrolling.
  102513. */
  102514. private _userIsZooming;
  102515. private _lastFrameRadius;
  102516. private _shouldAnimationStopForInteraction;
  102517. /**
  102518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102519. */
  102520. private _applyUserInteraction;
  102521. private _userIsMoving;
  102522. }
  102523. }
  102524. declare module BABYLON {
  102525. /**
  102526. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102527. */
  102528. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102529. private ui;
  102530. /**
  102531. * The name of the behavior
  102532. */
  102533. name: string;
  102534. /**
  102535. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102536. */
  102537. distanceAwayFromFace: number;
  102538. /**
  102539. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102540. */
  102541. distanceAwayFromBottomOfFace: number;
  102542. private _faceVectors;
  102543. private _target;
  102544. private _scene;
  102545. private _onRenderObserver;
  102546. private _tmpMatrix;
  102547. private _tmpVector;
  102548. /**
  102549. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102550. * @param ui The transform node that should be attched to the mesh
  102551. */
  102552. constructor(ui: TransformNode);
  102553. /**
  102554. * Initializes the behavior
  102555. */
  102556. init(): void;
  102557. private _closestFace;
  102558. private _zeroVector;
  102559. private _lookAtTmpMatrix;
  102560. private _lookAtToRef;
  102561. /**
  102562. * Attaches the AttachToBoxBehavior to the passed in mesh
  102563. * @param target The mesh that the specified node will be attached to
  102564. */
  102565. attach(target: Mesh): void;
  102566. /**
  102567. * Detaches the behavior from the mesh
  102568. */
  102569. detach(): void;
  102570. }
  102571. }
  102572. declare module BABYLON {
  102573. /**
  102574. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102575. */
  102576. export class FadeInOutBehavior implements Behavior<Mesh> {
  102577. /**
  102578. * Time in milliseconds to delay before fading in (Default: 0)
  102579. */
  102580. delay: number;
  102581. /**
  102582. * Time in milliseconds for the mesh to fade in (Default: 300)
  102583. */
  102584. fadeInTime: number;
  102585. private _millisecondsPerFrame;
  102586. private _hovered;
  102587. private _hoverValue;
  102588. private _ownerNode;
  102589. /**
  102590. * Instatiates the FadeInOutBehavior
  102591. */
  102592. constructor();
  102593. /**
  102594. * The name of the behavior
  102595. */
  102596. readonly name: string;
  102597. /**
  102598. * Initializes the behavior
  102599. */
  102600. init(): void;
  102601. /**
  102602. * Attaches the fade behavior on the passed in mesh
  102603. * @param ownerNode The mesh that will be faded in/out once attached
  102604. */
  102605. attach(ownerNode: Mesh): void;
  102606. /**
  102607. * Detaches the behavior from the mesh
  102608. */
  102609. detach(): void;
  102610. /**
  102611. * Triggers the mesh to begin fading in or out
  102612. * @param value if the object should fade in or out (true to fade in)
  102613. */
  102614. fadeIn(value: boolean): void;
  102615. private _update;
  102616. private _setAllVisibility;
  102617. }
  102618. }
  102619. declare module BABYLON {
  102620. /**
  102621. * Class containing a set of static utilities functions for managing Pivots
  102622. * @hidden
  102623. */
  102624. export class PivotTools {
  102625. private static _PivotCached;
  102626. private static _OldPivotPoint;
  102627. private static _PivotTranslation;
  102628. private static _PivotTmpVector;
  102629. /** @hidden */
  102630. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102631. /** @hidden */
  102632. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102633. }
  102634. }
  102635. declare module BABYLON {
  102636. /**
  102637. * Class containing static functions to help procedurally build meshes
  102638. */
  102639. export class PlaneBuilder {
  102640. /**
  102641. * Creates a plane mesh
  102642. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102643. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102644. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102648. * @param name defines the name of the mesh
  102649. * @param options defines the options used to create the mesh
  102650. * @param scene defines the hosting scene
  102651. * @returns the plane mesh
  102652. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102653. */
  102654. static CreatePlane(name: string, options: {
  102655. size?: number;
  102656. width?: number;
  102657. height?: number;
  102658. sideOrientation?: number;
  102659. frontUVs?: Vector4;
  102660. backUVs?: Vector4;
  102661. updatable?: boolean;
  102662. sourcePlane?: Plane;
  102663. }, scene?: Nullable<Scene>): Mesh;
  102664. }
  102665. }
  102666. declare module BABYLON {
  102667. /**
  102668. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102669. */
  102670. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102671. private static _AnyMouseID;
  102672. /**
  102673. * Abstract mesh the behavior is set on
  102674. */
  102675. attachedNode: AbstractMesh;
  102676. private _dragPlane;
  102677. private _scene;
  102678. private _pointerObserver;
  102679. private _beforeRenderObserver;
  102680. private static _planeScene;
  102681. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102682. /**
  102683. * 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)
  102684. */
  102685. maxDragAngle: number;
  102686. /**
  102687. * @hidden
  102688. */
  102689. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102690. /**
  102691. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102692. */
  102693. currentDraggingPointerID: number;
  102694. /**
  102695. * The last position where the pointer hit the drag plane in world space
  102696. */
  102697. lastDragPosition: Vector3;
  102698. /**
  102699. * If the behavior is currently in a dragging state
  102700. */
  102701. dragging: boolean;
  102702. /**
  102703. * 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)
  102704. */
  102705. dragDeltaRatio: number;
  102706. /**
  102707. * If the drag plane orientation should be updated during the dragging (Default: true)
  102708. */
  102709. updateDragPlane: boolean;
  102710. private _debugMode;
  102711. private _moving;
  102712. /**
  102713. * Fires each time the attached mesh is dragged with the pointer
  102714. * * delta between last drag position and current drag position in world space
  102715. * * dragDistance along the drag axis
  102716. * * dragPlaneNormal normal of the current drag plane used during the drag
  102717. * * dragPlanePoint in world space where the drag intersects the drag plane
  102718. */
  102719. onDragObservable: Observable<{
  102720. delta: Vector3;
  102721. dragPlanePoint: Vector3;
  102722. dragPlaneNormal: Vector3;
  102723. dragDistance: number;
  102724. pointerId: number;
  102725. }>;
  102726. /**
  102727. * Fires each time a drag begins (eg. mouse down on mesh)
  102728. */
  102729. onDragStartObservable: Observable<{
  102730. dragPlanePoint: Vector3;
  102731. pointerId: number;
  102732. }>;
  102733. /**
  102734. * Fires each time a drag ends (eg. mouse release after drag)
  102735. */
  102736. onDragEndObservable: Observable<{
  102737. dragPlanePoint: Vector3;
  102738. pointerId: number;
  102739. }>;
  102740. /**
  102741. * If the attached mesh should be moved when dragged
  102742. */
  102743. moveAttached: boolean;
  102744. /**
  102745. * If the drag behavior will react to drag events (Default: true)
  102746. */
  102747. enabled: boolean;
  102748. /**
  102749. * If pointer events should start and release the drag (Default: true)
  102750. */
  102751. startAndReleaseDragOnPointerEvents: boolean;
  102752. /**
  102753. * If camera controls should be detached during the drag
  102754. */
  102755. detachCameraControls: boolean;
  102756. /**
  102757. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102758. */
  102759. useObjectOrienationForDragging: boolean;
  102760. private _options;
  102761. /**
  102762. * Creates a pointer drag behavior that can be attached to a mesh
  102763. * @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)
  102764. */
  102765. constructor(options?: {
  102766. dragAxis?: Vector3;
  102767. dragPlaneNormal?: Vector3;
  102768. });
  102769. /**
  102770. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102771. */
  102772. validateDrag: (targetPosition: Vector3) => boolean;
  102773. /**
  102774. * The name of the behavior
  102775. */
  102776. readonly name: string;
  102777. /**
  102778. * Initializes the behavior
  102779. */
  102780. init(): void;
  102781. private _tmpVector;
  102782. private _alternatePickedPoint;
  102783. private _worldDragAxis;
  102784. private _targetPosition;
  102785. private _attachedElement;
  102786. /**
  102787. * Attaches the drag behavior the passed in mesh
  102788. * @param ownerNode The mesh that will be dragged around once attached
  102789. * @param predicate Predicate to use for pick filtering
  102790. */
  102791. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102792. /**
  102793. * Force relase the drag action by code.
  102794. */
  102795. releaseDrag(): void;
  102796. private _startDragRay;
  102797. private _lastPointerRay;
  102798. /**
  102799. * Simulates the start of a pointer drag event on the behavior
  102800. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102801. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102802. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102803. */
  102804. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102805. private _startDrag;
  102806. private _dragDelta;
  102807. private _moveDrag;
  102808. private _pickWithRayOnDragPlane;
  102809. private _pointA;
  102810. private _pointB;
  102811. private _pointC;
  102812. private _lineA;
  102813. private _lineB;
  102814. private _localAxis;
  102815. private _lookAt;
  102816. private _updateDragPlanePosition;
  102817. /**
  102818. * Detaches the behavior from the mesh
  102819. */
  102820. detach(): void;
  102821. }
  102822. }
  102823. declare module BABYLON {
  102824. /**
  102825. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102826. */
  102827. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102828. private _dragBehaviorA;
  102829. private _dragBehaviorB;
  102830. private _startDistance;
  102831. private _initialScale;
  102832. private _targetScale;
  102833. private _ownerNode;
  102834. private _sceneRenderObserver;
  102835. /**
  102836. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102837. */
  102838. constructor();
  102839. /**
  102840. * The name of the behavior
  102841. */
  102842. readonly name: string;
  102843. /**
  102844. * Initializes the behavior
  102845. */
  102846. init(): void;
  102847. private _getCurrentDistance;
  102848. /**
  102849. * Attaches the scale behavior the passed in mesh
  102850. * @param ownerNode The mesh that will be scaled around once attached
  102851. */
  102852. attach(ownerNode: Mesh): void;
  102853. /**
  102854. * Detaches the behavior from the mesh
  102855. */
  102856. detach(): void;
  102857. }
  102858. }
  102859. declare module BABYLON {
  102860. /**
  102861. * 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
  102862. */
  102863. export class SixDofDragBehavior implements Behavior<Mesh> {
  102864. private static _virtualScene;
  102865. private _ownerNode;
  102866. private _sceneRenderObserver;
  102867. private _scene;
  102868. private _targetPosition;
  102869. private _virtualOriginMesh;
  102870. private _virtualDragMesh;
  102871. private _pointerObserver;
  102872. private _moving;
  102873. private _startingOrientation;
  102874. /**
  102875. * 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)
  102876. */
  102877. private zDragFactor;
  102878. /**
  102879. * If the object should rotate to face the drag origin
  102880. */
  102881. rotateDraggedObject: boolean;
  102882. /**
  102883. * If the behavior is currently in a dragging state
  102884. */
  102885. dragging: boolean;
  102886. /**
  102887. * 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)
  102888. */
  102889. dragDeltaRatio: number;
  102890. /**
  102891. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102892. */
  102893. currentDraggingPointerID: number;
  102894. /**
  102895. * If camera controls should be detached during the drag
  102896. */
  102897. detachCameraControls: boolean;
  102898. /**
  102899. * Fires each time a drag starts
  102900. */
  102901. onDragStartObservable: Observable<{}>;
  102902. /**
  102903. * Fires each time a drag ends (eg. mouse release after drag)
  102904. */
  102905. onDragEndObservable: Observable<{}>;
  102906. /**
  102907. * 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
  102908. */
  102909. constructor();
  102910. /**
  102911. * The name of the behavior
  102912. */
  102913. readonly name: string;
  102914. /**
  102915. * Initializes the behavior
  102916. */
  102917. init(): void;
  102918. /**
  102919. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102920. */
  102921. private readonly _pointerCamera;
  102922. /**
  102923. * Attaches the scale behavior the passed in mesh
  102924. * @param ownerNode The mesh that will be scaled around once attached
  102925. */
  102926. attach(ownerNode: Mesh): void;
  102927. /**
  102928. * Detaches the behavior from the mesh
  102929. */
  102930. detach(): void;
  102931. }
  102932. }
  102933. declare module BABYLON {
  102934. /**
  102935. * Class used to apply inverse kinematics to bones
  102936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102937. */
  102938. export class BoneIKController {
  102939. private static _tmpVecs;
  102940. private static _tmpQuat;
  102941. private static _tmpMats;
  102942. /**
  102943. * Gets or sets the target mesh
  102944. */
  102945. targetMesh: AbstractMesh;
  102946. /** Gets or sets the mesh used as pole */
  102947. poleTargetMesh: AbstractMesh;
  102948. /**
  102949. * Gets or sets the bone used as pole
  102950. */
  102951. poleTargetBone: Nullable<Bone>;
  102952. /**
  102953. * Gets or sets the target position
  102954. */
  102955. targetPosition: Vector3;
  102956. /**
  102957. * Gets or sets the pole target position
  102958. */
  102959. poleTargetPosition: Vector3;
  102960. /**
  102961. * Gets or sets the pole target local offset
  102962. */
  102963. poleTargetLocalOffset: Vector3;
  102964. /**
  102965. * Gets or sets the pole angle
  102966. */
  102967. poleAngle: number;
  102968. /**
  102969. * Gets or sets the mesh associated with the controller
  102970. */
  102971. mesh: AbstractMesh;
  102972. /**
  102973. * 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)
  102974. */
  102975. slerpAmount: number;
  102976. private _bone1Quat;
  102977. private _bone1Mat;
  102978. private _bone2Ang;
  102979. private _bone1;
  102980. private _bone2;
  102981. private _bone1Length;
  102982. private _bone2Length;
  102983. private _maxAngle;
  102984. private _maxReach;
  102985. private _rightHandedSystem;
  102986. private _bendAxis;
  102987. private _slerping;
  102988. private _adjustRoll;
  102989. /**
  102990. * Gets or sets maximum allowed angle
  102991. */
  102992. maxAngle: number;
  102993. /**
  102994. * Creates a new BoneIKController
  102995. * @param mesh defines the mesh to control
  102996. * @param bone defines the bone to control
  102997. * @param options defines options to set up the controller
  102998. */
  102999. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103000. targetMesh?: AbstractMesh;
  103001. poleTargetMesh?: AbstractMesh;
  103002. poleTargetBone?: Bone;
  103003. poleTargetLocalOffset?: Vector3;
  103004. poleAngle?: number;
  103005. bendAxis?: Vector3;
  103006. maxAngle?: number;
  103007. slerpAmount?: number;
  103008. });
  103009. private _setMaxAngle;
  103010. /**
  103011. * Force the controller to update the bones
  103012. */
  103013. update(): void;
  103014. }
  103015. }
  103016. declare module BABYLON {
  103017. /**
  103018. * Class used to make a bone look toward a point in space
  103019. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103020. */
  103021. export class BoneLookController {
  103022. private static _tmpVecs;
  103023. private static _tmpQuat;
  103024. private static _tmpMats;
  103025. /**
  103026. * The target Vector3 that the bone will look at
  103027. */
  103028. target: Vector3;
  103029. /**
  103030. * The mesh that the bone is attached to
  103031. */
  103032. mesh: AbstractMesh;
  103033. /**
  103034. * The bone that will be looking to the target
  103035. */
  103036. bone: Bone;
  103037. /**
  103038. * The up axis of the coordinate system that is used when the bone is rotated
  103039. */
  103040. upAxis: Vector3;
  103041. /**
  103042. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  103043. */
  103044. upAxisSpace: Space;
  103045. /**
  103046. * Used to make an adjustment to the yaw of the bone
  103047. */
  103048. adjustYaw: number;
  103049. /**
  103050. * Used to make an adjustment to the pitch of the bone
  103051. */
  103052. adjustPitch: number;
  103053. /**
  103054. * Used to make an adjustment to the roll of the bone
  103055. */
  103056. adjustRoll: number;
  103057. /**
  103058. * 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)
  103059. */
  103060. slerpAmount: number;
  103061. private _minYaw;
  103062. private _maxYaw;
  103063. private _minPitch;
  103064. private _maxPitch;
  103065. private _minYawSin;
  103066. private _minYawCos;
  103067. private _maxYawSin;
  103068. private _maxYawCos;
  103069. private _midYawConstraint;
  103070. private _minPitchTan;
  103071. private _maxPitchTan;
  103072. private _boneQuat;
  103073. private _slerping;
  103074. private _transformYawPitch;
  103075. private _transformYawPitchInv;
  103076. private _firstFrameSkipped;
  103077. private _yawRange;
  103078. private _fowardAxis;
  103079. /**
  103080. * Gets or sets the minimum yaw angle that the bone can look to
  103081. */
  103082. minYaw: number;
  103083. /**
  103084. * Gets or sets the maximum yaw angle that the bone can look to
  103085. */
  103086. maxYaw: number;
  103087. /**
  103088. * Gets or sets the minimum pitch angle that the bone can look to
  103089. */
  103090. minPitch: number;
  103091. /**
  103092. * Gets or sets the maximum pitch angle that the bone can look to
  103093. */
  103094. maxPitch: number;
  103095. /**
  103096. * Create a BoneLookController
  103097. * @param mesh the mesh that the bone belongs to
  103098. * @param bone the bone that will be looking to the target
  103099. * @param target the target Vector3 to look at
  103100. * @param options optional settings:
  103101. * * maxYaw: the maximum angle the bone will yaw to
  103102. * * minYaw: the minimum angle the bone will yaw to
  103103. * * maxPitch: the maximum angle the bone will pitch to
  103104. * * minPitch: the minimum angle the bone will yaw to
  103105. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103106. * * upAxis: the up axis of the coordinate system
  103107. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  103108. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  103109. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  103110. * * adjustYaw: used to make an adjustment to the yaw of the bone
  103111. * * adjustPitch: used to make an adjustment to the pitch of the bone
  103112. * * adjustRoll: used to make an adjustment to the roll of the bone
  103113. **/
  103114. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  103115. maxYaw?: number;
  103116. minYaw?: number;
  103117. maxPitch?: number;
  103118. minPitch?: number;
  103119. slerpAmount?: number;
  103120. upAxis?: Vector3;
  103121. upAxisSpace?: Space;
  103122. yawAxis?: Vector3;
  103123. pitchAxis?: Vector3;
  103124. adjustYaw?: number;
  103125. adjustPitch?: number;
  103126. adjustRoll?: number;
  103127. });
  103128. /**
  103129. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  103130. */
  103131. update(): void;
  103132. private _getAngleDiff;
  103133. private _getAngleBetween;
  103134. private _isAngleBetween;
  103135. }
  103136. }
  103137. declare module BABYLON {
  103138. /**
  103139. * Manage the gamepad inputs to control an arc rotate camera.
  103140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103141. */
  103142. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103143. /**
  103144. * Defines the camera the input is attached to.
  103145. */
  103146. camera: ArcRotateCamera;
  103147. /**
  103148. * Defines the gamepad the input is gathering event from.
  103149. */
  103150. gamepad: Nullable<Gamepad>;
  103151. /**
  103152. * Defines the gamepad rotation sensiblity.
  103153. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103154. */
  103155. gamepadRotationSensibility: number;
  103156. /**
  103157. * Defines the gamepad move sensiblity.
  103158. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103159. */
  103160. gamepadMoveSensibility: number;
  103161. private _onGamepadConnectedObserver;
  103162. private _onGamepadDisconnectedObserver;
  103163. /**
  103164. * Attach the input controls to a specific dom element to get the input from.
  103165. * @param element Defines the element the controls should be listened from
  103166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103167. */
  103168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103169. /**
  103170. * Detach the current controls from the specified dom element.
  103171. * @param element Defines the element to stop listening the inputs from
  103172. */
  103173. detachControl(element: Nullable<HTMLElement>): void;
  103174. /**
  103175. * Update the current camera state depending on the inputs that have been used this frame.
  103176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103177. */
  103178. checkInputs(): void;
  103179. /**
  103180. * Gets the class name of the current intput.
  103181. * @returns the class name
  103182. */
  103183. getClassName(): string;
  103184. /**
  103185. * Get the friendly name associated with the input class.
  103186. * @returns the input friendly name
  103187. */
  103188. getSimpleName(): string;
  103189. }
  103190. }
  103191. declare module BABYLON {
  103192. interface ArcRotateCameraInputsManager {
  103193. /**
  103194. * Add orientation input support to the input manager.
  103195. * @returns the current input manager
  103196. */
  103197. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103198. }
  103199. /**
  103200. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103202. */
  103203. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103204. /**
  103205. * Defines the camera the input is attached to.
  103206. */
  103207. camera: ArcRotateCamera;
  103208. /**
  103209. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103210. */
  103211. alphaCorrection: number;
  103212. /**
  103213. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103214. */
  103215. gammaCorrection: number;
  103216. private _alpha;
  103217. private _gamma;
  103218. private _dirty;
  103219. private _deviceOrientationHandler;
  103220. /**
  103221. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103222. */
  103223. constructor();
  103224. /**
  103225. * Attach the input controls to a specific dom element to get the input from.
  103226. * @param element Defines the element the controls should be listened from
  103227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103228. */
  103229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103230. /** @hidden */
  103231. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103232. /**
  103233. * Update the current camera state depending on the inputs that have been used this frame.
  103234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103235. */
  103236. checkInputs(): void;
  103237. /**
  103238. * Detach the current controls from the specified dom element.
  103239. * @param element Defines the element to stop listening the inputs from
  103240. */
  103241. detachControl(element: Nullable<HTMLElement>): void;
  103242. /**
  103243. * Gets the class name of the current intput.
  103244. * @returns the class name
  103245. */
  103246. getClassName(): string;
  103247. /**
  103248. * Get the friendly name associated with the input class.
  103249. * @returns the input friendly name
  103250. */
  103251. getSimpleName(): string;
  103252. }
  103253. }
  103254. declare module BABYLON {
  103255. /**
  103256. * Listen to mouse events to control the camera.
  103257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103258. */
  103259. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103260. /**
  103261. * Defines the camera the input is attached to.
  103262. */
  103263. camera: FlyCamera;
  103264. /**
  103265. * Defines if touch is enabled. (Default is true.)
  103266. */
  103267. touchEnabled: boolean;
  103268. /**
  103269. * Defines the buttons associated with the input to handle camera rotation.
  103270. */
  103271. buttons: number[];
  103272. /**
  103273. * Assign buttons for Yaw control.
  103274. */
  103275. buttonsYaw: number[];
  103276. /**
  103277. * Assign buttons for Pitch control.
  103278. */
  103279. buttonsPitch: number[];
  103280. /**
  103281. * Assign buttons for Roll control.
  103282. */
  103283. buttonsRoll: number[];
  103284. /**
  103285. * Detect if any button is being pressed while mouse is moved.
  103286. * -1 = Mouse locked.
  103287. * 0 = Left button.
  103288. * 1 = Middle Button.
  103289. * 2 = Right Button.
  103290. */
  103291. activeButton: number;
  103292. /**
  103293. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103294. * Higher values reduce its sensitivity.
  103295. */
  103296. angularSensibility: number;
  103297. private _mousemoveCallback;
  103298. private _observer;
  103299. private _rollObserver;
  103300. private previousPosition;
  103301. private noPreventDefault;
  103302. private element;
  103303. /**
  103304. * Listen to mouse events to control the camera.
  103305. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103307. */
  103308. constructor(touchEnabled?: boolean);
  103309. /**
  103310. * Attach the mouse control to the HTML DOM element.
  103311. * @param element Defines the element that listens to the input events.
  103312. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103313. */
  103314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103315. /**
  103316. * Detach the current controls from the specified dom element.
  103317. * @param element Defines the element to stop listening the inputs from
  103318. */
  103319. detachControl(element: Nullable<HTMLElement>): void;
  103320. /**
  103321. * Gets the class name of the current input.
  103322. * @returns the class name.
  103323. */
  103324. getClassName(): string;
  103325. /**
  103326. * Get the friendly name associated with the input class.
  103327. * @returns the input's friendly name.
  103328. */
  103329. getSimpleName(): string;
  103330. private _pointerInput;
  103331. private _onMouseMove;
  103332. /**
  103333. * Rotate camera by mouse offset.
  103334. */
  103335. private rotateCamera;
  103336. }
  103337. }
  103338. declare module BABYLON {
  103339. /**
  103340. * Default Inputs manager for the FlyCamera.
  103341. * It groups all the default supported inputs for ease of use.
  103342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103343. */
  103344. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103345. /**
  103346. * Instantiates a new FlyCameraInputsManager.
  103347. * @param camera Defines the camera the inputs belong to.
  103348. */
  103349. constructor(camera: FlyCamera);
  103350. /**
  103351. * Add keyboard input support to the input manager.
  103352. * @returns the new FlyCameraKeyboardMoveInput().
  103353. */
  103354. addKeyboard(): FlyCameraInputsManager;
  103355. /**
  103356. * Add mouse input support to the input manager.
  103357. * @param touchEnabled Enable touch screen support.
  103358. * @returns the new FlyCameraMouseInput().
  103359. */
  103360. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103361. }
  103362. }
  103363. declare module BABYLON {
  103364. /**
  103365. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103366. * such as in a 3D Space Shooter or a Flight Simulator.
  103367. */
  103368. export class FlyCamera extends TargetCamera {
  103369. /**
  103370. * Define the collision ellipsoid of the camera.
  103371. * This is helpful for simulating a camera body, like a player's body.
  103372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103373. */
  103374. ellipsoid: Vector3;
  103375. /**
  103376. * Define an offset for the position of the ellipsoid around the camera.
  103377. * This can be helpful if the camera is attached away from the player's body center,
  103378. * such as at its head.
  103379. */
  103380. ellipsoidOffset: Vector3;
  103381. /**
  103382. * Enable or disable collisions of the camera with the rest of the scene objects.
  103383. */
  103384. checkCollisions: boolean;
  103385. /**
  103386. * Enable or disable gravity on the camera.
  103387. */
  103388. applyGravity: boolean;
  103389. /**
  103390. * Define the current direction the camera is moving to.
  103391. */
  103392. cameraDirection: Vector3;
  103393. /**
  103394. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103395. * This overrides and empties cameraRotation.
  103396. */
  103397. rotationQuaternion: Quaternion;
  103398. /**
  103399. * Track Roll to maintain the wanted Rolling when looking around.
  103400. */
  103401. _trackRoll: number;
  103402. /**
  103403. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103404. */
  103405. rollCorrect: number;
  103406. /**
  103407. * Mimic a banked turn, Rolling the camera when Yawing.
  103408. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103409. */
  103410. bankedTurn: boolean;
  103411. /**
  103412. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103413. */
  103414. bankedTurnLimit: number;
  103415. /**
  103416. * Value of 0 disables the banked Roll.
  103417. * Value of 1 is equal to the Yaw angle in radians.
  103418. */
  103419. bankedTurnMultiplier: number;
  103420. /**
  103421. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103422. */
  103423. inputs: FlyCameraInputsManager;
  103424. /**
  103425. * Gets the input sensibility for mouse input.
  103426. * Higher values reduce sensitivity.
  103427. */
  103428. /**
  103429. * Sets the input sensibility for a mouse input.
  103430. * Higher values reduce sensitivity.
  103431. */
  103432. angularSensibility: number;
  103433. /**
  103434. * Get the keys for camera movement forward.
  103435. */
  103436. /**
  103437. * Set the keys for camera movement forward.
  103438. */
  103439. keysForward: number[];
  103440. /**
  103441. * Get the keys for camera movement backward.
  103442. */
  103443. keysBackward: number[];
  103444. /**
  103445. * Get the keys for camera movement up.
  103446. */
  103447. /**
  103448. * Set the keys for camera movement up.
  103449. */
  103450. keysUp: number[];
  103451. /**
  103452. * Get the keys for camera movement down.
  103453. */
  103454. /**
  103455. * Set the keys for camera movement down.
  103456. */
  103457. keysDown: number[];
  103458. /**
  103459. * Get the keys for camera movement left.
  103460. */
  103461. /**
  103462. * Set the keys for camera movement left.
  103463. */
  103464. keysLeft: number[];
  103465. /**
  103466. * Set the keys for camera movement right.
  103467. */
  103468. /**
  103469. * Set the keys for camera movement right.
  103470. */
  103471. keysRight: number[];
  103472. /**
  103473. * Event raised when the camera collides with a mesh in the scene.
  103474. */
  103475. onCollide: (collidedMesh: AbstractMesh) => void;
  103476. private _collider;
  103477. private _needMoveForGravity;
  103478. private _oldPosition;
  103479. private _diffPosition;
  103480. private _newPosition;
  103481. /** @hidden */
  103482. _localDirection: Vector3;
  103483. /** @hidden */
  103484. _transformedDirection: Vector3;
  103485. /**
  103486. * Instantiates a FlyCamera.
  103487. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103488. * such as in a 3D Space Shooter or a Flight Simulator.
  103489. * @param name Define the name of the camera in the scene.
  103490. * @param position Define the starting position of the camera in the scene.
  103491. * @param scene Define the scene the camera belongs to.
  103492. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103493. */
  103494. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103495. /**
  103496. * Attach a control to the HTML DOM element.
  103497. * @param element Defines the element that listens to the input events.
  103498. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103499. */
  103500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103501. /**
  103502. * Detach a control from the HTML DOM element.
  103503. * The camera will stop reacting to that input.
  103504. * @param element Defines the element that listens to the input events.
  103505. */
  103506. detachControl(element: HTMLElement): void;
  103507. private _collisionMask;
  103508. /**
  103509. * Get the mask that the camera ignores in collision events.
  103510. */
  103511. /**
  103512. * Set the mask that the camera ignores in collision events.
  103513. */
  103514. collisionMask: number;
  103515. /** @hidden */
  103516. _collideWithWorld(displacement: Vector3): void;
  103517. /** @hidden */
  103518. private _onCollisionPositionChange;
  103519. /** @hidden */
  103520. _checkInputs(): void;
  103521. /** @hidden */
  103522. _decideIfNeedsToMove(): boolean;
  103523. /** @hidden */
  103524. _updatePosition(): void;
  103525. /**
  103526. * Restore the Roll to its target value at the rate specified.
  103527. * @param rate - Higher means slower restoring.
  103528. * @hidden
  103529. */
  103530. restoreRoll(rate: number): void;
  103531. /**
  103532. * Destroy the camera and release the current resources held by it.
  103533. */
  103534. dispose(): void;
  103535. /**
  103536. * Get the current object class name.
  103537. * @returns the class name.
  103538. */
  103539. getClassName(): string;
  103540. }
  103541. }
  103542. declare module BABYLON {
  103543. /**
  103544. * Listen to keyboard events to control the camera.
  103545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103546. */
  103547. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103548. /**
  103549. * Defines the camera the input is attached to.
  103550. */
  103551. camera: FlyCamera;
  103552. /**
  103553. * The list of keyboard keys used to control the forward move of the camera.
  103554. */
  103555. keysForward: number[];
  103556. /**
  103557. * The list of keyboard keys used to control the backward move of the camera.
  103558. */
  103559. keysBackward: number[];
  103560. /**
  103561. * The list of keyboard keys used to control the forward move of the camera.
  103562. */
  103563. keysUp: number[];
  103564. /**
  103565. * The list of keyboard keys used to control the backward move of the camera.
  103566. */
  103567. keysDown: number[];
  103568. /**
  103569. * The list of keyboard keys used to control the right strafe move of the camera.
  103570. */
  103571. keysRight: number[];
  103572. /**
  103573. * The list of keyboard keys used to control the left strafe move of the camera.
  103574. */
  103575. keysLeft: number[];
  103576. private _keys;
  103577. private _onCanvasBlurObserver;
  103578. private _onKeyboardObserver;
  103579. private _engine;
  103580. private _scene;
  103581. /**
  103582. * Attach the input controls to a specific dom element to get the input from.
  103583. * @param element Defines the element the controls should be listened from
  103584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103585. */
  103586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103587. /**
  103588. * Detach the current controls from the specified dom element.
  103589. * @param element Defines the element to stop listening the inputs from
  103590. */
  103591. detachControl(element: Nullable<HTMLElement>): void;
  103592. /**
  103593. * Gets the class name of the current intput.
  103594. * @returns the class name
  103595. */
  103596. getClassName(): string;
  103597. /** @hidden */
  103598. _onLostFocus(e: FocusEvent): void;
  103599. /**
  103600. * Get the friendly name associated with the input class.
  103601. * @returns the input friendly name
  103602. */
  103603. getSimpleName(): string;
  103604. /**
  103605. * Update the current camera state depending on the inputs that have been used this frame.
  103606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103607. */
  103608. checkInputs(): void;
  103609. }
  103610. }
  103611. declare module BABYLON {
  103612. /**
  103613. * Manage the mouse wheel inputs to control a follow camera.
  103614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103615. */
  103616. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103617. /**
  103618. * Defines the camera the input is attached to.
  103619. */
  103620. camera: FollowCamera;
  103621. /**
  103622. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103623. */
  103624. axisControlRadius: boolean;
  103625. /**
  103626. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103627. */
  103628. axisControlHeight: boolean;
  103629. /**
  103630. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103631. */
  103632. axisControlRotation: boolean;
  103633. /**
  103634. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103635. * relation to mouseWheel events.
  103636. */
  103637. wheelPrecision: number;
  103638. /**
  103639. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103640. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103641. */
  103642. wheelDeltaPercentage: number;
  103643. private _wheel;
  103644. private _observer;
  103645. /**
  103646. * Attach the input controls to a specific dom element to get the input from.
  103647. * @param element Defines the element the controls should be listened from
  103648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103649. */
  103650. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103651. /**
  103652. * Detach the current controls from the specified dom element.
  103653. * @param element Defines the element to stop listening the inputs from
  103654. */
  103655. detachControl(element: Nullable<HTMLElement>): void;
  103656. /**
  103657. * Gets the class name of the current intput.
  103658. * @returns the class name
  103659. */
  103660. getClassName(): string;
  103661. /**
  103662. * Get the friendly name associated with the input class.
  103663. * @returns the input friendly name
  103664. */
  103665. getSimpleName(): string;
  103666. }
  103667. }
  103668. declare module BABYLON {
  103669. /**
  103670. * Manage the pointers inputs to control an follow camera.
  103671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103672. */
  103673. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103674. /**
  103675. * Defines the camera the input is attached to.
  103676. */
  103677. camera: FollowCamera;
  103678. /**
  103679. * Gets the class name of the current input.
  103680. * @returns the class name
  103681. */
  103682. getClassName(): string;
  103683. /**
  103684. * Defines the pointer angular sensibility along the X axis or how fast is
  103685. * the camera rotating.
  103686. * A negative number will reverse the axis direction.
  103687. */
  103688. angularSensibilityX: number;
  103689. /**
  103690. * Defines the pointer angular sensibility along the Y axis or how fast is
  103691. * the camera rotating.
  103692. * A negative number will reverse the axis direction.
  103693. */
  103694. angularSensibilityY: number;
  103695. /**
  103696. * Defines the pointer pinch precision or how fast is the camera zooming.
  103697. * A negative number will reverse the axis direction.
  103698. */
  103699. pinchPrecision: number;
  103700. /**
  103701. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103702. * from 0.
  103703. * It defines the percentage of current camera.radius to use as delta when
  103704. * pinch zoom is used.
  103705. */
  103706. pinchDeltaPercentage: number;
  103707. /**
  103708. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103709. */
  103710. axisXControlRadius: boolean;
  103711. /**
  103712. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103713. */
  103714. axisXControlHeight: boolean;
  103715. /**
  103716. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103717. */
  103718. axisXControlRotation: boolean;
  103719. /**
  103720. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103721. */
  103722. axisYControlRadius: boolean;
  103723. /**
  103724. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103725. */
  103726. axisYControlHeight: boolean;
  103727. /**
  103728. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103729. */
  103730. axisYControlRotation: boolean;
  103731. /**
  103732. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103733. */
  103734. axisPinchControlRadius: boolean;
  103735. /**
  103736. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103737. */
  103738. axisPinchControlHeight: boolean;
  103739. /**
  103740. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103741. */
  103742. axisPinchControlRotation: boolean;
  103743. /**
  103744. * Log error messages if basic misconfiguration has occurred.
  103745. */
  103746. warningEnable: boolean;
  103747. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103748. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103749. private _warningCounter;
  103750. private _warning;
  103751. }
  103752. }
  103753. declare module BABYLON {
  103754. /**
  103755. * Default Inputs manager for the FollowCamera.
  103756. * It groups all the default supported inputs for ease of use.
  103757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103758. */
  103759. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103760. /**
  103761. * Instantiates a new FollowCameraInputsManager.
  103762. * @param camera Defines the camera the inputs belong to
  103763. */
  103764. constructor(camera: FollowCamera);
  103765. /**
  103766. * Add keyboard input support to the input manager.
  103767. * @returns the current input manager
  103768. */
  103769. addKeyboard(): FollowCameraInputsManager;
  103770. /**
  103771. * Add mouse wheel input support to the input manager.
  103772. * @returns the current input manager
  103773. */
  103774. addMouseWheel(): FollowCameraInputsManager;
  103775. /**
  103776. * Add pointers input support to the input manager.
  103777. * @returns the current input manager
  103778. */
  103779. addPointers(): FollowCameraInputsManager;
  103780. /**
  103781. * Add orientation input support to the input manager.
  103782. * @returns the current input manager
  103783. */
  103784. addVRDeviceOrientation(): FollowCameraInputsManager;
  103785. }
  103786. }
  103787. declare module BABYLON {
  103788. /**
  103789. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103790. * an arc rotate version arcFollowCamera are available.
  103791. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103792. */
  103793. export class FollowCamera extends TargetCamera {
  103794. /**
  103795. * Distance the follow camera should follow an object at
  103796. */
  103797. radius: number;
  103798. /**
  103799. * Minimum allowed distance of the camera to the axis of rotation
  103800. * (The camera can not get closer).
  103801. * This can help limiting how the Camera is able to move in the scene.
  103802. */
  103803. lowerRadiusLimit: Nullable<number>;
  103804. /**
  103805. * Maximum allowed distance of the camera to the axis of rotation
  103806. * (The camera can not get further).
  103807. * This can help limiting how the Camera is able to move in the scene.
  103808. */
  103809. upperRadiusLimit: Nullable<number>;
  103810. /**
  103811. * Define a rotation offset between the camera and the object it follows
  103812. */
  103813. rotationOffset: number;
  103814. /**
  103815. * Minimum allowed angle to camera position relative to target object.
  103816. * This can help limiting how the Camera is able to move in the scene.
  103817. */
  103818. lowerRotationOffsetLimit: Nullable<number>;
  103819. /**
  103820. * Maximum allowed angle to camera position relative to target object.
  103821. * This can help limiting how the Camera is able to move in the scene.
  103822. */
  103823. upperRotationOffsetLimit: Nullable<number>;
  103824. /**
  103825. * Define a height offset between the camera and the object it follows.
  103826. * It can help following an object from the top (like a car chaing a plane)
  103827. */
  103828. heightOffset: number;
  103829. /**
  103830. * Minimum allowed height of camera position relative to target object.
  103831. * This can help limiting how the Camera is able to move in the scene.
  103832. */
  103833. lowerHeightOffsetLimit: Nullable<number>;
  103834. /**
  103835. * Maximum allowed height of camera position relative to target object.
  103836. * This can help limiting how the Camera is able to move in the scene.
  103837. */
  103838. upperHeightOffsetLimit: Nullable<number>;
  103839. /**
  103840. * Define how fast the camera can accelerate to follow it s target.
  103841. */
  103842. cameraAcceleration: number;
  103843. /**
  103844. * Define the speed limit of the camera following an object.
  103845. */
  103846. maxCameraSpeed: number;
  103847. /**
  103848. * Define the target of the camera.
  103849. */
  103850. lockedTarget: Nullable<AbstractMesh>;
  103851. /**
  103852. * Defines the input associated with the camera.
  103853. */
  103854. inputs: FollowCameraInputsManager;
  103855. /**
  103856. * Instantiates the follow camera.
  103857. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103858. * @param name Define the name of the camera in the scene
  103859. * @param position Define the position of the camera
  103860. * @param scene Define the scene the camera belong to
  103861. * @param lockedTarget Define the target of the camera
  103862. */
  103863. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103864. private _follow;
  103865. /**
  103866. * Attached controls to the current camera.
  103867. * @param element Defines the element the controls should be listened from
  103868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103869. */
  103870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103871. /**
  103872. * Detach the current controls from the camera.
  103873. * The camera will stop reacting to inputs.
  103874. * @param element Defines the element to stop listening the inputs from
  103875. */
  103876. detachControl(element: HTMLElement): void;
  103877. /** @hidden */
  103878. _checkInputs(): void;
  103879. private _checkLimits;
  103880. /**
  103881. * Gets the camera class name.
  103882. * @returns the class name
  103883. */
  103884. getClassName(): string;
  103885. }
  103886. /**
  103887. * Arc Rotate version of the follow camera.
  103888. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103889. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103890. */
  103891. export class ArcFollowCamera extends TargetCamera {
  103892. /** The longitudinal angle of the camera */
  103893. alpha: number;
  103894. /** The latitudinal angle of the camera */
  103895. beta: number;
  103896. /** The radius of the camera from its target */
  103897. radius: number;
  103898. /** Define the camera target (the messh it should follow) */
  103899. target: Nullable<AbstractMesh>;
  103900. private _cartesianCoordinates;
  103901. /**
  103902. * Instantiates a new ArcFollowCamera
  103903. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103904. * @param name Define the name of the camera
  103905. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103906. * @param beta Define the rotation angle of the camera around the elevation axis
  103907. * @param radius Define the radius of the camera from its target point
  103908. * @param target Define the target of the camera
  103909. * @param scene Define the scene the camera belongs to
  103910. */
  103911. constructor(name: string,
  103912. /** The longitudinal angle of the camera */
  103913. alpha: number,
  103914. /** The latitudinal angle of the camera */
  103915. beta: number,
  103916. /** The radius of the camera from its target */
  103917. radius: number,
  103918. /** Define the camera target (the messh it should follow) */
  103919. target: Nullable<AbstractMesh>, scene: Scene);
  103920. private _follow;
  103921. /** @hidden */
  103922. _checkInputs(): void;
  103923. /**
  103924. * Returns the class name of the object.
  103925. * It is mostly used internally for serialization purposes.
  103926. */
  103927. getClassName(): string;
  103928. }
  103929. }
  103930. declare module BABYLON {
  103931. /**
  103932. * Manage the keyboard inputs to control the movement of a follow camera.
  103933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103934. */
  103935. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103936. /**
  103937. * Defines the camera the input is attached to.
  103938. */
  103939. camera: FollowCamera;
  103940. /**
  103941. * Defines the list of key codes associated with the up action (increase heightOffset)
  103942. */
  103943. keysHeightOffsetIncr: number[];
  103944. /**
  103945. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103946. */
  103947. keysHeightOffsetDecr: number[];
  103948. /**
  103949. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103950. */
  103951. keysHeightOffsetModifierAlt: boolean;
  103952. /**
  103953. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103954. */
  103955. keysHeightOffsetModifierCtrl: boolean;
  103956. /**
  103957. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103958. */
  103959. keysHeightOffsetModifierShift: boolean;
  103960. /**
  103961. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103962. */
  103963. keysRotationOffsetIncr: number[];
  103964. /**
  103965. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103966. */
  103967. keysRotationOffsetDecr: number[];
  103968. /**
  103969. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103970. */
  103971. keysRotationOffsetModifierAlt: boolean;
  103972. /**
  103973. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103974. */
  103975. keysRotationOffsetModifierCtrl: boolean;
  103976. /**
  103977. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103978. */
  103979. keysRotationOffsetModifierShift: boolean;
  103980. /**
  103981. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103982. */
  103983. keysRadiusIncr: number[];
  103984. /**
  103985. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103986. */
  103987. keysRadiusDecr: number[];
  103988. /**
  103989. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103990. */
  103991. keysRadiusModifierAlt: boolean;
  103992. /**
  103993. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103994. */
  103995. keysRadiusModifierCtrl: boolean;
  103996. /**
  103997. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103998. */
  103999. keysRadiusModifierShift: boolean;
  104000. /**
  104001. * Defines the rate of change of heightOffset.
  104002. */
  104003. heightSensibility: number;
  104004. /**
  104005. * Defines the rate of change of rotationOffset.
  104006. */
  104007. rotationSensibility: number;
  104008. /**
  104009. * Defines the rate of change of radius.
  104010. */
  104011. radiusSensibility: number;
  104012. private _keys;
  104013. private _ctrlPressed;
  104014. private _altPressed;
  104015. private _shiftPressed;
  104016. private _onCanvasBlurObserver;
  104017. private _onKeyboardObserver;
  104018. private _engine;
  104019. private _scene;
  104020. /**
  104021. * Attach the input controls to a specific dom element to get the input from.
  104022. * @param element Defines the element the controls should be listened from
  104023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104024. */
  104025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104026. /**
  104027. * Detach the current controls from the specified dom element.
  104028. * @param element Defines the element to stop listening the inputs from
  104029. */
  104030. detachControl(element: Nullable<HTMLElement>): void;
  104031. /**
  104032. * Update the current camera state depending on the inputs that have been used this frame.
  104033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104034. */
  104035. checkInputs(): void;
  104036. /**
  104037. * Gets the class name of the current input.
  104038. * @returns the class name
  104039. */
  104040. getClassName(): string;
  104041. /**
  104042. * Get the friendly name associated with the input class.
  104043. * @returns the input friendly name
  104044. */
  104045. getSimpleName(): string;
  104046. /**
  104047. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104048. * allow modification of the heightOffset value.
  104049. */
  104050. private _modifierHeightOffset;
  104051. /**
  104052. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104053. * allow modification of the rotationOffset value.
  104054. */
  104055. private _modifierRotationOffset;
  104056. /**
  104057. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104058. * allow modification of the radius value.
  104059. */
  104060. private _modifierRadius;
  104061. }
  104062. }
  104063. declare module BABYLON {
  104064. interface FreeCameraInputsManager {
  104065. /**
  104066. * @hidden
  104067. */
  104068. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104069. /**
  104070. * Add orientation input support to the input manager.
  104071. * @returns the current input manager
  104072. */
  104073. addDeviceOrientation(): FreeCameraInputsManager;
  104074. }
  104075. /**
  104076. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104077. * Screen rotation is taken into account.
  104078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104079. */
  104080. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104081. private _camera;
  104082. private _screenOrientationAngle;
  104083. private _constantTranform;
  104084. private _screenQuaternion;
  104085. private _alpha;
  104086. private _beta;
  104087. private _gamma;
  104088. /**
  104089. * Can be used to detect if a device orientation sensor is availible on a device
  104090. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104091. * @returns a promise that will resolve on orientation change
  104092. */
  104093. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104094. /**
  104095. * @hidden
  104096. */
  104097. _onDeviceOrientationChangedObservable: Observable<void>;
  104098. /**
  104099. * Instantiates a new input
  104100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104101. */
  104102. constructor();
  104103. /**
  104104. * Define the camera controlled by the input.
  104105. */
  104106. camera: FreeCamera;
  104107. /**
  104108. * Attach the input controls to a specific dom element to get the input from.
  104109. * @param element Defines the element the controls should be listened from
  104110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104111. */
  104112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104113. private _orientationChanged;
  104114. private _deviceOrientation;
  104115. /**
  104116. * Detach the current controls from the specified dom element.
  104117. * @param element Defines the element to stop listening the inputs from
  104118. */
  104119. detachControl(element: Nullable<HTMLElement>): void;
  104120. /**
  104121. * Update the current camera state depending on the inputs that have been used this frame.
  104122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104123. */
  104124. checkInputs(): void;
  104125. /**
  104126. * Gets the class name of the current intput.
  104127. * @returns the class name
  104128. */
  104129. getClassName(): string;
  104130. /**
  104131. * Get the friendly name associated with the input class.
  104132. * @returns the input friendly name
  104133. */
  104134. getSimpleName(): string;
  104135. }
  104136. }
  104137. declare module BABYLON {
  104138. /**
  104139. * Manage the gamepad inputs to control a free camera.
  104140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104141. */
  104142. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104143. /**
  104144. * Define the camera the input is attached to.
  104145. */
  104146. camera: FreeCamera;
  104147. /**
  104148. * Define the Gamepad controlling the input
  104149. */
  104150. gamepad: Nullable<Gamepad>;
  104151. /**
  104152. * Defines the gamepad rotation sensiblity.
  104153. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104154. */
  104155. gamepadAngularSensibility: number;
  104156. /**
  104157. * Defines the gamepad move sensiblity.
  104158. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104159. */
  104160. gamepadMoveSensibility: number;
  104161. private _onGamepadConnectedObserver;
  104162. private _onGamepadDisconnectedObserver;
  104163. private _cameraTransform;
  104164. private _deltaTransform;
  104165. private _vector3;
  104166. private _vector2;
  104167. /**
  104168. * Attach the input controls to a specific dom element to get the input from.
  104169. * @param element Defines the element the controls should be listened from
  104170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104171. */
  104172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104173. /**
  104174. * Detach the current controls from the specified dom element.
  104175. * @param element Defines the element to stop listening the inputs from
  104176. */
  104177. detachControl(element: Nullable<HTMLElement>): void;
  104178. /**
  104179. * Update the current camera state depending on the inputs that have been used this frame.
  104180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104181. */
  104182. checkInputs(): void;
  104183. /**
  104184. * Gets the class name of the current intput.
  104185. * @returns the class name
  104186. */
  104187. getClassName(): string;
  104188. /**
  104189. * Get the friendly name associated with the input class.
  104190. * @returns the input friendly name
  104191. */
  104192. getSimpleName(): string;
  104193. }
  104194. }
  104195. declare module BABYLON {
  104196. /**
  104197. * Defines the potential axis of a Joystick
  104198. */
  104199. export enum JoystickAxis {
  104200. /** X axis */
  104201. X = 0,
  104202. /** Y axis */
  104203. Y = 1,
  104204. /** Z axis */
  104205. Z = 2
  104206. }
  104207. /**
  104208. * Class used to define virtual joystick (used in touch mode)
  104209. */
  104210. export class VirtualJoystick {
  104211. /**
  104212. * Gets or sets a boolean indicating that left and right values must be inverted
  104213. */
  104214. reverseLeftRight: boolean;
  104215. /**
  104216. * Gets or sets a boolean indicating that up and down values must be inverted
  104217. */
  104218. reverseUpDown: boolean;
  104219. /**
  104220. * Gets the offset value for the position (ie. the change of the position value)
  104221. */
  104222. deltaPosition: Vector3;
  104223. /**
  104224. * Gets a boolean indicating if the virtual joystick was pressed
  104225. */
  104226. pressed: boolean;
  104227. /**
  104228. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104229. */
  104230. static Canvas: Nullable<HTMLCanvasElement>;
  104231. private static _globalJoystickIndex;
  104232. private static vjCanvasContext;
  104233. private static vjCanvasWidth;
  104234. private static vjCanvasHeight;
  104235. private static halfWidth;
  104236. private _action;
  104237. private _axisTargetedByLeftAndRight;
  104238. private _axisTargetedByUpAndDown;
  104239. private _joystickSensibility;
  104240. private _inversedSensibility;
  104241. private _joystickPointerID;
  104242. private _joystickColor;
  104243. private _joystickPointerPos;
  104244. private _joystickPreviousPointerPos;
  104245. private _joystickPointerStartPos;
  104246. private _deltaJoystickVector;
  104247. private _leftJoystick;
  104248. private _touches;
  104249. private _onPointerDownHandlerRef;
  104250. private _onPointerMoveHandlerRef;
  104251. private _onPointerUpHandlerRef;
  104252. private _onResize;
  104253. /**
  104254. * Creates a new virtual joystick
  104255. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104256. */
  104257. constructor(leftJoystick?: boolean);
  104258. /**
  104259. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104260. * @param newJoystickSensibility defines the new sensibility
  104261. */
  104262. setJoystickSensibility(newJoystickSensibility: number): void;
  104263. private _onPointerDown;
  104264. private _onPointerMove;
  104265. private _onPointerUp;
  104266. /**
  104267. * Change the color of the virtual joystick
  104268. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104269. */
  104270. setJoystickColor(newColor: string): void;
  104271. /**
  104272. * Defines a callback to call when the joystick is touched
  104273. * @param action defines the callback
  104274. */
  104275. setActionOnTouch(action: () => any): void;
  104276. /**
  104277. * Defines which axis you'd like to control for left & right
  104278. * @param axis defines the axis to use
  104279. */
  104280. setAxisForLeftRight(axis: JoystickAxis): void;
  104281. /**
  104282. * Defines which axis you'd like to control for up & down
  104283. * @param axis defines the axis to use
  104284. */
  104285. setAxisForUpDown(axis: JoystickAxis): void;
  104286. private _drawVirtualJoystick;
  104287. /**
  104288. * Release internal HTML canvas
  104289. */
  104290. releaseCanvas(): void;
  104291. }
  104292. }
  104293. declare module BABYLON {
  104294. interface FreeCameraInputsManager {
  104295. /**
  104296. * Add virtual joystick input support to the input manager.
  104297. * @returns the current input manager
  104298. */
  104299. addVirtualJoystick(): FreeCameraInputsManager;
  104300. }
  104301. /**
  104302. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104304. */
  104305. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104306. /**
  104307. * Defines the camera the input is attached to.
  104308. */
  104309. camera: FreeCamera;
  104310. private _leftjoystick;
  104311. private _rightjoystick;
  104312. /**
  104313. * Gets the left stick of the virtual joystick.
  104314. * @returns The virtual Joystick
  104315. */
  104316. getLeftJoystick(): VirtualJoystick;
  104317. /**
  104318. * Gets the right stick of the virtual joystick.
  104319. * @returns The virtual Joystick
  104320. */
  104321. getRightJoystick(): VirtualJoystick;
  104322. /**
  104323. * Update the current camera state depending on the inputs that have been used this frame.
  104324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104325. */
  104326. checkInputs(): void;
  104327. /**
  104328. * Attach the input controls to a specific dom element to get the input from.
  104329. * @param element Defines the element the controls should be listened from
  104330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104331. */
  104332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104333. /**
  104334. * Detach the current controls from the specified dom element.
  104335. * @param element Defines the element to stop listening the inputs from
  104336. */
  104337. detachControl(element: Nullable<HTMLElement>): void;
  104338. /**
  104339. * Gets the class name of the current intput.
  104340. * @returns the class name
  104341. */
  104342. getClassName(): string;
  104343. /**
  104344. * Get the friendly name associated with the input class.
  104345. * @returns the input friendly name
  104346. */
  104347. getSimpleName(): string;
  104348. }
  104349. }
  104350. declare module BABYLON {
  104351. /**
  104352. * This represents a FPS type of camera controlled by touch.
  104353. * This is like a universal camera minus the Gamepad controls.
  104354. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104355. */
  104356. export class TouchCamera extends FreeCamera {
  104357. /**
  104358. * Defines the touch sensibility for rotation.
  104359. * The higher the faster.
  104360. */
  104361. touchAngularSensibility: number;
  104362. /**
  104363. * Defines the touch sensibility for move.
  104364. * The higher the faster.
  104365. */
  104366. touchMoveSensibility: number;
  104367. /**
  104368. * Instantiates a new touch camera.
  104369. * This represents a FPS type of camera controlled by touch.
  104370. * This is like a universal camera minus the Gamepad controls.
  104371. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104372. * @param name Define the name of the camera in the scene
  104373. * @param position Define the start position of the camera in the scene
  104374. * @param scene Define the scene the camera belongs to
  104375. */
  104376. constructor(name: string, position: Vector3, scene: Scene);
  104377. /**
  104378. * Gets the current object class name.
  104379. * @return the class name
  104380. */
  104381. getClassName(): string;
  104382. /** @hidden */
  104383. _setupInputs(): void;
  104384. }
  104385. }
  104386. declare module BABYLON {
  104387. /**
  104388. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104389. * being tilted forward or back and left or right.
  104390. */
  104391. export class DeviceOrientationCamera extends FreeCamera {
  104392. private _initialQuaternion;
  104393. private _quaternionCache;
  104394. private _tmpDragQuaternion;
  104395. private _disablePointerInputWhenUsingDeviceOrientation;
  104396. /**
  104397. * Creates a new device orientation camera
  104398. * @param name The name of the camera
  104399. * @param position The start position camera
  104400. * @param scene The scene the camera belongs to
  104401. */
  104402. constructor(name: string, position: Vector3, scene: Scene);
  104403. /**
  104404. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104405. */
  104406. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104407. private _dragFactor;
  104408. /**
  104409. * Enabled turning on the y axis when the orientation sensor is active
  104410. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104411. */
  104412. enableHorizontalDragging(dragFactor?: number): void;
  104413. /**
  104414. * Gets the current instance class name ("DeviceOrientationCamera").
  104415. * This helps avoiding instanceof at run time.
  104416. * @returns the class name
  104417. */
  104418. getClassName(): string;
  104419. /**
  104420. * @hidden
  104421. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104422. */
  104423. _checkInputs(): void;
  104424. /**
  104425. * Reset the camera to its default orientation on the specified axis only.
  104426. * @param axis The axis to reset
  104427. */
  104428. resetToCurrentRotation(axis?: Axis): void;
  104429. }
  104430. }
  104431. declare module BABYLON {
  104432. /**
  104433. * Defines supported buttons for XBox360 compatible gamepads
  104434. */
  104435. export enum Xbox360Button {
  104436. /** A */
  104437. A = 0,
  104438. /** B */
  104439. B = 1,
  104440. /** X */
  104441. X = 2,
  104442. /** Y */
  104443. Y = 3,
  104444. /** Start */
  104445. Start = 4,
  104446. /** Back */
  104447. Back = 5,
  104448. /** Left button */
  104449. LB = 6,
  104450. /** Right button */
  104451. RB = 7,
  104452. /** Left stick */
  104453. LeftStick = 8,
  104454. /** Right stick */
  104455. RightStick = 9
  104456. }
  104457. /** Defines values for XBox360 DPad */
  104458. export enum Xbox360Dpad {
  104459. /** Up */
  104460. Up = 0,
  104461. /** Down */
  104462. Down = 1,
  104463. /** Left */
  104464. Left = 2,
  104465. /** Right */
  104466. Right = 3
  104467. }
  104468. /**
  104469. * Defines a XBox360 gamepad
  104470. */
  104471. export class Xbox360Pad extends Gamepad {
  104472. private _leftTrigger;
  104473. private _rightTrigger;
  104474. private _onlefttriggerchanged;
  104475. private _onrighttriggerchanged;
  104476. private _onbuttondown;
  104477. private _onbuttonup;
  104478. private _ondpaddown;
  104479. private _ondpadup;
  104480. /** Observable raised when a button is pressed */
  104481. onButtonDownObservable: Observable<Xbox360Button>;
  104482. /** Observable raised when a button is released */
  104483. onButtonUpObservable: Observable<Xbox360Button>;
  104484. /** Observable raised when a pad is pressed */
  104485. onPadDownObservable: Observable<Xbox360Dpad>;
  104486. /** Observable raised when a pad is released */
  104487. onPadUpObservable: Observable<Xbox360Dpad>;
  104488. private _buttonA;
  104489. private _buttonB;
  104490. private _buttonX;
  104491. private _buttonY;
  104492. private _buttonBack;
  104493. private _buttonStart;
  104494. private _buttonLB;
  104495. private _buttonRB;
  104496. private _buttonLeftStick;
  104497. private _buttonRightStick;
  104498. private _dPadUp;
  104499. private _dPadDown;
  104500. private _dPadLeft;
  104501. private _dPadRight;
  104502. private _isXboxOnePad;
  104503. /**
  104504. * Creates a new XBox360 gamepad object
  104505. * @param id defines the id of this gamepad
  104506. * @param index defines its index
  104507. * @param gamepad defines the internal HTML gamepad object
  104508. * @param xboxOne defines if it is a XBox One gamepad
  104509. */
  104510. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104511. /**
  104512. * Defines the callback to call when left trigger is pressed
  104513. * @param callback defines the callback to use
  104514. */
  104515. onlefttriggerchanged(callback: (value: number) => void): void;
  104516. /**
  104517. * Defines the callback to call when right trigger is pressed
  104518. * @param callback defines the callback to use
  104519. */
  104520. onrighttriggerchanged(callback: (value: number) => void): void;
  104521. /**
  104522. * Gets the left trigger value
  104523. */
  104524. /**
  104525. * Sets the left trigger value
  104526. */
  104527. leftTrigger: number;
  104528. /**
  104529. * Gets the right trigger value
  104530. */
  104531. /**
  104532. * Sets the right trigger value
  104533. */
  104534. rightTrigger: number;
  104535. /**
  104536. * Defines the callback to call when a button is pressed
  104537. * @param callback defines the callback to use
  104538. */
  104539. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104540. /**
  104541. * Defines the callback to call when a button is released
  104542. * @param callback defines the callback to use
  104543. */
  104544. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104545. /**
  104546. * Defines the callback to call when a pad is pressed
  104547. * @param callback defines the callback to use
  104548. */
  104549. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104550. /**
  104551. * Defines the callback to call when a pad is released
  104552. * @param callback defines the callback to use
  104553. */
  104554. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104555. private _setButtonValue;
  104556. private _setDPadValue;
  104557. /**
  104558. * Gets the value of the `A` button
  104559. */
  104560. /**
  104561. * Sets the value of the `A` button
  104562. */
  104563. buttonA: number;
  104564. /**
  104565. * Gets the value of the `B` button
  104566. */
  104567. /**
  104568. * Sets the value of the `B` button
  104569. */
  104570. buttonB: number;
  104571. /**
  104572. * Gets the value of the `X` button
  104573. */
  104574. /**
  104575. * Sets the value of the `X` button
  104576. */
  104577. buttonX: number;
  104578. /**
  104579. * Gets the value of the `Y` button
  104580. */
  104581. /**
  104582. * Sets the value of the `Y` button
  104583. */
  104584. buttonY: number;
  104585. /**
  104586. * Gets the value of the `Start` button
  104587. */
  104588. /**
  104589. * Sets the value of the `Start` button
  104590. */
  104591. buttonStart: number;
  104592. /**
  104593. * Gets the value of the `Back` button
  104594. */
  104595. /**
  104596. * Sets the value of the `Back` button
  104597. */
  104598. buttonBack: number;
  104599. /**
  104600. * Gets the value of the `Left` button
  104601. */
  104602. /**
  104603. * Sets the value of the `Left` button
  104604. */
  104605. buttonLB: number;
  104606. /**
  104607. * Gets the value of the `Right` button
  104608. */
  104609. /**
  104610. * Sets the value of the `Right` button
  104611. */
  104612. buttonRB: number;
  104613. /**
  104614. * Gets the value of the Left joystick
  104615. */
  104616. /**
  104617. * Sets the value of the Left joystick
  104618. */
  104619. buttonLeftStick: number;
  104620. /**
  104621. * Gets the value of the Right joystick
  104622. */
  104623. /**
  104624. * Sets the value of the Right joystick
  104625. */
  104626. buttonRightStick: number;
  104627. /**
  104628. * Gets the value of D-pad up
  104629. */
  104630. /**
  104631. * Sets the value of D-pad up
  104632. */
  104633. dPadUp: number;
  104634. /**
  104635. * Gets the value of D-pad down
  104636. */
  104637. /**
  104638. * Sets the value of D-pad down
  104639. */
  104640. dPadDown: number;
  104641. /**
  104642. * Gets the value of D-pad left
  104643. */
  104644. /**
  104645. * Sets the value of D-pad left
  104646. */
  104647. dPadLeft: number;
  104648. /**
  104649. * Gets the value of D-pad right
  104650. */
  104651. /**
  104652. * Sets the value of D-pad right
  104653. */
  104654. dPadRight: number;
  104655. /**
  104656. * Force the gamepad to synchronize with device values
  104657. */
  104658. update(): void;
  104659. /**
  104660. * Disposes the gamepad
  104661. */
  104662. dispose(): void;
  104663. }
  104664. }
  104665. declare module BABYLON {
  104666. /**
  104667. * Defines supported buttons for DualShock compatible gamepads
  104668. */
  104669. export enum DualShockButton {
  104670. /** Cross */
  104671. Cross = 0,
  104672. /** Circle */
  104673. Circle = 1,
  104674. /** Square */
  104675. Square = 2,
  104676. /** Triangle */
  104677. Triangle = 3,
  104678. /** Options */
  104679. Options = 4,
  104680. /** Share */
  104681. Share = 5,
  104682. /** L1 */
  104683. L1 = 6,
  104684. /** R1 */
  104685. R1 = 7,
  104686. /** Left stick */
  104687. LeftStick = 8,
  104688. /** Right stick */
  104689. RightStick = 9
  104690. }
  104691. /** Defines values for DualShock DPad */
  104692. export enum DualShockDpad {
  104693. /** Up */
  104694. Up = 0,
  104695. /** Down */
  104696. Down = 1,
  104697. /** Left */
  104698. Left = 2,
  104699. /** Right */
  104700. Right = 3
  104701. }
  104702. /**
  104703. * Defines a DualShock gamepad
  104704. */
  104705. export class DualShockPad extends Gamepad {
  104706. private _leftTrigger;
  104707. private _rightTrigger;
  104708. private _onlefttriggerchanged;
  104709. private _onrighttriggerchanged;
  104710. private _onbuttondown;
  104711. private _onbuttonup;
  104712. private _ondpaddown;
  104713. private _ondpadup;
  104714. /** Observable raised when a button is pressed */
  104715. onButtonDownObservable: Observable<DualShockButton>;
  104716. /** Observable raised when a button is released */
  104717. onButtonUpObservable: Observable<DualShockButton>;
  104718. /** Observable raised when a pad is pressed */
  104719. onPadDownObservable: Observable<DualShockDpad>;
  104720. /** Observable raised when a pad is released */
  104721. onPadUpObservable: Observable<DualShockDpad>;
  104722. private _buttonCross;
  104723. private _buttonCircle;
  104724. private _buttonSquare;
  104725. private _buttonTriangle;
  104726. private _buttonShare;
  104727. private _buttonOptions;
  104728. private _buttonL1;
  104729. private _buttonR1;
  104730. private _buttonLeftStick;
  104731. private _buttonRightStick;
  104732. private _dPadUp;
  104733. private _dPadDown;
  104734. private _dPadLeft;
  104735. private _dPadRight;
  104736. /**
  104737. * Creates a new DualShock gamepad object
  104738. * @param id defines the id of this gamepad
  104739. * @param index defines its index
  104740. * @param gamepad defines the internal HTML gamepad object
  104741. */
  104742. constructor(id: string, index: number, gamepad: any);
  104743. /**
  104744. * Defines the callback to call when left trigger is pressed
  104745. * @param callback defines the callback to use
  104746. */
  104747. onlefttriggerchanged(callback: (value: number) => void): void;
  104748. /**
  104749. * Defines the callback to call when right trigger is pressed
  104750. * @param callback defines the callback to use
  104751. */
  104752. onrighttriggerchanged(callback: (value: number) => void): void;
  104753. /**
  104754. * Gets the left trigger value
  104755. */
  104756. /**
  104757. * Sets the left trigger value
  104758. */
  104759. leftTrigger: number;
  104760. /**
  104761. * Gets the right trigger value
  104762. */
  104763. /**
  104764. * Sets the right trigger value
  104765. */
  104766. rightTrigger: number;
  104767. /**
  104768. * Defines the callback to call when a button is pressed
  104769. * @param callback defines the callback to use
  104770. */
  104771. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104772. /**
  104773. * Defines the callback to call when a button is released
  104774. * @param callback defines the callback to use
  104775. */
  104776. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104777. /**
  104778. * Defines the callback to call when a pad is pressed
  104779. * @param callback defines the callback to use
  104780. */
  104781. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104782. /**
  104783. * Defines the callback to call when a pad is released
  104784. * @param callback defines the callback to use
  104785. */
  104786. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104787. private _setButtonValue;
  104788. private _setDPadValue;
  104789. /**
  104790. * Gets the value of the `Cross` button
  104791. */
  104792. /**
  104793. * Sets the value of the `Cross` button
  104794. */
  104795. buttonCross: number;
  104796. /**
  104797. * Gets the value of the `Circle` button
  104798. */
  104799. /**
  104800. * Sets the value of the `Circle` button
  104801. */
  104802. buttonCircle: number;
  104803. /**
  104804. * Gets the value of the `Square` button
  104805. */
  104806. /**
  104807. * Sets the value of the `Square` button
  104808. */
  104809. buttonSquare: number;
  104810. /**
  104811. * Gets the value of the `Triangle` button
  104812. */
  104813. /**
  104814. * Sets the value of the `Triangle` button
  104815. */
  104816. buttonTriangle: number;
  104817. /**
  104818. * Gets the value of the `Options` button
  104819. */
  104820. /**
  104821. * Sets the value of the `Options` button
  104822. */
  104823. buttonOptions: number;
  104824. /**
  104825. * Gets the value of the `Share` button
  104826. */
  104827. /**
  104828. * Sets the value of the `Share` button
  104829. */
  104830. buttonShare: number;
  104831. /**
  104832. * Gets the value of the `L1` button
  104833. */
  104834. /**
  104835. * Sets the value of the `L1` button
  104836. */
  104837. buttonL1: number;
  104838. /**
  104839. * Gets the value of the `R1` button
  104840. */
  104841. /**
  104842. * Sets the value of the `R1` button
  104843. */
  104844. buttonR1: number;
  104845. /**
  104846. * Gets the value of the Left joystick
  104847. */
  104848. /**
  104849. * Sets the value of the Left joystick
  104850. */
  104851. buttonLeftStick: number;
  104852. /**
  104853. * Gets the value of the Right joystick
  104854. */
  104855. /**
  104856. * Sets the value of the Right joystick
  104857. */
  104858. buttonRightStick: number;
  104859. /**
  104860. * Gets the value of D-pad up
  104861. */
  104862. /**
  104863. * Sets the value of D-pad up
  104864. */
  104865. dPadUp: number;
  104866. /**
  104867. * Gets the value of D-pad down
  104868. */
  104869. /**
  104870. * Sets the value of D-pad down
  104871. */
  104872. dPadDown: number;
  104873. /**
  104874. * Gets the value of D-pad left
  104875. */
  104876. /**
  104877. * Sets the value of D-pad left
  104878. */
  104879. dPadLeft: number;
  104880. /**
  104881. * Gets the value of D-pad right
  104882. */
  104883. /**
  104884. * Sets the value of D-pad right
  104885. */
  104886. dPadRight: number;
  104887. /**
  104888. * Force the gamepad to synchronize with device values
  104889. */
  104890. update(): void;
  104891. /**
  104892. * Disposes the gamepad
  104893. */
  104894. dispose(): void;
  104895. }
  104896. }
  104897. declare module BABYLON {
  104898. /**
  104899. * Manager for handling gamepads
  104900. */
  104901. export class GamepadManager {
  104902. private _scene?;
  104903. private _babylonGamepads;
  104904. private _oneGamepadConnected;
  104905. /** @hidden */
  104906. _isMonitoring: boolean;
  104907. private _gamepadEventSupported;
  104908. private _gamepadSupport;
  104909. /**
  104910. * observable to be triggered when the gamepad controller has been connected
  104911. */
  104912. onGamepadConnectedObservable: Observable<Gamepad>;
  104913. /**
  104914. * observable to be triggered when the gamepad controller has been disconnected
  104915. */
  104916. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104917. private _onGamepadConnectedEvent;
  104918. private _onGamepadDisconnectedEvent;
  104919. /**
  104920. * Initializes the gamepad manager
  104921. * @param _scene BabylonJS scene
  104922. */
  104923. constructor(_scene?: Scene | undefined);
  104924. /**
  104925. * The gamepads in the game pad manager
  104926. */
  104927. readonly gamepads: Gamepad[];
  104928. /**
  104929. * Get the gamepad controllers based on type
  104930. * @param type The type of gamepad controller
  104931. * @returns Nullable gamepad
  104932. */
  104933. getGamepadByType(type?: number): Nullable<Gamepad>;
  104934. /**
  104935. * Disposes the gamepad manager
  104936. */
  104937. dispose(): void;
  104938. private _addNewGamepad;
  104939. private _startMonitoringGamepads;
  104940. private _stopMonitoringGamepads;
  104941. /** @hidden */
  104942. _checkGamepadsStatus(): void;
  104943. private _updateGamepadObjects;
  104944. }
  104945. }
  104946. declare module BABYLON {
  104947. interface Scene {
  104948. /** @hidden */
  104949. _gamepadManager: Nullable<GamepadManager>;
  104950. /**
  104951. * Gets the gamepad manager associated with the scene
  104952. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104953. */
  104954. gamepadManager: GamepadManager;
  104955. }
  104956. /**
  104957. * Interface representing a free camera inputs manager
  104958. */
  104959. interface FreeCameraInputsManager {
  104960. /**
  104961. * Adds gamepad input support to the FreeCameraInputsManager.
  104962. * @returns the FreeCameraInputsManager
  104963. */
  104964. addGamepad(): FreeCameraInputsManager;
  104965. }
  104966. /**
  104967. * Interface representing an arc rotate camera inputs manager
  104968. */
  104969. interface ArcRotateCameraInputsManager {
  104970. /**
  104971. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104972. * @returns the camera inputs manager
  104973. */
  104974. addGamepad(): ArcRotateCameraInputsManager;
  104975. }
  104976. /**
  104977. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104978. */
  104979. export class GamepadSystemSceneComponent implements ISceneComponent {
  104980. /**
  104981. * The component name helpfull to identify the component in the list of scene components.
  104982. */
  104983. readonly name: string;
  104984. /**
  104985. * The scene the component belongs to.
  104986. */
  104987. scene: Scene;
  104988. /**
  104989. * Creates a new instance of the component for the given scene
  104990. * @param scene Defines the scene to register the component in
  104991. */
  104992. constructor(scene: Scene);
  104993. /**
  104994. * Registers the component in a given scene
  104995. */
  104996. register(): void;
  104997. /**
  104998. * Rebuilds the elements related to this component in case of
  104999. * context lost for instance.
  105000. */
  105001. rebuild(): void;
  105002. /**
  105003. * Disposes the component and the associated ressources
  105004. */
  105005. dispose(): void;
  105006. private _beforeCameraUpdate;
  105007. }
  105008. }
  105009. declare module BABYLON {
  105010. /**
  105011. * 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,
  105012. * which still works and will still be found in many Playgrounds.
  105013. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105014. */
  105015. export class UniversalCamera extends TouchCamera {
  105016. /**
  105017. * Defines the gamepad rotation sensiblity.
  105018. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105019. */
  105020. gamepadAngularSensibility: number;
  105021. /**
  105022. * Defines the gamepad move sensiblity.
  105023. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105024. */
  105025. gamepadMoveSensibility: number;
  105026. /**
  105027. * 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,
  105028. * which still works and will still be found in many Playgrounds.
  105029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105030. * @param name Define the name of the camera in the scene
  105031. * @param position Define the start position of the camera in the scene
  105032. * @param scene Define the scene the camera belongs to
  105033. */
  105034. constructor(name: string, position: Vector3, scene: Scene);
  105035. /**
  105036. * Gets the current object class name.
  105037. * @return the class name
  105038. */
  105039. getClassName(): string;
  105040. }
  105041. }
  105042. declare module BABYLON {
  105043. /**
  105044. * This represents a FPS type of camera. This is only here for back compat purpose.
  105045. * Please use the UniversalCamera instead as both are identical.
  105046. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105047. */
  105048. export class GamepadCamera extends UniversalCamera {
  105049. /**
  105050. * Instantiates a new Gamepad Camera
  105051. * This represents a FPS type of camera. This is only here for back compat purpose.
  105052. * Please use the UniversalCamera instead as both are identical.
  105053. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105054. * @param name Define the name of the camera in the scene
  105055. * @param position Define the start position of the camera in the scene
  105056. * @param scene Define the scene the camera belongs to
  105057. */
  105058. constructor(name: string, position: Vector3, scene: Scene);
  105059. /**
  105060. * Gets the current object class name.
  105061. * @return the class name
  105062. */
  105063. getClassName(): string;
  105064. }
  105065. }
  105066. declare module BABYLON {
  105067. /** @hidden */
  105068. export var passPixelShader: {
  105069. name: string;
  105070. shader: string;
  105071. };
  105072. }
  105073. declare module BABYLON {
  105074. /** @hidden */
  105075. export var passCubePixelShader: {
  105076. name: string;
  105077. shader: string;
  105078. };
  105079. }
  105080. declare module BABYLON {
  105081. /**
  105082. * PassPostProcess which produces an output the same as it's input
  105083. */
  105084. export class PassPostProcess extends PostProcess {
  105085. /**
  105086. * Creates the PassPostProcess
  105087. * @param name The name of the effect.
  105088. * @param options The required width/height ratio to downsize to before computing the render pass.
  105089. * @param camera The camera to apply the render pass to.
  105090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105091. * @param engine The engine which the post process will be applied. (default: current engine)
  105092. * @param reusable If the post process can be reused on the same frame. (default: false)
  105093. * @param textureType The type of texture to be used when performing the post processing.
  105094. * @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)
  105095. */
  105096. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105097. }
  105098. /**
  105099. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105100. */
  105101. export class PassCubePostProcess extends PostProcess {
  105102. private _face;
  105103. /**
  105104. * Gets or sets the cube face to display.
  105105. * * 0 is +X
  105106. * * 1 is -X
  105107. * * 2 is +Y
  105108. * * 3 is -Y
  105109. * * 4 is +Z
  105110. * * 5 is -Z
  105111. */
  105112. face: number;
  105113. /**
  105114. * Creates the PassCubePostProcess
  105115. * @param name The name of the effect.
  105116. * @param options The required width/height ratio to downsize to before computing the render pass.
  105117. * @param camera The camera to apply the render pass to.
  105118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105119. * @param engine The engine which the post process will be applied. (default: current engine)
  105120. * @param reusable If the post process can be reused on the same frame. (default: false)
  105121. * @param textureType The type of texture to be used when performing the post processing.
  105122. * @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)
  105123. */
  105124. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105125. }
  105126. }
  105127. declare module BABYLON {
  105128. /** @hidden */
  105129. export var anaglyphPixelShader: {
  105130. name: string;
  105131. shader: string;
  105132. };
  105133. }
  105134. declare module BABYLON {
  105135. /**
  105136. * Postprocess used to generate anaglyphic rendering
  105137. */
  105138. export class AnaglyphPostProcess extends PostProcess {
  105139. private _passedProcess;
  105140. /**
  105141. * Creates a new AnaglyphPostProcess
  105142. * @param name defines postprocess name
  105143. * @param options defines creation options or target ratio scale
  105144. * @param rigCameras defines cameras using this postprocess
  105145. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105146. * @param engine defines hosting engine
  105147. * @param reusable defines if the postprocess will be reused multiple times per frame
  105148. */
  105149. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105150. }
  105151. }
  105152. declare module BABYLON {
  105153. /**
  105154. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105155. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105156. */
  105157. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105158. /**
  105159. * Creates a new AnaglyphArcRotateCamera
  105160. * @param name defines camera name
  105161. * @param alpha defines alpha angle (in radians)
  105162. * @param beta defines beta angle (in radians)
  105163. * @param radius defines radius
  105164. * @param target defines camera target
  105165. * @param interaxialDistance defines distance between each color axis
  105166. * @param scene defines the hosting scene
  105167. */
  105168. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105169. /**
  105170. * Gets camera class name
  105171. * @returns AnaglyphArcRotateCamera
  105172. */
  105173. getClassName(): string;
  105174. }
  105175. }
  105176. declare module BABYLON {
  105177. /**
  105178. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105179. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105180. */
  105181. export class AnaglyphFreeCamera extends FreeCamera {
  105182. /**
  105183. * Creates a new AnaglyphFreeCamera
  105184. * @param name defines camera name
  105185. * @param position defines initial position
  105186. * @param interaxialDistance defines distance between each color axis
  105187. * @param scene defines the hosting scene
  105188. */
  105189. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105190. /**
  105191. * Gets camera class name
  105192. * @returns AnaglyphFreeCamera
  105193. */
  105194. getClassName(): string;
  105195. }
  105196. }
  105197. declare module BABYLON {
  105198. /**
  105199. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105200. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105201. */
  105202. export class AnaglyphGamepadCamera extends GamepadCamera {
  105203. /**
  105204. * Creates a new AnaglyphGamepadCamera
  105205. * @param name defines camera name
  105206. * @param position defines initial position
  105207. * @param interaxialDistance defines distance between each color axis
  105208. * @param scene defines the hosting scene
  105209. */
  105210. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105211. /**
  105212. * Gets camera class name
  105213. * @returns AnaglyphGamepadCamera
  105214. */
  105215. getClassName(): string;
  105216. }
  105217. }
  105218. declare module BABYLON {
  105219. /**
  105220. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105221. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105222. */
  105223. export class AnaglyphUniversalCamera extends UniversalCamera {
  105224. /**
  105225. * Creates a new AnaglyphUniversalCamera
  105226. * @param name defines camera name
  105227. * @param position defines initial position
  105228. * @param interaxialDistance defines distance between each color axis
  105229. * @param scene defines the hosting scene
  105230. */
  105231. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105232. /**
  105233. * Gets camera class name
  105234. * @returns AnaglyphUniversalCamera
  105235. */
  105236. getClassName(): string;
  105237. }
  105238. }
  105239. declare module BABYLON {
  105240. /** @hidden */
  105241. export var stereoscopicInterlacePixelShader: {
  105242. name: string;
  105243. shader: string;
  105244. };
  105245. }
  105246. declare module BABYLON {
  105247. /**
  105248. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105249. */
  105250. export class StereoscopicInterlacePostProcess extends PostProcess {
  105251. private _stepSize;
  105252. private _passedProcess;
  105253. /**
  105254. * Initializes a StereoscopicInterlacePostProcess
  105255. * @param name The name of the effect.
  105256. * @param rigCameras The rig cameras to be appled to the post process
  105257. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105259. * @param engine The engine which the post process will be applied. (default: current engine)
  105260. * @param reusable If the post process can be reused on the same frame. (default: false)
  105261. */
  105262. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105263. }
  105264. }
  105265. declare module BABYLON {
  105266. /**
  105267. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105268. * @see http://doc.babylonjs.com/features/cameras
  105269. */
  105270. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105271. /**
  105272. * Creates a new StereoscopicArcRotateCamera
  105273. * @param name defines camera name
  105274. * @param alpha defines alpha angle (in radians)
  105275. * @param beta defines beta angle (in radians)
  105276. * @param radius defines radius
  105277. * @param target defines camera target
  105278. * @param interaxialDistance defines distance between each color axis
  105279. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105280. * @param scene defines the hosting scene
  105281. */
  105282. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105283. /**
  105284. * Gets camera class name
  105285. * @returns StereoscopicArcRotateCamera
  105286. */
  105287. getClassName(): string;
  105288. }
  105289. }
  105290. declare module BABYLON {
  105291. /**
  105292. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105293. * @see http://doc.babylonjs.com/features/cameras
  105294. */
  105295. export class StereoscopicFreeCamera extends FreeCamera {
  105296. /**
  105297. * Creates a new StereoscopicFreeCamera
  105298. * @param name defines camera name
  105299. * @param position defines initial position
  105300. * @param interaxialDistance defines distance between each color axis
  105301. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105302. * @param scene defines the hosting scene
  105303. */
  105304. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105305. /**
  105306. * Gets camera class name
  105307. * @returns StereoscopicFreeCamera
  105308. */
  105309. getClassName(): string;
  105310. }
  105311. }
  105312. declare module BABYLON {
  105313. /**
  105314. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105315. * @see http://doc.babylonjs.com/features/cameras
  105316. */
  105317. export class StereoscopicGamepadCamera extends GamepadCamera {
  105318. /**
  105319. * Creates a new StereoscopicGamepadCamera
  105320. * @param name defines camera name
  105321. * @param position defines initial position
  105322. * @param interaxialDistance defines distance between each color axis
  105323. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105324. * @param scene defines the hosting scene
  105325. */
  105326. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105327. /**
  105328. * Gets camera class name
  105329. * @returns StereoscopicGamepadCamera
  105330. */
  105331. getClassName(): string;
  105332. }
  105333. }
  105334. declare module BABYLON {
  105335. /**
  105336. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105337. * @see http://doc.babylonjs.com/features/cameras
  105338. */
  105339. export class StereoscopicUniversalCamera extends UniversalCamera {
  105340. /**
  105341. * Creates a new StereoscopicUniversalCamera
  105342. * @param name defines camera name
  105343. * @param position defines initial position
  105344. * @param interaxialDistance defines distance between each color axis
  105345. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105346. * @param scene defines the hosting scene
  105347. */
  105348. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105349. /**
  105350. * Gets camera class name
  105351. * @returns StereoscopicUniversalCamera
  105352. */
  105353. getClassName(): string;
  105354. }
  105355. }
  105356. declare module BABYLON {
  105357. /**
  105358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105359. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105360. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105361. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105362. */
  105363. export class VirtualJoysticksCamera extends FreeCamera {
  105364. /**
  105365. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105366. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105367. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105368. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105369. * @param name Define the name of the camera in the scene
  105370. * @param position Define the start position of the camera in the scene
  105371. * @param scene Define the scene the camera belongs to
  105372. */
  105373. constructor(name: string, position: Vector3, scene: Scene);
  105374. /**
  105375. * Gets the current object class name.
  105376. * @return the class name
  105377. */
  105378. getClassName(): string;
  105379. }
  105380. }
  105381. declare module BABYLON {
  105382. /**
  105383. * This represents all the required metrics to create a VR camera.
  105384. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105385. */
  105386. export class VRCameraMetrics {
  105387. /**
  105388. * Define the horizontal resolution off the screen.
  105389. */
  105390. hResolution: number;
  105391. /**
  105392. * Define the vertical resolution off the screen.
  105393. */
  105394. vResolution: number;
  105395. /**
  105396. * Define the horizontal screen size.
  105397. */
  105398. hScreenSize: number;
  105399. /**
  105400. * Define the vertical screen size.
  105401. */
  105402. vScreenSize: number;
  105403. /**
  105404. * Define the vertical screen center position.
  105405. */
  105406. vScreenCenter: number;
  105407. /**
  105408. * Define the distance of the eyes to the screen.
  105409. */
  105410. eyeToScreenDistance: number;
  105411. /**
  105412. * Define the distance between both lenses
  105413. */
  105414. lensSeparationDistance: number;
  105415. /**
  105416. * Define the distance between both viewer's eyes.
  105417. */
  105418. interpupillaryDistance: number;
  105419. /**
  105420. * Define the distortion factor of the VR postprocess.
  105421. * Please, touch with care.
  105422. */
  105423. distortionK: number[];
  105424. /**
  105425. * Define the chromatic aberration correction factors for the VR post process.
  105426. */
  105427. chromaAbCorrection: number[];
  105428. /**
  105429. * Define the scale factor of the post process.
  105430. * The smaller the better but the slower.
  105431. */
  105432. postProcessScaleFactor: number;
  105433. /**
  105434. * Define an offset for the lens center.
  105435. */
  105436. lensCenterOffset: number;
  105437. /**
  105438. * Define if the current vr camera should compensate the distortion of the lense or not.
  105439. */
  105440. compensateDistortion: boolean;
  105441. /**
  105442. * Defines if multiview should be enabled when rendering (Default: false)
  105443. */
  105444. multiviewEnabled: boolean;
  105445. /**
  105446. * Gets the rendering aspect ratio based on the provided resolutions.
  105447. */
  105448. readonly aspectRatio: number;
  105449. /**
  105450. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105451. */
  105452. readonly aspectRatioFov: number;
  105453. /**
  105454. * @hidden
  105455. */
  105456. readonly leftHMatrix: Matrix;
  105457. /**
  105458. * @hidden
  105459. */
  105460. readonly rightHMatrix: Matrix;
  105461. /**
  105462. * @hidden
  105463. */
  105464. readonly leftPreViewMatrix: Matrix;
  105465. /**
  105466. * @hidden
  105467. */
  105468. readonly rightPreViewMatrix: Matrix;
  105469. /**
  105470. * Get the default VRMetrics based on the most generic setup.
  105471. * @returns the default vr metrics
  105472. */
  105473. static GetDefault(): VRCameraMetrics;
  105474. }
  105475. }
  105476. declare module BABYLON {
  105477. /** @hidden */
  105478. export var vrDistortionCorrectionPixelShader: {
  105479. name: string;
  105480. shader: string;
  105481. };
  105482. }
  105483. declare module BABYLON {
  105484. /**
  105485. * VRDistortionCorrectionPostProcess used for mobile VR
  105486. */
  105487. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105488. private _isRightEye;
  105489. private _distortionFactors;
  105490. private _postProcessScaleFactor;
  105491. private _lensCenterOffset;
  105492. private _scaleIn;
  105493. private _scaleFactor;
  105494. private _lensCenter;
  105495. /**
  105496. * Initializes the VRDistortionCorrectionPostProcess
  105497. * @param name The name of the effect.
  105498. * @param camera The camera to apply the render pass to.
  105499. * @param isRightEye If this is for the right eye distortion
  105500. * @param vrMetrics All the required metrics for the VR camera
  105501. */
  105502. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105503. }
  105504. }
  105505. declare module BABYLON {
  105506. /**
  105507. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105508. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105509. */
  105510. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105511. /**
  105512. * Creates a new VRDeviceOrientationArcRotateCamera
  105513. * @param name defines camera name
  105514. * @param alpha defines the camera rotation along the logitudinal axis
  105515. * @param beta defines the camera rotation along the latitudinal axis
  105516. * @param radius defines the camera distance from its target
  105517. * @param target defines the camera target
  105518. * @param scene defines the scene the camera belongs to
  105519. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105520. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105521. */
  105522. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105523. /**
  105524. * Gets camera class name
  105525. * @returns VRDeviceOrientationArcRotateCamera
  105526. */
  105527. getClassName(): string;
  105528. }
  105529. }
  105530. declare module BABYLON {
  105531. /**
  105532. * Camera used to simulate VR rendering (based on FreeCamera)
  105533. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105534. */
  105535. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105536. /**
  105537. * Creates a new VRDeviceOrientationFreeCamera
  105538. * @param name defines camera name
  105539. * @param position defines the start position of the camera
  105540. * @param scene defines the scene the camera belongs to
  105541. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105542. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105543. */
  105544. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105545. /**
  105546. * Gets camera class name
  105547. * @returns VRDeviceOrientationFreeCamera
  105548. */
  105549. getClassName(): string;
  105550. }
  105551. }
  105552. declare module BABYLON {
  105553. /**
  105554. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105555. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105556. */
  105557. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105558. /**
  105559. * Creates a new VRDeviceOrientationGamepadCamera
  105560. * @param name defines camera name
  105561. * @param position defines the start position of the camera
  105562. * @param scene defines the scene the camera belongs to
  105563. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105564. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105565. */
  105566. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105567. /**
  105568. * Gets camera class name
  105569. * @returns VRDeviceOrientationGamepadCamera
  105570. */
  105571. getClassName(): string;
  105572. }
  105573. }
  105574. declare module BABYLON {
  105575. /**
  105576. * Base class of materials working in push mode in babylon JS
  105577. * @hidden
  105578. */
  105579. export class PushMaterial extends Material {
  105580. protected _activeEffect: Effect;
  105581. protected _normalMatrix: Matrix;
  105582. /**
  105583. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105584. * This means that the material can keep using a previous shader while a new one is being compiled.
  105585. * This is mostly used when shader parallel compilation is supported (true by default)
  105586. */
  105587. allowShaderHotSwapping: boolean;
  105588. constructor(name: string, scene: Scene);
  105589. getEffect(): Effect;
  105590. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105591. /**
  105592. * Binds the given world matrix to the active effect
  105593. *
  105594. * @param world the matrix to bind
  105595. */
  105596. bindOnlyWorldMatrix(world: Matrix): void;
  105597. /**
  105598. * Binds the given normal matrix to the active effect
  105599. *
  105600. * @param normalMatrix the matrix to bind
  105601. */
  105602. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105603. bind(world: Matrix, mesh?: Mesh): void;
  105604. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105605. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105606. }
  105607. }
  105608. declare module BABYLON {
  105609. /**
  105610. * This groups all the flags used to control the materials channel.
  105611. */
  105612. export class MaterialFlags {
  105613. private static _DiffuseTextureEnabled;
  105614. /**
  105615. * Are diffuse textures enabled in the application.
  105616. */
  105617. static DiffuseTextureEnabled: boolean;
  105618. private static _AmbientTextureEnabled;
  105619. /**
  105620. * Are ambient textures enabled in the application.
  105621. */
  105622. static AmbientTextureEnabled: boolean;
  105623. private static _OpacityTextureEnabled;
  105624. /**
  105625. * Are opacity textures enabled in the application.
  105626. */
  105627. static OpacityTextureEnabled: boolean;
  105628. private static _ReflectionTextureEnabled;
  105629. /**
  105630. * Are reflection textures enabled in the application.
  105631. */
  105632. static ReflectionTextureEnabled: boolean;
  105633. private static _EmissiveTextureEnabled;
  105634. /**
  105635. * Are emissive textures enabled in the application.
  105636. */
  105637. static EmissiveTextureEnabled: boolean;
  105638. private static _SpecularTextureEnabled;
  105639. /**
  105640. * Are specular textures enabled in the application.
  105641. */
  105642. static SpecularTextureEnabled: boolean;
  105643. private static _BumpTextureEnabled;
  105644. /**
  105645. * Are bump textures enabled in the application.
  105646. */
  105647. static BumpTextureEnabled: boolean;
  105648. private static _LightmapTextureEnabled;
  105649. /**
  105650. * Are lightmap textures enabled in the application.
  105651. */
  105652. static LightmapTextureEnabled: boolean;
  105653. private static _RefractionTextureEnabled;
  105654. /**
  105655. * Are refraction textures enabled in the application.
  105656. */
  105657. static RefractionTextureEnabled: boolean;
  105658. private static _ColorGradingTextureEnabled;
  105659. /**
  105660. * Are color grading textures enabled in the application.
  105661. */
  105662. static ColorGradingTextureEnabled: boolean;
  105663. private static _FresnelEnabled;
  105664. /**
  105665. * Are fresnels enabled in the application.
  105666. */
  105667. static FresnelEnabled: boolean;
  105668. private static _ClearCoatTextureEnabled;
  105669. /**
  105670. * Are clear coat textures enabled in the application.
  105671. */
  105672. static ClearCoatTextureEnabled: boolean;
  105673. private static _ClearCoatBumpTextureEnabled;
  105674. /**
  105675. * Are clear coat bump textures enabled in the application.
  105676. */
  105677. static ClearCoatBumpTextureEnabled: boolean;
  105678. private static _ClearCoatTintTextureEnabled;
  105679. /**
  105680. * Are clear coat tint textures enabled in the application.
  105681. */
  105682. static ClearCoatTintTextureEnabled: boolean;
  105683. private static _SheenTextureEnabled;
  105684. /**
  105685. * Are sheen textures enabled in the application.
  105686. */
  105687. static SheenTextureEnabled: boolean;
  105688. private static _AnisotropicTextureEnabled;
  105689. /**
  105690. * Are anisotropic textures enabled in the application.
  105691. */
  105692. static AnisotropicTextureEnabled: boolean;
  105693. private static _ThicknessTextureEnabled;
  105694. /**
  105695. * Are thickness textures enabled in the application.
  105696. */
  105697. static ThicknessTextureEnabled: boolean;
  105698. }
  105699. }
  105700. declare module BABYLON {
  105701. /** @hidden */
  105702. export var defaultFragmentDeclaration: {
  105703. name: string;
  105704. shader: string;
  105705. };
  105706. }
  105707. declare module BABYLON {
  105708. /** @hidden */
  105709. export var defaultUboDeclaration: {
  105710. name: string;
  105711. shader: string;
  105712. };
  105713. }
  105714. declare module BABYLON {
  105715. /** @hidden */
  105716. export var lightFragmentDeclaration: {
  105717. name: string;
  105718. shader: string;
  105719. };
  105720. }
  105721. declare module BABYLON {
  105722. /** @hidden */
  105723. export var lightUboDeclaration: {
  105724. name: string;
  105725. shader: string;
  105726. };
  105727. }
  105728. declare module BABYLON {
  105729. /** @hidden */
  105730. export var lightsFragmentFunctions: {
  105731. name: string;
  105732. shader: string;
  105733. };
  105734. }
  105735. declare module BABYLON {
  105736. /** @hidden */
  105737. export var shadowsFragmentFunctions: {
  105738. name: string;
  105739. shader: string;
  105740. };
  105741. }
  105742. declare module BABYLON {
  105743. /** @hidden */
  105744. export var fresnelFunction: {
  105745. name: string;
  105746. shader: string;
  105747. };
  105748. }
  105749. declare module BABYLON {
  105750. /** @hidden */
  105751. export var reflectionFunction: {
  105752. name: string;
  105753. shader: string;
  105754. };
  105755. }
  105756. declare module BABYLON {
  105757. /** @hidden */
  105758. export var bumpFragmentFunctions: {
  105759. name: string;
  105760. shader: string;
  105761. };
  105762. }
  105763. declare module BABYLON {
  105764. /** @hidden */
  105765. export var logDepthDeclaration: {
  105766. name: string;
  105767. shader: string;
  105768. };
  105769. }
  105770. declare module BABYLON {
  105771. /** @hidden */
  105772. export var bumpFragment: {
  105773. name: string;
  105774. shader: string;
  105775. };
  105776. }
  105777. declare module BABYLON {
  105778. /** @hidden */
  105779. export var depthPrePass: {
  105780. name: string;
  105781. shader: string;
  105782. };
  105783. }
  105784. declare module BABYLON {
  105785. /** @hidden */
  105786. export var lightFragment: {
  105787. name: string;
  105788. shader: string;
  105789. };
  105790. }
  105791. declare module BABYLON {
  105792. /** @hidden */
  105793. export var logDepthFragment: {
  105794. name: string;
  105795. shader: string;
  105796. };
  105797. }
  105798. declare module BABYLON {
  105799. /** @hidden */
  105800. export var defaultPixelShader: {
  105801. name: string;
  105802. shader: string;
  105803. };
  105804. }
  105805. declare module BABYLON {
  105806. /** @hidden */
  105807. export var defaultVertexDeclaration: {
  105808. name: string;
  105809. shader: string;
  105810. };
  105811. }
  105812. declare module BABYLON {
  105813. /** @hidden */
  105814. export var bumpVertexDeclaration: {
  105815. name: string;
  105816. shader: string;
  105817. };
  105818. }
  105819. declare module BABYLON {
  105820. /** @hidden */
  105821. export var bumpVertex: {
  105822. name: string;
  105823. shader: string;
  105824. };
  105825. }
  105826. declare module BABYLON {
  105827. /** @hidden */
  105828. export var fogVertex: {
  105829. name: string;
  105830. shader: string;
  105831. };
  105832. }
  105833. declare module BABYLON {
  105834. /** @hidden */
  105835. export var shadowsVertex: {
  105836. name: string;
  105837. shader: string;
  105838. };
  105839. }
  105840. declare module BABYLON {
  105841. /** @hidden */
  105842. export var pointCloudVertex: {
  105843. name: string;
  105844. shader: string;
  105845. };
  105846. }
  105847. declare module BABYLON {
  105848. /** @hidden */
  105849. export var logDepthVertex: {
  105850. name: string;
  105851. shader: string;
  105852. };
  105853. }
  105854. declare module BABYLON {
  105855. /** @hidden */
  105856. export var defaultVertexShader: {
  105857. name: string;
  105858. shader: string;
  105859. };
  105860. }
  105861. declare module BABYLON {
  105862. /** @hidden */
  105863. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105864. MAINUV1: boolean;
  105865. MAINUV2: boolean;
  105866. DIFFUSE: boolean;
  105867. DIFFUSEDIRECTUV: number;
  105868. AMBIENT: boolean;
  105869. AMBIENTDIRECTUV: number;
  105870. OPACITY: boolean;
  105871. OPACITYDIRECTUV: number;
  105872. OPACITYRGB: boolean;
  105873. REFLECTION: boolean;
  105874. EMISSIVE: boolean;
  105875. EMISSIVEDIRECTUV: number;
  105876. SPECULAR: boolean;
  105877. SPECULARDIRECTUV: number;
  105878. BUMP: boolean;
  105879. BUMPDIRECTUV: number;
  105880. PARALLAX: boolean;
  105881. PARALLAXOCCLUSION: boolean;
  105882. SPECULAROVERALPHA: boolean;
  105883. CLIPPLANE: boolean;
  105884. CLIPPLANE2: boolean;
  105885. CLIPPLANE3: boolean;
  105886. CLIPPLANE4: boolean;
  105887. ALPHATEST: boolean;
  105888. DEPTHPREPASS: boolean;
  105889. ALPHAFROMDIFFUSE: boolean;
  105890. POINTSIZE: boolean;
  105891. FOG: boolean;
  105892. SPECULARTERM: boolean;
  105893. DIFFUSEFRESNEL: boolean;
  105894. OPACITYFRESNEL: boolean;
  105895. REFLECTIONFRESNEL: boolean;
  105896. REFRACTIONFRESNEL: boolean;
  105897. EMISSIVEFRESNEL: boolean;
  105898. FRESNEL: boolean;
  105899. NORMAL: boolean;
  105900. UV1: boolean;
  105901. UV2: boolean;
  105902. VERTEXCOLOR: boolean;
  105903. VERTEXALPHA: boolean;
  105904. NUM_BONE_INFLUENCERS: number;
  105905. BonesPerMesh: number;
  105906. BONETEXTURE: boolean;
  105907. INSTANCES: boolean;
  105908. GLOSSINESS: boolean;
  105909. ROUGHNESS: boolean;
  105910. EMISSIVEASILLUMINATION: boolean;
  105911. LINKEMISSIVEWITHDIFFUSE: boolean;
  105912. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105913. LIGHTMAP: boolean;
  105914. LIGHTMAPDIRECTUV: number;
  105915. OBJECTSPACE_NORMALMAP: boolean;
  105916. USELIGHTMAPASSHADOWMAP: boolean;
  105917. REFLECTIONMAP_3D: boolean;
  105918. REFLECTIONMAP_SPHERICAL: boolean;
  105919. REFLECTIONMAP_PLANAR: boolean;
  105920. REFLECTIONMAP_CUBIC: boolean;
  105921. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105922. REFLECTIONMAP_PROJECTION: boolean;
  105923. REFLECTIONMAP_SKYBOX: boolean;
  105924. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105925. REFLECTIONMAP_EXPLICIT: boolean;
  105926. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105927. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105928. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105929. INVERTCUBICMAP: boolean;
  105930. LOGARITHMICDEPTH: boolean;
  105931. REFRACTION: boolean;
  105932. REFRACTIONMAP_3D: boolean;
  105933. REFLECTIONOVERALPHA: boolean;
  105934. TWOSIDEDLIGHTING: boolean;
  105935. SHADOWFLOAT: boolean;
  105936. MORPHTARGETS: boolean;
  105937. MORPHTARGETS_NORMAL: boolean;
  105938. MORPHTARGETS_TANGENT: boolean;
  105939. MORPHTARGETS_UV: boolean;
  105940. NUM_MORPH_INFLUENCERS: number;
  105941. NONUNIFORMSCALING: boolean;
  105942. PREMULTIPLYALPHA: boolean;
  105943. IMAGEPROCESSING: boolean;
  105944. VIGNETTE: boolean;
  105945. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105946. VIGNETTEBLENDMODEOPAQUE: boolean;
  105947. TONEMAPPING: boolean;
  105948. TONEMAPPING_ACES: boolean;
  105949. CONTRAST: boolean;
  105950. COLORCURVES: boolean;
  105951. COLORGRADING: boolean;
  105952. COLORGRADING3D: boolean;
  105953. SAMPLER3DGREENDEPTH: boolean;
  105954. SAMPLER3DBGRMAP: boolean;
  105955. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105956. MULTIVIEW: boolean;
  105957. /**
  105958. * If the reflection texture on this material is in linear color space
  105959. * @hidden
  105960. */
  105961. IS_REFLECTION_LINEAR: boolean;
  105962. /**
  105963. * If the refraction texture on this material is in linear color space
  105964. * @hidden
  105965. */
  105966. IS_REFRACTION_LINEAR: boolean;
  105967. EXPOSURE: boolean;
  105968. constructor();
  105969. setReflectionMode(modeToEnable: string): void;
  105970. }
  105971. /**
  105972. * This is the default material used in Babylon. It is the best trade off between quality
  105973. * and performances.
  105974. * @see http://doc.babylonjs.com/babylon101/materials
  105975. */
  105976. export class StandardMaterial extends PushMaterial {
  105977. private _diffuseTexture;
  105978. /**
  105979. * The basic texture of the material as viewed under a light.
  105980. */
  105981. diffuseTexture: Nullable<BaseTexture>;
  105982. private _ambientTexture;
  105983. /**
  105984. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105985. */
  105986. ambientTexture: Nullable<BaseTexture>;
  105987. private _opacityTexture;
  105988. /**
  105989. * Define the transparency of the material from a texture.
  105990. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105991. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105992. */
  105993. opacityTexture: Nullable<BaseTexture>;
  105994. private _reflectionTexture;
  105995. /**
  105996. * Define the texture used to display the reflection.
  105997. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105998. */
  105999. reflectionTexture: Nullable<BaseTexture>;
  106000. private _emissiveTexture;
  106001. /**
  106002. * Define texture of the material as if self lit.
  106003. * This will be mixed in the final result even in the absence of light.
  106004. */
  106005. emissiveTexture: Nullable<BaseTexture>;
  106006. private _specularTexture;
  106007. /**
  106008. * Define how the color and intensity of the highlight given by the light in the material.
  106009. */
  106010. specularTexture: Nullable<BaseTexture>;
  106011. private _bumpTexture;
  106012. /**
  106013. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106014. * 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.
  106015. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106016. */
  106017. bumpTexture: Nullable<BaseTexture>;
  106018. private _lightmapTexture;
  106019. /**
  106020. * Complex lighting can be computationally expensive to compute at runtime.
  106021. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106022. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106023. */
  106024. lightmapTexture: Nullable<BaseTexture>;
  106025. private _refractionTexture;
  106026. /**
  106027. * Define the texture used to display the refraction.
  106028. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106029. */
  106030. refractionTexture: Nullable<BaseTexture>;
  106031. /**
  106032. * The color of the material lit by the environmental background lighting.
  106033. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106034. */
  106035. ambientColor: Color3;
  106036. /**
  106037. * The basic color of the material as viewed under a light.
  106038. */
  106039. diffuseColor: Color3;
  106040. /**
  106041. * Define how the color and intensity of the highlight given by the light in the material.
  106042. */
  106043. specularColor: Color3;
  106044. /**
  106045. * Define the color of the material as if self lit.
  106046. * This will be mixed in the final result even in the absence of light.
  106047. */
  106048. emissiveColor: Color3;
  106049. /**
  106050. * Defines how sharp are the highlights in the material.
  106051. * The bigger the value the sharper giving a more glossy feeling to the result.
  106052. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106053. */
  106054. specularPower: number;
  106055. private _useAlphaFromDiffuseTexture;
  106056. /**
  106057. * Does the transparency come from the diffuse texture alpha channel.
  106058. */
  106059. useAlphaFromDiffuseTexture: boolean;
  106060. private _useEmissiveAsIllumination;
  106061. /**
  106062. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106063. */
  106064. useEmissiveAsIllumination: boolean;
  106065. private _linkEmissiveWithDiffuse;
  106066. /**
  106067. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106068. * the emissive level when the final color is close to one.
  106069. */
  106070. linkEmissiveWithDiffuse: boolean;
  106071. private _useSpecularOverAlpha;
  106072. /**
  106073. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106074. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106075. */
  106076. useSpecularOverAlpha: boolean;
  106077. private _useReflectionOverAlpha;
  106078. /**
  106079. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106080. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106081. */
  106082. useReflectionOverAlpha: boolean;
  106083. private _disableLighting;
  106084. /**
  106085. * Does lights from the scene impacts this material.
  106086. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106087. */
  106088. disableLighting: boolean;
  106089. private _useObjectSpaceNormalMap;
  106090. /**
  106091. * Allows using an object space normal map (instead of tangent space).
  106092. */
  106093. useObjectSpaceNormalMap: boolean;
  106094. private _useParallax;
  106095. /**
  106096. * Is parallax enabled or not.
  106097. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106098. */
  106099. useParallax: boolean;
  106100. private _useParallaxOcclusion;
  106101. /**
  106102. * Is parallax occlusion enabled or not.
  106103. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106104. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106105. */
  106106. useParallaxOcclusion: boolean;
  106107. /**
  106108. * 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.
  106109. */
  106110. parallaxScaleBias: number;
  106111. private _roughness;
  106112. /**
  106113. * Helps to define how blurry the reflections should appears in the material.
  106114. */
  106115. roughness: number;
  106116. /**
  106117. * In case of refraction, define the value of the index of refraction.
  106118. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106119. */
  106120. indexOfRefraction: number;
  106121. /**
  106122. * Invert the refraction texture alongside the y axis.
  106123. * It can be useful with procedural textures or probe for instance.
  106124. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106125. */
  106126. invertRefractionY: boolean;
  106127. /**
  106128. * Defines the alpha limits in alpha test mode.
  106129. */
  106130. alphaCutOff: number;
  106131. private _useLightmapAsShadowmap;
  106132. /**
  106133. * In case of light mapping, define whether the map contains light or shadow informations.
  106134. */
  106135. useLightmapAsShadowmap: boolean;
  106136. private _diffuseFresnelParameters;
  106137. /**
  106138. * Define the diffuse fresnel parameters of the material.
  106139. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106140. */
  106141. diffuseFresnelParameters: FresnelParameters;
  106142. private _opacityFresnelParameters;
  106143. /**
  106144. * Define the opacity fresnel parameters of the material.
  106145. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106146. */
  106147. opacityFresnelParameters: FresnelParameters;
  106148. private _reflectionFresnelParameters;
  106149. /**
  106150. * Define the reflection fresnel parameters of the material.
  106151. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106152. */
  106153. reflectionFresnelParameters: FresnelParameters;
  106154. private _refractionFresnelParameters;
  106155. /**
  106156. * Define the refraction fresnel parameters of the material.
  106157. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106158. */
  106159. refractionFresnelParameters: FresnelParameters;
  106160. private _emissiveFresnelParameters;
  106161. /**
  106162. * Define the emissive fresnel parameters of the material.
  106163. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106164. */
  106165. emissiveFresnelParameters: FresnelParameters;
  106166. private _useReflectionFresnelFromSpecular;
  106167. /**
  106168. * If true automatically deducts the fresnels values from the material specularity.
  106169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106170. */
  106171. useReflectionFresnelFromSpecular: boolean;
  106172. private _useGlossinessFromSpecularMapAlpha;
  106173. /**
  106174. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106175. */
  106176. useGlossinessFromSpecularMapAlpha: boolean;
  106177. private _maxSimultaneousLights;
  106178. /**
  106179. * Defines the maximum number of lights that can be used in the material
  106180. */
  106181. maxSimultaneousLights: number;
  106182. private _invertNormalMapX;
  106183. /**
  106184. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106185. */
  106186. invertNormalMapX: boolean;
  106187. private _invertNormalMapY;
  106188. /**
  106189. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106190. */
  106191. invertNormalMapY: boolean;
  106192. private _twoSidedLighting;
  106193. /**
  106194. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106195. */
  106196. twoSidedLighting: boolean;
  106197. /**
  106198. * Default configuration related to image processing available in the standard Material.
  106199. */
  106200. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106201. /**
  106202. * Gets the image processing configuration used either in this material.
  106203. */
  106204. /**
  106205. * Sets the Default image processing configuration used either in the this material.
  106206. *
  106207. * If sets to null, the scene one is in use.
  106208. */
  106209. imageProcessingConfiguration: ImageProcessingConfiguration;
  106210. /**
  106211. * Keep track of the image processing observer to allow dispose and replace.
  106212. */
  106213. private _imageProcessingObserver;
  106214. /**
  106215. * Attaches a new image processing configuration to the Standard Material.
  106216. * @param configuration
  106217. */
  106218. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106219. /**
  106220. * Gets wether the color curves effect is enabled.
  106221. */
  106222. /**
  106223. * Sets wether the color curves effect is enabled.
  106224. */
  106225. cameraColorCurvesEnabled: boolean;
  106226. /**
  106227. * Gets wether the color grading effect is enabled.
  106228. */
  106229. /**
  106230. * Gets wether the color grading effect is enabled.
  106231. */
  106232. cameraColorGradingEnabled: boolean;
  106233. /**
  106234. * Gets wether tonemapping is enabled or not.
  106235. */
  106236. /**
  106237. * Sets wether tonemapping is enabled or not
  106238. */
  106239. cameraToneMappingEnabled: boolean;
  106240. /**
  106241. * The camera exposure used on this material.
  106242. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106243. * This corresponds to a photographic exposure.
  106244. */
  106245. /**
  106246. * The camera exposure used on this material.
  106247. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106248. * This corresponds to a photographic exposure.
  106249. */
  106250. cameraExposure: number;
  106251. /**
  106252. * Gets The camera contrast used on this material.
  106253. */
  106254. /**
  106255. * Sets The camera contrast used on this material.
  106256. */
  106257. cameraContrast: number;
  106258. /**
  106259. * Gets the Color Grading 2D Lookup Texture.
  106260. */
  106261. /**
  106262. * Sets the Color Grading 2D Lookup Texture.
  106263. */
  106264. cameraColorGradingTexture: Nullable<BaseTexture>;
  106265. /**
  106266. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106267. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106268. * 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;
  106269. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106270. */
  106271. /**
  106272. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106273. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106274. * 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;
  106275. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106276. */
  106277. cameraColorCurves: Nullable<ColorCurves>;
  106278. /**
  106279. * Custom callback helping to override the default shader used in the material.
  106280. */
  106281. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106282. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106283. protected _worldViewProjectionMatrix: Matrix;
  106284. protected _globalAmbientColor: Color3;
  106285. protected _useLogarithmicDepth: boolean;
  106286. protected _rebuildInParallel: boolean;
  106287. /**
  106288. * Instantiates a new standard material.
  106289. * This is the default material used in Babylon. It is the best trade off between quality
  106290. * and performances.
  106291. * @see http://doc.babylonjs.com/babylon101/materials
  106292. * @param name Define the name of the material in the scene
  106293. * @param scene Define the scene the material belong to
  106294. */
  106295. constructor(name: string, scene: Scene);
  106296. /**
  106297. * Gets a boolean indicating that current material needs to register RTT
  106298. */
  106299. readonly hasRenderTargetTextures: boolean;
  106300. /**
  106301. * Gets the current class name of the material e.g. "StandardMaterial"
  106302. * Mainly use in serialization.
  106303. * @returns the class name
  106304. */
  106305. getClassName(): string;
  106306. /**
  106307. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106308. * You can try switching to logarithmic depth.
  106309. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106310. */
  106311. useLogarithmicDepth: boolean;
  106312. /**
  106313. * Specifies if the material will require alpha blending
  106314. * @returns a boolean specifying if alpha blending is needed
  106315. */
  106316. needAlphaBlending(): boolean;
  106317. /**
  106318. * Specifies if this material should be rendered in alpha test mode
  106319. * @returns a boolean specifying if an alpha test is needed.
  106320. */
  106321. needAlphaTesting(): boolean;
  106322. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106323. /**
  106324. * Get the texture used for alpha test purpose.
  106325. * @returns the diffuse texture in case of the standard material.
  106326. */
  106327. getAlphaTestTexture(): Nullable<BaseTexture>;
  106328. /**
  106329. * Get if the submesh is ready to be used and all its information available.
  106330. * Child classes can use it to update shaders
  106331. * @param mesh defines the mesh to check
  106332. * @param subMesh defines which submesh to check
  106333. * @param useInstances specifies that instances should be used
  106334. * @returns a boolean indicating that the submesh is ready or not
  106335. */
  106336. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106337. /**
  106338. * Builds the material UBO layouts.
  106339. * Used internally during the effect preparation.
  106340. */
  106341. buildUniformLayout(): void;
  106342. /**
  106343. * Unbinds the material from the mesh
  106344. */
  106345. unbind(): void;
  106346. /**
  106347. * Binds the submesh to this material by preparing the effect and shader to draw
  106348. * @param world defines the world transformation matrix
  106349. * @param mesh defines the mesh containing the submesh
  106350. * @param subMesh defines the submesh to bind the material to
  106351. */
  106352. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106353. /**
  106354. * Get the list of animatables in the material.
  106355. * @returns the list of animatables object used in the material
  106356. */
  106357. getAnimatables(): IAnimatable[];
  106358. /**
  106359. * Gets the active textures from the material
  106360. * @returns an array of textures
  106361. */
  106362. getActiveTextures(): BaseTexture[];
  106363. /**
  106364. * Specifies if the material uses a texture
  106365. * @param texture defines the texture to check against the material
  106366. * @returns a boolean specifying if the material uses the texture
  106367. */
  106368. hasTexture(texture: BaseTexture): boolean;
  106369. /**
  106370. * Disposes the material
  106371. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106372. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106373. */
  106374. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106375. /**
  106376. * Makes a duplicate of the material, and gives it a new name
  106377. * @param name defines the new name for the duplicated material
  106378. * @returns the cloned material
  106379. */
  106380. clone(name: string): StandardMaterial;
  106381. /**
  106382. * Serializes this material in a JSON representation
  106383. * @returns the serialized material object
  106384. */
  106385. serialize(): any;
  106386. /**
  106387. * Creates a standard material from parsed material data
  106388. * @param source defines the JSON representation of the material
  106389. * @param scene defines the hosting scene
  106390. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106391. * @returns a new standard material
  106392. */
  106393. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106394. /**
  106395. * Are diffuse textures enabled in the application.
  106396. */
  106397. static DiffuseTextureEnabled: boolean;
  106398. /**
  106399. * Are ambient textures enabled in the application.
  106400. */
  106401. static AmbientTextureEnabled: boolean;
  106402. /**
  106403. * Are opacity textures enabled in the application.
  106404. */
  106405. static OpacityTextureEnabled: boolean;
  106406. /**
  106407. * Are reflection textures enabled in the application.
  106408. */
  106409. static ReflectionTextureEnabled: boolean;
  106410. /**
  106411. * Are emissive textures enabled in the application.
  106412. */
  106413. static EmissiveTextureEnabled: boolean;
  106414. /**
  106415. * Are specular textures enabled in the application.
  106416. */
  106417. static SpecularTextureEnabled: boolean;
  106418. /**
  106419. * Are bump textures enabled in the application.
  106420. */
  106421. static BumpTextureEnabled: boolean;
  106422. /**
  106423. * Are lightmap textures enabled in the application.
  106424. */
  106425. static LightmapTextureEnabled: boolean;
  106426. /**
  106427. * Are refraction textures enabled in the application.
  106428. */
  106429. static RefractionTextureEnabled: boolean;
  106430. /**
  106431. * Are color grading textures enabled in the application.
  106432. */
  106433. static ColorGradingTextureEnabled: boolean;
  106434. /**
  106435. * Are fresnels enabled in the application.
  106436. */
  106437. static FresnelEnabled: boolean;
  106438. }
  106439. }
  106440. declare module BABYLON {
  106441. /** @hidden */
  106442. export var imageProcessingPixelShader: {
  106443. name: string;
  106444. shader: string;
  106445. };
  106446. }
  106447. declare module BABYLON {
  106448. /**
  106449. * ImageProcessingPostProcess
  106450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106451. */
  106452. export class ImageProcessingPostProcess extends PostProcess {
  106453. /**
  106454. * Default configuration related to image processing available in the PBR Material.
  106455. */
  106456. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106457. /**
  106458. * Gets the image processing configuration used either in this material.
  106459. */
  106460. /**
  106461. * Sets the Default image processing configuration used either in the this material.
  106462. *
  106463. * If sets to null, the scene one is in use.
  106464. */
  106465. imageProcessingConfiguration: ImageProcessingConfiguration;
  106466. /**
  106467. * Keep track of the image processing observer to allow dispose and replace.
  106468. */
  106469. private _imageProcessingObserver;
  106470. /**
  106471. * Attaches a new image processing configuration to the PBR Material.
  106472. * @param configuration
  106473. */
  106474. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106475. /**
  106476. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106477. */
  106478. /**
  106479. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106480. */
  106481. colorCurves: Nullable<ColorCurves>;
  106482. /**
  106483. * Gets wether the color curves effect is enabled.
  106484. */
  106485. /**
  106486. * Sets wether the color curves effect is enabled.
  106487. */
  106488. colorCurvesEnabled: boolean;
  106489. /**
  106490. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106491. */
  106492. /**
  106493. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106494. */
  106495. colorGradingTexture: Nullable<BaseTexture>;
  106496. /**
  106497. * Gets wether the color grading effect is enabled.
  106498. */
  106499. /**
  106500. * Gets wether the color grading effect is enabled.
  106501. */
  106502. colorGradingEnabled: boolean;
  106503. /**
  106504. * Gets exposure used in the effect.
  106505. */
  106506. /**
  106507. * Sets exposure used in the effect.
  106508. */
  106509. exposure: number;
  106510. /**
  106511. * Gets wether tonemapping is enabled or not.
  106512. */
  106513. /**
  106514. * Sets wether tonemapping is enabled or not
  106515. */
  106516. toneMappingEnabled: boolean;
  106517. /**
  106518. * Gets the type of tone mapping effect.
  106519. */
  106520. /**
  106521. * Sets the type of tone mapping effect.
  106522. */
  106523. toneMappingType: number;
  106524. /**
  106525. * Gets contrast used in the effect.
  106526. */
  106527. /**
  106528. * Sets contrast used in the effect.
  106529. */
  106530. contrast: number;
  106531. /**
  106532. * Gets Vignette stretch size.
  106533. */
  106534. /**
  106535. * Sets Vignette stretch size.
  106536. */
  106537. vignetteStretch: number;
  106538. /**
  106539. * Gets Vignette centre X Offset.
  106540. */
  106541. /**
  106542. * Sets Vignette centre X Offset.
  106543. */
  106544. vignetteCentreX: number;
  106545. /**
  106546. * Gets Vignette centre Y Offset.
  106547. */
  106548. /**
  106549. * Sets Vignette centre Y Offset.
  106550. */
  106551. vignetteCentreY: number;
  106552. /**
  106553. * Gets Vignette weight or intensity of the vignette effect.
  106554. */
  106555. /**
  106556. * Sets Vignette weight or intensity of the vignette effect.
  106557. */
  106558. vignetteWeight: number;
  106559. /**
  106560. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106561. * if vignetteEnabled is set to true.
  106562. */
  106563. /**
  106564. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106565. * if vignetteEnabled is set to true.
  106566. */
  106567. vignetteColor: Color4;
  106568. /**
  106569. * Gets Camera field of view used by the Vignette effect.
  106570. */
  106571. /**
  106572. * Sets Camera field of view used by the Vignette effect.
  106573. */
  106574. vignetteCameraFov: number;
  106575. /**
  106576. * Gets the vignette blend mode allowing different kind of effect.
  106577. */
  106578. /**
  106579. * Sets the vignette blend mode allowing different kind of effect.
  106580. */
  106581. vignetteBlendMode: number;
  106582. /**
  106583. * Gets wether the vignette effect is enabled.
  106584. */
  106585. /**
  106586. * Sets wether the vignette effect is enabled.
  106587. */
  106588. vignetteEnabled: boolean;
  106589. private _fromLinearSpace;
  106590. /**
  106591. * Gets wether the input of the processing is in Gamma or Linear Space.
  106592. */
  106593. /**
  106594. * Sets wether the input of the processing is in Gamma or Linear Space.
  106595. */
  106596. fromLinearSpace: boolean;
  106597. /**
  106598. * Defines cache preventing GC.
  106599. */
  106600. private _defines;
  106601. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106602. /**
  106603. * "ImageProcessingPostProcess"
  106604. * @returns "ImageProcessingPostProcess"
  106605. */
  106606. getClassName(): string;
  106607. protected _updateParameters(): void;
  106608. dispose(camera?: Camera): void;
  106609. }
  106610. }
  106611. declare module BABYLON {
  106612. /**
  106613. * Class containing static functions to help procedurally build meshes
  106614. */
  106615. export class GroundBuilder {
  106616. /**
  106617. * Creates a ground mesh
  106618. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106619. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106621. * @param name defines the name of the mesh
  106622. * @param options defines the options used to create the mesh
  106623. * @param scene defines the hosting scene
  106624. * @returns the ground mesh
  106625. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106626. */
  106627. static CreateGround(name: string, options: {
  106628. width?: number;
  106629. height?: number;
  106630. subdivisions?: number;
  106631. subdivisionsX?: number;
  106632. subdivisionsY?: number;
  106633. updatable?: boolean;
  106634. }, scene: any): Mesh;
  106635. /**
  106636. * Creates a tiled ground mesh
  106637. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106638. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106639. * * 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
  106640. * * 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
  106641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106642. * @param name defines the name of the mesh
  106643. * @param options defines the options used to create the mesh
  106644. * @param scene defines the hosting scene
  106645. * @returns the tiled ground mesh
  106646. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106647. */
  106648. static CreateTiledGround(name: string, options: {
  106649. xmin: number;
  106650. zmin: number;
  106651. xmax: number;
  106652. zmax: number;
  106653. subdivisions?: {
  106654. w: number;
  106655. h: number;
  106656. };
  106657. precision?: {
  106658. w: number;
  106659. h: number;
  106660. };
  106661. updatable?: boolean;
  106662. }, scene?: Nullable<Scene>): Mesh;
  106663. /**
  106664. * Creates a ground mesh from a height map
  106665. * * The parameter `url` sets the URL of the height map image resource.
  106666. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106667. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106668. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106669. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106670. * * 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.
  106671. * * 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).
  106672. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106674. * @param name defines the name of the mesh
  106675. * @param url defines the url to the height map
  106676. * @param options defines the options used to create the mesh
  106677. * @param scene defines the hosting scene
  106678. * @returns the ground mesh
  106679. * @see https://doc.babylonjs.com/babylon101/height_map
  106680. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106681. */
  106682. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106683. width?: number;
  106684. height?: number;
  106685. subdivisions?: number;
  106686. minHeight?: number;
  106687. maxHeight?: number;
  106688. colorFilter?: Color3;
  106689. alphaFilter?: number;
  106690. updatable?: boolean;
  106691. onReady?: (mesh: GroundMesh) => void;
  106692. }, scene?: Nullable<Scene>): GroundMesh;
  106693. }
  106694. }
  106695. declare module BABYLON {
  106696. /**
  106697. * Class containing static functions to help procedurally build meshes
  106698. */
  106699. export class TorusBuilder {
  106700. /**
  106701. * Creates a torus mesh
  106702. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106703. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106704. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106708. * @param name defines the name of the mesh
  106709. * @param options defines the options used to create the mesh
  106710. * @param scene defines the hosting scene
  106711. * @returns the torus mesh
  106712. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106713. */
  106714. static CreateTorus(name: string, options: {
  106715. diameter?: number;
  106716. thickness?: number;
  106717. tessellation?: number;
  106718. updatable?: boolean;
  106719. sideOrientation?: number;
  106720. frontUVs?: Vector4;
  106721. backUVs?: Vector4;
  106722. }, scene: any): Mesh;
  106723. }
  106724. }
  106725. declare module BABYLON {
  106726. /**
  106727. * Class containing static functions to help procedurally build meshes
  106728. */
  106729. export class CylinderBuilder {
  106730. /**
  106731. * Creates a cylinder or a cone mesh
  106732. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106733. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106734. * * 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.
  106735. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106736. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106737. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106738. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106739. * * 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).
  106740. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106741. * * 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).
  106742. * * 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
  106743. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106744. * * 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
  106745. * * 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.
  106746. * * If `enclose` is false, a ring surface is one element.
  106747. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106748. * * 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
  106749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106752. * @param name defines the name of the mesh
  106753. * @param options defines the options used to create the mesh
  106754. * @param scene defines the hosting scene
  106755. * @returns the cylinder mesh
  106756. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106757. */
  106758. static CreateCylinder(name: string, options: {
  106759. height?: number;
  106760. diameterTop?: number;
  106761. diameterBottom?: number;
  106762. diameter?: number;
  106763. tessellation?: number;
  106764. subdivisions?: number;
  106765. arc?: number;
  106766. faceColors?: Color4[];
  106767. faceUV?: Vector4[];
  106768. updatable?: boolean;
  106769. hasRings?: boolean;
  106770. enclose?: boolean;
  106771. cap?: number;
  106772. sideOrientation?: number;
  106773. frontUVs?: Vector4;
  106774. backUVs?: Vector4;
  106775. }, scene: any): Mesh;
  106776. }
  106777. }
  106778. declare module BABYLON {
  106779. /**
  106780. * Options to modify the vr teleportation behavior.
  106781. */
  106782. export interface VRTeleportationOptions {
  106783. /**
  106784. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106785. */
  106786. floorMeshName?: string;
  106787. /**
  106788. * A list of meshes to be used as the teleportation floor. (default: empty)
  106789. */
  106790. floorMeshes?: Mesh[];
  106791. }
  106792. /**
  106793. * Options to modify the vr experience helper's behavior.
  106794. */
  106795. export interface VRExperienceHelperOptions extends WebVROptions {
  106796. /**
  106797. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106798. */
  106799. createDeviceOrientationCamera?: boolean;
  106800. /**
  106801. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106802. */
  106803. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106804. /**
  106805. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106806. */
  106807. laserToggle?: boolean;
  106808. /**
  106809. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106810. */
  106811. floorMeshes?: Mesh[];
  106812. /**
  106813. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106814. */
  106815. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106816. }
  106817. /**
  106818. * Event containing information after VR has been entered
  106819. */
  106820. export class OnAfterEnteringVRObservableEvent {
  106821. /**
  106822. * If entering vr was successful
  106823. */
  106824. success: boolean;
  106825. }
  106826. /**
  106827. * Helps to quickly add VR support to an existing scene.
  106828. * See http://doc.babylonjs.com/how_to/webvr_helper
  106829. */
  106830. export class VRExperienceHelper {
  106831. /** Options to modify the vr experience helper's behavior. */
  106832. webVROptions: VRExperienceHelperOptions;
  106833. private _scene;
  106834. private _position;
  106835. private _btnVR;
  106836. private _btnVRDisplayed;
  106837. private _webVRsupported;
  106838. private _webVRready;
  106839. private _webVRrequesting;
  106840. private _webVRpresenting;
  106841. private _hasEnteredVR;
  106842. private _fullscreenVRpresenting;
  106843. private _canvas;
  106844. private _webVRCamera;
  106845. private _vrDeviceOrientationCamera;
  106846. private _deviceOrientationCamera;
  106847. private _existingCamera;
  106848. private _onKeyDown;
  106849. private _onVrDisplayPresentChange;
  106850. private _onVRDisplayChanged;
  106851. private _onVRRequestPresentStart;
  106852. private _onVRRequestPresentComplete;
  106853. /**
  106854. * 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)
  106855. */
  106856. enableGazeEvenWhenNoPointerLock: boolean;
  106857. /**
  106858. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106859. */
  106860. exitVROnDoubleTap: boolean;
  106861. /**
  106862. * Observable raised right before entering VR.
  106863. */
  106864. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106865. /**
  106866. * Observable raised when entering VR has completed.
  106867. */
  106868. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106869. /**
  106870. * Observable raised when exiting VR.
  106871. */
  106872. onExitingVRObservable: Observable<VRExperienceHelper>;
  106873. /**
  106874. * Observable raised when controller mesh is loaded.
  106875. */
  106876. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106877. /** Return this.onEnteringVRObservable
  106878. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106879. */
  106880. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106881. /** Return this.onExitingVRObservable
  106882. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106883. */
  106884. readonly onExitingVR: Observable<VRExperienceHelper>;
  106885. /** Return this.onControllerMeshLoadedObservable
  106886. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106887. */
  106888. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106889. private _rayLength;
  106890. private _useCustomVRButton;
  106891. private _teleportationRequested;
  106892. private _teleportActive;
  106893. private _floorMeshName;
  106894. private _floorMeshesCollection;
  106895. private _rotationAllowed;
  106896. private _teleportBackwardsVector;
  106897. private _teleportationTarget;
  106898. private _isDefaultTeleportationTarget;
  106899. private _postProcessMove;
  106900. private _teleportationFillColor;
  106901. private _teleportationBorderColor;
  106902. private _rotationAngle;
  106903. private _haloCenter;
  106904. private _cameraGazer;
  106905. private _padSensibilityUp;
  106906. private _padSensibilityDown;
  106907. private _leftController;
  106908. private _rightController;
  106909. /**
  106910. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106911. */
  106912. onNewMeshSelected: Observable<AbstractMesh>;
  106913. /**
  106914. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106915. * This observable will provide the mesh and the controller used to select the mesh
  106916. */
  106917. onMeshSelectedWithController: Observable<{
  106918. mesh: AbstractMesh;
  106919. controller: WebVRController;
  106920. }>;
  106921. /**
  106922. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106923. */
  106924. onNewMeshPicked: Observable<PickingInfo>;
  106925. private _circleEase;
  106926. /**
  106927. * Observable raised before camera teleportation
  106928. */
  106929. onBeforeCameraTeleport: Observable<Vector3>;
  106930. /**
  106931. * Observable raised after camera teleportation
  106932. */
  106933. onAfterCameraTeleport: Observable<Vector3>;
  106934. /**
  106935. * Observable raised when current selected mesh gets unselected
  106936. */
  106937. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106938. private _raySelectionPredicate;
  106939. /**
  106940. * To be optionaly changed by user to define custom ray selection
  106941. */
  106942. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106943. /**
  106944. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106945. */
  106946. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106947. /**
  106948. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106949. */
  106950. teleportationEnabled: boolean;
  106951. private _defaultHeight;
  106952. private _teleportationInitialized;
  106953. private _interactionsEnabled;
  106954. private _interactionsRequested;
  106955. private _displayGaze;
  106956. private _displayLaserPointer;
  106957. /**
  106958. * The mesh used to display where the user is going to teleport.
  106959. */
  106960. /**
  106961. * Sets the mesh to be used to display where the user is going to teleport.
  106962. */
  106963. teleportationTarget: Mesh;
  106964. /**
  106965. * 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
  106966. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106967. * See http://doc.babylonjs.com/resources/baking_transformations
  106968. */
  106969. gazeTrackerMesh: Mesh;
  106970. /**
  106971. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106972. */
  106973. updateGazeTrackerScale: boolean;
  106974. /**
  106975. * If the gaze trackers color should be updated when selecting meshes
  106976. */
  106977. updateGazeTrackerColor: boolean;
  106978. /**
  106979. * If the controller laser color should be updated when selecting meshes
  106980. */
  106981. updateControllerLaserColor: boolean;
  106982. /**
  106983. * The gaze tracking mesh corresponding to the left controller
  106984. */
  106985. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106986. /**
  106987. * The gaze tracking mesh corresponding to the right controller
  106988. */
  106989. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106990. /**
  106991. * If the ray of the gaze should be displayed.
  106992. */
  106993. /**
  106994. * Sets if the ray of the gaze should be displayed.
  106995. */
  106996. displayGaze: boolean;
  106997. /**
  106998. * If the ray of the LaserPointer should be displayed.
  106999. */
  107000. /**
  107001. * Sets if the ray of the LaserPointer should be displayed.
  107002. */
  107003. displayLaserPointer: boolean;
  107004. /**
  107005. * The deviceOrientationCamera used as the camera when not in VR.
  107006. */
  107007. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107008. /**
  107009. * Based on the current WebVR support, returns the current VR camera used.
  107010. */
  107011. readonly currentVRCamera: Nullable<Camera>;
  107012. /**
  107013. * The webVRCamera which is used when in VR.
  107014. */
  107015. readonly webVRCamera: WebVRFreeCamera;
  107016. /**
  107017. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107018. */
  107019. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107020. /**
  107021. * The html button that is used to trigger entering into VR.
  107022. */
  107023. readonly vrButton: Nullable<HTMLButtonElement>;
  107024. private readonly _teleportationRequestInitiated;
  107025. /**
  107026. * Defines wether or not Pointer lock should be requested when switching to
  107027. * full screen.
  107028. */
  107029. requestPointerLockOnFullScreen: boolean;
  107030. /**
  107031. * Instantiates a VRExperienceHelper.
  107032. * Helps to quickly add VR support to an existing scene.
  107033. * @param scene The scene the VRExperienceHelper belongs to.
  107034. * @param webVROptions Options to modify the vr experience helper's behavior.
  107035. */
  107036. constructor(scene: Scene,
  107037. /** Options to modify the vr experience helper's behavior. */
  107038. webVROptions?: VRExperienceHelperOptions);
  107039. private _onDefaultMeshLoaded;
  107040. private _onResize;
  107041. private _onFullscreenChange;
  107042. /**
  107043. * Gets a value indicating if we are currently in VR mode.
  107044. */
  107045. readonly isInVRMode: boolean;
  107046. private onVrDisplayPresentChange;
  107047. private onVRDisplayChanged;
  107048. private moveButtonToBottomRight;
  107049. private displayVRButton;
  107050. private updateButtonVisibility;
  107051. private _cachedAngularSensibility;
  107052. /**
  107053. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107054. * Otherwise, will use the fullscreen API.
  107055. */
  107056. enterVR(): void;
  107057. /**
  107058. * Attempt to exit VR, or fullscreen.
  107059. */
  107060. exitVR(): void;
  107061. /**
  107062. * The position of the vr experience helper.
  107063. */
  107064. /**
  107065. * Sets the position of the vr experience helper.
  107066. */
  107067. position: Vector3;
  107068. /**
  107069. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107070. */
  107071. enableInteractions(): void;
  107072. private readonly _noControllerIsActive;
  107073. private beforeRender;
  107074. private _isTeleportationFloor;
  107075. /**
  107076. * Adds a floor mesh to be used for teleportation.
  107077. * @param floorMesh the mesh to be used for teleportation.
  107078. */
  107079. addFloorMesh(floorMesh: Mesh): void;
  107080. /**
  107081. * Removes a floor mesh from being used for teleportation.
  107082. * @param floorMesh the mesh to be removed.
  107083. */
  107084. removeFloorMesh(floorMesh: Mesh): void;
  107085. /**
  107086. * Enables interactions and teleportation using the VR controllers and gaze.
  107087. * @param vrTeleportationOptions options to modify teleportation behavior.
  107088. */
  107089. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107090. private _onNewGamepadConnected;
  107091. private _tryEnableInteractionOnController;
  107092. private _onNewGamepadDisconnected;
  107093. private _enableInteractionOnController;
  107094. private _checkTeleportWithRay;
  107095. private _checkRotate;
  107096. private _checkTeleportBackwards;
  107097. private _enableTeleportationOnController;
  107098. private _createTeleportationCircles;
  107099. private _displayTeleportationTarget;
  107100. private _hideTeleportationTarget;
  107101. private _rotateCamera;
  107102. private _moveTeleportationSelectorTo;
  107103. private _workingVector;
  107104. private _workingQuaternion;
  107105. private _workingMatrix;
  107106. /**
  107107. * Teleports the users feet to the desired location
  107108. * @param location The location where the user's feet should be placed
  107109. */
  107110. teleportCamera(location: Vector3): void;
  107111. private _convertNormalToDirectionOfRay;
  107112. private _castRayAndSelectObject;
  107113. private _notifySelectedMeshUnselected;
  107114. /**
  107115. * Sets the color of the laser ray from the vr controllers.
  107116. * @param color new color for the ray.
  107117. */
  107118. changeLaserColor(color: Color3): void;
  107119. /**
  107120. * Sets the color of the ray from the vr headsets gaze.
  107121. * @param color new color for the ray.
  107122. */
  107123. changeGazeColor(color: Color3): void;
  107124. /**
  107125. * Exits VR and disposes of the vr experience helper
  107126. */
  107127. dispose(): void;
  107128. /**
  107129. * Gets the name of the VRExperienceHelper class
  107130. * @returns "VRExperienceHelper"
  107131. */
  107132. getClassName(): string;
  107133. }
  107134. }
  107135. declare module BABYLON {
  107136. /**
  107137. * Manages an XRSession to work with Babylon's engine
  107138. * @see https://doc.babylonjs.com/how_to/webxr
  107139. */
  107140. export class WebXRSessionManager implements IDisposable {
  107141. private scene;
  107142. /**
  107143. * Fires every time a new xrFrame arrives which can be used to update the camera
  107144. */
  107145. onXRFrameObservable: Observable<any>;
  107146. /**
  107147. * Fires when the xr session is ended either by the device or manually done
  107148. */
  107149. onXRSessionEnded: Observable<any>;
  107150. /**
  107151. * Underlying xr session
  107152. */
  107153. session: XRSession;
  107154. /**
  107155. * Type of reference space used when creating the session
  107156. */
  107157. referenceSpace: XRReferenceSpace;
  107158. /** @hidden */
  107159. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107160. /**
  107161. * Current XR frame
  107162. */
  107163. currentFrame: Nullable<XRFrame>;
  107164. private _xrNavigator;
  107165. private baseLayer;
  107166. /**
  107167. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107168. * @param scene The scene which the session should be created for
  107169. */
  107170. constructor(scene: Scene);
  107171. /**
  107172. * Initializes the manager
  107173. * After initialization enterXR can be called to start an XR session
  107174. * @returns Promise which resolves after it is initialized
  107175. */
  107176. initializeAsync(): Promise<void>;
  107177. /**
  107178. * Initializes an xr session
  107179. * @param xrSessionMode mode to initialize
  107180. * @returns a promise which will resolve once the session has been initialized
  107181. */
  107182. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107183. /**
  107184. * Sets the reference space on the xr session
  107185. * @param referenceSpace space to set
  107186. * @returns a promise that will resolve once the reference space has been set
  107187. */
  107188. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107189. /**
  107190. * Updates the render state of the session
  107191. * @param state state to set
  107192. * @returns a promise that resolves once the render state has been updated
  107193. */
  107194. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107195. /**
  107196. * Starts rendering to the xr layer
  107197. * @returns a promise that will resolve once rendering has started
  107198. */
  107199. startRenderingToXRAsync(): Promise<void>;
  107200. /**
  107201. * Stops the xrSession and restores the renderloop
  107202. * @returns Promise which resolves after it exits XR
  107203. */
  107204. exitXRAsync(): Promise<unknown>;
  107205. /**
  107206. * Checks if a session would be supported for the creation options specified
  107207. * @param sessionMode session mode to check if supported eg. immersive-vr
  107208. * @returns true if supported
  107209. */
  107210. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107211. /**
  107212. * @hidden
  107213. * Converts the render layer of xrSession to a render target
  107214. * @param session session to create render target for
  107215. * @param scene scene the new render target should be created for
  107216. */
  107217. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107218. /**
  107219. * Disposes of the session manager
  107220. */
  107221. dispose(): void;
  107222. }
  107223. }
  107224. declare module BABYLON {
  107225. /**
  107226. * WebXR Camera which holds the views for the xrSession
  107227. * @see https://doc.babylonjs.com/how_to/webxr
  107228. */
  107229. export class WebXRCamera extends FreeCamera {
  107230. private static _TmpMatrix;
  107231. /**
  107232. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107233. * @param name the name of the camera
  107234. * @param scene the scene to add the camera to
  107235. */
  107236. constructor(name: string, scene: Scene);
  107237. private _updateNumberOfRigCameras;
  107238. /** @hidden */
  107239. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107240. /**
  107241. * Updates the cameras position from the current pose information of the XR session
  107242. * @param xrSessionManager the session containing pose information
  107243. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107244. */
  107245. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107246. }
  107247. }
  107248. declare module BABYLON {
  107249. /**
  107250. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107251. */
  107252. export class WebXRManagedOutputCanvas implements IDisposable {
  107253. private helper;
  107254. private _canvas;
  107255. /**
  107256. * xrpresent context of the canvas which can be used to display/mirror xr content
  107257. */
  107258. canvasContext: WebGLRenderingContext;
  107259. /**
  107260. * xr layer for the canvas
  107261. */
  107262. xrLayer: Nullable<XRWebGLLayer>;
  107263. /**
  107264. * Initializes the xr layer for the session
  107265. * @param xrSession xr session
  107266. * @returns a promise that will resolve once the XR Layer has been created
  107267. */
  107268. initializeXRLayerAsync(xrSession: any): any;
  107269. /**
  107270. * Initializes the canvas to be added/removed upon entering/exiting xr
  107271. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107272. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107273. */
  107274. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107275. /**
  107276. * Disposes of the object
  107277. */
  107278. dispose(): void;
  107279. private _setManagedOutputCanvas;
  107280. private _addCanvas;
  107281. private _removeCanvas;
  107282. }
  107283. }
  107284. declare module BABYLON {
  107285. /**
  107286. * States of the webXR experience
  107287. */
  107288. export enum WebXRState {
  107289. /**
  107290. * Transitioning to being in XR mode
  107291. */
  107292. ENTERING_XR = 0,
  107293. /**
  107294. * Transitioning to non XR mode
  107295. */
  107296. EXITING_XR = 1,
  107297. /**
  107298. * In XR mode and presenting
  107299. */
  107300. IN_XR = 2,
  107301. /**
  107302. * Not entered XR mode
  107303. */
  107304. NOT_IN_XR = 3
  107305. }
  107306. /**
  107307. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107308. * @see https://doc.babylonjs.com/how_to/webxr
  107309. */
  107310. export class WebXRExperienceHelper implements IDisposable {
  107311. private scene;
  107312. /**
  107313. * 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
  107314. */
  107315. container: AbstractMesh;
  107316. /**
  107317. * Camera used to render xr content
  107318. */
  107319. camera: WebXRCamera;
  107320. /**
  107321. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107322. */
  107323. state: WebXRState;
  107324. private _setState;
  107325. private static _TmpVector;
  107326. /**
  107327. * Fires when the state of the experience helper has changed
  107328. */
  107329. onStateChangedObservable: Observable<WebXRState>;
  107330. /** Session manager used to keep track of xr session */
  107331. sessionManager: WebXRSessionManager;
  107332. private _nonVRCamera;
  107333. private _originalSceneAutoClear;
  107334. private _supported;
  107335. /**
  107336. * Creates the experience helper
  107337. * @param scene the scene to attach the experience helper to
  107338. * @returns a promise for the experience helper
  107339. */
  107340. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107341. /**
  107342. * Creates a WebXRExperienceHelper
  107343. * @param scene The scene the helper should be created in
  107344. */
  107345. private constructor();
  107346. /**
  107347. * Exits XR mode and returns the scene to its original state
  107348. * @returns promise that resolves after xr mode has exited
  107349. */
  107350. exitXRAsync(): Promise<unknown>;
  107351. /**
  107352. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107353. * @param sessionCreationOptions options for the XR session
  107354. * @param referenceSpaceType frame of reference of the XR session
  107355. * @param outputCanvas the output canvas that will be used to enter XR mode
  107356. * @returns promise that resolves after xr mode has entered
  107357. */
  107358. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107359. /**
  107360. * Updates the global position of the camera by moving the camera's container
  107361. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107362. * @param position The desired global position of the camera
  107363. */
  107364. setPositionOfCameraUsingContainer(position: Vector3): void;
  107365. /**
  107366. * Rotates the xr camera by rotating the camera's container around the camera's position
  107367. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107368. * @param rotation the desired quaternion rotation to apply to the camera
  107369. */
  107370. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107371. /**
  107372. * Disposes of the experience helper
  107373. */
  107374. dispose(): void;
  107375. }
  107376. }
  107377. declare module BABYLON {
  107378. /**
  107379. * Button which can be used to enter a different mode of XR
  107380. */
  107381. export class WebXREnterExitUIButton {
  107382. /** button element */
  107383. element: HTMLElement;
  107384. /** XR initialization options for the button */
  107385. sessionMode: XRSessionMode;
  107386. /** Reference space type */
  107387. referenceSpaceType: XRReferenceSpaceType;
  107388. /**
  107389. * Creates a WebXREnterExitUIButton
  107390. * @param element button element
  107391. * @param sessionMode XR initialization session mode
  107392. * @param referenceSpaceType the type of reference space to be used
  107393. */
  107394. constructor(
  107395. /** button element */
  107396. element: HTMLElement,
  107397. /** XR initialization options for the button */
  107398. sessionMode: XRSessionMode,
  107399. /** Reference space type */
  107400. referenceSpaceType: XRReferenceSpaceType);
  107401. /**
  107402. * Overwritable function which can be used to update the button's visuals when the state changes
  107403. * @param activeButton the current active button in the UI
  107404. */
  107405. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107406. }
  107407. /**
  107408. * Options to create the webXR UI
  107409. */
  107410. export class WebXREnterExitUIOptions {
  107411. /**
  107412. * Context to enter xr with
  107413. */
  107414. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107415. /**
  107416. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107417. */
  107418. customButtons?: Array<WebXREnterExitUIButton>;
  107419. }
  107420. /**
  107421. * UI to allow the user to enter/exit XR mode
  107422. */
  107423. export class WebXREnterExitUI implements IDisposable {
  107424. private scene;
  107425. private _overlay;
  107426. private _buttons;
  107427. private _activeButton;
  107428. /**
  107429. * Fired every time the active button is changed.
  107430. *
  107431. * When xr is entered via a button that launches xr that button will be the callback parameter
  107432. *
  107433. * When exiting xr the callback parameter will be null)
  107434. */
  107435. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107436. /**
  107437. * Creates UI to allow the user to enter/exit XR mode
  107438. * @param scene the scene to add the ui to
  107439. * @param helper the xr experience helper to enter/exit xr with
  107440. * @param options options to configure the UI
  107441. * @returns the created ui
  107442. */
  107443. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107444. private constructor();
  107445. private _updateButtons;
  107446. /**
  107447. * Disposes of the object
  107448. */
  107449. dispose(): void;
  107450. }
  107451. }
  107452. declare module BABYLON {
  107453. /**
  107454. * Represents an XR input
  107455. */
  107456. export class WebXRController {
  107457. private scene;
  107458. /** The underlying input source for the controller */
  107459. inputSource: XRInputSource;
  107460. private parentContainer;
  107461. /**
  107462. * 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
  107463. */
  107464. grip?: AbstractMesh;
  107465. /**
  107466. * Pointer which can be used to select objects or attach a visible laser to
  107467. */
  107468. pointer: AbstractMesh;
  107469. /**
  107470. * Event that fires when the controller is removed/disposed
  107471. */
  107472. onDisposeObservable: Observable<{}>;
  107473. private _tmpMatrix;
  107474. private _tmpQuaternion;
  107475. private _tmpVector;
  107476. /**
  107477. * Creates the controller
  107478. * @see https://doc.babylonjs.com/how_to/webxr
  107479. * @param scene the scene which the controller should be associated to
  107480. * @param inputSource the underlying input source for the controller
  107481. * @param parentContainer parent that the controller meshes should be children of
  107482. */
  107483. constructor(scene: Scene,
  107484. /** The underlying input source for the controller */
  107485. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107486. /**
  107487. * Updates the controller pose based on the given XRFrame
  107488. * @param xrFrame xr frame to update the pose with
  107489. * @param referenceSpace reference space to use
  107490. */
  107491. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107492. /**
  107493. * Gets a world space ray coming from the controller
  107494. * @param result the resulting ray
  107495. */
  107496. getWorldPointerRayToRef(result: Ray): void;
  107497. /**
  107498. * Disposes of the object
  107499. */
  107500. dispose(): void;
  107501. }
  107502. }
  107503. declare module BABYLON {
  107504. /**
  107505. * XR input used to track XR inputs such as controllers/rays
  107506. */
  107507. export class WebXRInput implements IDisposable {
  107508. /**
  107509. * Base experience the input listens to
  107510. */
  107511. baseExperience: WebXRExperienceHelper;
  107512. /**
  107513. * XR controllers being tracked
  107514. */
  107515. controllers: Array<WebXRController>;
  107516. private _frameObserver;
  107517. private _stateObserver;
  107518. /**
  107519. * Event when a controller has been connected/added
  107520. */
  107521. onControllerAddedObservable: Observable<WebXRController>;
  107522. /**
  107523. * Event when a controller has been removed/disconnected
  107524. */
  107525. onControllerRemovedObservable: Observable<WebXRController>;
  107526. /**
  107527. * Initializes the WebXRInput
  107528. * @param baseExperience experience helper which the input should be created for
  107529. */
  107530. constructor(
  107531. /**
  107532. * Base experience the input listens to
  107533. */
  107534. baseExperience: WebXRExperienceHelper);
  107535. private _onInputSourcesChange;
  107536. private _addAndRemoveControllers;
  107537. /**
  107538. * Disposes of the object
  107539. */
  107540. dispose(): void;
  107541. }
  107542. }
  107543. declare module BABYLON {
  107544. /**
  107545. * Enables teleportation
  107546. */
  107547. export class WebXRControllerTeleportation {
  107548. private _teleportationFillColor;
  107549. private _teleportationBorderColor;
  107550. private _tmpRay;
  107551. private _tmpVector;
  107552. /**
  107553. * Creates a WebXRControllerTeleportation
  107554. * @param input input manager to add teleportation to
  107555. * @param floorMeshes floormeshes which can be teleported to
  107556. */
  107557. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107558. }
  107559. }
  107560. declare module BABYLON {
  107561. /**
  107562. * Handles pointer input automatically for the pointer of XR controllers
  107563. */
  107564. export class WebXRControllerPointerSelection {
  107565. private static _idCounter;
  107566. private _tmpRay;
  107567. /**
  107568. * Creates a WebXRControllerPointerSelection
  107569. * @param input input manager to setup pointer selection
  107570. */
  107571. constructor(input: WebXRInput);
  107572. private _convertNormalToDirectionOfRay;
  107573. private _updatePointerDistance;
  107574. }
  107575. }
  107576. declare module BABYLON {
  107577. /**
  107578. * Class used to represent data loading progression
  107579. */
  107580. export class SceneLoaderProgressEvent {
  107581. /** defines if data length to load can be evaluated */
  107582. readonly lengthComputable: boolean;
  107583. /** defines the loaded data length */
  107584. readonly loaded: number;
  107585. /** defines the data length to load */
  107586. readonly total: number;
  107587. /**
  107588. * Create a new progress event
  107589. * @param lengthComputable defines if data length to load can be evaluated
  107590. * @param loaded defines the loaded data length
  107591. * @param total defines the data length to load
  107592. */
  107593. constructor(
  107594. /** defines if data length to load can be evaluated */
  107595. lengthComputable: boolean,
  107596. /** defines the loaded data length */
  107597. loaded: number,
  107598. /** defines the data length to load */
  107599. total: number);
  107600. /**
  107601. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107602. * @param event defines the source event
  107603. * @returns a new SceneLoaderProgressEvent
  107604. */
  107605. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107606. }
  107607. /**
  107608. * Interface used by SceneLoader plugins to define supported file extensions
  107609. */
  107610. export interface ISceneLoaderPluginExtensions {
  107611. /**
  107612. * Defines the list of supported extensions
  107613. */
  107614. [extension: string]: {
  107615. isBinary: boolean;
  107616. };
  107617. }
  107618. /**
  107619. * Interface used by SceneLoader plugin factory
  107620. */
  107621. export interface ISceneLoaderPluginFactory {
  107622. /**
  107623. * Defines the name of the factory
  107624. */
  107625. name: string;
  107626. /**
  107627. * Function called to create a new plugin
  107628. * @return the new plugin
  107629. */
  107630. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107631. /**
  107632. * Boolean indicating if the plugin can direct load specific data
  107633. */
  107634. canDirectLoad?: (data: string) => boolean;
  107635. }
  107636. /**
  107637. * Interface used to define a SceneLoader plugin
  107638. */
  107639. export interface ISceneLoaderPlugin {
  107640. /**
  107641. * The friendly name of this plugin.
  107642. */
  107643. name: string;
  107644. /**
  107645. * The file extensions supported by this plugin.
  107646. */
  107647. extensions: string | ISceneLoaderPluginExtensions;
  107648. /**
  107649. * Import meshes into a scene.
  107650. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107651. * @param scene The scene to import into
  107652. * @param data The data to import
  107653. * @param rootUrl The root url for scene and resources
  107654. * @param meshes The meshes array to import into
  107655. * @param particleSystems The particle systems array to import into
  107656. * @param skeletons The skeletons array to import into
  107657. * @param onError The callback when import fails
  107658. * @returns True if successful or false otherwise
  107659. */
  107660. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107661. /**
  107662. * Load into a scene.
  107663. * @param scene The scene to load into
  107664. * @param data The data to import
  107665. * @param rootUrl The root url for scene and resources
  107666. * @param onError The callback when import fails
  107667. * @returns true if successful or false otherwise
  107668. */
  107669. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107670. /**
  107671. * The callback that returns true if the data can be directly loaded.
  107672. */
  107673. canDirectLoad?: (data: string) => boolean;
  107674. /**
  107675. * The callback that allows custom handling of the root url based on the response url.
  107676. */
  107677. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107678. /**
  107679. * Load into an asset container.
  107680. * @param scene The scene to load into
  107681. * @param data The data to import
  107682. * @param rootUrl The root url for scene and resources
  107683. * @param onError The callback when import fails
  107684. * @returns The loaded asset container
  107685. */
  107686. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107687. }
  107688. /**
  107689. * Interface used to define an async SceneLoader plugin
  107690. */
  107691. export interface ISceneLoaderPluginAsync {
  107692. /**
  107693. * The friendly name of this plugin.
  107694. */
  107695. name: string;
  107696. /**
  107697. * The file extensions supported by this plugin.
  107698. */
  107699. extensions: string | ISceneLoaderPluginExtensions;
  107700. /**
  107701. * Import meshes into a scene.
  107702. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107703. * @param scene The scene to import into
  107704. * @param data The data to import
  107705. * @param rootUrl The root url for scene and resources
  107706. * @param onProgress The callback when the load progresses
  107707. * @param fileName Defines the name of the file to load
  107708. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107709. */
  107710. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107711. meshes: AbstractMesh[];
  107712. particleSystems: IParticleSystem[];
  107713. skeletons: Skeleton[];
  107714. animationGroups: AnimationGroup[];
  107715. }>;
  107716. /**
  107717. * Load into a scene.
  107718. * @param scene The scene to load into
  107719. * @param data The data to import
  107720. * @param rootUrl The root url for scene and resources
  107721. * @param onProgress The callback when the load progresses
  107722. * @param fileName Defines the name of the file to load
  107723. * @returns Nothing
  107724. */
  107725. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107726. /**
  107727. * The callback that returns true if the data can be directly loaded.
  107728. */
  107729. canDirectLoad?: (data: string) => boolean;
  107730. /**
  107731. * The callback that allows custom handling of the root url based on the response url.
  107732. */
  107733. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107734. /**
  107735. * Load into an asset container.
  107736. * @param scene The scene to load into
  107737. * @param data The data to import
  107738. * @param rootUrl The root url for scene and resources
  107739. * @param onProgress The callback when the load progresses
  107740. * @param fileName Defines the name of the file to load
  107741. * @returns The loaded asset container
  107742. */
  107743. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107744. }
  107745. /**
  107746. * Class used to load scene from various file formats using registered plugins
  107747. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107748. */
  107749. export class SceneLoader {
  107750. /**
  107751. * No logging while loading
  107752. */
  107753. static readonly NO_LOGGING: number;
  107754. /**
  107755. * Minimal logging while loading
  107756. */
  107757. static readonly MINIMAL_LOGGING: number;
  107758. /**
  107759. * Summary logging while loading
  107760. */
  107761. static readonly SUMMARY_LOGGING: number;
  107762. /**
  107763. * Detailled logging while loading
  107764. */
  107765. static readonly DETAILED_LOGGING: number;
  107766. /**
  107767. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107768. */
  107769. static ForceFullSceneLoadingForIncremental: boolean;
  107770. /**
  107771. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107772. */
  107773. static ShowLoadingScreen: boolean;
  107774. /**
  107775. * Defines the current logging level (while loading the scene)
  107776. * @ignorenaming
  107777. */
  107778. static loggingLevel: number;
  107779. /**
  107780. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107781. */
  107782. static CleanBoneMatrixWeights: boolean;
  107783. /**
  107784. * Event raised when a plugin is used to load a scene
  107785. */
  107786. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107787. private static _registeredPlugins;
  107788. private static _getDefaultPlugin;
  107789. private static _getPluginForExtension;
  107790. private static _getPluginForDirectLoad;
  107791. private static _getPluginForFilename;
  107792. private static _getDirectLoad;
  107793. private static _loadData;
  107794. private static _getFileInfo;
  107795. /**
  107796. * Gets a plugin that can load the given extension
  107797. * @param extension defines the extension to load
  107798. * @returns a plugin or null if none works
  107799. */
  107800. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107801. /**
  107802. * Gets a boolean indicating that the given extension can be loaded
  107803. * @param extension defines the extension to load
  107804. * @returns true if the extension is supported
  107805. */
  107806. static IsPluginForExtensionAvailable(extension: string): boolean;
  107807. /**
  107808. * Adds a new plugin to the list of registered plugins
  107809. * @param plugin defines the plugin to add
  107810. */
  107811. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107812. /**
  107813. * Import meshes into a scene
  107814. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107815. * @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)
  107816. * @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)
  107817. * @param scene the instance of BABYLON.Scene to append to
  107818. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107819. * @param onProgress a callback with a progress event for each file being loaded
  107820. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107821. * @param pluginExtension the extension used to determine the plugin
  107822. * @returns The loaded plugin
  107823. */
  107824. 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>;
  107825. /**
  107826. * Import meshes into a scene
  107827. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107828. * @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)
  107829. * @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)
  107830. * @param scene the instance of BABYLON.Scene to append to
  107831. * @param onProgress a callback with a progress event for each file being loaded
  107832. * @param pluginExtension the extension used to determine the plugin
  107833. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107834. */
  107835. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107836. meshes: AbstractMesh[];
  107837. particleSystems: IParticleSystem[];
  107838. skeletons: Skeleton[];
  107839. animationGroups: AnimationGroup[];
  107840. }>;
  107841. /**
  107842. * Load a scene
  107843. * @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)
  107844. * @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)
  107845. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107846. * @param onSuccess a callback with the scene when import succeeds
  107847. * @param onProgress a callback with a progress event for each file being loaded
  107848. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107849. * @param pluginExtension the extension used to determine the plugin
  107850. * @returns The loaded plugin
  107851. */
  107852. 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>;
  107853. /**
  107854. * Load a scene
  107855. * @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)
  107856. * @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)
  107857. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107858. * @param onProgress a callback with a progress event for each file being loaded
  107859. * @param pluginExtension the extension used to determine the plugin
  107860. * @returns The loaded scene
  107861. */
  107862. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107863. /**
  107864. * Append a scene
  107865. * @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)
  107866. * @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)
  107867. * @param scene is the instance of BABYLON.Scene to append to
  107868. * @param onSuccess a callback with the scene when import succeeds
  107869. * @param onProgress a callback with a progress event for each file being loaded
  107870. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107871. * @param pluginExtension the extension used to determine the plugin
  107872. * @returns The loaded plugin
  107873. */
  107874. 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>;
  107875. /**
  107876. * Append a scene
  107877. * @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)
  107878. * @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)
  107879. * @param scene is the instance of BABYLON.Scene to append to
  107880. * @param onProgress a callback with a progress event for each file being loaded
  107881. * @param pluginExtension the extension used to determine the plugin
  107882. * @returns The given scene
  107883. */
  107884. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107885. /**
  107886. * Load a scene into an asset container
  107887. * @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)
  107888. * @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)
  107889. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107890. * @param onSuccess a callback with the scene when import succeeds
  107891. * @param onProgress a callback with a progress event for each file being loaded
  107892. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107893. * @param pluginExtension the extension used to determine the plugin
  107894. * @returns The loaded plugin
  107895. */
  107896. 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>;
  107897. /**
  107898. * Load a scene into an asset container
  107899. * @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)
  107900. * @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)
  107901. * @param scene is the instance of Scene to append to
  107902. * @param onProgress a callback with a progress event for each file being loaded
  107903. * @param pluginExtension the extension used to determine the plugin
  107904. * @returns The loaded asset container
  107905. */
  107906. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107907. }
  107908. }
  107909. declare module BABYLON {
  107910. /**
  107911. * Generic Controller
  107912. */
  107913. export class GenericController extends WebVRController {
  107914. /**
  107915. * Base Url for the controller model.
  107916. */
  107917. static readonly MODEL_BASE_URL: string;
  107918. /**
  107919. * File name for the controller model.
  107920. */
  107921. static readonly MODEL_FILENAME: string;
  107922. /**
  107923. * Creates a new GenericController from a gamepad
  107924. * @param vrGamepad the gamepad that the controller should be created from
  107925. */
  107926. constructor(vrGamepad: any);
  107927. /**
  107928. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107929. * @param scene scene in which to add meshes
  107930. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107931. */
  107932. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107933. /**
  107934. * Called once for each button that changed state since the last frame
  107935. * @param buttonIdx Which button index changed
  107936. * @param state New state of the button
  107937. * @param changes Which properties on the state changed since last frame
  107938. */
  107939. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107940. }
  107941. }
  107942. declare module BABYLON {
  107943. /**
  107944. * Defines the WindowsMotionController object that the state of the windows motion controller
  107945. */
  107946. export class WindowsMotionController extends WebVRController {
  107947. /**
  107948. * The base url used to load the left and right controller models
  107949. */
  107950. static MODEL_BASE_URL: string;
  107951. /**
  107952. * The name of the left controller model file
  107953. */
  107954. static MODEL_LEFT_FILENAME: string;
  107955. /**
  107956. * The name of the right controller model file
  107957. */
  107958. static MODEL_RIGHT_FILENAME: string;
  107959. /**
  107960. * The controller name prefix for this controller type
  107961. */
  107962. static readonly GAMEPAD_ID_PREFIX: string;
  107963. /**
  107964. * The controller id pattern for this controller type
  107965. */
  107966. private static readonly GAMEPAD_ID_PATTERN;
  107967. private _loadedMeshInfo;
  107968. private readonly _mapping;
  107969. /**
  107970. * Fired when the trackpad on this controller is clicked
  107971. */
  107972. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107973. /**
  107974. * Fired when the trackpad on this controller is modified
  107975. */
  107976. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107977. /**
  107978. * The current x and y values of this controller's trackpad
  107979. */
  107980. trackpad: StickValues;
  107981. /**
  107982. * Creates a new WindowsMotionController from a gamepad
  107983. * @param vrGamepad the gamepad that the controller should be created from
  107984. */
  107985. constructor(vrGamepad: any);
  107986. /**
  107987. * Fired when the trigger on this controller is modified
  107988. */
  107989. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107990. /**
  107991. * Fired when the menu button on this controller is modified
  107992. */
  107993. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107994. /**
  107995. * Fired when the grip button on this controller is modified
  107996. */
  107997. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107998. /**
  107999. * Fired when the thumbstick button on this controller is modified
  108000. */
  108001. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108002. /**
  108003. * Fired when the touchpad button on this controller is modified
  108004. */
  108005. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108006. /**
  108007. * Fired when the touchpad values on this controller are modified
  108008. */
  108009. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108010. private _updateTrackpad;
  108011. /**
  108012. * Called once per frame by the engine.
  108013. */
  108014. update(): void;
  108015. /**
  108016. * Called once for each button that changed state since the last frame
  108017. * @param buttonIdx Which button index changed
  108018. * @param state New state of the button
  108019. * @param changes Which properties on the state changed since last frame
  108020. */
  108021. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108022. /**
  108023. * Moves the buttons on the controller mesh based on their current state
  108024. * @param buttonName the name of the button to move
  108025. * @param buttonValue the value of the button which determines the buttons new position
  108026. */
  108027. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108028. /**
  108029. * Moves the axis on the controller mesh based on its current state
  108030. * @param axis the index of the axis
  108031. * @param axisValue the value of the axis which determines the meshes new position
  108032. * @hidden
  108033. */
  108034. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108035. /**
  108036. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108037. * @param scene scene in which to add meshes
  108038. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108039. */
  108040. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  108041. /**
  108042. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  108043. * can be transformed by button presses and axes values, based on this._mapping.
  108044. *
  108045. * @param scene scene in which the meshes exist
  108046. * @param meshes list of meshes that make up the controller model to process
  108047. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108048. */
  108049. private processModel;
  108050. private createMeshInfo;
  108051. /**
  108052. * Gets the ray of the controller in the direction the controller is pointing
  108053. * @param length the length the resulting ray should be
  108054. * @returns a ray in the direction the controller is pointing
  108055. */
  108056. getForwardRay(length?: number): Ray;
  108057. /**
  108058. * Disposes of the controller
  108059. */
  108060. dispose(): void;
  108061. }
  108062. }
  108063. declare module BABYLON {
  108064. /**
  108065. * Oculus Touch Controller
  108066. */
  108067. export class OculusTouchController extends WebVRController {
  108068. /**
  108069. * Base Url for the controller model.
  108070. */
  108071. static MODEL_BASE_URL: string;
  108072. /**
  108073. * File name for the left controller model.
  108074. */
  108075. static MODEL_LEFT_FILENAME: string;
  108076. /**
  108077. * File name for the right controller model.
  108078. */
  108079. static MODEL_RIGHT_FILENAME: string;
  108080. /**
  108081. * Base Url for the Quest controller model.
  108082. */
  108083. static QUEST_MODEL_BASE_URL: string;
  108084. /**
  108085. * @hidden
  108086. * If the controllers are running on a device that needs the updated Quest controller models
  108087. */
  108088. static _IsQuest: boolean;
  108089. /**
  108090. * Fired when the secondary trigger on this controller is modified
  108091. */
  108092. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108093. /**
  108094. * Fired when the thumb rest on this controller is modified
  108095. */
  108096. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108097. /**
  108098. * Creates a new OculusTouchController from a gamepad
  108099. * @param vrGamepad the gamepad that the controller should be created from
  108100. */
  108101. constructor(vrGamepad: any);
  108102. /**
  108103. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108104. * @param scene scene in which to add meshes
  108105. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108106. */
  108107. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108108. /**
  108109. * Fired when the A button on this controller is modified
  108110. */
  108111. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108112. /**
  108113. * Fired when the B button on this controller is modified
  108114. */
  108115. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108116. /**
  108117. * Fired when the X button on this controller is modified
  108118. */
  108119. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108120. /**
  108121. * Fired when the Y button on this controller is modified
  108122. */
  108123. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108124. /**
  108125. * Called once for each button that changed state since the last frame
  108126. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  108127. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  108128. * 2) secondary trigger (same)
  108129. * 3) A (right) X (left), touch, pressed = value
  108130. * 4) B / Y
  108131. * 5) thumb rest
  108132. * @param buttonIdx Which button index changed
  108133. * @param state New state of the button
  108134. * @param changes Which properties on the state changed since last frame
  108135. */
  108136. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108137. }
  108138. }
  108139. declare module BABYLON {
  108140. /**
  108141. * Vive Controller
  108142. */
  108143. export class ViveController extends WebVRController {
  108144. /**
  108145. * Base Url for the controller model.
  108146. */
  108147. static MODEL_BASE_URL: string;
  108148. /**
  108149. * File name for the controller model.
  108150. */
  108151. static MODEL_FILENAME: string;
  108152. /**
  108153. * Creates a new ViveController from a gamepad
  108154. * @param vrGamepad the gamepad that the controller should be created from
  108155. */
  108156. constructor(vrGamepad: any);
  108157. /**
  108158. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108159. * @param scene scene in which to add meshes
  108160. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108161. */
  108162. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108163. /**
  108164. * Fired when the left button on this controller is modified
  108165. */
  108166. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108167. /**
  108168. * Fired when the right button on this controller is modified
  108169. */
  108170. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108171. /**
  108172. * Fired when the menu button on this controller is modified
  108173. */
  108174. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108175. /**
  108176. * Called once for each button that changed state since the last frame
  108177. * Vive mapping:
  108178. * 0: touchpad
  108179. * 1: trigger
  108180. * 2: left AND right buttons
  108181. * 3: menu button
  108182. * @param buttonIdx Which button index changed
  108183. * @param state New state of the button
  108184. * @param changes Which properties on the state changed since last frame
  108185. */
  108186. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108187. }
  108188. }
  108189. declare module BABYLON {
  108190. /**
  108191. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108192. */
  108193. export class WebXRControllerModelLoader {
  108194. /**
  108195. * Creates the WebXRControllerModelLoader
  108196. * @param input xr input that creates the controllers
  108197. */
  108198. constructor(input: WebXRInput);
  108199. }
  108200. }
  108201. declare module BABYLON {
  108202. /**
  108203. * Contains an array of blocks representing the octree
  108204. */
  108205. export interface IOctreeContainer<T> {
  108206. /**
  108207. * Blocks within the octree
  108208. */
  108209. blocks: Array<OctreeBlock<T>>;
  108210. }
  108211. /**
  108212. * Class used to store a cell in an octree
  108213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108214. */
  108215. export class OctreeBlock<T> {
  108216. /**
  108217. * Gets the content of the current block
  108218. */
  108219. entries: T[];
  108220. /**
  108221. * Gets the list of block children
  108222. */
  108223. blocks: Array<OctreeBlock<T>>;
  108224. private _depth;
  108225. private _maxDepth;
  108226. private _capacity;
  108227. private _minPoint;
  108228. private _maxPoint;
  108229. private _boundingVectors;
  108230. private _creationFunc;
  108231. /**
  108232. * Creates a new block
  108233. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108234. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108235. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108236. * @param depth defines the current depth of this block in the octree
  108237. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108238. * @param creationFunc defines a callback to call when an element is added to the block
  108239. */
  108240. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108241. /**
  108242. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108243. */
  108244. readonly capacity: number;
  108245. /**
  108246. * Gets the minimum vector (in world space) of the block's bounding box
  108247. */
  108248. readonly minPoint: Vector3;
  108249. /**
  108250. * Gets the maximum vector (in world space) of the block's bounding box
  108251. */
  108252. readonly maxPoint: Vector3;
  108253. /**
  108254. * Add a new element to this block
  108255. * @param entry defines the element to add
  108256. */
  108257. addEntry(entry: T): void;
  108258. /**
  108259. * Remove an element from this block
  108260. * @param entry defines the element to remove
  108261. */
  108262. removeEntry(entry: T): void;
  108263. /**
  108264. * Add an array of elements to this block
  108265. * @param entries defines the array of elements to add
  108266. */
  108267. addEntries(entries: T[]): void;
  108268. /**
  108269. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108270. * @param frustumPlanes defines the frustum planes to test
  108271. * @param selection defines the array to store current content if selection is positive
  108272. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108273. */
  108274. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108275. /**
  108276. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108277. * @param sphereCenter defines the bounding sphere center
  108278. * @param sphereRadius defines the bounding sphere radius
  108279. * @param selection defines the array to store current content if selection is positive
  108280. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108281. */
  108282. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108283. /**
  108284. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108285. * @param ray defines the ray to test with
  108286. * @param selection defines the array to store current content if selection is positive
  108287. */
  108288. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108289. /**
  108290. * Subdivide the content into child blocks (this block will then be empty)
  108291. */
  108292. createInnerBlocks(): void;
  108293. /**
  108294. * @hidden
  108295. */
  108296. 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;
  108297. }
  108298. }
  108299. declare module BABYLON {
  108300. /**
  108301. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108302. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108303. */
  108304. export class Octree<T> {
  108305. /** 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.) */
  108306. maxDepth: number;
  108307. /**
  108308. * Blocks within the octree containing objects
  108309. */
  108310. blocks: Array<OctreeBlock<T>>;
  108311. /**
  108312. * Content stored in the octree
  108313. */
  108314. dynamicContent: T[];
  108315. private _maxBlockCapacity;
  108316. private _selectionContent;
  108317. private _creationFunc;
  108318. /**
  108319. * Creates a octree
  108320. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108321. * @param creationFunc function to be used to instatiate the octree
  108322. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108323. * @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.)
  108324. */
  108325. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108326. /** 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.) */
  108327. maxDepth?: number);
  108328. /**
  108329. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108330. * @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);
  108331. * @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);
  108332. * @param entries meshes to be added to the octree blocks
  108333. */
  108334. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108335. /**
  108336. * Adds a mesh to the octree
  108337. * @param entry Mesh to add to the octree
  108338. */
  108339. addMesh(entry: T): void;
  108340. /**
  108341. * Remove an element from the octree
  108342. * @param entry defines the element to remove
  108343. */
  108344. removeMesh(entry: T): void;
  108345. /**
  108346. * Selects an array of meshes within the frustum
  108347. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108348. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108349. * @returns array of meshes within the frustum
  108350. */
  108351. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108352. /**
  108353. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108354. * @param sphereCenter defines the bounding sphere center
  108355. * @param sphereRadius defines the bounding sphere radius
  108356. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108357. * @returns an array of objects that intersect the sphere
  108358. */
  108359. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108360. /**
  108361. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108362. * @param ray defines the ray to test with
  108363. * @returns array of intersected objects
  108364. */
  108365. intersectsRay(ray: Ray): SmartArray<T>;
  108366. /**
  108367. * Adds a mesh into the octree block if it intersects the block
  108368. */
  108369. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108370. /**
  108371. * Adds a submesh into the octree block if it intersects the block
  108372. */
  108373. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108374. }
  108375. }
  108376. declare module BABYLON {
  108377. interface Scene {
  108378. /**
  108379. * @hidden
  108380. * Backing Filed
  108381. */
  108382. _selectionOctree: Octree<AbstractMesh>;
  108383. /**
  108384. * Gets the octree used to boost mesh selection (picking)
  108385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108386. */
  108387. selectionOctree: Octree<AbstractMesh>;
  108388. /**
  108389. * Creates or updates the octree used to boost selection (picking)
  108390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108391. * @param maxCapacity defines the maximum capacity per leaf
  108392. * @param maxDepth defines the maximum depth of the octree
  108393. * @returns an octree of AbstractMesh
  108394. */
  108395. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108396. }
  108397. interface AbstractMesh {
  108398. /**
  108399. * @hidden
  108400. * Backing Field
  108401. */
  108402. _submeshesOctree: Octree<SubMesh>;
  108403. /**
  108404. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108405. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108406. * @param maxCapacity defines the maximum size of each block (64 by default)
  108407. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108408. * @returns the new octree
  108409. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108410. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108411. */
  108412. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108413. }
  108414. /**
  108415. * Defines the octree scene component responsible to manage any octrees
  108416. * in a given scene.
  108417. */
  108418. export class OctreeSceneComponent {
  108419. /**
  108420. * The component name help to identify the component in the list of scene components.
  108421. */
  108422. readonly name: string;
  108423. /**
  108424. * The scene the component belongs to.
  108425. */
  108426. scene: Scene;
  108427. /**
  108428. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108429. */
  108430. readonly checksIsEnabled: boolean;
  108431. /**
  108432. * Creates a new instance of the component for the given scene
  108433. * @param scene Defines the scene to register the component in
  108434. */
  108435. constructor(scene: Scene);
  108436. /**
  108437. * Registers the component in a given scene
  108438. */
  108439. register(): void;
  108440. /**
  108441. * Return the list of active meshes
  108442. * @returns the list of active meshes
  108443. */
  108444. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108445. /**
  108446. * Return the list of active sub meshes
  108447. * @param mesh The mesh to get the candidates sub meshes from
  108448. * @returns the list of active sub meshes
  108449. */
  108450. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108451. private _tempRay;
  108452. /**
  108453. * Return the list of sub meshes intersecting with a given local ray
  108454. * @param mesh defines the mesh to find the submesh for
  108455. * @param localRay defines the ray in local space
  108456. * @returns the list of intersecting sub meshes
  108457. */
  108458. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108459. /**
  108460. * Return the list of sub meshes colliding with a collider
  108461. * @param mesh defines the mesh to find the submesh for
  108462. * @param collider defines the collider to evaluate the collision against
  108463. * @returns the list of colliding sub meshes
  108464. */
  108465. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108466. /**
  108467. * Rebuilds the elements related to this component in case of
  108468. * context lost for instance.
  108469. */
  108470. rebuild(): void;
  108471. /**
  108472. * Disposes the component and the associated ressources.
  108473. */
  108474. dispose(): void;
  108475. }
  108476. }
  108477. declare module BABYLON {
  108478. /**
  108479. * Renders a layer on top of an existing scene
  108480. */
  108481. export class UtilityLayerRenderer implements IDisposable {
  108482. /** the original scene that will be rendered on top of */
  108483. originalScene: Scene;
  108484. private _pointerCaptures;
  108485. private _lastPointerEvents;
  108486. private static _DefaultUtilityLayer;
  108487. private static _DefaultKeepDepthUtilityLayer;
  108488. private _sharedGizmoLight;
  108489. private _renderCamera;
  108490. /**
  108491. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108492. * @returns the camera that is used when rendering the utility layer
  108493. */
  108494. getRenderCamera(): Nullable<Camera>;
  108495. /**
  108496. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108497. * @param cam the camera that should be used when rendering the utility layer
  108498. */
  108499. setRenderCamera(cam: Nullable<Camera>): void;
  108500. /**
  108501. * @hidden
  108502. * Light which used by gizmos to get light shading
  108503. */
  108504. _getSharedGizmoLight(): HemisphericLight;
  108505. /**
  108506. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108507. */
  108508. pickUtilitySceneFirst: boolean;
  108509. /**
  108510. * 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)
  108511. */
  108512. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108513. /**
  108514. * 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)
  108515. */
  108516. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108517. /**
  108518. * The scene that is rendered on top of the original scene
  108519. */
  108520. utilityLayerScene: Scene;
  108521. /**
  108522. * If the utility layer should automatically be rendered on top of existing scene
  108523. */
  108524. shouldRender: boolean;
  108525. /**
  108526. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108527. */
  108528. onlyCheckPointerDownEvents: boolean;
  108529. /**
  108530. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108531. */
  108532. processAllEvents: boolean;
  108533. /**
  108534. * Observable raised when the pointer move from the utility layer scene to the main scene
  108535. */
  108536. onPointerOutObservable: Observable<number>;
  108537. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108538. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108539. private _afterRenderObserver;
  108540. private _sceneDisposeObserver;
  108541. private _originalPointerObserver;
  108542. /**
  108543. * Instantiates a UtilityLayerRenderer
  108544. * @param originalScene the original scene that will be rendered on top of
  108545. * @param handleEvents boolean indicating if the utility layer should handle events
  108546. */
  108547. constructor(
  108548. /** the original scene that will be rendered on top of */
  108549. originalScene: Scene, handleEvents?: boolean);
  108550. private _notifyObservers;
  108551. /**
  108552. * Renders the utility layers scene on top of the original scene
  108553. */
  108554. render(): void;
  108555. /**
  108556. * Disposes of the renderer
  108557. */
  108558. dispose(): void;
  108559. private _updateCamera;
  108560. }
  108561. }
  108562. declare module BABYLON {
  108563. /**
  108564. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108565. */
  108566. export class Gizmo implements IDisposable {
  108567. /** The utility layer the gizmo will be added to */
  108568. gizmoLayer: UtilityLayerRenderer;
  108569. /**
  108570. * The root mesh of the gizmo
  108571. */
  108572. _rootMesh: Mesh;
  108573. private _attachedMesh;
  108574. /**
  108575. * Ratio for the scale of the gizmo (Default: 1)
  108576. */
  108577. scaleRatio: number;
  108578. /**
  108579. * If a custom mesh has been set (Default: false)
  108580. */
  108581. protected _customMeshSet: boolean;
  108582. /**
  108583. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108584. * * When set, interactions will be enabled
  108585. */
  108586. attachedMesh: Nullable<AbstractMesh>;
  108587. /**
  108588. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108589. * @param mesh The mesh to replace the default mesh of the gizmo
  108590. */
  108591. setCustomMesh(mesh: Mesh): void;
  108592. /**
  108593. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108594. */
  108595. updateGizmoRotationToMatchAttachedMesh: boolean;
  108596. /**
  108597. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108598. */
  108599. updateGizmoPositionToMatchAttachedMesh: boolean;
  108600. /**
  108601. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108602. */
  108603. updateScale: boolean;
  108604. protected _interactionsEnabled: boolean;
  108605. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108606. private _beforeRenderObserver;
  108607. private _tempVector;
  108608. /**
  108609. * Creates a gizmo
  108610. * @param gizmoLayer The utility layer the gizmo will be added to
  108611. */
  108612. constructor(
  108613. /** The utility layer the gizmo will be added to */
  108614. gizmoLayer?: UtilityLayerRenderer);
  108615. /**
  108616. * Updates the gizmo to match the attached mesh's position/rotation
  108617. */
  108618. protected _update(): void;
  108619. /**
  108620. * Disposes of the gizmo
  108621. */
  108622. dispose(): void;
  108623. }
  108624. }
  108625. declare module BABYLON {
  108626. /**
  108627. * Single plane drag gizmo
  108628. */
  108629. export class PlaneDragGizmo extends Gizmo {
  108630. /**
  108631. * Drag behavior responsible for the gizmos dragging interactions
  108632. */
  108633. dragBehavior: PointerDragBehavior;
  108634. private _pointerObserver;
  108635. /**
  108636. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108637. */
  108638. snapDistance: number;
  108639. /**
  108640. * Event that fires each time the gizmo snaps to a new location.
  108641. * * snapDistance is the the change in distance
  108642. */
  108643. onSnapObservable: Observable<{
  108644. snapDistance: number;
  108645. }>;
  108646. private _plane;
  108647. private _coloredMaterial;
  108648. private _hoverMaterial;
  108649. private _isEnabled;
  108650. private _parent;
  108651. /** @hidden */
  108652. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108653. /** @hidden */
  108654. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108655. /**
  108656. * Creates a PlaneDragGizmo
  108657. * @param gizmoLayer The utility layer the gizmo will be added to
  108658. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108659. * @param color The color of the gizmo
  108660. */
  108661. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108662. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108663. /**
  108664. * If the gizmo is enabled
  108665. */
  108666. isEnabled: boolean;
  108667. /**
  108668. * Disposes of the gizmo
  108669. */
  108670. dispose(): void;
  108671. }
  108672. }
  108673. declare module BABYLON {
  108674. /**
  108675. * Gizmo that enables dragging a mesh along 3 axis
  108676. */
  108677. export class PositionGizmo extends Gizmo {
  108678. /**
  108679. * Internal gizmo used for interactions on the x axis
  108680. */
  108681. xGizmo: AxisDragGizmo;
  108682. /**
  108683. * Internal gizmo used for interactions on the y axis
  108684. */
  108685. yGizmo: AxisDragGizmo;
  108686. /**
  108687. * Internal gizmo used for interactions on the z axis
  108688. */
  108689. zGizmo: AxisDragGizmo;
  108690. /**
  108691. * Internal gizmo used for interactions on the yz plane
  108692. */
  108693. xPlaneGizmo: PlaneDragGizmo;
  108694. /**
  108695. * Internal gizmo used for interactions on the xz plane
  108696. */
  108697. yPlaneGizmo: PlaneDragGizmo;
  108698. /**
  108699. * Internal gizmo used for interactions on the xy plane
  108700. */
  108701. zPlaneGizmo: PlaneDragGizmo;
  108702. /**
  108703. * private variables
  108704. */
  108705. private _meshAttached;
  108706. private _updateGizmoRotationToMatchAttachedMesh;
  108707. private _snapDistance;
  108708. private _scaleRatio;
  108709. /** Fires an event when any of it's sub gizmos are dragged */
  108710. onDragStartObservable: Observable<unknown>;
  108711. /** Fires an event when any of it's sub gizmos are released from dragging */
  108712. onDragEndObservable: Observable<unknown>;
  108713. /**
  108714. * If set to true, planar drag is enabled
  108715. */
  108716. private _planarGizmoEnabled;
  108717. attachedMesh: Nullable<AbstractMesh>;
  108718. /**
  108719. * Creates a PositionGizmo
  108720. * @param gizmoLayer The utility layer the gizmo will be added to
  108721. */
  108722. constructor(gizmoLayer?: UtilityLayerRenderer);
  108723. /**
  108724. * If the planar drag gizmo is enabled
  108725. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108726. */
  108727. planarGizmoEnabled: boolean;
  108728. updateGizmoRotationToMatchAttachedMesh: boolean;
  108729. /**
  108730. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108731. */
  108732. snapDistance: number;
  108733. /**
  108734. * Ratio for the scale of the gizmo (Default: 1)
  108735. */
  108736. scaleRatio: number;
  108737. /**
  108738. * Disposes of the gizmo
  108739. */
  108740. dispose(): void;
  108741. /**
  108742. * CustomMeshes are not supported by this gizmo
  108743. * @param mesh The mesh to replace the default mesh of the gizmo
  108744. */
  108745. setCustomMesh(mesh: Mesh): void;
  108746. }
  108747. }
  108748. declare module BABYLON {
  108749. /**
  108750. * Single axis drag gizmo
  108751. */
  108752. export class AxisDragGizmo extends Gizmo {
  108753. /**
  108754. * Drag behavior responsible for the gizmos dragging interactions
  108755. */
  108756. dragBehavior: PointerDragBehavior;
  108757. private _pointerObserver;
  108758. /**
  108759. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108760. */
  108761. snapDistance: number;
  108762. /**
  108763. * Event that fires each time the gizmo snaps to a new location.
  108764. * * snapDistance is the the change in distance
  108765. */
  108766. onSnapObservable: Observable<{
  108767. snapDistance: number;
  108768. }>;
  108769. private _isEnabled;
  108770. private _parent;
  108771. private _arrow;
  108772. private _coloredMaterial;
  108773. private _hoverMaterial;
  108774. /** @hidden */
  108775. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108776. /** @hidden */
  108777. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108778. /**
  108779. * Creates an AxisDragGizmo
  108780. * @param gizmoLayer The utility layer the gizmo will be added to
  108781. * @param dragAxis The axis which the gizmo will be able to drag on
  108782. * @param color The color of the gizmo
  108783. */
  108784. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108785. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108786. /**
  108787. * If the gizmo is enabled
  108788. */
  108789. isEnabled: boolean;
  108790. /**
  108791. * Disposes of the gizmo
  108792. */
  108793. dispose(): void;
  108794. }
  108795. }
  108796. declare module BABYLON.Debug {
  108797. /**
  108798. * The Axes viewer will show 3 axes in a specific point in space
  108799. */
  108800. export class AxesViewer {
  108801. private _xAxis;
  108802. private _yAxis;
  108803. private _zAxis;
  108804. private _scaleLinesFactor;
  108805. private _instanced;
  108806. /**
  108807. * Gets the hosting scene
  108808. */
  108809. scene: Scene;
  108810. /**
  108811. * Gets or sets a number used to scale line length
  108812. */
  108813. scaleLines: number;
  108814. /** Gets the node hierarchy used to render x-axis */
  108815. readonly xAxis: TransformNode;
  108816. /** Gets the node hierarchy used to render y-axis */
  108817. readonly yAxis: TransformNode;
  108818. /** Gets the node hierarchy used to render z-axis */
  108819. readonly zAxis: TransformNode;
  108820. /**
  108821. * Creates a new AxesViewer
  108822. * @param scene defines the hosting scene
  108823. * @param scaleLines defines a number used to scale line length (1 by default)
  108824. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108825. * @param xAxis defines the node hierarchy used to render the x-axis
  108826. * @param yAxis defines the node hierarchy used to render the y-axis
  108827. * @param zAxis defines the node hierarchy used to render the z-axis
  108828. */
  108829. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108830. /**
  108831. * Force the viewer to update
  108832. * @param position defines the position of the viewer
  108833. * @param xaxis defines the x axis of the viewer
  108834. * @param yaxis defines the y axis of the viewer
  108835. * @param zaxis defines the z axis of the viewer
  108836. */
  108837. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108838. /**
  108839. * Creates an instance of this axes viewer.
  108840. * @returns a new axes viewer with instanced meshes
  108841. */
  108842. createInstance(): AxesViewer;
  108843. /** Releases resources */
  108844. dispose(): void;
  108845. private static _SetRenderingGroupId;
  108846. }
  108847. }
  108848. declare module BABYLON.Debug {
  108849. /**
  108850. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108851. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108852. */
  108853. export class BoneAxesViewer extends AxesViewer {
  108854. /**
  108855. * Gets or sets the target mesh where to display the axes viewer
  108856. */
  108857. mesh: Nullable<Mesh>;
  108858. /**
  108859. * Gets or sets the target bone where to display the axes viewer
  108860. */
  108861. bone: Nullable<Bone>;
  108862. /** Gets current position */
  108863. pos: Vector3;
  108864. /** Gets direction of X axis */
  108865. xaxis: Vector3;
  108866. /** Gets direction of Y axis */
  108867. yaxis: Vector3;
  108868. /** Gets direction of Z axis */
  108869. zaxis: Vector3;
  108870. /**
  108871. * Creates a new BoneAxesViewer
  108872. * @param scene defines the hosting scene
  108873. * @param bone defines the target bone
  108874. * @param mesh defines the target mesh
  108875. * @param scaleLines defines a scaling factor for line length (1 by default)
  108876. */
  108877. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108878. /**
  108879. * Force the viewer to update
  108880. */
  108881. update(): void;
  108882. /** Releases resources */
  108883. dispose(): void;
  108884. }
  108885. }
  108886. declare module BABYLON {
  108887. /**
  108888. * Interface used to define scene explorer extensibility option
  108889. */
  108890. export interface IExplorerExtensibilityOption {
  108891. /**
  108892. * Define the option label
  108893. */
  108894. label: string;
  108895. /**
  108896. * Defines the action to execute on click
  108897. */
  108898. action: (entity: any) => void;
  108899. }
  108900. /**
  108901. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108902. */
  108903. export interface IExplorerExtensibilityGroup {
  108904. /**
  108905. * Defines a predicate to test if a given type mut be extended
  108906. */
  108907. predicate: (entity: any) => boolean;
  108908. /**
  108909. * Gets the list of options added to a type
  108910. */
  108911. entries: IExplorerExtensibilityOption[];
  108912. }
  108913. /**
  108914. * Interface used to define the options to use to create the Inspector
  108915. */
  108916. export interface IInspectorOptions {
  108917. /**
  108918. * Display in overlay mode (default: false)
  108919. */
  108920. overlay?: boolean;
  108921. /**
  108922. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108923. */
  108924. globalRoot?: HTMLElement;
  108925. /**
  108926. * Display the Scene explorer
  108927. */
  108928. showExplorer?: boolean;
  108929. /**
  108930. * Display the property inspector
  108931. */
  108932. showInspector?: boolean;
  108933. /**
  108934. * Display in embed mode (both panes on the right)
  108935. */
  108936. embedMode?: boolean;
  108937. /**
  108938. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108939. */
  108940. handleResize?: boolean;
  108941. /**
  108942. * Allow the panes to popup (default: true)
  108943. */
  108944. enablePopup?: boolean;
  108945. /**
  108946. * Allow the panes to be closed by users (default: true)
  108947. */
  108948. enableClose?: boolean;
  108949. /**
  108950. * Optional list of extensibility entries
  108951. */
  108952. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108953. /**
  108954. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108955. */
  108956. inspectorURL?: string;
  108957. }
  108958. interface Scene {
  108959. /**
  108960. * @hidden
  108961. * Backing field
  108962. */
  108963. _debugLayer: DebugLayer;
  108964. /**
  108965. * Gets the debug layer (aka Inspector) associated with the scene
  108966. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108967. */
  108968. debugLayer: DebugLayer;
  108969. }
  108970. /**
  108971. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108972. * what is happening in your scene
  108973. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108974. */
  108975. export class DebugLayer {
  108976. /**
  108977. * Define the url to get the inspector script from.
  108978. * By default it uses the babylonjs CDN.
  108979. * @ignoreNaming
  108980. */
  108981. static InspectorURL: string;
  108982. private _scene;
  108983. private BJSINSPECTOR;
  108984. private _onPropertyChangedObservable?;
  108985. /**
  108986. * Observable triggered when a property is changed through the inspector.
  108987. */
  108988. readonly onPropertyChangedObservable: any;
  108989. /**
  108990. * Instantiates a new debug layer.
  108991. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108992. * what is happening in your scene
  108993. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108994. * @param scene Defines the scene to inspect
  108995. */
  108996. constructor(scene: Scene);
  108997. /** Creates the inspector window. */
  108998. private _createInspector;
  108999. /**
  109000. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109001. * @param entity defines the entity to select
  109002. * @param lineContainerTitle defines the specific block to highlight
  109003. */
  109004. select(entity: any, lineContainerTitle?: string): void;
  109005. /** Get the inspector from bundle or global */
  109006. private _getGlobalInspector;
  109007. /**
  109008. * Get if the inspector is visible or not.
  109009. * @returns true if visible otherwise, false
  109010. */
  109011. isVisible(): boolean;
  109012. /**
  109013. * Hide the inspector and close its window.
  109014. */
  109015. hide(): void;
  109016. /**
  109017. * Launch the debugLayer.
  109018. * @param config Define the configuration of the inspector
  109019. * @return a promise fulfilled when the debug layer is visible
  109020. */
  109021. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109022. }
  109023. }
  109024. declare module BABYLON {
  109025. /**
  109026. * Class containing static functions to help procedurally build meshes
  109027. */
  109028. export class BoxBuilder {
  109029. /**
  109030. * Creates a box mesh
  109031. * * The parameter `size` sets the size (float) of each box side (default 1)
  109032. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109033. * * 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)
  109034. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109038. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109039. * @param name defines the name of the mesh
  109040. * @param options defines the options used to create the mesh
  109041. * @param scene defines the hosting scene
  109042. * @returns the box mesh
  109043. */
  109044. static CreateBox(name: string, options: {
  109045. size?: number;
  109046. width?: number;
  109047. height?: number;
  109048. depth?: number;
  109049. faceUV?: Vector4[];
  109050. faceColors?: Color4[];
  109051. sideOrientation?: number;
  109052. frontUVs?: Vector4;
  109053. backUVs?: Vector4;
  109054. wrap?: boolean;
  109055. topBaseAt?: number;
  109056. bottomBaseAt?: number;
  109057. updatable?: boolean;
  109058. }, scene?: Nullable<Scene>): Mesh;
  109059. }
  109060. }
  109061. declare module BABYLON {
  109062. /**
  109063. * Class containing static functions to help procedurally build meshes
  109064. */
  109065. export class SphereBuilder {
  109066. /**
  109067. * Creates a sphere mesh
  109068. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109069. * * 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`)
  109070. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109071. * * 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
  109072. * * 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)
  109073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109076. * @param name defines the name of the mesh
  109077. * @param options defines the options used to create the mesh
  109078. * @param scene defines the hosting scene
  109079. * @returns the sphere mesh
  109080. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109081. */
  109082. static CreateSphere(name: string, options: {
  109083. segments?: number;
  109084. diameter?: number;
  109085. diameterX?: number;
  109086. diameterY?: number;
  109087. diameterZ?: number;
  109088. arc?: number;
  109089. slice?: number;
  109090. sideOrientation?: number;
  109091. frontUVs?: Vector4;
  109092. backUVs?: Vector4;
  109093. updatable?: boolean;
  109094. }, scene?: Nullable<Scene>): Mesh;
  109095. }
  109096. }
  109097. declare module BABYLON.Debug {
  109098. /**
  109099. * Used to show the physics impostor around the specific mesh
  109100. */
  109101. export class PhysicsViewer {
  109102. /** @hidden */
  109103. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109104. /** @hidden */
  109105. protected _meshes: Array<Nullable<AbstractMesh>>;
  109106. /** @hidden */
  109107. protected _scene: Nullable<Scene>;
  109108. /** @hidden */
  109109. protected _numMeshes: number;
  109110. /** @hidden */
  109111. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  109112. private _renderFunction;
  109113. private _utilityLayer;
  109114. private _debugBoxMesh;
  109115. private _debugSphereMesh;
  109116. private _debugCylinderMesh;
  109117. private _debugMaterial;
  109118. private _debugMeshMeshes;
  109119. /**
  109120. * Creates a new PhysicsViewer
  109121. * @param scene defines the hosting scene
  109122. */
  109123. constructor(scene: Scene);
  109124. /** @hidden */
  109125. protected _updateDebugMeshes(): void;
  109126. /**
  109127. * Renders a specified physic impostor
  109128. * @param impostor defines the impostor to render
  109129. * @param targetMesh defines the mesh represented by the impostor
  109130. * @returns the new debug mesh used to render the impostor
  109131. */
  109132. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109133. /**
  109134. * Hides a specified physic impostor
  109135. * @param impostor defines the impostor to hide
  109136. */
  109137. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109138. private _getDebugMaterial;
  109139. private _getDebugBoxMesh;
  109140. private _getDebugSphereMesh;
  109141. private _getDebugCylinderMesh;
  109142. private _getDebugMeshMesh;
  109143. private _getDebugMesh;
  109144. /** Releases all resources */
  109145. dispose(): void;
  109146. }
  109147. }
  109148. declare module BABYLON {
  109149. /**
  109150. * Class containing static functions to help procedurally build meshes
  109151. */
  109152. export class LinesBuilder {
  109153. /**
  109154. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109155. * * 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
  109156. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109157. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109158. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109159. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109160. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109161. * * 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
  109162. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109165. * @param name defines the name of the new line system
  109166. * @param options defines the options used to create the line system
  109167. * @param scene defines the hosting scene
  109168. * @returns a new line system mesh
  109169. */
  109170. static CreateLineSystem(name: string, options: {
  109171. lines: Vector3[][];
  109172. updatable?: boolean;
  109173. instance?: Nullable<LinesMesh>;
  109174. colors?: Nullable<Color4[][]>;
  109175. useVertexAlpha?: boolean;
  109176. }, scene: Nullable<Scene>): LinesMesh;
  109177. /**
  109178. * Creates a line mesh
  109179. * 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
  109180. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109181. * * The parameter `points` is an array successive Vector3
  109182. * * 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
  109183. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109184. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109185. * * When updating an instance, remember that only point positions can change, not the number of points
  109186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109188. * @param name defines the name of the new line system
  109189. * @param options defines the options used to create the line system
  109190. * @param scene defines the hosting scene
  109191. * @returns a new line mesh
  109192. */
  109193. static CreateLines(name: string, options: {
  109194. points: Vector3[];
  109195. updatable?: boolean;
  109196. instance?: Nullable<LinesMesh>;
  109197. colors?: Color4[];
  109198. useVertexAlpha?: boolean;
  109199. }, scene?: Nullable<Scene>): LinesMesh;
  109200. /**
  109201. * Creates a dashed line mesh
  109202. * * 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
  109203. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109204. * * The parameter `points` is an array successive Vector3
  109205. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109206. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109207. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109208. * * 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
  109209. * * When updating an instance, remember that only point positions can change, not the number of points
  109210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109211. * @param name defines the name of the mesh
  109212. * @param options defines the options used to create the mesh
  109213. * @param scene defines the hosting scene
  109214. * @returns the dashed line mesh
  109215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109216. */
  109217. static CreateDashedLines(name: string, options: {
  109218. points: Vector3[];
  109219. dashSize?: number;
  109220. gapSize?: number;
  109221. dashNb?: number;
  109222. updatable?: boolean;
  109223. instance?: LinesMesh;
  109224. }, scene?: Nullable<Scene>): LinesMesh;
  109225. }
  109226. }
  109227. declare module BABYLON {
  109228. /**
  109229. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109230. * in order to better appreciate the issue one might have.
  109231. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109232. */
  109233. export class RayHelper {
  109234. /**
  109235. * Defines the ray we are currently tryin to visualize.
  109236. */
  109237. ray: Nullable<Ray>;
  109238. private _renderPoints;
  109239. private _renderLine;
  109240. private _renderFunction;
  109241. private _scene;
  109242. private _updateToMeshFunction;
  109243. private _attachedToMesh;
  109244. private _meshSpaceDirection;
  109245. private _meshSpaceOrigin;
  109246. /**
  109247. * Helper function to create a colored helper in a scene in one line.
  109248. * @param ray Defines the ray we are currently tryin to visualize
  109249. * @param scene Defines the scene the ray is used in
  109250. * @param color Defines the color we want to see the ray in
  109251. * @returns The newly created ray helper.
  109252. */
  109253. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109254. /**
  109255. * Instantiate a new ray helper.
  109256. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109257. * in order to better appreciate the issue one might have.
  109258. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109259. * @param ray Defines the ray we are currently tryin to visualize
  109260. */
  109261. constructor(ray: Ray);
  109262. /**
  109263. * Shows the ray we are willing to debug.
  109264. * @param scene Defines the scene the ray needs to be rendered in
  109265. * @param color Defines the color the ray needs to be rendered in
  109266. */
  109267. show(scene: Scene, color?: Color3): void;
  109268. /**
  109269. * Hides the ray we are debugging.
  109270. */
  109271. hide(): void;
  109272. private _render;
  109273. /**
  109274. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109275. * @param mesh Defines the mesh we want the helper attached to
  109276. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109277. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109278. * @param length Defines the length of the ray
  109279. */
  109280. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109281. /**
  109282. * Detach the ray helper from the mesh it has previously been attached to.
  109283. */
  109284. detachFromMesh(): void;
  109285. private _updateToMesh;
  109286. /**
  109287. * Dispose the helper and release its associated resources.
  109288. */
  109289. dispose(): void;
  109290. }
  109291. }
  109292. declare module BABYLON.Debug {
  109293. /**
  109294. * Class used to render a debug view of a given skeleton
  109295. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109296. */
  109297. export class SkeletonViewer {
  109298. /** defines the skeleton to render */
  109299. skeleton: Skeleton;
  109300. /** defines the mesh attached to the skeleton */
  109301. mesh: AbstractMesh;
  109302. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109303. autoUpdateBonesMatrices: boolean;
  109304. /** defines the rendering group id to use with the viewer */
  109305. renderingGroupId: number;
  109306. /** Gets or sets the color used to render the skeleton */
  109307. color: Color3;
  109308. private _scene;
  109309. private _debugLines;
  109310. private _debugMesh;
  109311. private _isEnabled;
  109312. private _renderFunction;
  109313. private _utilityLayer;
  109314. /**
  109315. * Returns the mesh used to render the bones
  109316. */
  109317. readonly debugMesh: Nullable<LinesMesh>;
  109318. /**
  109319. * Creates a new SkeletonViewer
  109320. * @param skeleton defines the skeleton to render
  109321. * @param mesh defines the mesh attached to the skeleton
  109322. * @param scene defines the hosting scene
  109323. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109324. * @param renderingGroupId defines the rendering group id to use with the viewer
  109325. */
  109326. constructor(
  109327. /** defines the skeleton to render */
  109328. skeleton: Skeleton,
  109329. /** defines the mesh attached to the skeleton */
  109330. mesh: AbstractMesh, scene: Scene,
  109331. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109332. autoUpdateBonesMatrices?: boolean,
  109333. /** defines the rendering group id to use with the viewer */
  109334. renderingGroupId?: number);
  109335. /** Gets or sets a boolean indicating if the viewer is enabled */
  109336. isEnabled: boolean;
  109337. private _getBonePosition;
  109338. private _getLinesForBonesWithLength;
  109339. private _getLinesForBonesNoLength;
  109340. /** Update the viewer to sync with current skeleton state */
  109341. update(): void;
  109342. /** Release associated resources */
  109343. dispose(): void;
  109344. }
  109345. }
  109346. declare module BABYLON {
  109347. /**
  109348. * Options to create the null engine
  109349. */
  109350. export class NullEngineOptions {
  109351. /**
  109352. * Render width (Default: 512)
  109353. */
  109354. renderWidth: number;
  109355. /**
  109356. * Render height (Default: 256)
  109357. */
  109358. renderHeight: number;
  109359. /**
  109360. * Texture size (Default: 512)
  109361. */
  109362. textureSize: number;
  109363. /**
  109364. * If delta time between frames should be constant
  109365. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109366. */
  109367. deterministicLockstep: boolean;
  109368. /**
  109369. * Maximum about of steps between frames (Default: 4)
  109370. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109371. */
  109372. lockstepMaxSteps: number;
  109373. }
  109374. /**
  109375. * The null engine class provides support for headless version of babylon.js.
  109376. * This can be used in server side scenario or for testing purposes
  109377. */
  109378. export class NullEngine extends Engine {
  109379. private _options;
  109380. /**
  109381. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  109382. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109383. * @returns true if engine is in deterministic lock step mode
  109384. */
  109385. isDeterministicLockStep(): boolean;
  109386. /**
  109387. * Gets the max steps when engine is running in deterministic lock step
  109388. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109389. * @returns the max steps
  109390. */
  109391. getLockstepMaxSteps(): number;
  109392. /**
  109393. * Gets the current hardware scaling level.
  109394. * By default the hardware scaling level is computed from the window device ratio.
  109395. * 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.
  109396. * @returns a number indicating the current hardware scaling level
  109397. */
  109398. getHardwareScalingLevel(): number;
  109399. constructor(options?: NullEngineOptions);
  109400. /**
  109401. * Creates a vertex buffer
  109402. * @param vertices the data for the vertex buffer
  109403. * @returns the new WebGL static buffer
  109404. */
  109405. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109406. /**
  109407. * Creates a new index buffer
  109408. * @param indices defines the content of the index buffer
  109409. * @param updatable defines if the index buffer must be updatable
  109410. * @returns a new webGL buffer
  109411. */
  109412. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109413. /**
  109414. * Clear the current render buffer or the current render target (if any is set up)
  109415. * @param color defines the color to use
  109416. * @param backBuffer defines if the back buffer must be cleared
  109417. * @param depth defines if the depth buffer must be cleared
  109418. * @param stencil defines if the stencil buffer must be cleared
  109419. */
  109420. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109421. /**
  109422. * Gets the current render width
  109423. * @param useScreen defines if screen size must be used (or the current render target if any)
  109424. * @returns a number defining the current render width
  109425. */
  109426. getRenderWidth(useScreen?: boolean): number;
  109427. /**
  109428. * Gets the current render height
  109429. * @param useScreen defines if screen size must be used (or the current render target if any)
  109430. * @returns a number defining the current render height
  109431. */
  109432. getRenderHeight(useScreen?: boolean): number;
  109433. /**
  109434. * Set the WebGL's viewport
  109435. * @param viewport defines the viewport element to be used
  109436. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  109437. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  109438. */
  109439. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109440. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109441. /**
  109442. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  109443. * @param pipelineContext defines the pipeline context to use
  109444. * @param uniformsNames defines the list of uniform names
  109445. * @returns an array of webGL uniform locations
  109446. */
  109447. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109448. /**
  109449. * Gets the lsit of active attributes for a given webGL program
  109450. * @param pipelineContext defines the pipeline context to use
  109451. * @param attributesNames defines the list of attribute names to get
  109452. * @returns an array of indices indicating the offset of each attribute
  109453. */
  109454. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109455. /**
  109456. * Binds an effect to the webGL context
  109457. * @param effect defines the effect to bind
  109458. */
  109459. bindSamplers(effect: Effect): void;
  109460. /**
  109461. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  109462. * @param effect defines the effect to activate
  109463. */
  109464. enableEffect(effect: Effect): void;
  109465. /**
  109466. * Set various states to the webGL context
  109467. * @param culling defines backface culling state
  109468. * @param zOffset defines the value to apply to zOffset (0 by default)
  109469. * @param force defines if states must be applied even if cache is up to date
  109470. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  109471. */
  109472. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109473. /**
  109474. * Set the value of an uniform to an array of int32
  109475. * @param uniform defines the webGL uniform location where to store the value
  109476. * @param array defines the array of int32 to store
  109477. */
  109478. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109479. /**
  109480. * Set the value of an uniform to an array of int32 (stored as vec2)
  109481. * @param uniform defines the webGL uniform location where to store the value
  109482. * @param array defines the array of int32 to store
  109483. */
  109484. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109485. /**
  109486. * Set the value of an uniform to an array of int32 (stored as vec3)
  109487. * @param uniform defines the webGL uniform location where to store the value
  109488. * @param array defines the array of int32 to store
  109489. */
  109490. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109491. /**
  109492. * Set the value of an uniform to an array of int32 (stored as vec4)
  109493. * @param uniform defines the webGL uniform location where to store the value
  109494. * @param array defines the array of int32 to store
  109495. */
  109496. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109497. /**
  109498. * Set the value of an uniform to an array of float32
  109499. * @param uniform defines the webGL uniform location where to store the value
  109500. * @param array defines the array of float32 to store
  109501. */
  109502. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109503. /**
  109504. * Set the value of an uniform to an array of float32 (stored as vec2)
  109505. * @param uniform defines the webGL uniform location where to store the value
  109506. * @param array defines the array of float32 to store
  109507. */
  109508. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109509. /**
  109510. * Set the value of an uniform to an array of float32 (stored as vec3)
  109511. * @param uniform defines the webGL uniform location where to store the value
  109512. * @param array defines the array of float32 to store
  109513. */
  109514. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109515. /**
  109516. * Set the value of an uniform to an array of float32 (stored as vec4)
  109517. * @param uniform defines the webGL uniform location where to store the value
  109518. * @param array defines the array of float32 to store
  109519. */
  109520. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109521. /**
  109522. * Set the value of an uniform to an array of number
  109523. * @param uniform defines the webGL uniform location where to store the value
  109524. * @param array defines the array of number to store
  109525. */
  109526. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109527. /**
  109528. * Set the value of an uniform to an array of number (stored as vec2)
  109529. * @param uniform defines the webGL uniform location where to store the value
  109530. * @param array defines the array of number to store
  109531. */
  109532. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109533. /**
  109534. * Set the value of an uniform to an array of number (stored as vec3)
  109535. * @param uniform defines the webGL uniform location where to store the value
  109536. * @param array defines the array of number to store
  109537. */
  109538. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109539. /**
  109540. * Set the value of an uniform to an array of number (stored as vec4)
  109541. * @param uniform defines the webGL uniform location where to store the value
  109542. * @param array defines the array of number to store
  109543. */
  109544. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109545. /**
  109546. * Set the value of an uniform to an array of float32 (stored as matrices)
  109547. * @param uniform defines the webGL uniform location where to store the value
  109548. * @param matrices defines the array of float32 to store
  109549. */
  109550. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109551. /**
  109552. * Set the value of an uniform to a matrix (3x3)
  109553. * @param uniform defines the webGL uniform location where to store the value
  109554. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  109555. */
  109556. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109557. /**
  109558. * Set the value of an uniform to a matrix (2x2)
  109559. * @param uniform defines the webGL uniform location where to store the value
  109560. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  109561. */
  109562. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109563. /**
  109564. * Set the value of an uniform to a number (float)
  109565. * @param uniform defines the webGL uniform location where to store the value
  109566. * @param value defines the float number to store
  109567. */
  109568. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109569. /**
  109570. * Set the value of an uniform to a vec2
  109571. * @param uniform defines the webGL uniform location where to store the value
  109572. * @param x defines the 1st component of the value
  109573. * @param y defines the 2nd component of the value
  109574. */
  109575. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109576. /**
  109577. * Set the value of an uniform to a vec3
  109578. * @param uniform defines the webGL uniform location where to store the value
  109579. * @param x defines the 1st component of the value
  109580. * @param y defines the 2nd component of the value
  109581. * @param z defines the 3rd component of the value
  109582. */
  109583. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109584. /**
  109585. * Set the value of an uniform to a boolean
  109586. * @param uniform defines the webGL uniform location where to store the value
  109587. * @param bool defines the boolean to store
  109588. */
  109589. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109590. /**
  109591. * Set the value of an uniform to a vec4
  109592. * @param uniform defines the webGL uniform location where to store the value
  109593. * @param x defines the 1st component of the value
  109594. * @param y defines the 2nd component of the value
  109595. * @param z defines the 3rd component of the value
  109596. * @param w defines the 4th component of the value
  109597. */
  109598. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109599. /**
  109600. * Sets the current alpha mode
  109601. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  109602. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109603. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109604. */
  109605. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109606. /**
  109607. * Bind webGl buffers directly to the webGL context
  109608. * @param vertexBuffers defines the vertex buffer to bind
  109609. * @param indexBuffer defines the index buffer to bind
  109610. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  109611. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  109612. * @param effect defines the effect associated with the vertex buffer
  109613. */
  109614. bindBuffers(vertexBuffers: {
  109615. [key: string]: VertexBuffer;
  109616. }, indexBuffer: DataBuffer, effect: Effect): void;
  109617. /**
  109618. * Force the entire cache to be cleared
  109619. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  109620. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  109621. */
  109622. wipeCaches(bruteForce?: boolean): void;
  109623. /**
  109624. * Send a draw order
  109625. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  109626. * @param indexStart defines the starting index
  109627. * @param indexCount defines the number of index to draw
  109628. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109629. */
  109630. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109631. /**
  109632. * Draw a list of indexed primitives
  109633. * @param fillMode defines the primitive to use
  109634. * @param indexStart defines the starting index
  109635. * @param indexCount defines the number of index to draw
  109636. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109637. */
  109638. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109639. /**
  109640. * Draw a list of unindexed primitives
  109641. * @param fillMode defines the primitive to use
  109642. * @param verticesStart defines the index of first vertex to draw
  109643. * @param verticesCount defines the count of vertices to draw
  109644. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109645. */
  109646. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109647. /** @hidden */
  109648. _createTexture(): WebGLTexture;
  109649. /** @hidden */
  109650. _releaseTexture(texture: InternalTexture): void;
  109651. /**
  109652. * Usually called from Texture.ts.
  109653. * Passed information to create a WebGLTexture
  109654. * @param urlArg defines a value which contains one of the following:
  109655. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  109656. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  109657. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  109658. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  109659. * @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)
  109660. * @param scene needed for loading to the correct scene
  109661. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  109662. * @param onLoad optional callback to be called upon successful completion
  109663. * @param onError optional callback to be called upon failure
  109664. * @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
  109665. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  109666. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  109667. * @param forcedExtension defines the extension to use to pick the right loader
  109668. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  109669. * @returns a InternalTexture for assignment back into BABYLON.Texture
  109670. */
  109671. 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;
  109672. /**
  109673. * Creates a new render target texture
  109674. * @param size defines the size of the texture
  109675. * @param options defines the options used to create the texture
  109676. * @returns a new render target texture stored in an InternalTexture
  109677. */
  109678. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109679. /**
  109680. * Update the sampling mode of a given texture
  109681. * @param samplingMode defines the required sampling mode
  109682. * @param texture defines the texture to update
  109683. */
  109684. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109685. /**
  109686. * Binds the frame buffer to the specified texture.
  109687. * @param texture The texture to render to or null for the default canvas
  109688. * @param faceIndex The face of the texture to render to in case of cube texture
  109689. * @param requiredWidth The width of the target to render to
  109690. * @param requiredHeight The height of the target to render to
  109691. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  109692. * @param depthStencilTexture The depth stencil texture to use to render
  109693. * @param lodLevel defines le lod level to bind to the frame buffer
  109694. */
  109695. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109696. /**
  109697. * Unbind the current render target texture from the webGL context
  109698. * @param texture defines the render target texture to unbind
  109699. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109700. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109701. */
  109702. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109703. /**
  109704. * Creates a dynamic vertex buffer
  109705. * @param vertices the data for the dynamic vertex buffer
  109706. * @returns the new WebGL dynamic buffer
  109707. */
  109708. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109709. /**
  109710. * Update the content of a dynamic texture
  109711. * @param texture defines the texture to update
  109712. * @param canvas defines the canvas containing the source
  109713. * @param invertY defines if data must be stored with Y axis inverted
  109714. * @param premulAlpha defines if alpha is stored as premultiplied
  109715. * @param format defines the format of the data
  109716. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  109717. */
  109718. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109719. /**
  109720. * Gets a boolean indicating if all created effects are ready
  109721. * @returns true if all effects are ready
  109722. */
  109723. areAllEffectsReady(): boolean;
  109724. /**
  109725. * @hidden
  109726. * Get the current error code of the webGL context
  109727. * @returns the error code
  109728. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109729. */
  109730. getError(): number;
  109731. /** @hidden */
  109732. _getUnpackAlignement(): number;
  109733. /** @hidden */
  109734. _unpackFlipY(value: boolean): void;
  109735. /**
  109736. * Update a dynamic index buffer
  109737. * @param indexBuffer defines the target index buffer
  109738. * @param indices defines the data to update
  109739. * @param offset defines the offset in the target index buffer where update should start
  109740. */
  109741. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109742. /**
  109743. * Updates a dynamic vertex buffer.
  109744. * @param vertexBuffer the vertex buffer to update
  109745. * @param vertices the data used to update the vertex buffer
  109746. * @param byteOffset the byte offset of the data (optional)
  109747. * @param byteLength the byte length of the data (optional)
  109748. */
  109749. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109750. /** @hidden */
  109751. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109752. /** @hidden */
  109753. _bindTexture(channel: number, texture: InternalTexture): void;
  109754. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109755. /**
  109756. * 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
  109757. */
  109758. releaseEffects(): void;
  109759. displayLoadingUI(): void;
  109760. hideLoadingUI(): void;
  109761. /** @hidden */
  109762. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109763. /** @hidden */
  109764. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109765. /** @hidden */
  109766. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109767. /** @hidden */
  109768. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109769. }
  109770. }
  109771. declare module BABYLON {
  109772. /** @hidden */
  109773. export class _OcclusionDataStorage {
  109774. /** @hidden */
  109775. occlusionInternalRetryCounter: number;
  109776. /** @hidden */
  109777. isOcclusionQueryInProgress: boolean;
  109778. /** @hidden */
  109779. isOccluded: boolean;
  109780. /** @hidden */
  109781. occlusionRetryCount: number;
  109782. /** @hidden */
  109783. occlusionType: number;
  109784. /** @hidden */
  109785. occlusionQueryAlgorithmType: number;
  109786. }
  109787. interface Engine {
  109788. /**
  109789. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109790. * @return the new query
  109791. */
  109792. createQuery(): WebGLQuery;
  109793. /**
  109794. * Delete and release a webGL query
  109795. * @param query defines the query to delete
  109796. * @return the current engine
  109797. */
  109798. deleteQuery(query: WebGLQuery): Engine;
  109799. /**
  109800. * Check if a given query has resolved and got its value
  109801. * @param query defines the query to check
  109802. * @returns true if the query got its value
  109803. */
  109804. isQueryResultAvailable(query: WebGLQuery): boolean;
  109805. /**
  109806. * Gets the value of a given query
  109807. * @param query defines the query to check
  109808. * @returns the value of the query
  109809. */
  109810. getQueryResult(query: WebGLQuery): number;
  109811. /**
  109812. * Initiates an occlusion query
  109813. * @param algorithmType defines the algorithm to use
  109814. * @param query defines the query to use
  109815. * @returns the current engine
  109816. * @see http://doc.babylonjs.com/features/occlusionquery
  109817. */
  109818. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109819. /**
  109820. * Ends an occlusion query
  109821. * @see http://doc.babylonjs.com/features/occlusionquery
  109822. * @param algorithmType defines the algorithm to use
  109823. * @returns the current engine
  109824. */
  109825. endOcclusionQuery(algorithmType: number): Engine;
  109826. /**
  109827. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109828. * Please note that only one query can be issued at a time
  109829. * @returns a time token used to track the time span
  109830. */
  109831. startTimeQuery(): Nullable<_TimeToken>;
  109832. /**
  109833. * Ends a time query
  109834. * @param token defines the token used to measure the time span
  109835. * @returns the time spent (in ns)
  109836. */
  109837. endTimeQuery(token: _TimeToken): int;
  109838. /** @hidden */
  109839. _currentNonTimestampToken: Nullable<_TimeToken>;
  109840. /** @hidden */
  109841. _createTimeQuery(): WebGLQuery;
  109842. /** @hidden */
  109843. _deleteTimeQuery(query: WebGLQuery): void;
  109844. /** @hidden */
  109845. _getGlAlgorithmType(algorithmType: number): number;
  109846. /** @hidden */
  109847. _getTimeQueryResult(query: WebGLQuery): any;
  109848. /** @hidden */
  109849. _getTimeQueryAvailability(query: WebGLQuery): any;
  109850. }
  109851. interface AbstractMesh {
  109852. /**
  109853. * Backing filed
  109854. * @hidden
  109855. */
  109856. __occlusionDataStorage: _OcclusionDataStorage;
  109857. /**
  109858. * Access property
  109859. * @hidden
  109860. */
  109861. _occlusionDataStorage: _OcclusionDataStorage;
  109862. /**
  109863. * 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.
  109864. * The default value is -1 which means don't break the query and wait till the result
  109865. * @see http://doc.babylonjs.com/features/occlusionquery
  109866. */
  109867. occlusionRetryCount: number;
  109868. /**
  109869. * 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:
  109870. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109871. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109872. * * 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.
  109873. * @see http://doc.babylonjs.com/features/occlusionquery
  109874. */
  109875. occlusionType: number;
  109876. /**
  109877. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109878. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109879. * * 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.
  109880. * @see http://doc.babylonjs.com/features/occlusionquery
  109881. */
  109882. occlusionQueryAlgorithmType: number;
  109883. /**
  109884. * 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
  109885. * @see http://doc.babylonjs.com/features/occlusionquery
  109886. */
  109887. isOccluded: boolean;
  109888. /**
  109889. * Flag to check the progress status of the query
  109890. * @see http://doc.babylonjs.com/features/occlusionquery
  109891. */
  109892. isOcclusionQueryInProgress: boolean;
  109893. }
  109894. }
  109895. declare module BABYLON {
  109896. /** @hidden */
  109897. export var _forceTransformFeedbackToBundle: boolean;
  109898. interface Engine {
  109899. /**
  109900. * Creates a webGL transform feedback object
  109901. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109902. * @returns the webGL transform feedback object
  109903. */
  109904. createTransformFeedback(): WebGLTransformFeedback;
  109905. /**
  109906. * Delete a webGL transform feedback object
  109907. * @param value defines the webGL transform feedback object to delete
  109908. */
  109909. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109910. /**
  109911. * Bind a webGL transform feedback object to the webgl context
  109912. * @param value defines the webGL transform feedback object to bind
  109913. */
  109914. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109915. /**
  109916. * Begins a transform feedback operation
  109917. * @param usePoints defines if points or triangles must be used
  109918. */
  109919. beginTransformFeedback(usePoints: boolean): void;
  109920. /**
  109921. * Ends a transform feedback operation
  109922. */
  109923. endTransformFeedback(): void;
  109924. /**
  109925. * Specify the varyings to use with transform feedback
  109926. * @param program defines the associated webGL program
  109927. * @param value defines the list of strings representing the varying names
  109928. */
  109929. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109930. /**
  109931. * Bind a webGL buffer for a transform feedback operation
  109932. * @param value defines the webGL buffer to bind
  109933. */
  109934. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109935. }
  109936. }
  109937. declare module BABYLON {
  109938. /**
  109939. * Creation options of the multi render target texture.
  109940. */
  109941. export interface IMultiRenderTargetOptions {
  109942. /**
  109943. * Define if the texture needs to create mip maps after render.
  109944. */
  109945. generateMipMaps?: boolean;
  109946. /**
  109947. * Define the types of all the draw buffers we want to create
  109948. */
  109949. types?: number[];
  109950. /**
  109951. * Define the sampling modes of all the draw buffers we want to create
  109952. */
  109953. samplingModes?: number[];
  109954. /**
  109955. * Define if a depth buffer is required
  109956. */
  109957. generateDepthBuffer?: boolean;
  109958. /**
  109959. * Define if a stencil buffer is required
  109960. */
  109961. generateStencilBuffer?: boolean;
  109962. /**
  109963. * Define if a depth texture is required instead of a depth buffer
  109964. */
  109965. generateDepthTexture?: boolean;
  109966. /**
  109967. * Define the number of desired draw buffers
  109968. */
  109969. textureCount?: number;
  109970. /**
  109971. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109972. */
  109973. doNotChangeAspectRatio?: boolean;
  109974. /**
  109975. * Define the default type of the buffers we are creating
  109976. */
  109977. defaultType?: number;
  109978. }
  109979. /**
  109980. * A multi render target, like a render target provides the ability to render to a texture.
  109981. * Unlike the render target, it can render to several draw buffers in one draw.
  109982. * This is specially interesting in deferred rendering or for any effects requiring more than
  109983. * just one color from a single pass.
  109984. */
  109985. export class MultiRenderTarget extends RenderTargetTexture {
  109986. private _internalTextures;
  109987. private _textures;
  109988. private _multiRenderTargetOptions;
  109989. /**
  109990. * Get if draw buffers are currently supported by the used hardware and browser.
  109991. */
  109992. readonly isSupported: boolean;
  109993. /**
  109994. * Get the list of textures generated by the multi render target.
  109995. */
  109996. readonly textures: Texture[];
  109997. /**
  109998. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109999. */
  110000. readonly depthTexture: Texture;
  110001. /**
  110002. * Set the wrapping mode on U of all the textures we are rendering to.
  110003. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110004. */
  110005. wrapU: number;
  110006. /**
  110007. * Set the wrapping mode on V of all the textures we are rendering to.
  110008. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110009. */
  110010. wrapV: number;
  110011. /**
  110012. * Instantiate a new multi render target texture.
  110013. * A multi render target, like a render target provides the ability to render to a texture.
  110014. * Unlike the render target, it can render to several draw buffers in one draw.
  110015. * This is specially interesting in deferred rendering or for any effects requiring more than
  110016. * just one color from a single pass.
  110017. * @param name Define the name of the texture
  110018. * @param size Define the size of the buffers to render to
  110019. * @param count Define the number of target we are rendering into
  110020. * @param scene Define the scene the texture belongs to
  110021. * @param options Define the options used to create the multi render target
  110022. */
  110023. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  110024. /** @hidden */
  110025. _rebuild(): void;
  110026. private _createInternalTextures;
  110027. private _createTextures;
  110028. /**
  110029. * Define the number of samples used if MSAA is enabled.
  110030. */
  110031. samples: number;
  110032. /**
  110033. * Resize all the textures in the multi render target.
  110034. * Be carrefull as it will recreate all the data in the new texture.
  110035. * @param size Define the new size
  110036. */
  110037. resize(size: any): void;
  110038. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110039. /**
  110040. * Dispose the render targets and their associated resources
  110041. */
  110042. dispose(): void;
  110043. /**
  110044. * Release all the underlying texture used as draw buffers.
  110045. */
  110046. releaseInternalTextures(): void;
  110047. }
  110048. }
  110049. declare module BABYLON {
  110050. interface BaseEngine {
  110051. /**
  110052. * Unbind a list of render target textures from the webGL context
  110053. * This is used only when drawBuffer extension or webGL2 are active
  110054. * @param textures defines the render target textures to unbind
  110055. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110056. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110057. */
  110058. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  110059. /**
  110060. * Create a multi render target texture
  110061. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  110062. * @param size defines the size of the texture
  110063. * @param options defines the creation options
  110064. * @returns the cube texture as an InternalTexture
  110065. */
  110066. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  110067. /**
  110068. * Update the sample count for a given multiple render target texture
  110069. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110070. * @param textures defines the textures to update
  110071. * @param samples defines the sample count to set
  110072. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110073. */
  110074. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  110075. }
  110076. }
  110077. declare module BABYLON {
  110078. /** @hidden */
  110079. export var rgbdEncodePixelShader: {
  110080. name: string;
  110081. shader: string;
  110082. };
  110083. }
  110084. declare module BABYLON {
  110085. /** @hidden */
  110086. export var rgbdDecodePixelShader: {
  110087. name: string;
  110088. shader: string;
  110089. };
  110090. }
  110091. declare module BABYLON {
  110092. /**
  110093. * Raw texture data and descriptor sufficient for WebGL texture upload
  110094. */
  110095. export interface EnvironmentTextureInfo {
  110096. /**
  110097. * Version of the environment map
  110098. */
  110099. version: number;
  110100. /**
  110101. * Width of image
  110102. */
  110103. width: number;
  110104. /**
  110105. * Irradiance information stored in the file.
  110106. */
  110107. irradiance: any;
  110108. /**
  110109. * Specular information stored in the file.
  110110. */
  110111. specular: any;
  110112. }
  110113. /**
  110114. * Defines One Image in the file. It requires only the position in the file
  110115. * as well as the length.
  110116. */
  110117. interface BufferImageData {
  110118. /**
  110119. * Length of the image data.
  110120. */
  110121. length: number;
  110122. /**
  110123. * Position of the data from the null terminator delimiting the end of the JSON.
  110124. */
  110125. position: number;
  110126. }
  110127. /**
  110128. * Defines the specular data enclosed in the file.
  110129. * This corresponds to the version 1 of the data.
  110130. */
  110131. export interface EnvironmentTextureSpecularInfoV1 {
  110132. /**
  110133. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  110134. */
  110135. specularDataPosition?: number;
  110136. /**
  110137. * This contains all the images data needed to reconstruct the cubemap.
  110138. */
  110139. mipmaps: Array<BufferImageData>;
  110140. /**
  110141. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  110142. */
  110143. lodGenerationScale: number;
  110144. }
  110145. /**
  110146. * Sets of helpers addressing the serialization and deserialization of environment texture
  110147. * stored in a BabylonJS env file.
  110148. * Those files are usually stored as .env files.
  110149. */
  110150. export class EnvironmentTextureTools {
  110151. /**
  110152. * Magic number identifying the env file.
  110153. */
  110154. private static _MagicBytes;
  110155. /**
  110156. * Gets the environment info from an env file.
  110157. * @param data The array buffer containing the .env bytes.
  110158. * @returns the environment file info (the json header) if successfully parsed.
  110159. */
  110160. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  110161. /**
  110162. * Creates an environment texture from a loaded cube texture.
  110163. * @param texture defines the cube texture to convert in env file
  110164. * @return a promise containing the environment data if succesfull.
  110165. */
  110166. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  110167. /**
  110168. * Creates a JSON representation of the spherical data.
  110169. * @param texture defines the texture containing the polynomials
  110170. * @return the JSON representation of the spherical info
  110171. */
  110172. private static _CreateEnvTextureIrradiance;
  110173. /**
  110174. * Creates the ArrayBufferViews used for initializing environment texture image data.
  110175. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  110176. * @param info parameters that determine what views will be created for accessing the underlying buffer
  110177. * @return the views described by info providing access to the underlying buffer
  110178. */
  110179. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  110180. /**
  110181. * Uploads the texture info contained in the env file to the GPU.
  110182. * @param texture defines the internal texture to upload to
  110183. * @param arrayBuffer defines the buffer cotaining the data to load
  110184. * @param info defines the texture info retrieved through the GetEnvInfo method
  110185. * @returns a promise
  110186. */
  110187. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  110188. /**
  110189. * Uploads the levels of image data to the GPU.
  110190. * @param texture defines the internal texture to upload to
  110191. * @param imageData defines the array buffer views of image data [mipmap][face]
  110192. * @returns a promise
  110193. */
  110194. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  110195. /**
  110196. * Uploads spherical polynomials information to the texture.
  110197. * @param texture defines the texture we are trying to upload the information to
  110198. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  110199. */
  110200. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  110201. /** @hidden */
  110202. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  110203. }
  110204. }
  110205. declare module BABYLON {
  110206. /**
  110207. * Contains position and normal vectors for a vertex
  110208. */
  110209. export class PositionNormalVertex {
  110210. /** the position of the vertex (defaut: 0,0,0) */
  110211. position: Vector3;
  110212. /** the normal of the vertex (defaut: 0,1,0) */
  110213. normal: Vector3;
  110214. /**
  110215. * Creates a PositionNormalVertex
  110216. * @param position the position of the vertex (defaut: 0,0,0)
  110217. * @param normal the normal of the vertex (defaut: 0,1,0)
  110218. */
  110219. constructor(
  110220. /** the position of the vertex (defaut: 0,0,0) */
  110221. position?: Vector3,
  110222. /** the normal of the vertex (defaut: 0,1,0) */
  110223. normal?: Vector3);
  110224. /**
  110225. * Clones the PositionNormalVertex
  110226. * @returns the cloned PositionNormalVertex
  110227. */
  110228. clone(): PositionNormalVertex;
  110229. }
  110230. /**
  110231. * Contains position, normal and uv vectors for a vertex
  110232. */
  110233. export class PositionNormalTextureVertex {
  110234. /** the position of the vertex (defaut: 0,0,0) */
  110235. position: Vector3;
  110236. /** the normal of the vertex (defaut: 0,1,0) */
  110237. normal: Vector3;
  110238. /** the uv of the vertex (default: 0,0) */
  110239. uv: Vector2;
  110240. /**
  110241. * Creates a PositionNormalTextureVertex
  110242. * @param position the position of the vertex (defaut: 0,0,0)
  110243. * @param normal the normal of the vertex (defaut: 0,1,0)
  110244. * @param uv the uv of the vertex (default: 0,0)
  110245. */
  110246. constructor(
  110247. /** the position of the vertex (defaut: 0,0,0) */
  110248. position?: Vector3,
  110249. /** the normal of the vertex (defaut: 0,1,0) */
  110250. normal?: Vector3,
  110251. /** the uv of the vertex (default: 0,0) */
  110252. uv?: Vector2);
  110253. /**
  110254. * Clones the PositionNormalTextureVertex
  110255. * @returns the cloned PositionNormalTextureVertex
  110256. */
  110257. clone(): PositionNormalTextureVertex;
  110258. }
  110259. }
  110260. declare module BABYLON {
  110261. /** @hidden */
  110262. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  110263. private _genericAttributeLocation;
  110264. private _varyingLocationCount;
  110265. private _varyingLocationMap;
  110266. private _replacements;
  110267. private _textureCount;
  110268. private _uniforms;
  110269. lineProcessor(line: string): string;
  110270. attributeProcessor(attribute: string): string;
  110271. varyingProcessor(varying: string, isFragment: boolean): string;
  110272. uniformProcessor(uniform: string): string;
  110273. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  110274. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  110275. }
  110276. }
  110277. declare module BABYLON {
  110278. /**
  110279. * Container for accessors for natively-stored mesh data buffers.
  110280. */
  110281. class NativeDataBuffer extends DataBuffer {
  110282. /**
  110283. * Accessor value used to identify/retrieve a natively-stored index buffer.
  110284. */
  110285. nativeIndexBuffer?: any;
  110286. /**
  110287. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  110288. */
  110289. nativeVertexBuffer?: any;
  110290. }
  110291. /** @hidden */
  110292. export class NativeEngine extends Engine {
  110293. private readonly _native;
  110294. getHardwareScalingLevel(): number;
  110295. constructor();
  110296. /**
  110297. * Can be used to override the current requestAnimationFrame requester.
  110298. * @hidden
  110299. */
  110300. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  110301. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110302. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  110303. createVertexBuffer(data: DataArray): NativeDataBuffer;
  110304. recordVertexArrayObject(vertexBuffers: {
  110305. [key: string]: VertexBuffer;
  110306. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  110307. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110308. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110309. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110310. /**
  110311. * Draw a list of indexed primitives
  110312. * @param fillMode defines the primitive to use
  110313. * @param indexStart defines the starting index
  110314. * @param indexCount defines the number of index to draw
  110315. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110316. */
  110317. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110318. /**
  110319. * Draw a list of unindexed primitives
  110320. * @param fillMode defines the primitive to use
  110321. * @param verticesStart defines the index of first vertex to draw
  110322. * @param verticesCount defines the count of vertices to draw
  110323. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110324. */
  110325. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110326. createPipelineContext(): IPipelineContext;
  110327. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  110328. /** @hidden */
  110329. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  110330. /** @hidden */
  110331. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  110332. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110333. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110334. protected _setProgram(program: WebGLProgram): void;
  110335. _releaseEffect(effect: Effect): void;
  110336. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110337. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  110338. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  110339. bindSamplers(effect: Effect): void;
  110340. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  110341. getRenderWidth(useScreen?: boolean): number;
  110342. getRenderHeight(useScreen?: boolean): number;
  110343. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  110344. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110345. /**
  110346. * Set the z offset to apply to current rendering
  110347. * @param value defines the offset to apply
  110348. */
  110349. setZOffset(value: number): void;
  110350. /**
  110351. * Gets the current value of the zOffset
  110352. * @returns the current zOffset state
  110353. */
  110354. getZOffset(): number;
  110355. /**
  110356. * Enable or disable depth buffering
  110357. * @param enable defines the state to set
  110358. */
  110359. setDepthBuffer(enable: boolean): void;
  110360. /**
  110361. * Gets a boolean indicating if depth writing is enabled
  110362. * @returns the current depth writing state
  110363. */
  110364. getDepthWrite(): boolean;
  110365. /**
  110366. * Enable or disable depth writing
  110367. * @param enable defines the state to set
  110368. */
  110369. setDepthWrite(enable: boolean): void;
  110370. /**
  110371. * Enable or disable color writing
  110372. * @param enable defines the state to set
  110373. */
  110374. setColorWrite(enable: boolean): void;
  110375. /**
  110376. * Gets a boolean indicating if color writing is enabled
  110377. * @returns the current color writing state
  110378. */
  110379. getColorWrite(): boolean;
  110380. /**
  110381. * Sets alpha constants used by some alpha blending modes
  110382. * @param r defines the red component
  110383. * @param g defines the green component
  110384. * @param b defines the blue component
  110385. * @param a defines the alpha component
  110386. */
  110387. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  110388. /**
  110389. * Sets the current alpha mode
  110390. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  110391. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110392. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110393. */
  110394. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110395. /**
  110396. * Gets the current alpha mode
  110397. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110398. * @returns the current alpha mode
  110399. */
  110400. getAlphaMode(): number;
  110401. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110402. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110403. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110404. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110405. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110406. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110407. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110408. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110409. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110410. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110411. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110412. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110413. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110414. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110415. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110416. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110417. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110418. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110419. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110420. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110421. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  110422. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  110423. wipeCaches(bruteForce?: boolean): void;
  110424. _createTexture(): WebGLTexture;
  110425. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  110426. /**
  110427. * Usually called from BABYLON.Texture.ts.
  110428. * Passed information to create a WebGLTexture
  110429. * @param urlArg defines a value which contains one of the following:
  110430. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110431. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110432. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110433. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110434. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110435. * @param scene needed for loading to the correct scene
  110436. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110437. * @param onLoad optional callback to be called upon successful completion
  110438. * @param onError optional callback to be called upon failure
  110439. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110440. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110441. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110442. * @param forcedExtension defines the extension to use to pick the right loader
  110443. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110444. */
  110445. 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;
  110446. /**
  110447. * Creates a cube texture
  110448. * @param rootUrl defines the url where the files to load is located
  110449. * @param scene defines the current scene
  110450. * @param files defines the list of files to load (1 per face)
  110451. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110452. * @param onLoad defines an optional callback raised when the texture is loaded
  110453. * @param onError defines an optional callback raised if there is an issue to load the texture
  110454. * @param format defines the format of the data
  110455. * @param forcedExtension defines the extension to use to pick the right loader
  110456. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110457. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110458. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110459. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110460. * @returns the cube texture as an InternalTexture
  110461. */
  110462. 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;
  110463. private _getSamplingFilter;
  110464. private static _GetNativeTextureFormat;
  110465. createRenderTargetTexture(size: number | {
  110466. width: number;
  110467. height: number;
  110468. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110469. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110470. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110471. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110472. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110473. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110474. /**
  110475. * Updates a dynamic vertex buffer.
  110476. * @param vertexBuffer the vertex buffer to update
  110477. * @param data the data used to update the vertex buffer
  110478. * @param byteOffset the byte offset of the data (optional)
  110479. * @param byteLength the byte length of the data (optional)
  110480. */
  110481. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110482. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110483. private _updateAnisotropicLevel;
  110484. private _getAddressMode;
  110485. /** @hidden */
  110486. _bindTexture(channel: number, texture: InternalTexture): void;
  110487. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110488. releaseEffects(): void;
  110489. /** @hidden */
  110490. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110491. /** @hidden */
  110492. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110493. /** @hidden */
  110494. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110495. /** @hidden */
  110496. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110497. }
  110498. }
  110499. declare module BABYLON {
  110500. /**
  110501. * Gather the list of clipboard event types as constants.
  110502. */
  110503. export class ClipboardEventTypes {
  110504. /**
  110505. * The clipboard event is fired when a copy command is active (pressed).
  110506. */
  110507. static readonly COPY: number;
  110508. /**
  110509. * The clipboard event is fired when a cut command is active (pressed).
  110510. */
  110511. static readonly CUT: number;
  110512. /**
  110513. * The clipboard event is fired when a paste command is active (pressed).
  110514. */
  110515. static readonly PASTE: number;
  110516. }
  110517. /**
  110518. * This class is used to store clipboard related info for the onClipboardObservable event.
  110519. */
  110520. export class ClipboardInfo {
  110521. /**
  110522. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110523. */
  110524. type: number;
  110525. /**
  110526. * Defines the related dom event
  110527. */
  110528. event: ClipboardEvent;
  110529. /**
  110530. *Creates an instance of ClipboardInfo.
  110531. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110532. * @param event Defines the related dom event
  110533. */
  110534. constructor(
  110535. /**
  110536. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110537. */
  110538. type: number,
  110539. /**
  110540. * Defines the related dom event
  110541. */
  110542. event: ClipboardEvent);
  110543. /**
  110544. * Get the clipboard event's type from the keycode.
  110545. * @param keyCode Defines the keyCode for the current keyboard event.
  110546. * @return {number}
  110547. */
  110548. static GetTypeFromCharacter(keyCode: number): number;
  110549. }
  110550. }
  110551. declare module BABYLON {
  110552. /**
  110553. * Google Daydream controller
  110554. */
  110555. export class DaydreamController extends WebVRController {
  110556. /**
  110557. * Base Url for the controller model.
  110558. */
  110559. static MODEL_BASE_URL: string;
  110560. /**
  110561. * File name for the controller model.
  110562. */
  110563. static MODEL_FILENAME: string;
  110564. /**
  110565. * Gamepad Id prefix used to identify Daydream Controller.
  110566. */
  110567. static readonly GAMEPAD_ID_PREFIX: string;
  110568. /**
  110569. * Creates a new DaydreamController from a gamepad
  110570. * @param vrGamepad the gamepad that the controller should be created from
  110571. */
  110572. constructor(vrGamepad: any);
  110573. /**
  110574. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110575. * @param scene scene in which to add meshes
  110576. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110577. */
  110578. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110579. /**
  110580. * Called once for each button that changed state since the last frame
  110581. * @param buttonIdx Which button index changed
  110582. * @param state New state of the button
  110583. * @param changes Which properties on the state changed since last frame
  110584. */
  110585. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110586. }
  110587. }
  110588. declare module BABYLON {
  110589. /**
  110590. * Gear VR Controller
  110591. */
  110592. export class GearVRController extends WebVRController {
  110593. /**
  110594. * Base Url for the controller model.
  110595. */
  110596. static MODEL_BASE_URL: string;
  110597. /**
  110598. * File name for the controller model.
  110599. */
  110600. static MODEL_FILENAME: string;
  110601. /**
  110602. * Gamepad Id prefix used to identify this controller.
  110603. */
  110604. static readonly GAMEPAD_ID_PREFIX: string;
  110605. private readonly _buttonIndexToObservableNameMap;
  110606. /**
  110607. * Creates a new GearVRController from a gamepad
  110608. * @param vrGamepad the gamepad that the controller should be created from
  110609. */
  110610. constructor(vrGamepad: any);
  110611. /**
  110612. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110613. * @param scene scene in which to add meshes
  110614. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110615. */
  110616. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110617. /**
  110618. * Called once for each button that changed state since the last frame
  110619. * @param buttonIdx Which button index changed
  110620. * @param state New state of the button
  110621. * @param changes Which properties on the state changed since last frame
  110622. */
  110623. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110624. }
  110625. }
  110626. declare module BABYLON {
  110627. /**
  110628. * Class containing static functions to help procedurally build meshes
  110629. */
  110630. export class PolyhedronBuilder {
  110631. /**
  110632. * Creates a polyhedron mesh
  110633. * * 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
  110634. * * The parameter `size` (positive float, default 1) sets the polygon size
  110635. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110636. * * 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`
  110637. * * 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
  110638. * * 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)`)
  110639. * * 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
  110640. * * 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
  110641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110644. * @param name defines the name of the mesh
  110645. * @param options defines the options used to create the mesh
  110646. * @param scene defines the hosting scene
  110647. * @returns the polyhedron mesh
  110648. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110649. */
  110650. static CreatePolyhedron(name: string, options: {
  110651. type?: number;
  110652. size?: number;
  110653. sizeX?: number;
  110654. sizeY?: number;
  110655. sizeZ?: number;
  110656. custom?: any;
  110657. faceUV?: Vector4[];
  110658. faceColors?: Color4[];
  110659. flat?: boolean;
  110660. updatable?: boolean;
  110661. sideOrientation?: number;
  110662. frontUVs?: Vector4;
  110663. backUVs?: Vector4;
  110664. }, scene?: Nullable<Scene>): Mesh;
  110665. }
  110666. }
  110667. declare module BABYLON {
  110668. /**
  110669. * Gizmo that enables scaling a mesh along 3 axis
  110670. */
  110671. export class ScaleGizmo extends Gizmo {
  110672. /**
  110673. * Internal gizmo used for interactions on the x axis
  110674. */
  110675. xGizmo: AxisScaleGizmo;
  110676. /**
  110677. * Internal gizmo used for interactions on the y axis
  110678. */
  110679. yGizmo: AxisScaleGizmo;
  110680. /**
  110681. * Internal gizmo used for interactions on the z axis
  110682. */
  110683. zGizmo: AxisScaleGizmo;
  110684. /**
  110685. * Internal gizmo used to scale all axis equally
  110686. */
  110687. uniformScaleGizmo: AxisScaleGizmo;
  110688. private _meshAttached;
  110689. private _updateGizmoRotationToMatchAttachedMesh;
  110690. private _snapDistance;
  110691. private _scaleRatio;
  110692. private _uniformScalingMesh;
  110693. private _octahedron;
  110694. /** Fires an event when any of it's sub gizmos are dragged */
  110695. onDragStartObservable: Observable<unknown>;
  110696. /** Fires an event when any of it's sub gizmos are released from dragging */
  110697. onDragEndObservable: Observable<unknown>;
  110698. attachedMesh: Nullable<AbstractMesh>;
  110699. /**
  110700. * Creates a ScaleGizmo
  110701. * @param gizmoLayer The utility layer the gizmo will be added to
  110702. */
  110703. constructor(gizmoLayer?: UtilityLayerRenderer);
  110704. updateGizmoRotationToMatchAttachedMesh: boolean;
  110705. /**
  110706. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110707. */
  110708. snapDistance: number;
  110709. /**
  110710. * Ratio for the scale of the gizmo (Default: 1)
  110711. */
  110712. scaleRatio: number;
  110713. /**
  110714. * Disposes of the gizmo
  110715. */
  110716. dispose(): void;
  110717. }
  110718. }
  110719. declare module BABYLON {
  110720. /**
  110721. * Single axis scale gizmo
  110722. */
  110723. export class AxisScaleGizmo extends Gizmo {
  110724. /**
  110725. * Drag behavior responsible for the gizmos dragging interactions
  110726. */
  110727. dragBehavior: PointerDragBehavior;
  110728. private _pointerObserver;
  110729. /**
  110730. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110731. */
  110732. snapDistance: number;
  110733. /**
  110734. * Event that fires each time the gizmo snaps to a new location.
  110735. * * snapDistance is the the change in distance
  110736. */
  110737. onSnapObservable: Observable<{
  110738. snapDistance: number;
  110739. }>;
  110740. /**
  110741. * If the scaling operation should be done on all axis (default: false)
  110742. */
  110743. uniformScaling: boolean;
  110744. private _isEnabled;
  110745. private _parent;
  110746. private _arrow;
  110747. private _coloredMaterial;
  110748. private _hoverMaterial;
  110749. /**
  110750. * Creates an AxisScaleGizmo
  110751. * @param gizmoLayer The utility layer the gizmo will be added to
  110752. * @param dragAxis The axis which the gizmo will be able to scale on
  110753. * @param color The color of the gizmo
  110754. */
  110755. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110756. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110757. /**
  110758. * If the gizmo is enabled
  110759. */
  110760. isEnabled: boolean;
  110761. /**
  110762. * Disposes of the gizmo
  110763. */
  110764. dispose(): void;
  110765. /**
  110766. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110767. * @param mesh The mesh to replace the default mesh of the gizmo
  110768. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110769. */
  110770. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110771. }
  110772. }
  110773. declare module BABYLON {
  110774. /**
  110775. * Bounding box gizmo
  110776. */
  110777. export class BoundingBoxGizmo extends Gizmo {
  110778. private _lineBoundingBox;
  110779. private _rotateSpheresParent;
  110780. private _scaleBoxesParent;
  110781. private _boundingDimensions;
  110782. private _renderObserver;
  110783. private _pointerObserver;
  110784. private _scaleDragSpeed;
  110785. private _tmpQuaternion;
  110786. private _tmpVector;
  110787. private _tmpRotationMatrix;
  110788. /**
  110789. * 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)
  110790. */
  110791. ignoreChildren: boolean;
  110792. /**
  110793. * 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)
  110794. */
  110795. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110796. /**
  110797. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110798. */
  110799. rotationSphereSize: number;
  110800. /**
  110801. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110802. */
  110803. scaleBoxSize: number;
  110804. /**
  110805. * 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)
  110806. */
  110807. fixedDragMeshScreenSize: boolean;
  110808. /**
  110809. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110810. */
  110811. fixedDragMeshScreenSizeDistanceFactor: number;
  110812. /**
  110813. * Fired when a rotation sphere or scale box is dragged
  110814. */
  110815. onDragStartObservable: Observable<{}>;
  110816. /**
  110817. * Fired when a scale box is dragged
  110818. */
  110819. onScaleBoxDragObservable: Observable<{}>;
  110820. /**
  110821. * Fired when a scale box drag is ended
  110822. */
  110823. onScaleBoxDragEndObservable: Observable<{}>;
  110824. /**
  110825. * Fired when a rotation sphere is dragged
  110826. */
  110827. onRotationSphereDragObservable: Observable<{}>;
  110828. /**
  110829. * Fired when a rotation sphere drag is ended
  110830. */
  110831. onRotationSphereDragEndObservable: Observable<{}>;
  110832. /**
  110833. * 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)
  110834. */
  110835. scalePivot: Nullable<Vector3>;
  110836. /**
  110837. * Mesh used as a pivot to rotate the attached mesh
  110838. */
  110839. private _anchorMesh;
  110840. private _existingMeshScale;
  110841. private _dragMesh;
  110842. private pointerDragBehavior;
  110843. private coloredMaterial;
  110844. private hoverColoredMaterial;
  110845. /**
  110846. * Sets the color of the bounding box gizmo
  110847. * @param color the color to set
  110848. */
  110849. setColor(color: Color3): void;
  110850. /**
  110851. * Creates an BoundingBoxGizmo
  110852. * @param gizmoLayer The utility layer the gizmo will be added to
  110853. * @param color The color of the gizmo
  110854. */
  110855. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110856. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110857. private _selectNode;
  110858. /**
  110859. * Updates the bounding box information for the Gizmo
  110860. */
  110861. updateBoundingBox(): void;
  110862. private _updateRotationSpheres;
  110863. private _updateScaleBoxes;
  110864. /**
  110865. * Enables rotation on the specified axis and disables rotation on the others
  110866. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110867. */
  110868. setEnabledRotationAxis(axis: string): void;
  110869. /**
  110870. * Enables/disables scaling
  110871. * @param enable if scaling should be enabled
  110872. */
  110873. setEnabledScaling(enable: boolean): void;
  110874. private _updateDummy;
  110875. /**
  110876. * Enables a pointer drag behavior on the bounding box of the gizmo
  110877. */
  110878. enableDragBehavior(): void;
  110879. /**
  110880. * Disposes of the gizmo
  110881. */
  110882. dispose(): void;
  110883. /**
  110884. * 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)
  110885. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110886. * @returns the bounding box mesh with the passed in mesh as a child
  110887. */
  110888. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110889. /**
  110890. * CustomMeshes are not supported by this gizmo
  110891. * @param mesh The mesh to replace the default mesh of the gizmo
  110892. */
  110893. setCustomMesh(mesh: Mesh): void;
  110894. }
  110895. }
  110896. declare module BABYLON {
  110897. /**
  110898. * Single plane rotation gizmo
  110899. */
  110900. export class PlaneRotationGizmo extends Gizmo {
  110901. /**
  110902. * Drag behavior responsible for the gizmos dragging interactions
  110903. */
  110904. dragBehavior: PointerDragBehavior;
  110905. private _pointerObserver;
  110906. /**
  110907. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110908. */
  110909. snapDistance: number;
  110910. /**
  110911. * Event that fires each time the gizmo snaps to a new location.
  110912. * * snapDistance is the the change in distance
  110913. */
  110914. onSnapObservable: Observable<{
  110915. snapDistance: number;
  110916. }>;
  110917. private _isEnabled;
  110918. private _parent;
  110919. /**
  110920. * Creates a PlaneRotationGizmo
  110921. * @param gizmoLayer The utility layer the gizmo will be added to
  110922. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110923. * @param color The color of the gizmo
  110924. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110925. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110926. */
  110927. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110928. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110929. /**
  110930. * If the gizmo is enabled
  110931. */
  110932. isEnabled: boolean;
  110933. /**
  110934. * Disposes of the gizmo
  110935. */
  110936. dispose(): void;
  110937. }
  110938. }
  110939. declare module BABYLON {
  110940. /**
  110941. * Gizmo that enables rotating a mesh along 3 axis
  110942. */
  110943. export class RotationGizmo extends Gizmo {
  110944. /**
  110945. * Internal gizmo used for interactions on the x axis
  110946. */
  110947. xGizmo: PlaneRotationGizmo;
  110948. /**
  110949. * Internal gizmo used for interactions on the y axis
  110950. */
  110951. yGizmo: PlaneRotationGizmo;
  110952. /**
  110953. * Internal gizmo used for interactions on the z axis
  110954. */
  110955. zGizmo: PlaneRotationGizmo;
  110956. /** Fires an event when any of it's sub gizmos are dragged */
  110957. onDragStartObservable: Observable<unknown>;
  110958. /** Fires an event when any of it's sub gizmos are released from dragging */
  110959. onDragEndObservable: Observable<unknown>;
  110960. private _meshAttached;
  110961. attachedMesh: Nullable<AbstractMesh>;
  110962. /**
  110963. * Creates a RotationGizmo
  110964. * @param gizmoLayer The utility layer the gizmo will be added to
  110965. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110966. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110967. */
  110968. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110969. updateGizmoRotationToMatchAttachedMesh: boolean;
  110970. /**
  110971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110972. */
  110973. snapDistance: number;
  110974. /**
  110975. * Ratio for the scale of the gizmo (Default: 1)
  110976. */
  110977. scaleRatio: number;
  110978. /**
  110979. * Disposes of the gizmo
  110980. */
  110981. dispose(): void;
  110982. /**
  110983. * CustomMeshes are not supported by this gizmo
  110984. * @param mesh The mesh to replace the default mesh of the gizmo
  110985. */
  110986. setCustomMesh(mesh: Mesh): void;
  110987. }
  110988. }
  110989. declare module BABYLON {
  110990. /**
  110991. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110992. */
  110993. export class GizmoManager implements IDisposable {
  110994. private scene;
  110995. /**
  110996. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110997. */
  110998. gizmos: {
  110999. positionGizmo: Nullable<PositionGizmo>;
  111000. rotationGizmo: Nullable<RotationGizmo>;
  111001. scaleGizmo: Nullable<ScaleGizmo>;
  111002. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  111003. };
  111004. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  111005. clearGizmoOnEmptyPointerEvent: boolean;
  111006. /** Fires an event when the manager is attached to a mesh */
  111007. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  111008. private _gizmosEnabled;
  111009. private _pointerObserver;
  111010. private _attachedMesh;
  111011. private _boundingBoxColor;
  111012. private _defaultUtilityLayer;
  111013. private _defaultKeepDepthUtilityLayer;
  111014. /**
  111015. * When bounding box gizmo is enabled, this can be used to track drag/end events
  111016. */
  111017. boundingBoxDragBehavior: SixDofDragBehavior;
  111018. /**
  111019. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  111020. */
  111021. attachableMeshes: Nullable<Array<AbstractMesh>>;
  111022. /**
  111023. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  111024. */
  111025. usePointerToAttachGizmos: boolean;
  111026. /**
  111027. * Utility layer that the bounding box gizmo belongs to
  111028. */
  111029. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  111030. /**
  111031. * Utility layer that all gizmos besides bounding box belong to
  111032. */
  111033. readonly utilityLayer: UtilityLayerRenderer;
  111034. /**
  111035. * Instatiates a gizmo manager
  111036. * @param scene the scene to overlay the gizmos on top of
  111037. */
  111038. constructor(scene: Scene);
  111039. /**
  111040. * Attaches a set of gizmos to the specified mesh
  111041. * @param mesh The mesh the gizmo's should be attached to
  111042. */
  111043. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111044. /**
  111045. * If the position gizmo is enabled
  111046. */
  111047. positionGizmoEnabled: boolean;
  111048. /**
  111049. * If the rotation gizmo is enabled
  111050. */
  111051. rotationGizmoEnabled: boolean;
  111052. /**
  111053. * If the scale gizmo is enabled
  111054. */
  111055. scaleGizmoEnabled: boolean;
  111056. /**
  111057. * If the boundingBox gizmo is enabled
  111058. */
  111059. boundingBoxGizmoEnabled: boolean;
  111060. /**
  111061. * Disposes of the gizmo manager
  111062. */
  111063. dispose(): void;
  111064. }
  111065. }
  111066. declare module BABYLON {
  111067. /**
  111068. * A directional light is defined by a direction (what a surprise!).
  111069. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  111070. * 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.
  111071. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111072. */
  111073. export class DirectionalLight extends ShadowLight {
  111074. private _shadowFrustumSize;
  111075. /**
  111076. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  111077. */
  111078. /**
  111079. * Specifies a fix frustum size for the shadow generation.
  111080. */
  111081. shadowFrustumSize: number;
  111082. private _shadowOrthoScale;
  111083. /**
  111084. * Gets the shadow projection scale against the optimal computed one.
  111085. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111086. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111087. */
  111088. /**
  111089. * Sets the shadow projection scale against the optimal computed one.
  111090. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111091. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111092. */
  111093. shadowOrthoScale: number;
  111094. /**
  111095. * Automatically compute the projection matrix to best fit (including all the casters)
  111096. * on each frame.
  111097. */
  111098. autoUpdateExtends: boolean;
  111099. private _orthoLeft;
  111100. private _orthoRight;
  111101. private _orthoTop;
  111102. private _orthoBottom;
  111103. /**
  111104. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  111105. * The directional light is emitted from everywhere in the given direction.
  111106. * It can cast shadows.
  111107. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111108. * @param name The friendly name of the light
  111109. * @param direction The direction of the light
  111110. * @param scene The scene the light belongs to
  111111. */
  111112. constructor(name: string, direction: Vector3, scene: Scene);
  111113. /**
  111114. * Returns the string "DirectionalLight".
  111115. * @return The class name
  111116. */
  111117. getClassName(): string;
  111118. /**
  111119. * Returns the integer 1.
  111120. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111121. */
  111122. getTypeID(): number;
  111123. /**
  111124. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  111125. * Returns the DirectionalLight Shadow projection matrix.
  111126. */
  111127. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111128. /**
  111129. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  111130. * Returns the DirectionalLight Shadow projection matrix.
  111131. */
  111132. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  111133. /**
  111134. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  111135. * Returns the DirectionalLight Shadow projection matrix.
  111136. */
  111137. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111138. protected _buildUniformLayout(): void;
  111139. /**
  111140. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  111141. * @param effect The effect to update
  111142. * @param lightIndex The index of the light in the effect to update
  111143. * @returns The directional light
  111144. */
  111145. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  111146. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  111147. /**
  111148. * Gets the minZ used for shadow according to both the scene and the light.
  111149. *
  111150. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  111151. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  111152. * @param activeCamera The camera we are returning the min for
  111153. * @returns the depth min z
  111154. */
  111155. getDepthMinZ(activeCamera: Camera): number;
  111156. /**
  111157. * Gets the maxZ used for shadow according to both the scene and the light.
  111158. *
  111159. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  111160. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  111161. * @param activeCamera The camera we are returning the max for
  111162. * @returns the depth max z
  111163. */
  111164. getDepthMaxZ(activeCamera: Camera): number;
  111165. /**
  111166. * Prepares the list of defines specific to the light type.
  111167. * @param defines the list of defines
  111168. * @param lightIndex defines the index of the light for the effect
  111169. */
  111170. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111171. }
  111172. }
  111173. declare module BABYLON {
  111174. /**
  111175. * Class containing static functions to help procedurally build meshes
  111176. */
  111177. export class HemisphereBuilder {
  111178. /**
  111179. * Creates a hemisphere mesh
  111180. * @param name defines the name of the mesh
  111181. * @param options defines the options used to create the mesh
  111182. * @param scene defines the hosting scene
  111183. * @returns the hemisphere mesh
  111184. */
  111185. static CreateHemisphere(name: string, options: {
  111186. segments?: number;
  111187. diameter?: number;
  111188. sideOrientation?: number;
  111189. }, scene: any): Mesh;
  111190. }
  111191. }
  111192. declare module BABYLON {
  111193. /**
  111194. * A spot light is defined by a position, a direction, an angle, and an exponent.
  111195. * These values define a cone of light starting from the position, emitting toward the direction.
  111196. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  111197. * and the exponent defines the speed of the decay of the light with distance (reach).
  111198. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111199. */
  111200. export class SpotLight extends ShadowLight {
  111201. private _angle;
  111202. private _innerAngle;
  111203. private _cosHalfAngle;
  111204. private _lightAngleScale;
  111205. private _lightAngleOffset;
  111206. /**
  111207. * Gets the cone angle of the spot light in Radians.
  111208. */
  111209. /**
  111210. * Sets the cone angle of the spot light in Radians.
  111211. */
  111212. angle: number;
  111213. /**
  111214. * Only used in gltf falloff mode, this defines the angle where
  111215. * the directional falloff will start before cutting at angle which could be seen
  111216. * as outer angle.
  111217. */
  111218. /**
  111219. * Only used in gltf falloff mode, this defines the angle where
  111220. * the directional falloff will start before cutting at angle which could be seen
  111221. * as outer angle.
  111222. */
  111223. innerAngle: number;
  111224. private _shadowAngleScale;
  111225. /**
  111226. * Allows scaling the angle of the light for shadow generation only.
  111227. */
  111228. /**
  111229. * Allows scaling the angle of the light for shadow generation only.
  111230. */
  111231. shadowAngleScale: number;
  111232. /**
  111233. * The light decay speed with the distance from the emission spot.
  111234. */
  111235. exponent: number;
  111236. private _projectionTextureMatrix;
  111237. /**
  111238. * Allows reading the projecton texture
  111239. */
  111240. readonly projectionTextureMatrix: Matrix;
  111241. protected _projectionTextureLightNear: number;
  111242. /**
  111243. * Gets the near clip of the Spotlight for texture projection.
  111244. */
  111245. /**
  111246. * Sets the near clip of the Spotlight for texture projection.
  111247. */
  111248. projectionTextureLightNear: number;
  111249. protected _projectionTextureLightFar: number;
  111250. /**
  111251. * Gets the far clip of the Spotlight for texture projection.
  111252. */
  111253. /**
  111254. * Sets the far clip of the Spotlight for texture projection.
  111255. */
  111256. projectionTextureLightFar: number;
  111257. protected _projectionTextureUpDirection: Vector3;
  111258. /**
  111259. * Gets the Up vector of the Spotlight for texture projection.
  111260. */
  111261. /**
  111262. * Sets the Up vector of the Spotlight for texture projection.
  111263. */
  111264. projectionTextureUpDirection: Vector3;
  111265. private _projectionTexture;
  111266. /**
  111267. * Gets the projection texture of the light.
  111268. */
  111269. /**
  111270. * Sets the projection texture of the light.
  111271. */
  111272. projectionTexture: Nullable<BaseTexture>;
  111273. private _projectionTextureViewLightDirty;
  111274. private _projectionTextureProjectionLightDirty;
  111275. private _projectionTextureDirty;
  111276. private _projectionTextureViewTargetVector;
  111277. private _projectionTextureViewLightMatrix;
  111278. private _projectionTextureProjectionLightMatrix;
  111279. private _projectionTextureScalingMatrix;
  111280. /**
  111281. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  111282. * It can cast shadows.
  111283. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111284. * @param name The light friendly name
  111285. * @param position The position of the spot light in the scene
  111286. * @param direction The direction of the light in the scene
  111287. * @param angle The cone angle of the light in Radians
  111288. * @param exponent The light decay speed with the distance from the emission spot
  111289. * @param scene The scene the lights belongs to
  111290. */
  111291. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  111292. /**
  111293. * Returns the string "SpotLight".
  111294. * @returns the class name
  111295. */
  111296. getClassName(): string;
  111297. /**
  111298. * Returns the integer 2.
  111299. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111300. */
  111301. getTypeID(): number;
  111302. /**
  111303. * Overrides the direction setter to recompute the projection texture view light Matrix.
  111304. */
  111305. protected _setDirection(value: Vector3): void;
  111306. /**
  111307. * Overrides the position setter to recompute the projection texture view light Matrix.
  111308. */
  111309. protected _setPosition(value: Vector3): void;
  111310. /**
  111311. * 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.
  111312. * Returns the SpotLight.
  111313. */
  111314. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111315. protected _computeProjectionTextureViewLightMatrix(): void;
  111316. protected _computeProjectionTextureProjectionLightMatrix(): void;
  111317. /**
  111318. * Main function for light texture projection matrix computing.
  111319. */
  111320. protected _computeProjectionTextureMatrix(): void;
  111321. protected _buildUniformLayout(): void;
  111322. private _computeAngleValues;
  111323. /**
  111324. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  111325. * @param effect The effect to update
  111326. * @param lightIndex The index of the light in the effect to update
  111327. * @returns The spot light
  111328. */
  111329. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  111330. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  111331. /**
  111332. * Disposes the light and the associated resources.
  111333. */
  111334. dispose(): void;
  111335. /**
  111336. * Prepares the list of defines specific to the light type.
  111337. * @param defines the list of defines
  111338. * @param lightIndex defines the index of the light for the effect
  111339. */
  111340. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111341. }
  111342. }
  111343. declare module BABYLON {
  111344. /**
  111345. * Gizmo that enables viewing a light
  111346. */
  111347. export class LightGizmo extends Gizmo {
  111348. private _lightMesh;
  111349. private _material;
  111350. private cachedPosition;
  111351. private cachedForward;
  111352. /**
  111353. * Creates a LightGizmo
  111354. * @param gizmoLayer The utility layer the gizmo will be added to
  111355. */
  111356. constructor(gizmoLayer?: UtilityLayerRenderer);
  111357. private _light;
  111358. /**
  111359. * The light that the gizmo is attached to
  111360. */
  111361. light: Nullable<Light>;
  111362. /**
  111363. * Gets the material used to render the light gizmo
  111364. */
  111365. readonly material: StandardMaterial;
  111366. /**
  111367. * @hidden
  111368. * Updates the gizmo to match the attached mesh's position/rotation
  111369. */
  111370. protected _update(): void;
  111371. private static _Scale;
  111372. /**
  111373. * Creates the lines for a light mesh
  111374. */
  111375. private static _createLightLines;
  111376. /**
  111377. * Disposes of the light gizmo
  111378. */
  111379. dispose(): void;
  111380. private static _CreateHemisphericLightMesh;
  111381. private static _CreatePointLightMesh;
  111382. private static _CreateSpotLightMesh;
  111383. private static _CreateDirectionalLightMesh;
  111384. }
  111385. }
  111386. declare module BABYLON {
  111387. /** @hidden */
  111388. export var backgroundFragmentDeclaration: {
  111389. name: string;
  111390. shader: string;
  111391. };
  111392. }
  111393. declare module BABYLON {
  111394. /** @hidden */
  111395. export var backgroundUboDeclaration: {
  111396. name: string;
  111397. shader: string;
  111398. };
  111399. }
  111400. declare module BABYLON {
  111401. /** @hidden */
  111402. export var backgroundPixelShader: {
  111403. name: string;
  111404. shader: string;
  111405. };
  111406. }
  111407. declare module BABYLON {
  111408. /** @hidden */
  111409. export var backgroundVertexDeclaration: {
  111410. name: string;
  111411. shader: string;
  111412. };
  111413. }
  111414. declare module BABYLON {
  111415. /** @hidden */
  111416. export var backgroundVertexShader: {
  111417. name: string;
  111418. shader: string;
  111419. };
  111420. }
  111421. declare module BABYLON {
  111422. /**
  111423. * Background material used to create an efficient environement around your scene.
  111424. */
  111425. export class BackgroundMaterial extends PushMaterial {
  111426. /**
  111427. * Standard reflectance value at parallel view angle.
  111428. */
  111429. static StandardReflectance0: number;
  111430. /**
  111431. * Standard reflectance value at grazing angle.
  111432. */
  111433. static StandardReflectance90: number;
  111434. protected _primaryColor: Color3;
  111435. /**
  111436. * Key light Color (multiply against the environement texture)
  111437. */
  111438. primaryColor: Color3;
  111439. protected __perceptualColor: Nullable<Color3>;
  111440. /**
  111441. * Experimental Internal Use Only.
  111442. *
  111443. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111444. * This acts as a helper to set the primary color to a more "human friendly" value.
  111445. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111446. * output color as close as possible from the chosen value.
  111447. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111448. * part of lighting setup.)
  111449. */
  111450. _perceptualColor: Nullable<Color3>;
  111451. protected _primaryColorShadowLevel: float;
  111452. /**
  111453. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111454. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111455. */
  111456. primaryColorShadowLevel: float;
  111457. protected _primaryColorHighlightLevel: float;
  111458. /**
  111459. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111460. * The primary color is used at the level chosen to define what the white area would look.
  111461. */
  111462. primaryColorHighlightLevel: float;
  111463. protected _reflectionTexture: Nullable<BaseTexture>;
  111464. /**
  111465. * Reflection Texture used in the material.
  111466. * Should be author in a specific way for the best result (refer to the documentation).
  111467. */
  111468. reflectionTexture: Nullable<BaseTexture>;
  111469. protected _reflectionBlur: float;
  111470. /**
  111471. * Reflection Texture level of blur.
  111472. *
  111473. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111474. * texture twice.
  111475. */
  111476. reflectionBlur: float;
  111477. protected _diffuseTexture: Nullable<BaseTexture>;
  111478. /**
  111479. * Diffuse Texture used in the material.
  111480. * Should be author in a specific way for the best result (refer to the documentation).
  111481. */
  111482. diffuseTexture: Nullable<BaseTexture>;
  111483. protected _shadowLights: Nullable<IShadowLight[]>;
  111484. /**
  111485. * Specify the list of lights casting shadow on the material.
  111486. * All scene shadow lights will be included if null.
  111487. */
  111488. shadowLights: Nullable<IShadowLight[]>;
  111489. protected _shadowLevel: float;
  111490. /**
  111491. * Helps adjusting the shadow to a softer level if required.
  111492. * 0 means black shadows and 1 means no shadows.
  111493. */
  111494. shadowLevel: float;
  111495. protected _sceneCenter: Vector3;
  111496. /**
  111497. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111498. * It is usually zero but might be interesting to modify according to your setup.
  111499. */
  111500. sceneCenter: Vector3;
  111501. protected _opacityFresnel: boolean;
  111502. /**
  111503. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111504. * This helps ensuring a nice transition when the camera goes under the ground.
  111505. */
  111506. opacityFresnel: boolean;
  111507. protected _reflectionFresnel: boolean;
  111508. /**
  111509. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111510. * This helps adding a mirror texture on the ground.
  111511. */
  111512. reflectionFresnel: boolean;
  111513. protected _reflectionFalloffDistance: number;
  111514. /**
  111515. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111516. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111517. */
  111518. reflectionFalloffDistance: number;
  111519. protected _reflectionAmount: number;
  111520. /**
  111521. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111522. */
  111523. reflectionAmount: number;
  111524. protected _reflectionReflectance0: number;
  111525. /**
  111526. * This specifies the weight of the reflection at grazing angle.
  111527. */
  111528. reflectionReflectance0: number;
  111529. protected _reflectionReflectance90: number;
  111530. /**
  111531. * This specifies the weight of the reflection at a perpendicular point of view.
  111532. */
  111533. reflectionReflectance90: number;
  111534. /**
  111535. * Sets the reflection reflectance fresnel values according to the default standard
  111536. * empirically know to work well :-)
  111537. */
  111538. reflectionStandardFresnelWeight: number;
  111539. protected _useRGBColor: boolean;
  111540. /**
  111541. * Helps to directly use the maps channels instead of their level.
  111542. */
  111543. useRGBColor: boolean;
  111544. protected _enableNoise: boolean;
  111545. /**
  111546. * This helps reducing the banding effect that could occur on the background.
  111547. */
  111548. enableNoise: boolean;
  111549. /**
  111550. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111551. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111552. * Recommended to be keep at 1.0 except for special cases.
  111553. */
  111554. fovMultiplier: number;
  111555. private _fovMultiplier;
  111556. /**
  111557. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111558. */
  111559. useEquirectangularFOV: boolean;
  111560. private _maxSimultaneousLights;
  111561. /**
  111562. * Number of Simultaneous lights allowed on the material.
  111563. */
  111564. maxSimultaneousLights: int;
  111565. /**
  111566. * Default configuration related to image processing available in the Background Material.
  111567. */
  111568. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111569. /**
  111570. * Keep track of the image processing observer to allow dispose and replace.
  111571. */
  111572. private _imageProcessingObserver;
  111573. /**
  111574. * Attaches a new image processing configuration to the PBR Material.
  111575. * @param configuration (if null the scene configuration will be use)
  111576. */
  111577. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111578. /**
  111579. * Gets the image processing configuration used either in this material.
  111580. */
  111581. /**
  111582. * Sets the Default image processing configuration used either in the this material.
  111583. *
  111584. * If sets to null, the scene one is in use.
  111585. */
  111586. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111587. /**
  111588. * Gets wether the color curves effect is enabled.
  111589. */
  111590. /**
  111591. * Sets wether the color curves effect is enabled.
  111592. */
  111593. cameraColorCurvesEnabled: boolean;
  111594. /**
  111595. * Gets wether the color grading effect is enabled.
  111596. */
  111597. /**
  111598. * Gets wether the color grading effect is enabled.
  111599. */
  111600. cameraColorGradingEnabled: boolean;
  111601. /**
  111602. * Gets wether tonemapping is enabled or not.
  111603. */
  111604. /**
  111605. * Sets wether tonemapping is enabled or not
  111606. */
  111607. cameraToneMappingEnabled: boolean;
  111608. /**
  111609. * The camera exposure used on this material.
  111610. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111611. * This corresponds to a photographic exposure.
  111612. */
  111613. /**
  111614. * The camera exposure used on this material.
  111615. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111616. * This corresponds to a photographic exposure.
  111617. */
  111618. cameraExposure: float;
  111619. /**
  111620. * Gets The camera contrast used on this material.
  111621. */
  111622. /**
  111623. * Sets The camera contrast used on this material.
  111624. */
  111625. cameraContrast: float;
  111626. /**
  111627. * Gets the Color Grading 2D Lookup Texture.
  111628. */
  111629. /**
  111630. * Sets the Color Grading 2D Lookup Texture.
  111631. */
  111632. cameraColorGradingTexture: Nullable<BaseTexture>;
  111633. /**
  111634. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111636. * 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;
  111637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111638. */
  111639. /**
  111640. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111641. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111642. * 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;
  111643. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111644. */
  111645. cameraColorCurves: Nullable<ColorCurves>;
  111646. /**
  111647. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111648. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111649. */
  111650. switchToBGR: boolean;
  111651. private _renderTargets;
  111652. private _reflectionControls;
  111653. private _white;
  111654. private _primaryShadowColor;
  111655. private _primaryHighlightColor;
  111656. /**
  111657. * Instantiates a Background Material in the given scene
  111658. * @param name The friendly name of the material
  111659. * @param scene The scene to add the material to
  111660. */
  111661. constructor(name: string, scene: Scene);
  111662. /**
  111663. * Gets a boolean indicating that current material needs to register RTT
  111664. */
  111665. readonly hasRenderTargetTextures: boolean;
  111666. /**
  111667. * The entire material has been created in order to prevent overdraw.
  111668. * @returns false
  111669. */
  111670. needAlphaTesting(): boolean;
  111671. /**
  111672. * The entire material has been created in order to prevent overdraw.
  111673. * @returns true if blending is enable
  111674. */
  111675. needAlphaBlending(): boolean;
  111676. /**
  111677. * Checks wether the material is ready to be rendered for a given mesh.
  111678. * @param mesh The mesh to render
  111679. * @param subMesh The submesh to check against
  111680. * @param useInstances Specify wether or not the material is used with instances
  111681. * @returns true if all the dependencies are ready (Textures, Effects...)
  111682. */
  111683. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111684. /**
  111685. * Compute the primary color according to the chosen perceptual color.
  111686. */
  111687. private _computePrimaryColorFromPerceptualColor;
  111688. /**
  111689. * Compute the highlights and shadow colors according to their chosen levels.
  111690. */
  111691. private _computePrimaryColors;
  111692. /**
  111693. * Build the uniform buffer used in the material.
  111694. */
  111695. buildUniformLayout(): void;
  111696. /**
  111697. * Unbind the material.
  111698. */
  111699. unbind(): void;
  111700. /**
  111701. * Bind only the world matrix to the material.
  111702. * @param world The world matrix to bind.
  111703. */
  111704. bindOnlyWorldMatrix(world: Matrix): void;
  111705. /**
  111706. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111707. * @param world The world matrix to bind.
  111708. * @param subMesh The submesh to bind for.
  111709. */
  111710. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111711. /**
  111712. * Checks to see if a texture is used in the material.
  111713. * @param texture - Base texture to use.
  111714. * @returns - Boolean specifying if a texture is used in the material.
  111715. */
  111716. hasTexture(texture: BaseTexture): boolean;
  111717. /**
  111718. * Dispose the material.
  111719. * @param forceDisposeEffect Force disposal of the associated effect.
  111720. * @param forceDisposeTextures Force disposal of the associated textures.
  111721. */
  111722. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111723. /**
  111724. * Clones the material.
  111725. * @param name The cloned name.
  111726. * @returns The cloned material.
  111727. */
  111728. clone(name: string): BackgroundMaterial;
  111729. /**
  111730. * Serializes the current material to its JSON representation.
  111731. * @returns The JSON representation.
  111732. */
  111733. serialize(): any;
  111734. /**
  111735. * Gets the class name of the material
  111736. * @returns "BackgroundMaterial"
  111737. */
  111738. getClassName(): string;
  111739. /**
  111740. * Parse a JSON input to create back a background material.
  111741. * @param source The JSON data to parse
  111742. * @param scene The scene to create the parsed material in
  111743. * @param rootUrl The root url of the assets the material depends upon
  111744. * @returns the instantiated BackgroundMaterial.
  111745. */
  111746. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111747. }
  111748. }
  111749. declare module BABYLON {
  111750. /**
  111751. * Represents the different options available during the creation of
  111752. * a Environment helper.
  111753. *
  111754. * This can control the default ground, skybox and image processing setup of your scene.
  111755. */
  111756. export interface IEnvironmentHelperOptions {
  111757. /**
  111758. * Specifies wether or not to create a ground.
  111759. * True by default.
  111760. */
  111761. createGround: boolean;
  111762. /**
  111763. * Specifies the ground size.
  111764. * 15 by default.
  111765. */
  111766. groundSize: number;
  111767. /**
  111768. * The texture used on the ground for the main color.
  111769. * Comes from the BabylonJS CDN by default.
  111770. *
  111771. * Remarks: Can be either a texture or a url.
  111772. */
  111773. groundTexture: string | BaseTexture;
  111774. /**
  111775. * The color mixed in the ground texture by default.
  111776. * BabylonJS clearColor by default.
  111777. */
  111778. groundColor: Color3;
  111779. /**
  111780. * Specifies the ground opacity.
  111781. * 1 by default.
  111782. */
  111783. groundOpacity: number;
  111784. /**
  111785. * Enables the ground to receive shadows.
  111786. * True by default.
  111787. */
  111788. enableGroundShadow: boolean;
  111789. /**
  111790. * Helps preventing the shadow to be fully black on the ground.
  111791. * 0.5 by default.
  111792. */
  111793. groundShadowLevel: number;
  111794. /**
  111795. * Creates a mirror texture attach to the ground.
  111796. * false by default.
  111797. */
  111798. enableGroundMirror: boolean;
  111799. /**
  111800. * Specifies the ground mirror size ratio.
  111801. * 0.3 by default as the default kernel is 64.
  111802. */
  111803. groundMirrorSizeRatio: number;
  111804. /**
  111805. * Specifies the ground mirror blur kernel size.
  111806. * 64 by default.
  111807. */
  111808. groundMirrorBlurKernel: number;
  111809. /**
  111810. * Specifies the ground mirror visibility amount.
  111811. * 1 by default
  111812. */
  111813. groundMirrorAmount: number;
  111814. /**
  111815. * Specifies the ground mirror reflectance weight.
  111816. * This uses the standard weight of the background material to setup the fresnel effect
  111817. * of the mirror.
  111818. * 1 by default.
  111819. */
  111820. groundMirrorFresnelWeight: number;
  111821. /**
  111822. * Specifies the ground mirror Falloff distance.
  111823. * This can helps reducing the size of the reflection.
  111824. * 0 by Default.
  111825. */
  111826. groundMirrorFallOffDistance: number;
  111827. /**
  111828. * Specifies the ground mirror texture type.
  111829. * Unsigned Int by Default.
  111830. */
  111831. groundMirrorTextureType: number;
  111832. /**
  111833. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111834. * the shown objects.
  111835. */
  111836. groundYBias: number;
  111837. /**
  111838. * Specifies wether or not to create a skybox.
  111839. * True by default.
  111840. */
  111841. createSkybox: boolean;
  111842. /**
  111843. * Specifies the skybox size.
  111844. * 20 by default.
  111845. */
  111846. skyboxSize: number;
  111847. /**
  111848. * The texture used on the skybox for the main color.
  111849. * Comes from the BabylonJS CDN by default.
  111850. *
  111851. * Remarks: Can be either a texture or a url.
  111852. */
  111853. skyboxTexture: string | BaseTexture;
  111854. /**
  111855. * The color mixed in the skybox texture by default.
  111856. * BabylonJS clearColor by default.
  111857. */
  111858. skyboxColor: Color3;
  111859. /**
  111860. * The background rotation around the Y axis of the scene.
  111861. * This helps aligning the key lights of your scene with the background.
  111862. * 0 by default.
  111863. */
  111864. backgroundYRotation: number;
  111865. /**
  111866. * Compute automatically the size of the elements to best fit with the scene.
  111867. */
  111868. sizeAuto: boolean;
  111869. /**
  111870. * Default position of the rootMesh if autoSize is not true.
  111871. */
  111872. rootPosition: Vector3;
  111873. /**
  111874. * Sets up the image processing in the scene.
  111875. * true by default.
  111876. */
  111877. setupImageProcessing: boolean;
  111878. /**
  111879. * The texture used as your environment texture in the scene.
  111880. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111881. *
  111882. * Remarks: Can be either a texture or a url.
  111883. */
  111884. environmentTexture: string | BaseTexture;
  111885. /**
  111886. * The value of the exposure to apply to the scene.
  111887. * 0.6 by default if setupImageProcessing is true.
  111888. */
  111889. cameraExposure: number;
  111890. /**
  111891. * The value of the contrast to apply to the scene.
  111892. * 1.6 by default if setupImageProcessing is true.
  111893. */
  111894. cameraContrast: number;
  111895. /**
  111896. * Specifies wether or not tonemapping should be enabled in the scene.
  111897. * true by default if setupImageProcessing is true.
  111898. */
  111899. toneMappingEnabled: boolean;
  111900. }
  111901. /**
  111902. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111903. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111904. * It also helps with the default setup of your imageProcessing configuration.
  111905. */
  111906. export class EnvironmentHelper {
  111907. /**
  111908. * Default ground texture URL.
  111909. */
  111910. private static _groundTextureCDNUrl;
  111911. /**
  111912. * Default skybox texture URL.
  111913. */
  111914. private static _skyboxTextureCDNUrl;
  111915. /**
  111916. * Default environment texture URL.
  111917. */
  111918. private static _environmentTextureCDNUrl;
  111919. /**
  111920. * Creates the default options for the helper.
  111921. */
  111922. private static _getDefaultOptions;
  111923. private _rootMesh;
  111924. /**
  111925. * Gets the root mesh created by the helper.
  111926. */
  111927. readonly rootMesh: Mesh;
  111928. private _skybox;
  111929. /**
  111930. * Gets the skybox created by the helper.
  111931. */
  111932. readonly skybox: Nullable<Mesh>;
  111933. private _skyboxTexture;
  111934. /**
  111935. * Gets the skybox texture created by the helper.
  111936. */
  111937. readonly skyboxTexture: Nullable<BaseTexture>;
  111938. private _skyboxMaterial;
  111939. /**
  111940. * Gets the skybox material created by the helper.
  111941. */
  111942. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111943. private _ground;
  111944. /**
  111945. * Gets the ground mesh created by the helper.
  111946. */
  111947. readonly ground: Nullable<Mesh>;
  111948. private _groundTexture;
  111949. /**
  111950. * Gets the ground texture created by the helper.
  111951. */
  111952. readonly groundTexture: Nullable<BaseTexture>;
  111953. private _groundMirror;
  111954. /**
  111955. * Gets the ground mirror created by the helper.
  111956. */
  111957. readonly groundMirror: Nullable<MirrorTexture>;
  111958. /**
  111959. * Gets the ground mirror render list to helps pushing the meshes
  111960. * you wish in the ground reflection.
  111961. */
  111962. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111963. private _groundMaterial;
  111964. /**
  111965. * Gets the ground material created by the helper.
  111966. */
  111967. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111968. /**
  111969. * Stores the creation options.
  111970. */
  111971. private readonly _scene;
  111972. private _options;
  111973. /**
  111974. * This observable will be notified with any error during the creation of the environment,
  111975. * mainly texture creation errors.
  111976. */
  111977. onErrorObservable: Observable<{
  111978. message?: string;
  111979. exception?: any;
  111980. }>;
  111981. /**
  111982. * constructor
  111983. * @param options Defines the options we want to customize the helper
  111984. * @param scene The scene to add the material to
  111985. */
  111986. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111987. /**
  111988. * Updates the background according to the new options
  111989. * @param options
  111990. */
  111991. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111992. /**
  111993. * Sets the primary color of all the available elements.
  111994. * @param color the main color to affect to the ground and the background
  111995. */
  111996. setMainColor(color: Color3): void;
  111997. /**
  111998. * Setup the image processing according to the specified options.
  111999. */
  112000. private _setupImageProcessing;
  112001. /**
  112002. * Setup the environment texture according to the specified options.
  112003. */
  112004. private _setupEnvironmentTexture;
  112005. /**
  112006. * Setup the background according to the specified options.
  112007. */
  112008. private _setupBackground;
  112009. /**
  112010. * Get the scene sizes according to the setup.
  112011. */
  112012. private _getSceneSize;
  112013. /**
  112014. * Setup the ground according to the specified options.
  112015. */
  112016. private _setupGround;
  112017. /**
  112018. * Setup the ground material according to the specified options.
  112019. */
  112020. private _setupGroundMaterial;
  112021. /**
  112022. * Setup the ground diffuse texture according to the specified options.
  112023. */
  112024. private _setupGroundDiffuseTexture;
  112025. /**
  112026. * Setup the ground mirror texture according to the specified options.
  112027. */
  112028. private _setupGroundMirrorTexture;
  112029. /**
  112030. * Setup the ground to receive the mirror texture.
  112031. */
  112032. private _setupMirrorInGroundMaterial;
  112033. /**
  112034. * Setup the skybox according to the specified options.
  112035. */
  112036. private _setupSkybox;
  112037. /**
  112038. * Setup the skybox material according to the specified options.
  112039. */
  112040. private _setupSkyboxMaterial;
  112041. /**
  112042. * Setup the skybox reflection texture according to the specified options.
  112043. */
  112044. private _setupSkyboxReflectionTexture;
  112045. private _errorHandler;
  112046. /**
  112047. * Dispose all the elements created by the Helper.
  112048. */
  112049. dispose(): void;
  112050. }
  112051. }
  112052. declare module BABYLON {
  112053. /**
  112054. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  112055. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  112056. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  112057. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112058. */
  112059. export class PhotoDome extends TransformNode {
  112060. /**
  112061. * Define the image as a Monoscopic panoramic 360 image.
  112062. */
  112063. static readonly MODE_MONOSCOPIC: number;
  112064. /**
  112065. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112066. */
  112067. static readonly MODE_TOPBOTTOM: number;
  112068. /**
  112069. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112070. */
  112071. static readonly MODE_SIDEBYSIDE: number;
  112072. private _useDirectMapping;
  112073. /**
  112074. * The texture being displayed on the sphere
  112075. */
  112076. protected _photoTexture: Texture;
  112077. /**
  112078. * Gets or sets the texture being displayed on the sphere
  112079. */
  112080. photoTexture: Texture;
  112081. /**
  112082. * Observable raised when an error occured while loading the 360 image
  112083. */
  112084. onLoadErrorObservable: Observable<string>;
  112085. /**
  112086. * The skybox material
  112087. */
  112088. protected _material: BackgroundMaterial;
  112089. /**
  112090. * The surface used for the skybox
  112091. */
  112092. protected _mesh: Mesh;
  112093. /**
  112094. * Gets the mesh used for the skybox.
  112095. */
  112096. readonly mesh: Mesh;
  112097. /**
  112098. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112099. * Also see the options.resolution property.
  112100. */
  112101. fovMultiplier: number;
  112102. private _imageMode;
  112103. /**
  112104. * Gets or set the current video mode for the video. It can be:
  112105. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  112106. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112107. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112108. */
  112109. imageMode: number;
  112110. /**
  112111. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  112112. * @param name Element's name, child elements will append suffixes for their own names.
  112113. * @param urlsOfPhoto defines the url of the photo to display
  112114. * @param options defines an object containing optional or exposed sub element properties
  112115. * @param onError defines a callback called when an error occured while loading the texture
  112116. */
  112117. constructor(name: string, urlOfPhoto: string, options: {
  112118. resolution?: number;
  112119. size?: number;
  112120. useDirectMapping?: boolean;
  112121. faceForward?: boolean;
  112122. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  112123. private _onBeforeCameraRenderObserver;
  112124. private _changeImageMode;
  112125. /**
  112126. * Releases resources associated with this node.
  112127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112129. */
  112130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112131. }
  112132. }
  112133. declare module BABYLON {
  112134. /**
  112135. * Class used to host RGBD texture specific utilities
  112136. */
  112137. export class RGBDTextureTools {
  112138. /**
  112139. * Expand the RGBD Texture from RGBD to Half Float if possible.
  112140. * @param texture the texture to expand.
  112141. */
  112142. static ExpandRGBDTexture(texture: Texture): void;
  112143. }
  112144. }
  112145. declare module BABYLON {
  112146. /**
  112147. * Class used to host texture specific utilities
  112148. */
  112149. export class BRDFTextureTools {
  112150. /**
  112151. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  112152. * @param scene defines the hosting scene
  112153. * @returns the environment BRDF texture
  112154. */
  112155. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  112156. private static _environmentBRDFBase64Texture;
  112157. }
  112158. }
  112159. declare module BABYLON {
  112160. /**
  112161. * @hidden
  112162. */
  112163. export interface IMaterialClearCoatDefines {
  112164. CLEARCOAT: boolean;
  112165. CLEARCOAT_DEFAULTIOR: boolean;
  112166. CLEARCOAT_TEXTURE: boolean;
  112167. CLEARCOAT_TEXTUREDIRECTUV: number;
  112168. CLEARCOAT_BUMP: boolean;
  112169. CLEARCOAT_BUMPDIRECTUV: number;
  112170. CLEARCOAT_TINT: boolean;
  112171. CLEARCOAT_TINT_TEXTURE: boolean;
  112172. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112173. /** @hidden */
  112174. _areTexturesDirty: boolean;
  112175. }
  112176. /**
  112177. * Define the code related to the clear coat parameters of the pbr material.
  112178. */
  112179. export class PBRClearCoatConfiguration {
  112180. /**
  112181. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  112182. * The default fits with a polyurethane material.
  112183. */
  112184. private static readonly _DefaultIndexOfRefraction;
  112185. private _isEnabled;
  112186. /**
  112187. * Defines if the clear coat is enabled in the material.
  112188. */
  112189. isEnabled: boolean;
  112190. /**
  112191. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  112192. */
  112193. intensity: number;
  112194. /**
  112195. * Defines the clear coat layer roughness.
  112196. */
  112197. roughness: number;
  112198. private _indexOfRefraction;
  112199. /**
  112200. * Defines the index of refraction of the clear coat.
  112201. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  112202. * The default fits with a polyurethane material.
  112203. * Changing the default value is more performance intensive.
  112204. */
  112205. indexOfRefraction: number;
  112206. private _texture;
  112207. /**
  112208. * Stores the clear coat values in a texture.
  112209. */
  112210. texture: Nullable<BaseTexture>;
  112211. private _bumpTexture;
  112212. /**
  112213. * Define the clear coat specific bump texture.
  112214. */
  112215. bumpTexture: Nullable<BaseTexture>;
  112216. private _isTintEnabled;
  112217. /**
  112218. * Defines if the clear coat tint is enabled in the material.
  112219. */
  112220. isTintEnabled: boolean;
  112221. /**
  112222. * Defines the clear coat tint of the material.
  112223. * This is only use if tint is enabled
  112224. */
  112225. tintColor: Color3;
  112226. /**
  112227. * Defines the distance at which the tint color should be found in the
  112228. * clear coat media.
  112229. * This is only use if tint is enabled
  112230. */
  112231. tintColorAtDistance: number;
  112232. /**
  112233. * Defines the clear coat layer thickness.
  112234. * This is only use if tint is enabled
  112235. */
  112236. tintThickness: number;
  112237. private _tintTexture;
  112238. /**
  112239. * Stores the clear tint values in a texture.
  112240. * rgb is tint
  112241. * a is a thickness factor
  112242. */
  112243. tintTexture: Nullable<BaseTexture>;
  112244. /** @hidden */
  112245. private _internalMarkAllSubMeshesAsTexturesDirty;
  112246. /** @hidden */
  112247. _markAllSubMeshesAsTexturesDirty(): void;
  112248. /**
  112249. * Instantiate a new istance of clear coat configuration.
  112250. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112251. */
  112252. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112253. /**
  112254. * Gets wehter the submesh is ready to be used or not.
  112255. * @param defines the list of "defines" to update.
  112256. * @param scene defines the scene the material belongs to.
  112257. * @param engine defines the engine the material belongs to.
  112258. * @param disableBumpMap defines wether the material disables bump or not.
  112259. * @returns - boolean indicating that the submesh is ready or not.
  112260. */
  112261. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  112262. /**
  112263. * Checks to see if a texture is used in the material.
  112264. * @param defines the list of "defines" to update.
  112265. * @param scene defines the scene to the material belongs to.
  112266. */
  112267. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  112268. /**
  112269. * Binds the material data.
  112270. * @param uniformBuffer defines the Uniform buffer to fill in.
  112271. * @param scene defines the scene the material belongs to.
  112272. * @param engine defines the engine the material belongs to.
  112273. * @param disableBumpMap defines wether the material disables bump or not.
  112274. * @param isFrozen defines wether the material is frozen or not.
  112275. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  112276. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  112277. */
  112278. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  112279. /**
  112280. * Checks to see if a texture is used in the material.
  112281. * @param texture - Base texture to use.
  112282. * @returns - Boolean specifying if a texture is used in the material.
  112283. */
  112284. hasTexture(texture: BaseTexture): boolean;
  112285. /**
  112286. * Returns an array of the actively used textures.
  112287. * @param activeTextures Array of BaseTextures
  112288. */
  112289. getActiveTextures(activeTextures: BaseTexture[]): void;
  112290. /**
  112291. * Returns the animatable textures.
  112292. * @param animatables Array of animatable textures.
  112293. */
  112294. getAnimatables(animatables: IAnimatable[]): void;
  112295. /**
  112296. * Disposes the resources of the material.
  112297. * @param forceDisposeTextures - Forces the disposal of all textures.
  112298. */
  112299. dispose(forceDisposeTextures?: boolean): void;
  112300. /**
  112301. * Get the current class name of the texture useful for serialization or dynamic coding.
  112302. * @returns "PBRClearCoatConfiguration"
  112303. */
  112304. getClassName(): string;
  112305. /**
  112306. * Add fallbacks to the effect fallbacks list.
  112307. * @param defines defines the Base texture to use.
  112308. * @param fallbacks defines the current fallback list.
  112309. * @param currentRank defines the current fallback rank.
  112310. * @returns the new fallback rank.
  112311. */
  112312. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112313. /**
  112314. * Add the required uniforms to the current list.
  112315. * @param uniforms defines the current uniform list.
  112316. */
  112317. static AddUniforms(uniforms: string[]): void;
  112318. /**
  112319. * Add the required samplers to the current list.
  112320. * @param samplers defines the current sampler list.
  112321. */
  112322. static AddSamplers(samplers: string[]): void;
  112323. /**
  112324. * Add the required uniforms to the current buffer.
  112325. * @param uniformBuffer defines the current uniform buffer.
  112326. */
  112327. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112328. /**
  112329. * Makes a duplicate of the current configuration into another one.
  112330. * @param clearCoatConfiguration define the config where to copy the info
  112331. */
  112332. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  112333. /**
  112334. * Serializes this clear coat configuration.
  112335. * @returns - An object with the serialized config.
  112336. */
  112337. serialize(): any;
  112338. /**
  112339. * Parses a anisotropy Configuration from a serialized object.
  112340. * @param source - Serialized object.
  112341. * @param scene Defines the scene we are parsing for
  112342. * @param rootUrl Defines the rootUrl to load from
  112343. */
  112344. parse(source: any, scene: Scene, rootUrl: string): void;
  112345. }
  112346. }
  112347. declare module BABYLON {
  112348. /**
  112349. * @hidden
  112350. */
  112351. export interface IMaterialAnisotropicDefines {
  112352. ANISOTROPIC: boolean;
  112353. ANISOTROPIC_TEXTURE: boolean;
  112354. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112355. MAINUV1: boolean;
  112356. _areTexturesDirty: boolean;
  112357. _needUVs: boolean;
  112358. }
  112359. /**
  112360. * Define the code related to the anisotropic parameters of the pbr material.
  112361. */
  112362. export class PBRAnisotropicConfiguration {
  112363. private _isEnabled;
  112364. /**
  112365. * Defines if the anisotropy is enabled in the material.
  112366. */
  112367. isEnabled: boolean;
  112368. /**
  112369. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  112370. */
  112371. intensity: number;
  112372. /**
  112373. * Defines if the effect is along the tangents, bitangents or in between.
  112374. * By default, the effect is "strectching" the highlights along the tangents.
  112375. */
  112376. direction: Vector2;
  112377. private _texture;
  112378. /**
  112379. * Stores the anisotropy values in a texture.
  112380. * rg is direction (like normal from -1 to 1)
  112381. * b is a intensity
  112382. */
  112383. texture: Nullable<BaseTexture>;
  112384. /** @hidden */
  112385. private _internalMarkAllSubMeshesAsTexturesDirty;
  112386. /** @hidden */
  112387. _markAllSubMeshesAsTexturesDirty(): void;
  112388. /**
  112389. * Instantiate a new istance of anisotropy configuration.
  112390. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112391. */
  112392. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112393. /**
  112394. * Specifies that the submesh is ready to be used.
  112395. * @param defines the list of "defines" to update.
  112396. * @param scene defines the scene the material belongs to.
  112397. * @returns - boolean indicating that the submesh is ready or not.
  112398. */
  112399. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  112400. /**
  112401. * Checks to see if a texture is used in the material.
  112402. * @param defines the list of "defines" to update.
  112403. * @param mesh the mesh we are preparing the defines for.
  112404. * @param scene defines the scene the material belongs to.
  112405. */
  112406. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  112407. /**
  112408. * Binds the material data.
  112409. * @param uniformBuffer defines the Uniform buffer to fill in.
  112410. * @param scene defines the scene the material belongs to.
  112411. * @param isFrozen defines wether the material is frozen or not.
  112412. */
  112413. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112414. /**
  112415. * Checks to see if a texture is used in the material.
  112416. * @param texture - Base texture to use.
  112417. * @returns - Boolean specifying if a texture is used in the material.
  112418. */
  112419. hasTexture(texture: BaseTexture): boolean;
  112420. /**
  112421. * Returns an array of the actively used textures.
  112422. * @param activeTextures Array of BaseTextures
  112423. */
  112424. getActiveTextures(activeTextures: BaseTexture[]): void;
  112425. /**
  112426. * Returns the animatable textures.
  112427. * @param animatables Array of animatable textures.
  112428. */
  112429. getAnimatables(animatables: IAnimatable[]): void;
  112430. /**
  112431. * Disposes the resources of the material.
  112432. * @param forceDisposeTextures - Forces the disposal of all textures.
  112433. */
  112434. dispose(forceDisposeTextures?: boolean): void;
  112435. /**
  112436. * Get the current class name of the texture useful for serialization or dynamic coding.
  112437. * @returns "PBRAnisotropicConfiguration"
  112438. */
  112439. getClassName(): string;
  112440. /**
  112441. * Add fallbacks to the effect fallbacks list.
  112442. * @param defines defines the Base texture to use.
  112443. * @param fallbacks defines the current fallback list.
  112444. * @param currentRank defines the current fallback rank.
  112445. * @returns the new fallback rank.
  112446. */
  112447. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112448. /**
  112449. * Add the required uniforms to the current list.
  112450. * @param uniforms defines the current uniform list.
  112451. */
  112452. static AddUniforms(uniforms: string[]): void;
  112453. /**
  112454. * Add the required uniforms to the current buffer.
  112455. * @param uniformBuffer defines the current uniform buffer.
  112456. */
  112457. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112458. /**
  112459. * Add the required samplers to the current list.
  112460. * @param samplers defines the current sampler list.
  112461. */
  112462. static AddSamplers(samplers: string[]): void;
  112463. /**
  112464. * Makes a duplicate of the current configuration into another one.
  112465. * @param anisotropicConfiguration define the config where to copy the info
  112466. */
  112467. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112468. /**
  112469. * Serializes this anisotropy configuration.
  112470. * @returns - An object with the serialized config.
  112471. */
  112472. serialize(): any;
  112473. /**
  112474. * Parses a anisotropy Configuration from a serialized object.
  112475. * @param source - Serialized object.
  112476. * @param scene Defines the scene we are parsing for
  112477. * @param rootUrl Defines the rootUrl to load from
  112478. */
  112479. parse(source: any, scene: Scene, rootUrl: string): void;
  112480. }
  112481. }
  112482. declare module BABYLON {
  112483. /**
  112484. * @hidden
  112485. */
  112486. export interface IMaterialBRDFDefines {
  112487. BRDF_V_HEIGHT_CORRELATED: boolean;
  112488. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112489. SPHERICAL_HARMONICS: boolean;
  112490. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112491. /** @hidden */
  112492. _areMiscDirty: boolean;
  112493. }
  112494. /**
  112495. * Define the code related to the BRDF parameters of the pbr material.
  112496. */
  112497. export class PBRBRDFConfiguration {
  112498. /**
  112499. * Default value used for the energy conservation.
  112500. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112501. */
  112502. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112503. /**
  112504. * Default value used for the Smith Visibility Height Correlated mode.
  112505. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112506. */
  112507. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112508. /**
  112509. * Default value used for the IBL diffuse part.
  112510. * This can help switching back to the polynomials mode globally which is a tiny bit
  112511. * less GPU intensive at the drawback of a lower quality.
  112512. */
  112513. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112514. /**
  112515. * Default value used for activating energy conservation for the specular workflow.
  112516. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112517. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112518. */
  112519. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112520. private _useEnergyConservation;
  112521. /**
  112522. * Defines if the material uses energy conservation.
  112523. */
  112524. useEnergyConservation: boolean;
  112525. private _useSmithVisibilityHeightCorrelated;
  112526. /**
  112527. * LEGACY Mode set to false
  112528. * Defines if the material uses height smith correlated visibility term.
  112529. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112530. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112531. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112532. * Not relying on height correlated will also disable energy conservation.
  112533. */
  112534. useSmithVisibilityHeightCorrelated: boolean;
  112535. private _useSphericalHarmonics;
  112536. /**
  112537. * LEGACY Mode set to false
  112538. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112539. * diffuse part of the IBL.
  112540. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112541. * to the ground truth.
  112542. */
  112543. useSphericalHarmonics: boolean;
  112544. private _useSpecularGlossinessInputEnergyConservation;
  112545. /**
  112546. * Defines if the material uses energy conservation, when the specular workflow is active.
  112547. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112548. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112549. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112550. */
  112551. useSpecularGlossinessInputEnergyConservation: boolean;
  112552. /** @hidden */
  112553. private _internalMarkAllSubMeshesAsMiscDirty;
  112554. /** @hidden */
  112555. _markAllSubMeshesAsMiscDirty(): void;
  112556. /**
  112557. * Instantiate a new istance of clear coat configuration.
  112558. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112559. */
  112560. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112561. /**
  112562. * Checks to see if a texture is used in the material.
  112563. * @param defines the list of "defines" to update.
  112564. */
  112565. prepareDefines(defines: IMaterialBRDFDefines): void;
  112566. /**
  112567. * Get the current class name of the texture useful for serialization or dynamic coding.
  112568. * @returns "PBRClearCoatConfiguration"
  112569. */
  112570. getClassName(): string;
  112571. /**
  112572. * Makes a duplicate of the current configuration into another one.
  112573. * @param brdfConfiguration define the config where to copy the info
  112574. */
  112575. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112576. /**
  112577. * Serializes this BRDF configuration.
  112578. * @returns - An object with the serialized config.
  112579. */
  112580. serialize(): any;
  112581. /**
  112582. * Parses a anisotropy Configuration from a serialized object.
  112583. * @param source - Serialized object.
  112584. * @param scene Defines the scene we are parsing for
  112585. * @param rootUrl Defines the rootUrl to load from
  112586. */
  112587. parse(source: any, scene: Scene, rootUrl: string): void;
  112588. }
  112589. }
  112590. declare module BABYLON {
  112591. /**
  112592. * @hidden
  112593. */
  112594. export interface IMaterialSheenDefines {
  112595. SHEEN: boolean;
  112596. SHEEN_TEXTURE: boolean;
  112597. SHEEN_TEXTUREDIRECTUV: number;
  112598. SHEEN_LINKWITHALBEDO: boolean;
  112599. /** @hidden */
  112600. _areTexturesDirty: boolean;
  112601. }
  112602. /**
  112603. * Define the code related to the Sheen parameters of the pbr material.
  112604. */
  112605. export class PBRSheenConfiguration {
  112606. private _isEnabled;
  112607. /**
  112608. * Defines if the material uses sheen.
  112609. */
  112610. isEnabled: boolean;
  112611. private _linkSheenWithAlbedo;
  112612. /**
  112613. * Defines if the sheen is linked to the sheen color.
  112614. */
  112615. linkSheenWithAlbedo: boolean;
  112616. /**
  112617. * Defines the sheen intensity.
  112618. */
  112619. intensity: number;
  112620. /**
  112621. * Defines the sheen color.
  112622. */
  112623. color: Color3;
  112624. private _texture;
  112625. /**
  112626. * Stores the sheen tint values in a texture.
  112627. * rgb is tint
  112628. * a is a intensity
  112629. */
  112630. texture: Nullable<BaseTexture>;
  112631. /** @hidden */
  112632. private _internalMarkAllSubMeshesAsTexturesDirty;
  112633. /** @hidden */
  112634. _markAllSubMeshesAsTexturesDirty(): void;
  112635. /**
  112636. * Instantiate a new istance of clear coat configuration.
  112637. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112638. */
  112639. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112640. /**
  112641. * Specifies that the submesh is ready to be used.
  112642. * @param defines the list of "defines" to update.
  112643. * @param scene defines the scene the material belongs to.
  112644. * @returns - boolean indicating that the submesh is ready or not.
  112645. */
  112646. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112647. /**
  112648. * Checks to see if a texture is used in the material.
  112649. * @param defines the list of "defines" to update.
  112650. * @param scene defines the scene the material belongs to.
  112651. */
  112652. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112653. /**
  112654. * Binds the material data.
  112655. * @param uniformBuffer defines the Uniform buffer to fill in.
  112656. * @param scene defines the scene the material belongs to.
  112657. * @param isFrozen defines wether the material is frozen or not.
  112658. */
  112659. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112660. /**
  112661. * Checks to see if a texture is used in the material.
  112662. * @param texture - Base texture to use.
  112663. * @returns - Boolean specifying if a texture is used in the material.
  112664. */
  112665. hasTexture(texture: BaseTexture): boolean;
  112666. /**
  112667. * Returns an array of the actively used textures.
  112668. * @param activeTextures Array of BaseTextures
  112669. */
  112670. getActiveTextures(activeTextures: BaseTexture[]): void;
  112671. /**
  112672. * Returns the animatable textures.
  112673. * @param animatables Array of animatable textures.
  112674. */
  112675. getAnimatables(animatables: IAnimatable[]): void;
  112676. /**
  112677. * Disposes the resources of the material.
  112678. * @param forceDisposeTextures - Forces the disposal of all textures.
  112679. */
  112680. dispose(forceDisposeTextures?: boolean): void;
  112681. /**
  112682. * Get the current class name of the texture useful for serialization or dynamic coding.
  112683. * @returns "PBRSheenConfiguration"
  112684. */
  112685. getClassName(): string;
  112686. /**
  112687. * Add fallbacks to the effect fallbacks list.
  112688. * @param defines defines the Base texture to use.
  112689. * @param fallbacks defines the current fallback list.
  112690. * @param currentRank defines the current fallback rank.
  112691. * @returns the new fallback rank.
  112692. */
  112693. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112694. /**
  112695. * Add the required uniforms to the current list.
  112696. * @param uniforms defines the current uniform list.
  112697. */
  112698. static AddUniforms(uniforms: string[]): void;
  112699. /**
  112700. * Add the required uniforms to the current buffer.
  112701. * @param uniformBuffer defines the current uniform buffer.
  112702. */
  112703. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112704. /**
  112705. * Add the required samplers to the current list.
  112706. * @param samplers defines the current sampler list.
  112707. */
  112708. static AddSamplers(samplers: string[]): void;
  112709. /**
  112710. * Makes a duplicate of the current configuration into another one.
  112711. * @param sheenConfiguration define the config where to copy the info
  112712. */
  112713. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112714. /**
  112715. * Serializes this BRDF configuration.
  112716. * @returns - An object with the serialized config.
  112717. */
  112718. serialize(): any;
  112719. /**
  112720. * Parses a anisotropy Configuration from a serialized object.
  112721. * @param source - Serialized object.
  112722. * @param scene Defines the scene we are parsing for
  112723. * @param rootUrl Defines the rootUrl to load from
  112724. */
  112725. parse(source: any, scene: Scene, rootUrl: string): void;
  112726. }
  112727. }
  112728. declare module BABYLON {
  112729. /**
  112730. * @hidden
  112731. */
  112732. export interface IMaterialSubSurfaceDefines {
  112733. SUBSURFACE: boolean;
  112734. SS_REFRACTION: boolean;
  112735. SS_TRANSLUCENCY: boolean;
  112736. SS_SCATERRING: boolean;
  112737. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112738. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112739. SS_REFRACTIONMAP_3D: boolean;
  112740. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112741. SS_LODINREFRACTIONALPHA: boolean;
  112742. SS_GAMMAREFRACTION: boolean;
  112743. SS_RGBDREFRACTION: boolean;
  112744. SS_LINEARSPECULARREFRACTION: boolean;
  112745. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112746. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112747. /** @hidden */
  112748. _areTexturesDirty: boolean;
  112749. }
  112750. /**
  112751. * Define the code related to the sub surface parameters of the pbr material.
  112752. */
  112753. export class PBRSubSurfaceConfiguration {
  112754. private _isRefractionEnabled;
  112755. /**
  112756. * Defines if the refraction is enabled in the material.
  112757. */
  112758. isRefractionEnabled: boolean;
  112759. private _isTranslucencyEnabled;
  112760. /**
  112761. * Defines if the translucency is enabled in the material.
  112762. */
  112763. isTranslucencyEnabled: boolean;
  112764. private _isScatteringEnabled;
  112765. /**
  112766. * Defines the refraction intensity of the material.
  112767. * The refraction when enabled replaces the Diffuse part of the material.
  112768. * The intensity helps transitionning between diffuse and refraction.
  112769. */
  112770. refractionIntensity: number;
  112771. /**
  112772. * Defines the translucency intensity of the material.
  112773. * When translucency has been enabled, this defines how much of the "translucency"
  112774. * is addded to the diffuse part of the material.
  112775. */
  112776. translucencyIntensity: number;
  112777. /**
  112778. * Defines the scattering intensity of the material.
  112779. * When scattering has been enabled, this defines how much of the "scattered light"
  112780. * is addded to the diffuse part of the material.
  112781. */
  112782. scatteringIntensity: number;
  112783. private _thicknessTexture;
  112784. /**
  112785. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112786. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112787. * 0 would mean minimumThickness
  112788. * 1 would mean maximumThickness
  112789. * The other channels might be use as a mask to vary the different effects intensity.
  112790. */
  112791. thicknessTexture: Nullable<BaseTexture>;
  112792. private _refractionTexture;
  112793. /**
  112794. * Defines the texture to use for refraction.
  112795. */
  112796. refractionTexture: Nullable<BaseTexture>;
  112797. private _indexOfRefraction;
  112798. /**
  112799. * Defines the index of refraction used in the material.
  112800. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112801. */
  112802. indexOfRefraction: number;
  112803. private _invertRefractionY;
  112804. /**
  112805. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112806. */
  112807. invertRefractionY: boolean;
  112808. private _linkRefractionWithTransparency;
  112809. /**
  112810. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112811. * Materials half opaque for instance using refraction could benefit from this control.
  112812. */
  112813. linkRefractionWithTransparency: boolean;
  112814. /**
  112815. * Defines the minimum thickness stored in the thickness map.
  112816. * If no thickness map is defined, this value will be used to simulate thickness.
  112817. */
  112818. minimumThickness: number;
  112819. /**
  112820. * Defines the maximum thickness stored in the thickness map.
  112821. */
  112822. maximumThickness: number;
  112823. /**
  112824. * Defines the volume tint of the material.
  112825. * This is used for both translucency and scattering.
  112826. */
  112827. tintColor: Color3;
  112828. /**
  112829. * Defines the distance at which the tint color should be found in the media.
  112830. * This is used for refraction only.
  112831. */
  112832. tintColorAtDistance: number;
  112833. /**
  112834. * Defines how far each channel transmit through the media.
  112835. * It is defined as a color to simplify it selection.
  112836. */
  112837. diffusionDistance: Color3;
  112838. private _useMaskFromThicknessTexture;
  112839. /**
  112840. * Stores the intensity of the different subsurface effects in the thickness texture.
  112841. * * the green channel is the translucency intensity.
  112842. * * the blue channel is the scattering intensity.
  112843. * * the alpha channel is the refraction intensity.
  112844. */
  112845. useMaskFromThicknessTexture: boolean;
  112846. /** @hidden */
  112847. private _internalMarkAllSubMeshesAsTexturesDirty;
  112848. /** @hidden */
  112849. _markAllSubMeshesAsTexturesDirty(): void;
  112850. /**
  112851. * Instantiate a new istance of sub surface configuration.
  112852. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112853. */
  112854. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112855. /**
  112856. * Gets wehter the submesh is ready to be used or not.
  112857. * @param defines the list of "defines" to update.
  112858. * @param scene defines the scene the material belongs to.
  112859. * @returns - boolean indicating that the submesh is ready or not.
  112860. */
  112861. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112862. /**
  112863. * Checks to see if a texture is used in the material.
  112864. * @param defines the list of "defines" to update.
  112865. * @param scene defines the scene to the material belongs to.
  112866. */
  112867. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112868. /**
  112869. * Binds the material data.
  112870. * @param uniformBuffer defines the Uniform buffer to fill in.
  112871. * @param scene defines the scene the material belongs to.
  112872. * @param engine defines the engine the material belongs to.
  112873. * @param isFrozen defines wether the material is frozen or not.
  112874. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112875. */
  112876. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112877. /**
  112878. * Unbinds the material from the mesh.
  112879. * @param activeEffect defines the effect that should be unbound from.
  112880. * @returns true if unbound, otherwise false
  112881. */
  112882. unbind(activeEffect: Effect): boolean;
  112883. /**
  112884. * Returns the texture used for refraction or null if none is used.
  112885. * @param scene defines the scene the material belongs to.
  112886. * @returns - Refraction texture if present. If no refraction texture and refraction
  112887. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112888. */
  112889. private _getRefractionTexture;
  112890. /**
  112891. * Returns true if alpha blending should be disabled.
  112892. */
  112893. readonly disableAlphaBlending: boolean;
  112894. /**
  112895. * Fills the list of render target textures.
  112896. * @param renderTargets the list of render targets to update
  112897. */
  112898. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112899. /**
  112900. * Checks to see if a texture is used in the material.
  112901. * @param texture - Base texture to use.
  112902. * @returns - Boolean specifying if a texture is used in the material.
  112903. */
  112904. hasTexture(texture: BaseTexture): boolean;
  112905. /**
  112906. * Gets a boolean indicating that current material needs to register RTT
  112907. * @returns true if this uses a render target otherwise false.
  112908. */
  112909. hasRenderTargetTextures(): boolean;
  112910. /**
  112911. * Returns an array of the actively used textures.
  112912. * @param activeTextures Array of BaseTextures
  112913. */
  112914. getActiveTextures(activeTextures: BaseTexture[]): void;
  112915. /**
  112916. * Returns the animatable textures.
  112917. * @param animatables Array of animatable textures.
  112918. */
  112919. getAnimatables(animatables: IAnimatable[]): void;
  112920. /**
  112921. * Disposes the resources of the material.
  112922. * @param forceDisposeTextures - Forces the disposal of all textures.
  112923. */
  112924. dispose(forceDisposeTextures?: boolean): void;
  112925. /**
  112926. * Get the current class name of the texture useful for serialization or dynamic coding.
  112927. * @returns "PBRSubSurfaceConfiguration"
  112928. */
  112929. getClassName(): string;
  112930. /**
  112931. * Add fallbacks to the effect fallbacks list.
  112932. * @param defines defines the Base texture to use.
  112933. * @param fallbacks defines the current fallback list.
  112934. * @param currentRank defines the current fallback rank.
  112935. * @returns the new fallback rank.
  112936. */
  112937. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112938. /**
  112939. * Add the required uniforms to the current list.
  112940. * @param uniforms defines the current uniform list.
  112941. */
  112942. static AddUniforms(uniforms: string[]): void;
  112943. /**
  112944. * Add the required samplers to the current list.
  112945. * @param samplers defines the current sampler list.
  112946. */
  112947. static AddSamplers(samplers: string[]): void;
  112948. /**
  112949. * Add the required uniforms to the current buffer.
  112950. * @param uniformBuffer defines the current uniform buffer.
  112951. */
  112952. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112953. /**
  112954. * Makes a duplicate of the current configuration into another one.
  112955. * @param configuration define the config where to copy the info
  112956. */
  112957. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112958. /**
  112959. * Serializes this Sub Surface configuration.
  112960. * @returns - An object with the serialized config.
  112961. */
  112962. serialize(): any;
  112963. /**
  112964. * Parses a anisotropy Configuration from a serialized object.
  112965. * @param source - Serialized object.
  112966. * @param scene Defines the scene we are parsing for
  112967. * @param rootUrl Defines the rootUrl to load from
  112968. */
  112969. parse(source: any, scene: Scene, rootUrl: string): void;
  112970. }
  112971. }
  112972. declare module BABYLON {
  112973. /** @hidden */
  112974. export var pbrFragmentDeclaration: {
  112975. name: string;
  112976. shader: string;
  112977. };
  112978. }
  112979. declare module BABYLON {
  112980. /** @hidden */
  112981. export var pbrUboDeclaration: {
  112982. name: string;
  112983. shader: string;
  112984. };
  112985. }
  112986. declare module BABYLON {
  112987. /** @hidden */
  112988. export var pbrFragmentExtraDeclaration: {
  112989. name: string;
  112990. shader: string;
  112991. };
  112992. }
  112993. declare module BABYLON {
  112994. /** @hidden */
  112995. export var pbrFragmentSamplersDeclaration: {
  112996. name: string;
  112997. shader: string;
  112998. };
  112999. }
  113000. declare module BABYLON {
  113001. /** @hidden */
  113002. export var pbrHelperFunctions: {
  113003. name: string;
  113004. shader: string;
  113005. };
  113006. }
  113007. declare module BABYLON {
  113008. /** @hidden */
  113009. export var harmonicsFunctions: {
  113010. name: string;
  113011. shader: string;
  113012. };
  113013. }
  113014. declare module BABYLON {
  113015. /** @hidden */
  113016. export var pbrDirectLightingSetupFunctions: {
  113017. name: string;
  113018. shader: string;
  113019. };
  113020. }
  113021. declare module BABYLON {
  113022. /** @hidden */
  113023. export var pbrDirectLightingFalloffFunctions: {
  113024. name: string;
  113025. shader: string;
  113026. };
  113027. }
  113028. declare module BABYLON {
  113029. /** @hidden */
  113030. export var pbrBRDFFunctions: {
  113031. name: string;
  113032. shader: string;
  113033. };
  113034. }
  113035. declare module BABYLON {
  113036. /** @hidden */
  113037. export var pbrDirectLightingFunctions: {
  113038. name: string;
  113039. shader: string;
  113040. };
  113041. }
  113042. declare module BABYLON {
  113043. /** @hidden */
  113044. export var pbrIBLFunctions: {
  113045. name: string;
  113046. shader: string;
  113047. };
  113048. }
  113049. declare module BABYLON {
  113050. /** @hidden */
  113051. export var pbrDebug: {
  113052. name: string;
  113053. shader: string;
  113054. };
  113055. }
  113056. declare module BABYLON {
  113057. /** @hidden */
  113058. export var pbrPixelShader: {
  113059. name: string;
  113060. shader: string;
  113061. };
  113062. }
  113063. declare module BABYLON {
  113064. /** @hidden */
  113065. export var pbrVertexDeclaration: {
  113066. name: string;
  113067. shader: string;
  113068. };
  113069. }
  113070. declare module BABYLON {
  113071. /** @hidden */
  113072. export var pbrVertexShader: {
  113073. name: string;
  113074. shader: string;
  113075. };
  113076. }
  113077. declare module BABYLON {
  113078. /**
  113079. * Manages the defines for the PBR Material.
  113080. * @hidden
  113081. */
  113082. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  113083. PBR: boolean;
  113084. MAINUV1: boolean;
  113085. MAINUV2: boolean;
  113086. UV1: boolean;
  113087. UV2: boolean;
  113088. ALBEDO: boolean;
  113089. ALBEDODIRECTUV: number;
  113090. VERTEXCOLOR: boolean;
  113091. AMBIENT: boolean;
  113092. AMBIENTDIRECTUV: number;
  113093. AMBIENTINGRAYSCALE: boolean;
  113094. OPACITY: boolean;
  113095. VERTEXALPHA: boolean;
  113096. OPACITYDIRECTUV: number;
  113097. OPACITYRGB: boolean;
  113098. ALPHATEST: boolean;
  113099. DEPTHPREPASS: boolean;
  113100. ALPHABLEND: boolean;
  113101. ALPHAFROMALBEDO: boolean;
  113102. ALPHATESTVALUE: string;
  113103. SPECULAROVERALPHA: boolean;
  113104. RADIANCEOVERALPHA: boolean;
  113105. ALPHAFRESNEL: boolean;
  113106. LINEARALPHAFRESNEL: boolean;
  113107. PREMULTIPLYALPHA: boolean;
  113108. EMISSIVE: boolean;
  113109. EMISSIVEDIRECTUV: number;
  113110. REFLECTIVITY: boolean;
  113111. REFLECTIVITYDIRECTUV: number;
  113112. SPECULARTERM: boolean;
  113113. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  113114. MICROSURFACEAUTOMATIC: boolean;
  113115. LODBASEDMICROSFURACE: boolean;
  113116. MICROSURFACEMAP: boolean;
  113117. MICROSURFACEMAPDIRECTUV: number;
  113118. METALLICWORKFLOW: boolean;
  113119. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  113120. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  113121. METALLNESSSTOREINMETALMAPBLUE: boolean;
  113122. AOSTOREINMETALMAPRED: boolean;
  113123. ENVIRONMENTBRDF: boolean;
  113124. ENVIRONMENTBRDF_RGBD: boolean;
  113125. NORMAL: boolean;
  113126. TANGENT: boolean;
  113127. BUMP: boolean;
  113128. BUMPDIRECTUV: number;
  113129. OBJECTSPACE_NORMALMAP: boolean;
  113130. PARALLAX: boolean;
  113131. PARALLAXOCCLUSION: boolean;
  113132. NORMALXYSCALE: boolean;
  113133. LIGHTMAP: boolean;
  113134. LIGHTMAPDIRECTUV: number;
  113135. USELIGHTMAPASSHADOWMAP: boolean;
  113136. GAMMALIGHTMAP: boolean;
  113137. RGBDLIGHTMAP: boolean;
  113138. REFLECTION: boolean;
  113139. REFLECTIONMAP_3D: boolean;
  113140. REFLECTIONMAP_SPHERICAL: boolean;
  113141. REFLECTIONMAP_PLANAR: boolean;
  113142. REFLECTIONMAP_CUBIC: boolean;
  113143. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  113144. REFLECTIONMAP_PROJECTION: boolean;
  113145. REFLECTIONMAP_SKYBOX: boolean;
  113146. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  113147. REFLECTIONMAP_EXPLICIT: boolean;
  113148. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  113149. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  113150. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  113151. INVERTCUBICMAP: boolean;
  113152. USESPHERICALFROMREFLECTIONMAP: boolean;
  113153. USEIRRADIANCEMAP: boolean;
  113154. SPHERICAL_HARMONICS: boolean;
  113155. USESPHERICALINVERTEX: boolean;
  113156. REFLECTIONMAP_OPPOSITEZ: boolean;
  113157. LODINREFLECTIONALPHA: boolean;
  113158. GAMMAREFLECTION: boolean;
  113159. RGBDREFLECTION: boolean;
  113160. LINEARSPECULARREFLECTION: boolean;
  113161. RADIANCEOCCLUSION: boolean;
  113162. HORIZONOCCLUSION: boolean;
  113163. INSTANCES: boolean;
  113164. NUM_BONE_INFLUENCERS: number;
  113165. BonesPerMesh: number;
  113166. BONETEXTURE: boolean;
  113167. NONUNIFORMSCALING: boolean;
  113168. MORPHTARGETS: boolean;
  113169. MORPHTARGETS_NORMAL: boolean;
  113170. MORPHTARGETS_TANGENT: boolean;
  113171. MORPHTARGETS_UV: boolean;
  113172. NUM_MORPH_INFLUENCERS: number;
  113173. IMAGEPROCESSING: boolean;
  113174. VIGNETTE: boolean;
  113175. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113176. VIGNETTEBLENDMODEOPAQUE: boolean;
  113177. TONEMAPPING: boolean;
  113178. TONEMAPPING_ACES: boolean;
  113179. CONTRAST: boolean;
  113180. COLORCURVES: boolean;
  113181. COLORGRADING: boolean;
  113182. COLORGRADING3D: boolean;
  113183. SAMPLER3DGREENDEPTH: boolean;
  113184. SAMPLER3DBGRMAP: boolean;
  113185. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113186. EXPOSURE: boolean;
  113187. MULTIVIEW: boolean;
  113188. USEPHYSICALLIGHTFALLOFF: boolean;
  113189. USEGLTFLIGHTFALLOFF: boolean;
  113190. TWOSIDEDLIGHTING: boolean;
  113191. SHADOWFLOAT: boolean;
  113192. CLIPPLANE: boolean;
  113193. CLIPPLANE2: boolean;
  113194. CLIPPLANE3: boolean;
  113195. CLIPPLANE4: boolean;
  113196. POINTSIZE: boolean;
  113197. FOG: boolean;
  113198. LOGARITHMICDEPTH: boolean;
  113199. FORCENORMALFORWARD: boolean;
  113200. SPECULARAA: boolean;
  113201. CLEARCOAT: boolean;
  113202. CLEARCOAT_DEFAULTIOR: boolean;
  113203. CLEARCOAT_TEXTURE: boolean;
  113204. CLEARCOAT_TEXTUREDIRECTUV: number;
  113205. CLEARCOAT_BUMP: boolean;
  113206. CLEARCOAT_BUMPDIRECTUV: number;
  113207. CLEARCOAT_TINT: boolean;
  113208. CLEARCOAT_TINT_TEXTURE: boolean;
  113209. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113210. ANISOTROPIC: boolean;
  113211. ANISOTROPIC_TEXTURE: boolean;
  113212. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113213. BRDF_V_HEIGHT_CORRELATED: boolean;
  113214. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113215. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113216. SHEEN: boolean;
  113217. SHEEN_TEXTURE: boolean;
  113218. SHEEN_TEXTUREDIRECTUV: number;
  113219. SHEEN_LINKWITHALBEDO: boolean;
  113220. SUBSURFACE: boolean;
  113221. SS_REFRACTION: boolean;
  113222. SS_TRANSLUCENCY: boolean;
  113223. SS_SCATERRING: boolean;
  113224. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113225. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113226. SS_REFRACTIONMAP_3D: boolean;
  113227. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113228. SS_LODINREFRACTIONALPHA: boolean;
  113229. SS_GAMMAREFRACTION: boolean;
  113230. SS_RGBDREFRACTION: boolean;
  113231. SS_LINEARSPECULARREFRACTION: boolean;
  113232. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113233. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113234. UNLIT: boolean;
  113235. DEBUGMODE: number;
  113236. /**
  113237. * Initializes the PBR Material defines.
  113238. */
  113239. constructor();
  113240. /**
  113241. * Resets the PBR Material defines.
  113242. */
  113243. reset(): void;
  113244. }
  113245. /**
  113246. * The Physically based material base class of BJS.
  113247. *
  113248. * This offers the main features of a standard PBR material.
  113249. * For more information, please refer to the documentation :
  113250. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113251. */
  113252. export abstract class PBRBaseMaterial extends PushMaterial {
  113253. /**
  113254. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113255. */
  113256. static readonly PBRMATERIAL_OPAQUE: number;
  113257. /**
  113258. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113259. */
  113260. static readonly PBRMATERIAL_ALPHATEST: number;
  113261. /**
  113262. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113263. */
  113264. static readonly PBRMATERIAL_ALPHABLEND: number;
  113265. /**
  113266. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113267. * They are also discarded below the alpha cutoff threshold to improve performances.
  113268. */
  113269. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113270. /**
  113271. * Defines the default value of how much AO map is occluding the analytical lights
  113272. * (point spot...).
  113273. */
  113274. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113275. /**
  113276. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  113277. */
  113278. static readonly LIGHTFALLOFF_PHYSICAL: number;
  113279. /**
  113280. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  113281. * to enhance interoperability with other engines.
  113282. */
  113283. static readonly LIGHTFALLOFF_GLTF: number;
  113284. /**
  113285. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  113286. * to enhance interoperability with other materials.
  113287. */
  113288. static readonly LIGHTFALLOFF_STANDARD: number;
  113289. /**
  113290. * Intensity of the direct lights e.g. the four lights available in your scene.
  113291. * This impacts both the direct diffuse and specular highlights.
  113292. */
  113293. protected _directIntensity: number;
  113294. /**
  113295. * Intensity of the emissive part of the material.
  113296. * This helps controlling the emissive effect without modifying the emissive color.
  113297. */
  113298. protected _emissiveIntensity: number;
  113299. /**
  113300. * Intensity of the environment e.g. how much the environment will light the object
  113301. * either through harmonics for rough material or through the refelction for shiny ones.
  113302. */
  113303. protected _environmentIntensity: number;
  113304. /**
  113305. * This is a special control allowing the reduction of the specular highlights coming from the
  113306. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113307. */
  113308. protected _specularIntensity: number;
  113309. /**
  113310. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  113311. */
  113312. private _lightingInfos;
  113313. /**
  113314. * Debug Control allowing disabling the bump map on this material.
  113315. */
  113316. protected _disableBumpMap: boolean;
  113317. /**
  113318. * AKA Diffuse Texture in standard nomenclature.
  113319. */
  113320. protected _albedoTexture: Nullable<BaseTexture>;
  113321. /**
  113322. * AKA Occlusion Texture in other nomenclature.
  113323. */
  113324. protected _ambientTexture: Nullable<BaseTexture>;
  113325. /**
  113326. * AKA Occlusion Texture Intensity in other nomenclature.
  113327. */
  113328. protected _ambientTextureStrength: number;
  113329. /**
  113330. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113331. * 1 means it completely occludes it
  113332. * 0 mean it has no impact
  113333. */
  113334. protected _ambientTextureImpactOnAnalyticalLights: number;
  113335. /**
  113336. * Stores the alpha values in a texture.
  113337. */
  113338. protected _opacityTexture: Nullable<BaseTexture>;
  113339. /**
  113340. * Stores the reflection values in a texture.
  113341. */
  113342. protected _reflectionTexture: Nullable<BaseTexture>;
  113343. /**
  113344. * Stores the emissive values in a texture.
  113345. */
  113346. protected _emissiveTexture: Nullable<BaseTexture>;
  113347. /**
  113348. * AKA Specular texture in other nomenclature.
  113349. */
  113350. protected _reflectivityTexture: Nullable<BaseTexture>;
  113351. /**
  113352. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113353. */
  113354. protected _metallicTexture: Nullable<BaseTexture>;
  113355. /**
  113356. * Specifies the metallic scalar of the metallic/roughness workflow.
  113357. * Can also be used to scale the metalness values of the metallic texture.
  113358. */
  113359. protected _metallic: Nullable<number>;
  113360. /**
  113361. * Specifies the roughness scalar of the metallic/roughness workflow.
  113362. * Can also be used to scale the roughness values of the metallic texture.
  113363. */
  113364. protected _roughness: Nullable<number>;
  113365. /**
  113366. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113367. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113368. */
  113369. protected _microSurfaceTexture: Nullable<BaseTexture>;
  113370. /**
  113371. * Stores surface normal data used to displace a mesh in a texture.
  113372. */
  113373. protected _bumpTexture: Nullable<BaseTexture>;
  113374. /**
  113375. * Stores the pre-calculated light information of a mesh in a texture.
  113376. */
  113377. protected _lightmapTexture: Nullable<BaseTexture>;
  113378. /**
  113379. * The color of a material in ambient lighting.
  113380. */
  113381. protected _ambientColor: Color3;
  113382. /**
  113383. * AKA Diffuse Color in other nomenclature.
  113384. */
  113385. protected _albedoColor: Color3;
  113386. /**
  113387. * AKA Specular Color in other nomenclature.
  113388. */
  113389. protected _reflectivityColor: Color3;
  113390. /**
  113391. * The color applied when light is reflected from a material.
  113392. */
  113393. protected _reflectionColor: Color3;
  113394. /**
  113395. * The color applied when light is emitted from a material.
  113396. */
  113397. protected _emissiveColor: Color3;
  113398. /**
  113399. * AKA Glossiness in other nomenclature.
  113400. */
  113401. protected _microSurface: number;
  113402. /**
  113403. * Specifies that the material will use the light map as a show map.
  113404. */
  113405. protected _useLightmapAsShadowmap: boolean;
  113406. /**
  113407. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113408. * makes the reflect vector face the model (under horizon).
  113409. */
  113410. protected _useHorizonOcclusion: boolean;
  113411. /**
  113412. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113413. * too much the area relying on ambient texture to define their ambient occlusion.
  113414. */
  113415. protected _useRadianceOcclusion: boolean;
  113416. /**
  113417. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113418. */
  113419. protected _useAlphaFromAlbedoTexture: boolean;
  113420. /**
  113421. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  113422. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113423. */
  113424. protected _useSpecularOverAlpha: boolean;
  113425. /**
  113426. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113427. */
  113428. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113429. /**
  113430. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113431. */
  113432. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  113433. /**
  113434. * Specifies if the metallic texture contains the roughness information in its green channel.
  113435. */
  113436. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113437. /**
  113438. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113439. */
  113440. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113441. /**
  113442. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113443. */
  113444. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113445. /**
  113446. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113447. */
  113448. protected _useAmbientInGrayScale: boolean;
  113449. /**
  113450. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113451. * The material will try to infer what glossiness each pixel should be.
  113452. */
  113453. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113454. /**
  113455. * Defines the falloff type used in this material.
  113456. * It by default is Physical.
  113457. */
  113458. protected _lightFalloff: number;
  113459. /**
  113460. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113461. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113462. */
  113463. protected _useRadianceOverAlpha: boolean;
  113464. /**
  113465. * Allows using an object space normal map (instead of tangent space).
  113466. */
  113467. protected _useObjectSpaceNormalMap: boolean;
  113468. /**
  113469. * Allows using the bump map in parallax mode.
  113470. */
  113471. protected _useParallax: boolean;
  113472. /**
  113473. * Allows using the bump map in parallax occlusion mode.
  113474. */
  113475. protected _useParallaxOcclusion: boolean;
  113476. /**
  113477. * Controls the scale bias of the parallax mode.
  113478. */
  113479. protected _parallaxScaleBias: number;
  113480. /**
  113481. * If sets to true, disables all the lights affecting the material.
  113482. */
  113483. protected _disableLighting: boolean;
  113484. /**
  113485. * Number of Simultaneous lights allowed on the material.
  113486. */
  113487. protected _maxSimultaneousLights: number;
  113488. /**
  113489. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113490. */
  113491. protected _invertNormalMapX: boolean;
  113492. /**
  113493. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113494. */
  113495. protected _invertNormalMapY: boolean;
  113496. /**
  113497. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113498. */
  113499. protected _twoSidedLighting: boolean;
  113500. /**
  113501. * Defines the alpha limits in alpha test mode.
  113502. */
  113503. protected _alphaCutOff: number;
  113504. /**
  113505. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113506. */
  113507. protected _forceAlphaTest: boolean;
  113508. /**
  113509. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113510. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113511. */
  113512. protected _useAlphaFresnel: boolean;
  113513. /**
  113514. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113515. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113516. */
  113517. protected _useLinearAlphaFresnel: boolean;
  113518. /**
  113519. * The transparency mode of the material.
  113520. */
  113521. protected _transparencyMode: Nullable<number>;
  113522. /**
  113523. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113524. * from cos thetav and roughness:
  113525. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113526. */
  113527. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113528. /**
  113529. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113530. */
  113531. protected _forceIrradianceInFragment: boolean;
  113532. /**
  113533. * Force normal to face away from face.
  113534. */
  113535. protected _forceNormalForward: boolean;
  113536. /**
  113537. * Enables specular anti aliasing in the PBR shader.
  113538. * It will both interacts on the Geometry for analytical and IBL lighting.
  113539. * It also prefilter the roughness map based on the bump values.
  113540. */
  113541. protected _enableSpecularAntiAliasing: boolean;
  113542. /**
  113543. * Default configuration related to image processing available in the PBR Material.
  113544. */
  113545. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113546. /**
  113547. * Keep track of the image processing observer to allow dispose and replace.
  113548. */
  113549. private _imageProcessingObserver;
  113550. /**
  113551. * Attaches a new image processing configuration to the PBR Material.
  113552. * @param configuration
  113553. */
  113554. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113555. /**
  113556. * Stores the available render targets.
  113557. */
  113558. private _renderTargets;
  113559. /**
  113560. * Sets the global ambient color for the material used in lighting calculations.
  113561. */
  113562. private _globalAmbientColor;
  113563. /**
  113564. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113565. */
  113566. private _useLogarithmicDepth;
  113567. /**
  113568. * If set to true, no lighting calculations will be applied.
  113569. */
  113570. private _unlit;
  113571. private _debugMode;
  113572. /**
  113573. * @hidden
  113574. * This is reserved for the inspector.
  113575. * Defines the material debug mode.
  113576. * It helps seeing only some components of the material while troubleshooting.
  113577. */
  113578. debugMode: number;
  113579. /**
  113580. * @hidden
  113581. * This is reserved for the inspector.
  113582. * Specify from where on screen the debug mode should start.
  113583. * The value goes from -1 (full screen) to 1 (not visible)
  113584. * It helps with side by side comparison against the final render
  113585. * This defaults to -1
  113586. */
  113587. private debugLimit;
  113588. /**
  113589. * @hidden
  113590. * This is reserved for the inspector.
  113591. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113592. * You can use the factor to better multiply the final value.
  113593. */
  113594. private debugFactor;
  113595. /**
  113596. * Defines the clear coat layer parameters for the material.
  113597. */
  113598. readonly clearCoat: PBRClearCoatConfiguration;
  113599. /**
  113600. * Defines the anisotropic parameters for the material.
  113601. */
  113602. readonly anisotropy: PBRAnisotropicConfiguration;
  113603. /**
  113604. * Defines the BRDF parameters for the material.
  113605. */
  113606. readonly brdf: PBRBRDFConfiguration;
  113607. /**
  113608. * Defines the Sheen parameters for the material.
  113609. */
  113610. readonly sheen: PBRSheenConfiguration;
  113611. /**
  113612. * Defines the SubSurface parameters for the material.
  113613. */
  113614. readonly subSurface: PBRSubSurfaceConfiguration;
  113615. /**
  113616. * Custom callback helping to override the default shader used in the material.
  113617. */
  113618. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113619. protected _rebuildInParallel: boolean;
  113620. /**
  113621. * Instantiates a new PBRMaterial instance.
  113622. *
  113623. * @param name The material name
  113624. * @param scene The scene the material will be use in.
  113625. */
  113626. constructor(name: string, scene: Scene);
  113627. /**
  113628. * Gets a boolean indicating that current material needs to register RTT
  113629. */
  113630. readonly hasRenderTargetTextures: boolean;
  113631. /**
  113632. * Gets the name of the material class.
  113633. */
  113634. getClassName(): string;
  113635. /**
  113636. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113637. */
  113638. /**
  113639. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113640. */
  113641. useLogarithmicDepth: boolean;
  113642. /**
  113643. * Gets the current transparency mode.
  113644. */
  113645. /**
  113646. * Sets the transparency mode of the material.
  113647. *
  113648. * | Value | Type | Description |
  113649. * | ----- | ----------------------------------- | ----------- |
  113650. * | 0 | OPAQUE | |
  113651. * | 1 | ALPHATEST | |
  113652. * | 2 | ALPHABLEND | |
  113653. * | 3 | ALPHATESTANDBLEND | |
  113654. *
  113655. */
  113656. transparencyMode: Nullable<number>;
  113657. /**
  113658. * Returns true if alpha blending should be disabled.
  113659. */
  113660. private readonly _disableAlphaBlending;
  113661. /**
  113662. * Specifies whether or not this material should be rendered in alpha blend mode.
  113663. */
  113664. needAlphaBlending(): boolean;
  113665. /**
  113666. * Specifies if the mesh will require alpha blending.
  113667. * @param mesh - BJS mesh.
  113668. */
  113669. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113670. /**
  113671. * Specifies whether or not this material should be rendered in alpha test mode.
  113672. */
  113673. needAlphaTesting(): boolean;
  113674. /**
  113675. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113676. */
  113677. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113678. /**
  113679. * Gets the texture used for the alpha test.
  113680. */
  113681. getAlphaTestTexture(): Nullable<BaseTexture>;
  113682. /**
  113683. * Specifies that the submesh is ready to be used.
  113684. * @param mesh - BJS mesh.
  113685. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113686. * @param useInstances - Specifies that instances should be used.
  113687. * @returns - boolean indicating that the submesh is ready or not.
  113688. */
  113689. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113690. /**
  113691. * Specifies if the material uses metallic roughness workflow.
  113692. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113693. */
  113694. isMetallicWorkflow(): boolean;
  113695. private _prepareEffect;
  113696. private _prepareDefines;
  113697. /**
  113698. * Force shader compilation
  113699. */
  113700. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113701. clipPlane: boolean;
  113702. }>): void;
  113703. /**
  113704. * Initializes the uniform buffer layout for the shader.
  113705. */
  113706. buildUniformLayout(): void;
  113707. /**
  113708. * Unbinds the material from the mesh
  113709. */
  113710. unbind(): void;
  113711. /**
  113712. * Binds the submesh data.
  113713. * @param world - The world matrix.
  113714. * @param mesh - The BJS mesh.
  113715. * @param subMesh - A submesh of the BJS mesh.
  113716. */
  113717. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113718. /**
  113719. * Returns the animatable textures.
  113720. * @returns - Array of animatable textures.
  113721. */
  113722. getAnimatables(): IAnimatable[];
  113723. /**
  113724. * Returns the texture used for reflections.
  113725. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113726. */
  113727. private _getReflectionTexture;
  113728. /**
  113729. * Returns an array of the actively used textures.
  113730. * @returns - Array of BaseTextures
  113731. */
  113732. getActiveTextures(): BaseTexture[];
  113733. /**
  113734. * Checks to see if a texture is used in the material.
  113735. * @param texture - Base texture to use.
  113736. * @returns - Boolean specifying if a texture is used in the material.
  113737. */
  113738. hasTexture(texture: BaseTexture): boolean;
  113739. /**
  113740. * Disposes the resources of the material.
  113741. * @param forceDisposeEffect - Forces the disposal of effects.
  113742. * @param forceDisposeTextures - Forces the disposal of all textures.
  113743. */
  113744. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113745. }
  113746. }
  113747. declare module BABYLON {
  113748. /**
  113749. * The Physically based material of BJS.
  113750. *
  113751. * This offers the main features of a standard PBR material.
  113752. * For more information, please refer to the documentation :
  113753. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113754. */
  113755. export class PBRMaterial extends PBRBaseMaterial {
  113756. /**
  113757. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113758. */
  113759. static readonly PBRMATERIAL_OPAQUE: number;
  113760. /**
  113761. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113762. */
  113763. static readonly PBRMATERIAL_ALPHATEST: number;
  113764. /**
  113765. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113766. */
  113767. static readonly PBRMATERIAL_ALPHABLEND: number;
  113768. /**
  113769. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113770. * They are also discarded below the alpha cutoff threshold to improve performances.
  113771. */
  113772. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113773. /**
  113774. * Defines the default value of how much AO map is occluding the analytical lights
  113775. * (point spot...).
  113776. */
  113777. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113778. /**
  113779. * Intensity of the direct lights e.g. the four lights available in your scene.
  113780. * This impacts both the direct diffuse and specular highlights.
  113781. */
  113782. directIntensity: number;
  113783. /**
  113784. * Intensity of the emissive part of the material.
  113785. * This helps controlling the emissive effect without modifying the emissive color.
  113786. */
  113787. emissiveIntensity: number;
  113788. /**
  113789. * Intensity of the environment e.g. how much the environment will light the object
  113790. * either through harmonics for rough material or through the refelction for shiny ones.
  113791. */
  113792. environmentIntensity: number;
  113793. /**
  113794. * This is a special control allowing the reduction of the specular highlights coming from the
  113795. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113796. */
  113797. specularIntensity: number;
  113798. /**
  113799. * Debug Control allowing disabling the bump map on this material.
  113800. */
  113801. disableBumpMap: boolean;
  113802. /**
  113803. * AKA Diffuse Texture in standard nomenclature.
  113804. */
  113805. albedoTexture: BaseTexture;
  113806. /**
  113807. * AKA Occlusion Texture in other nomenclature.
  113808. */
  113809. ambientTexture: BaseTexture;
  113810. /**
  113811. * AKA Occlusion Texture Intensity in other nomenclature.
  113812. */
  113813. ambientTextureStrength: number;
  113814. /**
  113815. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113816. * 1 means it completely occludes it
  113817. * 0 mean it has no impact
  113818. */
  113819. ambientTextureImpactOnAnalyticalLights: number;
  113820. /**
  113821. * Stores the alpha values in a texture.
  113822. */
  113823. opacityTexture: BaseTexture;
  113824. /**
  113825. * Stores the reflection values in a texture.
  113826. */
  113827. reflectionTexture: Nullable<BaseTexture>;
  113828. /**
  113829. * Stores the emissive values in a texture.
  113830. */
  113831. emissiveTexture: BaseTexture;
  113832. /**
  113833. * AKA Specular texture in other nomenclature.
  113834. */
  113835. reflectivityTexture: BaseTexture;
  113836. /**
  113837. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113838. */
  113839. metallicTexture: BaseTexture;
  113840. /**
  113841. * Specifies the metallic scalar of the metallic/roughness workflow.
  113842. * Can also be used to scale the metalness values of the metallic texture.
  113843. */
  113844. metallic: Nullable<number>;
  113845. /**
  113846. * Specifies the roughness scalar of the metallic/roughness workflow.
  113847. * Can also be used to scale the roughness values of the metallic texture.
  113848. */
  113849. roughness: Nullable<number>;
  113850. /**
  113851. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113852. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113853. */
  113854. microSurfaceTexture: BaseTexture;
  113855. /**
  113856. * Stores surface normal data used to displace a mesh in a texture.
  113857. */
  113858. bumpTexture: BaseTexture;
  113859. /**
  113860. * Stores the pre-calculated light information of a mesh in a texture.
  113861. */
  113862. lightmapTexture: BaseTexture;
  113863. /**
  113864. * Stores the refracted light information in a texture.
  113865. */
  113866. refractionTexture: Nullable<BaseTexture>;
  113867. /**
  113868. * The color of a material in ambient lighting.
  113869. */
  113870. ambientColor: Color3;
  113871. /**
  113872. * AKA Diffuse Color in other nomenclature.
  113873. */
  113874. albedoColor: Color3;
  113875. /**
  113876. * AKA Specular Color in other nomenclature.
  113877. */
  113878. reflectivityColor: Color3;
  113879. /**
  113880. * The color reflected from the material.
  113881. */
  113882. reflectionColor: Color3;
  113883. /**
  113884. * The color emitted from the material.
  113885. */
  113886. emissiveColor: Color3;
  113887. /**
  113888. * AKA Glossiness in other nomenclature.
  113889. */
  113890. microSurface: number;
  113891. /**
  113892. * source material index of refraction (IOR)' / 'destination material IOR.
  113893. */
  113894. indexOfRefraction: number;
  113895. /**
  113896. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113897. */
  113898. invertRefractionY: boolean;
  113899. /**
  113900. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113901. * Materials half opaque for instance using refraction could benefit from this control.
  113902. */
  113903. linkRefractionWithTransparency: boolean;
  113904. /**
  113905. * If true, the light map contains occlusion information instead of lighting info.
  113906. */
  113907. useLightmapAsShadowmap: boolean;
  113908. /**
  113909. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113910. */
  113911. useAlphaFromAlbedoTexture: boolean;
  113912. /**
  113913. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113914. */
  113915. forceAlphaTest: boolean;
  113916. /**
  113917. * Defines the alpha limits in alpha test mode.
  113918. */
  113919. alphaCutOff: number;
  113920. /**
  113921. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113922. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113923. */
  113924. useSpecularOverAlpha: boolean;
  113925. /**
  113926. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113927. */
  113928. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113929. /**
  113930. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113931. */
  113932. useRoughnessFromMetallicTextureAlpha: boolean;
  113933. /**
  113934. * Specifies if the metallic texture contains the roughness information in its green channel.
  113935. */
  113936. useRoughnessFromMetallicTextureGreen: boolean;
  113937. /**
  113938. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113939. */
  113940. useMetallnessFromMetallicTextureBlue: boolean;
  113941. /**
  113942. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113943. */
  113944. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113945. /**
  113946. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113947. */
  113948. useAmbientInGrayScale: boolean;
  113949. /**
  113950. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113951. * The material will try to infer what glossiness each pixel should be.
  113952. */
  113953. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113954. /**
  113955. * BJS is using an harcoded light falloff based on a manually sets up range.
  113956. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113957. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113958. */
  113959. /**
  113960. * BJS is using an harcoded light falloff based on a manually sets up range.
  113961. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113962. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113963. */
  113964. usePhysicalLightFalloff: boolean;
  113965. /**
  113966. * In order to support the falloff compatibility with gltf, a special mode has been added
  113967. * to reproduce the gltf light falloff.
  113968. */
  113969. /**
  113970. * In order to support the falloff compatibility with gltf, a special mode has been added
  113971. * to reproduce the gltf light falloff.
  113972. */
  113973. useGLTFLightFalloff: boolean;
  113974. /**
  113975. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113976. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113977. */
  113978. useRadianceOverAlpha: boolean;
  113979. /**
  113980. * Allows using an object space normal map (instead of tangent space).
  113981. */
  113982. useObjectSpaceNormalMap: boolean;
  113983. /**
  113984. * Allows using the bump map in parallax mode.
  113985. */
  113986. useParallax: boolean;
  113987. /**
  113988. * Allows using the bump map in parallax occlusion mode.
  113989. */
  113990. useParallaxOcclusion: boolean;
  113991. /**
  113992. * Controls the scale bias of the parallax mode.
  113993. */
  113994. parallaxScaleBias: number;
  113995. /**
  113996. * If sets to true, disables all the lights affecting the material.
  113997. */
  113998. disableLighting: boolean;
  113999. /**
  114000. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114001. */
  114002. forceIrradianceInFragment: boolean;
  114003. /**
  114004. * Number of Simultaneous lights allowed on the material.
  114005. */
  114006. maxSimultaneousLights: number;
  114007. /**
  114008. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114009. */
  114010. invertNormalMapX: boolean;
  114011. /**
  114012. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114013. */
  114014. invertNormalMapY: boolean;
  114015. /**
  114016. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114017. */
  114018. twoSidedLighting: boolean;
  114019. /**
  114020. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114021. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114022. */
  114023. useAlphaFresnel: boolean;
  114024. /**
  114025. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114026. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114027. */
  114028. useLinearAlphaFresnel: boolean;
  114029. /**
  114030. * Let user defines the brdf lookup texture used for IBL.
  114031. * A default 8bit version is embedded but you could point at :
  114032. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  114033. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  114034. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  114035. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  114036. */
  114037. environmentBRDFTexture: Nullable<BaseTexture>;
  114038. /**
  114039. * Force normal to face away from face.
  114040. */
  114041. forceNormalForward: boolean;
  114042. /**
  114043. * Enables specular anti aliasing in the PBR shader.
  114044. * It will both interacts on the Geometry for analytical and IBL lighting.
  114045. * It also prefilter the roughness map based on the bump values.
  114046. */
  114047. enableSpecularAntiAliasing: boolean;
  114048. /**
  114049. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114050. * makes the reflect vector face the model (under horizon).
  114051. */
  114052. useHorizonOcclusion: boolean;
  114053. /**
  114054. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114055. * too much the area relying on ambient texture to define their ambient occlusion.
  114056. */
  114057. useRadianceOcclusion: boolean;
  114058. /**
  114059. * If set to true, no lighting calculations will be applied.
  114060. */
  114061. unlit: boolean;
  114062. /**
  114063. * Gets the image processing configuration used either in this material.
  114064. */
  114065. /**
  114066. * Sets the Default image processing configuration used either in the this material.
  114067. *
  114068. * If sets to null, the scene one is in use.
  114069. */
  114070. imageProcessingConfiguration: ImageProcessingConfiguration;
  114071. /**
  114072. * Gets wether the color curves effect is enabled.
  114073. */
  114074. /**
  114075. * Sets wether the color curves effect is enabled.
  114076. */
  114077. cameraColorCurvesEnabled: boolean;
  114078. /**
  114079. * Gets wether the color grading effect is enabled.
  114080. */
  114081. /**
  114082. * Gets wether the color grading effect is enabled.
  114083. */
  114084. cameraColorGradingEnabled: boolean;
  114085. /**
  114086. * Gets wether tonemapping is enabled or not.
  114087. */
  114088. /**
  114089. * Sets wether tonemapping is enabled or not
  114090. */
  114091. cameraToneMappingEnabled: boolean;
  114092. /**
  114093. * The camera exposure used on this material.
  114094. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114095. * This corresponds to a photographic exposure.
  114096. */
  114097. /**
  114098. * The camera exposure used on this material.
  114099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114100. * This corresponds to a photographic exposure.
  114101. */
  114102. cameraExposure: number;
  114103. /**
  114104. * Gets The camera contrast used on this material.
  114105. */
  114106. /**
  114107. * Sets The camera contrast used on this material.
  114108. */
  114109. cameraContrast: number;
  114110. /**
  114111. * Gets the Color Grading 2D Lookup Texture.
  114112. */
  114113. /**
  114114. * Sets the Color Grading 2D Lookup Texture.
  114115. */
  114116. cameraColorGradingTexture: Nullable<BaseTexture>;
  114117. /**
  114118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114120. * 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;
  114121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114122. */
  114123. /**
  114124. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114125. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114126. * 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;
  114127. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114128. */
  114129. cameraColorCurves: Nullable<ColorCurves>;
  114130. /**
  114131. * Instantiates a new PBRMaterial instance.
  114132. *
  114133. * @param name The material name
  114134. * @param scene The scene the material will be use in.
  114135. */
  114136. constructor(name: string, scene: Scene);
  114137. /**
  114138. * Returns the name of this material class.
  114139. */
  114140. getClassName(): string;
  114141. /**
  114142. * Makes a duplicate of the current material.
  114143. * @param name - name to use for the new material.
  114144. */
  114145. clone(name: string): PBRMaterial;
  114146. /**
  114147. * Serializes this PBR Material.
  114148. * @returns - An object with the serialized material.
  114149. */
  114150. serialize(): any;
  114151. /**
  114152. * Parses a PBR Material from a serialized object.
  114153. * @param source - Serialized object.
  114154. * @param scene - BJS scene instance.
  114155. * @param rootUrl - url for the scene object
  114156. * @returns - PBRMaterial
  114157. */
  114158. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  114159. }
  114160. }
  114161. declare module BABYLON {
  114162. /**
  114163. * Direct draw surface info
  114164. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  114165. */
  114166. export interface DDSInfo {
  114167. /**
  114168. * Width of the texture
  114169. */
  114170. width: number;
  114171. /**
  114172. * Width of the texture
  114173. */
  114174. height: number;
  114175. /**
  114176. * Number of Mipmaps for the texture
  114177. * @see https://en.wikipedia.org/wiki/Mipmap
  114178. */
  114179. mipmapCount: number;
  114180. /**
  114181. * If the textures format is a known fourCC format
  114182. * @see https://www.fourcc.org/
  114183. */
  114184. isFourCC: boolean;
  114185. /**
  114186. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  114187. */
  114188. isRGB: boolean;
  114189. /**
  114190. * If the texture is a lumincance format
  114191. */
  114192. isLuminance: boolean;
  114193. /**
  114194. * If this is a cube texture
  114195. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  114196. */
  114197. isCube: boolean;
  114198. /**
  114199. * If the texture is a compressed format eg. FOURCC_DXT1
  114200. */
  114201. isCompressed: boolean;
  114202. /**
  114203. * The dxgiFormat of the texture
  114204. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  114205. */
  114206. dxgiFormat: number;
  114207. /**
  114208. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  114209. */
  114210. textureType: number;
  114211. /**
  114212. * Sphericle polynomial created for the dds texture
  114213. */
  114214. sphericalPolynomial?: SphericalPolynomial;
  114215. }
  114216. /**
  114217. * Class used to provide DDS decompression tools
  114218. */
  114219. export class DDSTools {
  114220. /**
  114221. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  114222. */
  114223. static StoreLODInAlphaChannel: boolean;
  114224. /**
  114225. * Gets DDS information from an array buffer
  114226. * @param arrayBuffer defines the array buffer to read data from
  114227. * @returns the DDS information
  114228. */
  114229. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  114230. private static _FloatView;
  114231. private static _Int32View;
  114232. private static _ToHalfFloat;
  114233. private static _FromHalfFloat;
  114234. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  114235. private static _GetHalfFloatRGBAArrayBuffer;
  114236. private static _GetFloatRGBAArrayBuffer;
  114237. private static _GetFloatAsUIntRGBAArrayBuffer;
  114238. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  114239. private static _GetRGBAArrayBuffer;
  114240. private static _ExtractLongWordOrder;
  114241. private static _GetRGBArrayBuffer;
  114242. private static _GetLuminanceArrayBuffer;
  114243. /**
  114244. * Uploads DDS Levels to a Babylon Texture
  114245. * @hidden
  114246. */
  114247. static UploadDDSLevels(engine: BaseEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  114248. }
  114249. interface BaseEngine {
  114250. /**
  114251. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  114252. * @param rootUrl defines the url where the file to load is located
  114253. * @param scene defines the current scene
  114254. * @param lodScale defines scale to apply to the mip map selection
  114255. * @param lodOffset defines offset to apply to the mip map selection
  114256. * @param onLoad defines an optional callback raised when the texture is loaded
  114257. * @param onError defines an optional callback raised if there is an issue to load the texture
  114258. * @param format defines the format of the data
  114259. * @param forcedExtension defines the extension to use to pick the right loader
  114260. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  114261. * @returns the cube texture as an InternalTexture
  114262. */
  114263. 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;
  114264. }
  114265. }
  114266. declare module BABYLON {
  114267. /**
  114268. * Implementation of the DDS Texture Loader.
  114269. * @hidden
  114270. */
  114271. export class _DDSTextureLoader implements IInternalTextureLoader {
  114272. /**
  114273. * Defines wether the loader supports cascade loading the different faces.
  114274. */
  114275. readonly supportCascades: boolean;
  114276. /**
  114277. * This returns if the loader support the current file information.
  114278. * @param extension defines the file extension of the file being loaded
  114279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114280. * @param fallback defines the fallback internal texture if any
  114281. * @param isBase64 defines whether the texture is encoded as a base64
  114282. * @param isBuffer defines whether the texture data are stored as a buffer
  114283. * @returns true if the loader can load the specified file
  114284. */
  114285. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114286. /**
  114287. * Transform the url before loading if required.
  114288. * @param rootUrl the url of the texture
  114289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114290. * @returns the transformed texture
  114291. */
  114292. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114293. /**
  114294. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114295. * @param rootUrl the url of the texture
  114296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114297. * @returns the fallback texture
  114298. */
  114299. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114300. /**
  114301. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114302. * @param data contains the texture data
  114303. * @param texture defines the BabylonJS internal texture
  114304. * @param createPolynomials will be true if polynomials have been requested
  114305. * @param onLoad defines the callback to trigger once the texture is ready
  114306. * @param onError defines the callback to trigger in case of error
  114307. */
  114308. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114309. /**
  114310. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114311. * @param data contains the texture data
  114312. * @param texture defines the BabylonJS internal texture
  114313. * @param callback defines the method to call once ready to upload
  114314. */
  114315. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114316. }
  114317. }
  114318. declare module BABYLON {
  114319. /**
  114320. * Implementation of the ENV Texture Loader.
  114321. * @hidden
  114322. */
  114323. export class _ENVTextureLoader implements IInternalTextureLoader {
  114324. /**
  114325. * Defines wether the loader supports cascade loading the different faces.
  114326. */
  114327. readonly supportCascades: boolean;
  114328. /**
  114329. * This returns if the loader support the current file information.
  114330. * @param extension defines the file extension of the file being loaded
  114331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114332. * @param fallback defines the fallback internal texture if any
  114333. * @param isBase64 defines whether the texture is encoded as a base64
  114334. * @param isBuffer defines whether the texture data are stored as a buffer
  114335. * @returns true if the loader can load the specified file
  114336. */
  114337. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114338. /**
  114339. * Transform the url before loading if required.
  114340. * @param rootUrl the url of the texture
  114341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114342. * @returns the transformed texture
  114343. */
  114344. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114345. /**
  114346. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114347. * @param rootUrl the url of the texture
  114348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114349. * @returns the fallback texture
  114350. */
  114351. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114352. /**
  114353. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114354. * @param data contains the texture data
  114355. * @param texture defines the BabylonJS internal texture
  114356. * @param createPolynomials will be true if polynomials have been requested
  114357. * @param onLoad defines the callback to trigger once the texture is ready
  114358. * @param onError defines the callback to trigger in case of error
  114359. */
  114360. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114361. /**
  114362. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114363. * @param data contains the texture data
  114364. * @param texture defines the BabylonJS internal texture
  114365. * @param callback defines the method to call once ready to upload
  114366. */
  114367. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114368. }
  114369. }
  114370. declare module BABYLON {
  114371. /**
  114372. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  114373. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  114374. */
  114375. export class KhronosTextureContainer {
  114376. /** contents of the KTX container file */
  114377. arrayBuffer: any;
  114378. private static HEADER_LEN;
  114379. private static COMPRESSED_2D;
  114380. private static COMPRESSED_3D;
  114381. private static TEX_2D;
  114382. private static TEX_3D;
  114383. /**
  114384. * Gets the openGL type
  114385. */
  114386. glType: number;
  114387. /**
  114388. * Gets the openGL type size
  114389. */
  114390. glTypeSize: number;
  114391. /**
  114392. * Gets the openGL format
  114393. */
  114394. glFormat: number;
  114395. /**
  114396. * Gets the openGL internal format
  114397. */
  114398. glInternalFormat: number;
  114399. /**
  114400. * Gets the base internal format
  114401. */
  114402. glBaseInternalFormat: number;
  114403. /**
  114404. * Gets image width in pixel
  114405. */
  114406. pixelWidth: number;
  114407. /**
  114408. * Gets image height in pixel
  114409. */
  114410. pixelHeight: number;
  114411. /**
  114412. * Gets image depth in pixels
  114413. */
  114414. pixelDepth: number;
  114415. /**
  114416. * Gets the number of array elements
  114417. */
  114418. numberOfArrayElements: number;
  114419. /**
  114420. * Gets the number of faces
  114421. */
  114422. numberOfFaces: number;
  114423. /**
  114424. * Gets the number of mipmap levels
  114425. */
  114426. numberOfMipmapLevels: number;
  114427. /**
  114428. * Gets the bytes of key value data
  114429. */
  114430. bytesOfKeyValueData: number;
  114431. /**
  114432. * Gets the load type
  114433. */
  114434. loadType: number;
  114435. /**
  114436. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114437. */
  114438. isInvalid: boolean;
  114439. /**
  114440. * Creates a new KhronosTextureContainer
  114441. * @param arrayBuffer contents of the KTX container file
  114442. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114443. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114444. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114445. */
  114446. constructor(
  114447. /** contents of the KTX container file */
  114448. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114449. /**
  114450. * Uploads KTX content to a Babylon Texture.
  114451. * It is assumed that the texture has already been created & is currently bound
  114452. * @hidden
  114453. */
  114454. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114455. private _upload2DCompressedLevels;
  114456. }
  114457. }
  114458. declare module BABYLON {
  114459. /**
  114460. * Implementation of the KTX Texture Loader.
  114461. * @hidden
  114462. */
  114463. export class _KTXTextureLoader implements IInternalTextureLoader {
  114464. /**
  114465. * Defines wether the loader supports cascade loading the different faces.
  114466. */
  114467. readonly supportCascades: boolean;
  114468. /**
  114469. * This returns if the loader support the current file information.
  114470. * @param extension defines the file extension of the file being loaded
  114471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114472. * @param fallback defines the fallback internal texture if any
  114473. * @param isBase64 defines whether the texture is encoded as a base64
  114474. * @param isBuffer defines whether the texture data are stored as a buffer
  114475. * @returns true if the loader can load the specified file
  114476. */
  114477. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114478. /**
  114479. * Transform the url before loading if required.
  114480. * @param rootUrl the url of the texture
  114481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114482. * @returns the transformed texture
  114483. */
  114484. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114485. /**
  114486. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114487. * @param rootUrl the url of the texture
  114488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114489. * @returns the fallback texture
  114490. */
  114491. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114492. /**
  114493. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114494. * @param data contains the texture data
  114495. * @param texture defines the BabylonJS internal texture
  114496. * @param createPolynomials will be true if polynomials have been requested
  114497. * @param onLoad defines the callback to trigger once the texture is ready
  114498. * @param onError defines the callback to trigger in case of error
  114499. */
  114500. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114501. /**
  114502. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114503. * @param data contains the texture data
  114504. * @param texture defines the BabylonJS internal texture
  114505. * @param callback defines the method to call once ready to upload
  114506. */
  114507. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114508. }
  114509. }
  114510. declare module BABYLON {
  114511. /**
  114512. * Options for the default xr helper
  114513. */
  114514. export class WebXRDefaultExperienceOptions {
  114515. /**
  114516. * Floor meshes that should be used for teleporting
  114517. */
  114518. floorMeshes: Array<AbstractMesh>;
  114519. }
  114520. /**
  114521. * Default experience which provides a similar setup to the previous webVRExperience
  114522. */
  114523. export class WebXRDefaultExperience {
  114524. /**
  114525. * Base experience
  114526. */
  114527. baseExperience: WebXRExperienceHelper;
  114528. /**
  114529. * Input experience extension
  114530. */
  114531. input: WebXRInput;
  114532. /**
  114533. * Loads the controller models
  114534. */
  114535. controllerModelLoader: WebXRControllerModelLoader;
  114536. /**
  114537. * Enables laser pointer and selection
  114538. */
  114539. pointerSelection: WebXRControllerPointerSelection;
  114540. /**
  114541. * Enables teleportation
  114542. */
  114543. teleportation: WebXRControllerTeleportation;
  114544. /**
  114545. * Enables ui for enetering/exiting xr
  114546. */
  114547. enterExitUI: WebXREnterExitUI;
  114548. /**
  114549. * Default output canvas xr should render to
  114550. */
  114551. outputCanvas: WebXRManagedOutputCanvas;
  114552. /**
  114553. * Creates the default xr experience
  114554. * @param scene scene
  114555. * @param options options for basic configuration
  114556. * @returns resulting WebXRDefaultExperience
  114557. */
  114558. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114559. private constructor();
  114560. /**
  114561. * DIsposes of the experience helper
  114562. */
  114563. dispose(): void;
  114564. }
  114565. }
  114566. declare module BABYLON {
  114567. /** @hidden */
  114568. export var _forceSceneHelpersToBundle: boolean;
  114569. interface Scene {
  114570. /**
  114571. * Creates a default light for the scene.
  114572. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114573. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114574. */
  114575. createDefaultLight(replace?: boolean): void;
  114576. /**
  114577. * Creates a default camera for the scene.
  114578. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114579. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114580. * @param replace has default false, when true replaces the active camera in the scene
  114581. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114582. */
  114583. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114584. /**
  114585. * Creates a default camera and a default light.
  114586. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114587. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114588. * @param replace has the default false, when true replaces the active camera/light in the scene
  114589. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114590. */
  114591. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114592. /**
  114593. * Creates a new sky box
  114594. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114595. * @param environmentTexture defines the texture to use as environment texture
  114596. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114597. * @param scale defines the overall scale of the skybox
  114598. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114599. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114600. * @returns a new mesh holding the sky box
  114601. */
  114602. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114603. /**
  114604. * Creates a new environment
  114605. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114606. * @param options defines the options you can use to configure the environment
  114607. * @returns the new EnvironmentHelper
  114608. */
  114609. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114610. /**
  114611. * Creates a new VREXperienceHelper
  114612. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114613. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114614. * @returns a new VREXperienceHelper
  114615. */
  114616. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114617. /**
  114618. * Creates a new WebXRDefaultExperience
  114619. * @see http://doc.babylonjs.com/how_to/webxr
  114620. * @param options experience options
  114621. * @returns a promise for a new WebXRDefaultExperience
  114622. */
  114623. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114624. }
  114625. }
  114626. declare module BABYLON {
  114627. /**
  114628. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114629. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114630. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114631. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114632. */
  114633. export class VideoDome extends TransformNode {
  114634. /**
  114635. * Define the video source as a Monoscopic panoramic 360 video.
  114636. */
  114637. static readonly MODE_MONOSCOPIC: number;
  114638. /**
  114639. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114640. */
  114641. static readonly MODE_TOPBOTTOM: number;
  114642. /**
  114643. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114644. */
  114645. static readonly MODE_SIDEBYSIDE: number;
  114646. private _halfDome;
  114647. private _useDirectMapping;
  114648. /**
  114649. * The video texture being displayed on the sphere
  114650. */
  114651. protected _videoTexture: VideoTexture;
  114652. /**
  114653. * Gets the video texture being displayed on the sphere
  114654. */
  114655. readonly videoTexture: VideoTexture;
  114656. /**
  114657. * The skybox material
  114658. */
  114659. protected _material: BackgroundMaterial;
  114660. /**
  114661. * The surface used for the skybox
  114662. */
  114663. protected _mesh: Mesh;
  114664. /**
  114665. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114666. */
  114667. private _halfDomeMask;
  114668. /**
  114669. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114670. * Also see the options.resolution property.
  114671. */
  114672. fovMultiplier: number;
  114673. private _videoMode;
  114674. /**
  114675. * Gets or set the current video mode for the video. It can be:
  114676. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114677. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114678. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114679. */
  114680. videoMode: number;
  114681. /**
  114682. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114683. *
  114684. */
  114685. /**
  114686. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114687. */
  114688. halfDome: boolean;
  114689. /**
  114690. * Oberserver used in Stereoscopic VR Mode.
  114691. */
  114692. private _onBeforeCameraRenderObserver;
  114693. /**
  114694. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114695. * @param name Element's name, child elements will append suffixes for their own names.
  114696. * @param urlsOrVideo defines the url(s) or the video element to use
  114697. * @param options An object containing optional or exposed sub element properties
  114698. */
  114699. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114700. resolution?: number;
  114701. clickToPlay?: boolean;
  114702. autoPlay?: boolean;
  114703. loop?: boolean;
  114704. size?: number;
  114705. poster?: string;
  114706. faceForward?: boolean;
  114707. useDirectMapping?: boolean;
  114708. halfDomeMode?: boolean;
  114709. }, scene: Scene);
  114710. private _changeVideoMode;
  114711. /**
  114712. * Releases resources associated with this node.
  114713. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114714. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114715. */
  114716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114717. }
  114718. }
  114719. declare module BABYLON {
  114720. /**
  114721. * This class can be used to get instrumentation data from a Babylon engine
  114722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114723. */
  114724. export class EngineInstrumentation implements IDisposable {
  114725. /**
  114726. * Define the instrumented engine.
  114727. */
  114728. engine: Engine;
  114729. private _captureGPUFrameTime;
  114730. private _gpuFrameTimeToken;
  114731. private _gpuFrameTime;
  114732. private _captureShaderCompilationTime;
  114733. private _shaderCompilationTime;
  114734. private _onBeginFrameObserver;
  114735. private _onEndFrameObserver;
  114736. private _onBeforeShaderCompilationObserver;
  114737. private _onAfterShaderCompilationObserver;
  114738. /**
  114739. * Gets the perf counter used for GPU frame time
  114740. */
  114741. readonly gpuFrameTimeCounter: PerfCounter;
  114742. /**
  114743. * Gets the GPU frame time capture status
  114744. */
  114745. /**
  114746. * Enable or disable the GPU frame time capture
  114747. */
  114748. captureGPUFrameTime: boolean;
  114749. /**
  114750. * Gets the perf counter used for shader compilation time
  114751. */
  114752. readonly shaderCompilationTimeCounter: PerfCounter;
  114753. /**
  114754. * Gets the shader compilation time capture status
  114755. */
  114756. /**
  114757. * Enable or disable the shader compilation time capture
  114758. */
  114759. captureShaderCompilationTime: boolean;
  114760. /**
  114761. * Instantiates a new engine instrumentation.
  114762. * This class can be used to get instrumentation data from a Babylon engine
  114763. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114764. * @param engine Defines the engine to instrument
  114765. */
  114766. constructor(
  114767. /**
  114768. * Define the instrumented engine.
  114769. */
  114770. engine: Engine);
  114771. /**
  114772. * Dispose and release associated resources.
  114773. */
  114774. dispose(): void;
  114775. }
  114776. }
  114777. declare module BABYLON {
  114778. /**
  114779. * This class can be used to get instrumentation data from a Babylon engine
  114780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114781. */
  114782. export class SceneInstrumentation implements IDisposable {
  114783. /**
  114784. * Defines the scene to instrument
  114785. */
  114786. scene: Scene;
  114787. private _captureActiveMeshesEvaluationTime;
  114788. private _activeMeshesEvaluationTime;
  114789. private _captureRenderTargetsRenderTime;
  114790. private _renderTargetsRenderTime;
  114791. private _captureFrameTime;
  114792. private _frameTime;
  114793. private _captureRenderTime;
  114794. private _renderTime;
  114795. private _captureInterFrameTime;
  114796. private _interFrameTime;
  114797. private _captureParticlesRenderTime;
  114798. private _particlesRenderTime;
  114799. private _captureSpritesRenderTime;
  114800. private _spritesRenderTime;
  114801. private _capturePhysicsTime;
  114802. private _physicsTime;
  114803. private _captureAnimationsTime;
  114804. private _animationsTime;
  114805. private _captureCameraRenderTime;
  114806. private _cameraRenderTime;
  114807. private _onBeforeActiveMeshesEvaluationObserver;
  114808. private _onAfterActiveMeshesEvaluationObserver;
  114809. private _onBeforeRenderTargetsRenderObserver;
  114810. private _onAfterRenderTargetsRenderObserver;
  114811. private _onAfterRenderObserver;
  114812. private _onBeforeDrawPhaseObserver;
  114813. private _onAfterDrawPhaseObserver;
  114814. private _onBeforeAnimationsObserver;
  114815. private _onBeforeParticlesRenderingObserver;
  114816. private _onAfterParticlesRenderingObserver;
  114817. private _onBeforeSpritesRenderingObserver;
  114818. private _onAfterSpritesRenderingObserver;
  114819. private _onBeforePhysicsObserver;
  114820. private _onAfterPhysicsObserver;
  114821. private _onAfterAnimationsObserver;
  114822. private _onBeforeCameraRenderObserver;
  114823. private _onAfterCameraRenderObserver;
  114824. /**
  114825. * Gets the perf counter used for active meshes evaluation time
  114826. */
  114827. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114828. /**
  114829. * Gets the active meshes evaluation time capture status
  114830. */
  114831. /**
  114832. * Enable or disable the active meshes evaluation time capture
  114833. */
  114834. captureActiveMeshesEvaluationTime: boolean;
  114835. /**
  114836. * Gets the perf counter used for render targets render time
  114837. */
  114838. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114839. /**
  114840. * Gets the render targets render time capture status
  114841. */
  114842. /**
  114843. * Enable or disable the render targets render time capture
  114844. */
  114845. captureRenderTargetsRenderTime: boolean;
  114846. /**
  114847. * Gets the perf counter used for particles render time
  114848. */
  114849. readonly particlesRenderTimeCounter: PerfCounter;
  114850. /**
  114851. * Gets the particles render time capture status
  114852. */
  114853. /**
  114854. * Enable or disable the particles render time capture
  114855. */
  114856. captureParticlesRenderTime: boolean;
  114857. /**
  114858. * Gets the perf counter used for sprites render time
  114859. */
  114860. readonly spritesRenderTimeCounter: PerfCounter;
  114861. /**
  114862. * Gets the sprites render time capture status
  114863. */
  114864. /**
  114865. * Enable or disable the sprites render time capture
  114866. */
  114867. captureSpritesRenderTime: boolean;
  114868. /**
  114869. * Gets the perf counter used for physics time
  114870. */
  114871. readonly physicsTimeCounter: PerfCounter;
  114872. /**
  114873. * Gets the physics time capture status
  114874. */
  114875. /**
  114876. * Enable or disable the physics time capture
  114877. */
  114878. capturePhysicsTime: boolean;
  114879. /**
  114880. * Gets the perf counter used for animations time
  114881. */
  114882. readonly animationsTimeCounter: PerfCounter;
  114883. /**
  114884. * Gets the animations time capture status
  114885. */
  114886. /**
  114887. * Enable or disable the animations time capture
  114888. */
  114889. captureAnimationsTime: boolean;
  114890. /**
  114891. * Gets the perf counter used for frame time capture
  114892. */
  114893. readonly frameTimeCounter: PerfCounter;
  114894. /**
  114895. * Gets the frame time capture status
  114896. */
  114897. /**
  114898. * Enable or disable the frame time capture
  114899. */
  114900. captureFrameTime: boolean;
  114901. /**
  114902. * Gets the perf counter used for inter-frames time capture
  114903. */
  114904. readonly interFrameTimeCounter: PerfCounter;
  114905. /**
  114906. * Gets the inter-frames time capture status
  114907. */
  114908. /**
  114909. * Enable or disable the inter-frames time capture
  114910. */
  114911. captureInterFrameTime: boolean;
  114912. /**
  114913. * Gets the perf counter used for render time capture
  114914. */
  114915. readonly renderTimeCounter: PerfCounter;
  114916. /**
  114917. * Gets the render time capture status
  114918. */
  114919. /**
  114920. * Enable or disable the render time capture
  114921. */
  114922. captureRenderTime: boolean;
  114923. /**
  114924. * Gets the perf counter used for camera render time capture
  114925. */
  114926. readonly cameraRenderTimeCounter: PerfCounter;
  114927. /**
  114928. * Gets the camera render time capture status
  114929. */
  114930. /**
  114931. * Enable or disable the camera render time capture
  114932. */
  114933. captureCameraRenderTime: boolean;
  114934. /**
  114935. * Gets the perf counter used for draw calls
  114936. */
  114937. readonly drawCallsCounter: PerfCounter;
  114938. /**
  114939. * Instantiates a new scene instrumentation.
  114940. * This class can be used to get instrumentation data from a Babylon engine
  114941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114942. * @param scene Defines the scene to instrument
  114943. */
  114944. constructor(
  114945. /**
  114946. * Defines the scene to instrument
  114947. */
  114948. scene: Scene);
  114949. /**
  114950. * Dispose and release associated resources.
  114951. */
  114952. dispose(): void;
  114953. }
  114954. }
  114955. declare module BABYLON {
  114956. /** @hidden */
  114957. export var glowMapGenerationPixelShader: {
  114958. name: string;
  114959. shader: string;
  114960. };
  114961. }
  114962. declare module BABYLON {
  114963. /** @hidden */
  114964. export var glowMapGenerationVertexShader: {
  114965. name: string;
  114966. shader: string;
  114967. };
  114968. }
  114969. declare module BABYLON {
  114970. /**
  114971. * Effect layer options. This helps customizing the behaviour
  114972. * of the effect layer.
  114973. */
  114974. export interface IEffectLayerOptions {
  114975. /**
  114976. * Multiplication factor apply to the canvas size to compute the render target size
  114977. * used to generated the objects (the smaller the faster).
  114978. */
  114979. mainTextureRatio: number;
  114980. /**
  114981. * Enforces a fixed size texture to ensure effect stability across devices.
  114982. */
  114983. mainTextureFixedSize?: number;
  114984. /**
  114985. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114986. */
  114987. alphaBlendingMode: number;
  114988. /**
  114989. * The camera attached to the layer.
  114990. */
  114991. camera: Nullable<Camera>;
  114992. /**
  114993. * The rendering group to draw the layer in.
  114994. */
  114995. renderingGroupId: number;
  114996. }
  114997. /**
  114998. * The effect layer Helps adding post process effect blended with the main pass.
  114999. *
  115000. * This can be for instance use to generate glow or higlight effects on the scene.
  115001. *
  115002. * The effect layer class can not be used directly and is intented to inherited from to be
  115003. * customized per effects.
  115004. */
  115005. export abstract class EffectLayer {
  115006. private _vertexBuffers;
  115007. private _indexBuffer;
  115008. private _cachedDefines;
  115009. private _effectLayerMapGenerationEffect;
  115010. private _effectLayerOptions;
  115011. private _mergeEffect;
  115012. protected _scene: Scene;
  115013. protected _engine: Engine;
  115014. protected _maxSize: number;
  115015. protected _mainTextureDesiredSize: ISize;
  115016. protected _mainTexture: RenderTargetTexture;
  115017. protected _shouldRender: boolean;
  115018. protected _postProcesses: PostProcess[];
  115019. protected _textures: BaseTexture[];
  115020. protected _emissiveTextureAndColor: {
  115021. texture: Nullable<BaseTexture>;
  115022. color: Color4;
  115023. };
  115024. /**
  115025. * The name of the layer
  115026. */
  115027. name: string;
  115028. /**
  115029. * The clear color of the texture used to generate the glow map.
  115030. */
  115031. neutralColor: Color4;
  115032. /**
  115033. * Specifies wether the highlight layer is enabled or not.
  115034. */
  115035. isEnabled: boolean;
  115036. /**
  115037. * Gets the camera attached to the layer.
  115038. */
  115039. readonly camera: Nullable<Camera>;
  115040. /**
  115041. * Gets the rendering group id the layer should render in.
  115042. */
  115043. renderingGroupId: number;
  115044. /**
  115045. * An event triggered when the effect layer has been disposed.
  115046. */
  115047. onDisposeObservable: Observable<EffectLayer>;
  115048. /**
  115049. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  115050. */
  115051. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  115052. /**
  115053. * An event triggered when the generated texture is being merged in the scene.
  115054. */
  115055. onBeforeComposeObservable: Observable<EffectLayer>;
  115056. /**
  115057. * An event triggered when the generated texture has been merged in the scene.
  115058. */
  115059. onAfterComposeObservable: Observable<EffectLayer>;
  115060. /**
  115061. * An event triggered when the efffect layer changes its size.
  115062. */
  115063. onSizeChangedObservable: Observable<EffectLayer>;
  115064. /** @hidden */
  115065. static _SceneComponentInitialization: (scene: Scene) => void;
  115066. /**
  115067. * Instantiates a new effect Layer and references it in the scene.
  115068. * @param name The name of the layer
  115069. * @param scene The scene to use the layer in
  115070. */
  115071. constructor(
  115072. /** The Friendly of the effect in the scene */
  115073. name: string, scene: Scene);
  115074. /**
  115075. * Get the effect name of the layer.
  115076. * @return The effect name
  115077. */
  115078. abstract getEffectName(): string;
  115079. /**
  115080. * Checks for the readiness of the element composing the layer.
  115081. * @param subMesh the mesh to check for
  115082. * @param useInstances specify wether or not to use instances to render the mesh
  115083. * @return true if ready otherwise, false
  115084. */
  115085. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115086. /**
  115087. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115088. * @returns true if the effect requires stencil during the main canvas render pass.
  115089. */
  115090. abstract needStencil(): boolean;
  115091. /**
  115092. * Create the merge effect. This is the shader use to blit the information back
  115093. * to the main canvas at the end of the scene rendering.
  115094. * @returns The effect containing the shader used to merge the effect on the main canvas
  115095. */
  115096. protected abstract _createMergeEffect(): Effect;
  115097. /**
  115098. * Creates the render target textures and post processes used in the effect layer.
  115099. */
  115100. protected abstract _createTextureAndPostProcesses(): void;
  115101. /**
  115102. * Implementation specific of rendering the generating effect on the main canvas.
  115103. * @param effect The effect used to render through
  115104. */
  115105. protected abstract _internalRender(effect: Effect): void;
  115106. /**
  115107. * Sets the required values for both the emissive texture and and the main color.
  115108. */
  115109. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115110. /**
  115111. * Free any resources and references associated to a mesh.
  115112. * Internal use
  115113. * @param mesh The mesh to free.
  115114. */
  115115. abstract _disposeMesh(mesh: Mesh): void;
  115116. /**
  115117. * Serializes this layer (Glow or Highlight for example)
  115118. * @returns a serialized layer object
  115119. */
  115120. abstract serialize?(): any;
  115121. /**
  115122. * Initializes the effect layer with the required options.
  115123. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  115124. */
  115125. protected _init(options: Partial<IEffectLayerOptions>): void;
  115126. /**
  115127. * Generates the index buffer of the full screen quad blending to the main canvas.
  115128. */
  115129. private _generateIndexBuffer;
  115130. /**
  115131. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  115132. */
  115133. private _generateVertexBuffer;
  115134. /**
  115135. * Sets the main texture desired size which is the closest power of two
  115136. * of the engine canvas size.
  115137. */
  115138. private _setMainTextureSize;
  115139. /**
  115140. * Creates the main texture for the effect layer.
  115141. */
  115142. protected _createMainTexture(): void;
  115143. /**
  115144. * Adds specific effects defines.
  115145. * @param defines The defines to add specifics to.
  115146. */
  115147. protected _addCustomEffectDefines(defines: string[]): void;
  115148. /**
  115149. * Checks for the readiness of the element composing the layer.
  115150. * @param subMesh the mesh to check for
  115151. * @param useInstances specify wether or not to use instances to render the mesh
  115152. * @param emissiveTexture the associated emissive texture used to generate the glow
  115153. * @return true if ready otherwise, false
  115154. */
  115155. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  115156. /**
  115157. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  115158. */
  115159. render(): void;
  115160. /**
  115161. * Determine if a given mesh will be used in the current effect.
  115162. * @param mesh mesh to test
  115163. * @returns true if the mesh will be used
  115164. */
  115165. hasMesh(mesh: AbstractMesh): boolean;
  115166. /**
  115167. * Returns true if the layer contains information to display, otherwise false.
  115168. * @returns true if the glow layer should be rendered
  115169. */
  115170. shouldRender(): boolean;
  115171. /**
  115172. * Returns true if the mesh should render, otherwise false.
  115173. * @param mesh The mesh to render
  115174. * @returns true if it should render otherwise false
  115175. */
  115176. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  115177. /**
  115178. * Returns true if the mesh can be rendered, otherwise false.
  115179. * @param mesh The mesh to render
  115180. * @param material The material used on the mesh
  115181. * @returns true if it can be rendered otherwise false
  115182. */
  115183. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115184. /**
  115185. * Returns true if the mesh should render, otherwise false.
  115186. * @param mesh The mesh to render
  115187. * @returns true if it should render otherwise false
  115188. */
  115189. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  115190. /**
  115191. * Renders the submesh passed in parameter to the generation map.
  115192. */
  115193. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  115194. /**
  115195. * Rebuild the required buffers.
  115196. * @hidden Internal use only.
  115197. */
  115198. _rebuild(): void;
  115199. /**
  115200. * Dispose only the render target textures and post process.
  115201. */
  115202. private _disposeTextureAndPostProcesses;
  115203. /**
  115204. * Dispose the highlight layer and free resources.
  115205. */
  115206. dispose(): void;
  115207. /**
  115208. * Gets the class name of the effect layer
  115209. * @returns the string with the class name of the effect layer
  115210. */
  115211. getClassName(): string;
  115212. /**
  115213. * Creates an effect layer from parsed effect layer data
  115214. * @param parsedEffectLayer defines effect layer data
  115215. * @param scene defines the current scene
  115216. * @param rootUrl defines the root URL containing the effect layer information
  115217. * @returns a parsed effect Layer
  115218. */
  115219. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  115220. }
  115221. }
  115222. declare module BABYLON {
  115223. interface AbstractScene {
  115224. /**
  115225. * The list of effect layers (highlights/glow) added to the scene
  115226. * @see http://doc.babylonjs.com/how_to/highlight_layer
  115227. * @see http://doc.babylonjs.com/how_to/glow_layer
  115228. */
  115229. effectLayers: Array<EffectLayer>;
  115230. /**
  115231. * Removes the given effect layer from this scene.
  115232. * @param toRemove defines the effect layer to remove
  115233. * @returns the index of the removed effect layer
  115234. */
  115235. removeEffectLayer(toRemove: EffectLayer): number;
  115236. /**
  115237. * Adds the given effect layer to this scene
  115238. * @param newEffectLayer defines the effect layer to add
  115239. */
  115240. addEffectLayer(newEffectLayer: EffectLayer): void;
  115241. }
  115242. /**
  115243. * Defines the layer scene component responsible to manage any effect layers
  115244. * in a given scene.
  115245. */
  115246. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  115247. /**
  115248. * The component name helpfull to identify the component in the list of scene components.
  115249. */
  115250. readonly name: string;
  115251. /**
  115252. * The scene the component belongs to.
  115253. */
  115254. scene: Scene;
  115255. private _engine;
  115256. private _renderEffects;
  115257. private _needStencil;
  115258. private _previousStencilState;
  115259. /**
  115260. * Creates a new instance of the component for the given scene
  115261. * @param scene Defines the scene to register the component in
  115262. */
  115263. constructor(scene: Scene);
  115264. /**
  115265. * Registers the component in a given scene
  115266. */
  115267. register(): void;
  115268. /**
  115269. * Rebuilds the elements related to this component in case of
  115270. * context lost for instance.
  115271. */
  115272. rebuild(): void;
  115273. /**
  115274. * Serializes the component data to the specified json object
  115275. * @param serializationObject The object to serialize to
  115276. */
  115277. serialize(serializationObject: any): void;
  115278. /**
  115279. * Adds all the elements from the container to the scene
  115280. * @param container the container holding the elements
  115281. */
  115282. addFromContainer(container: AbstractScene): void;
  115283. /**
  115284. * Removes all the elements in the container from the scene
  115285. * @param container contains the elements to remove
  115286. * @param dispose if the removed element should be disposed (default: false)
  115287. */
  115288. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115289. /**
  115290. * Disposes the component and the associated ressources.
  115291. */
  115292. dispose(): void;
  115293. private _isReadyForMesh;
  115294. private _renderMainTexture;
  115295. private _setStencil;
  115296. private _setStencilBack;
  115297. private _draw;
  115298. private _drawCamera;
  115299. private _drawRenderingGroup;
  115300. }
  115301. }
  115302. declare module BABYLON {
  115303. /** @hidden */
  115304. export var glowMapMergePixelShader: {
  115305. name: string;
  115306. shader: string;
  115307. };
  115308. }
  115309. declare module BABYLON {
  115310. /** @hidden */
  115311. export var glowMapMergeVertexShader: {
  115312. name: string;
  115313. shader: string;
  115314. };
  115315. }
  115316. declare module BABYLON {
  115317. interface AbstractScene {
  115318. /**
  115319. * Return a the first highlight layer of the scene with a given name.
  115320. * @param name The name of the highlight layer to look for.
  115321. * @return The highlight layer if found otherwise null.
  115322. */
  115323. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  115324. }
  115325. /**
  115326. * Glow layer options. This helps customizing the behaviour
  115327. * of the glow layer.
  115328. */
  115329. export interface IGlowLayerOptions {
  115330. /**
  115331. * Multiplication factor apply to the canvas size to compute the render target size
  115332. * used to generated the glowing objects (the smaller the faster).
  115333. */
  115334. mainTextureRatio: number;
  115335. /**
  115336. * Enforces a fixed size texture to ensure resize independant blur.
  115337. */
  115338. mainTextureFixedSize?: number;
  115339. /**
  115340. * How big is the kernel of the blur texture.
  115341. */
  115342. blurKernelSize: number;
  115343. /**
  115344. * The camera attached to the layer.
  115345. */
  115346. camera: Nullable<Camera>;
  115347. /**
  115348. * Enable MSAA by chosing the number of samples.
  115349. */
  115350. mainTextureSamples?: number;
  115351. /**
  115352. * The rendering group to draw the layer in.
  115353. */
  115354. renderingGroupId: number;
  115355. }
  115356. /**
  115357. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  115358. *
  115359. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115360. * glowy meshes to your scene.
  115361. *
  115362. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  115363. */
  115364. export class GlowLayer extends EffectLayer {
  115365. /**
  115366. * Effect Name of the layer.
  115367. */
  115368. static readonly EffectName: string;
  115369. /**
  115370. * The default blur kernel size used for the glow.
  115371. */
  115372. static DefaultBlurKernelSize: number;
  115373. /**
  115374. * The default texture size ratio used for the glow.
  115375. */
  115376. static DefaultTextureRatio: number;
  115377. /**
  115378. * Sets the kernel size of the blur.
  115379. */
  115380. /**
  115381. * Gets the kernel size of the blur.
  115382. */
  115383. blurKernelSize: number;
  115384. /**
  115385. * Sets the glow intensity.
  115386. */
  115387. /**
  115388. * Gets the glow intensity.
  115389. */
  115390. intensity: number;
  115391. private _options;
  115392. private _intensity;
  115393. private _horizontalBlurPostprocess1;
  115394. private _verticalBlurPostprocess1;
  115395. private _horizontalBlurPostprocess2;
  115396. private _verticalBlurPostprocess2;
  115397. private _blurTexture1;
  115398. private _blurTexture2;
  115399. private _postProcesses1;
  115400. private _postProcesses2;
  115401. private _includedOnlyMeshes;
  115402. private _excludedMeshes;
  115403. /**
  115404. * Callback used to let the user override the color selection on a per mesh basis
  115405. */
  115406. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  115407. /**
  115408. * Callback used to let the user override the texture selection on a per mesh basis
  115409. */
  115410. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  115411. /**
  115412. * Instantiates a new glow Layer and references it to the scene.
  115413. * @param name The name of the layer
  115414. * @param scene The scene to use the layer in
  115415. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  115416. */
  115417. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  115418. /**
  115419. * Get the effect name of the layer.
  115420. * @return The effect name
  115421. */
  115422. getEffectName(): string;
  115423. /**
  115424. * Create the merge effect. This is the shader use to blit the information back
  115425. * to the main canvas at the end of the scene rendering.
  115426. */
  115427. protected _createMergeEffect(): Effect;
  115428. /**
  115429. * Creates the render target textures and post processes used in the glow layer.
  115430. */
  115431. protected _createTextureAndPostProcesses(): void;
  115432. /**
  115433. * Checks for the readiness of the element composing the layer.
  115434. * @param subMesh the mesh to check for
  115435. * @param useInstances specify wether or not to use instances to render the mesh
  115436. * @param emissiveTexture the associated emissive texture used to generate the glow
  115437. * @return true if ready otherwise, false
  115438. */
  115439. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115440. /**
  115441. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115442. */
  115443. needStencil(): boolean;
  115444. /**
  115445. * Returns true if the mesh can be rendered, otherwise false.
  115446. * @param mesh The mesh to render
  115447. * @param material The material used on the mesh
  115448. * @returns true if it can be rendered otherwise false
  115449. */
  115450. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115451. /**
  115452. * Implementation specific of rendering the generating effect on the main canvas.
  115453. * @param effect The effect used to render through
  115454. */
  115455. protected _internalRender(effect: Effect): void;
  115456. /**
  115457. * Sets the required values for both the emissive texture and and the main color.
  115458. */
  115459. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115460. /**
  115461. * Returns true if the mesh should render, otherwise false.
  115462. * @param mesh The mesh to render
  115463. * @returns true if it should render otherwise false
  115464. */
  115465. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115466. /**
  115467. * Adds specific effects defines.
  115468. * @param defines The defines to add specifics to.
  115469. */
  115470. protected _addCustomEffectDefines(defines: string[]): void;
  115471. /**
  115472. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115473. * @param mesh The mesh to exclude from the glow layer
  115474. */
  115475. addExcludedMesh(mesh: Mesh): void;
  115476. /**
  115477. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115478. * @param mesh The mesh to remove
  115479. */
  115480. removeExcludedMesh(mesh: Mesh): void;
  115481. /**
  115482. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115483. * @param mesh The mesh to include in the glow layer
  115484. */
  115485. addIncludedOnlyMesh(mesh: Mesh): void;
  115486. /**
  115487. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115488. * @param mesh The mesh to remove
  115489. */
  115490. removeIncludedOnlyMesh(mesh: Mesh): void;
  115491. /**
  115492. * Determine if a given mesh will be used in the glow layer
  115493. * @param mesh The mesh to test
  115494. * @returns true if the mesh will be highlighted by the current glow layer
  115495. */
  115496. hasMesh(mesh: AbstractMesh): boolean;
  115497. /**
  115498. * Free any resources and references associated to a mesh.
  115499. * Internal use
  115500. * @param mesh The mesh to free.
  115501. * @hidden
  115502. */
  115503. _disposeMesh(mesh: Mesh): void;
  115504. /**
  115505. * Gets the class name of the effect layer
  115506. * @returns the string with the class name of the effect layer
  115507. */
  115508. getClassName(): string;
  115509. /**
  115510. * Serializes this glow layer
  115511. * @returns a serialized glow layer object
  115512. */
  115513. serialize(): any;
  115514. /**
  115515. * Creates a Glow Layer from parsed glow layer data
  115516. * @param parsedGlowLayer defines glow layer data
  115517. * @param scene defines the current scene
  115518. * @param rootUrl defines the root URL containing the glow layer information
  115519. * @returns a parsed Glow Layer
  115520. */
  115521. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115522. }
  115523. }
  115524. declare module BABYLON {
  115525. /** @hidden */
  115526. export var glowBlurPostProcessPixelShader: {
  115527. name: string;
  115528. shader: string;
  115529. };
  115530. }
  115531. declare module BABYLON {
  115532. interface AbstractScene {
  115533. /**
  115534. * Return a the first highlight layer of the scene with a given name.
  115535. * @param name The name of the highlight layer to look for.
  115536. * @return The highlight layer if found otherwise null.
  115537. */
  115538. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115539. }
  115540. /**
  115541. * Highlight layer options. This helps customizing the behaviour
  115542. * of the highlight layer.
  115543. */
  115544. export interface IHighlightLayerOptions {
  115545. /**
  115546. * Multiplication factor apply to the canvas size to compute the render target size
  115547. * used to generated the glowing objects (the smaller the faster).
  115548. */
  115549. mainTextureRatio: number;
  115550. /**
  115551. * Enforces a fixed size texture to ensure resize independant blur.
  115552. */
  115553. mainTextureFixedSize?: number;
  115554. /**
  115555. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115556. * of the picture to blur (the smaller the faster).
  115557. */
  115558. blurTextureSizeRatio: number;
  115559. /**
  115560. * How big in texel of the blur texture is the vertical blur.
  115561. */
  115562. blurVerticalSize: number;
  115563. /**
  115564. * How big in texel of the blur texture is the horizontal blur.
  115565. */
  115566. blurHorizontalSize: number;
  115567. /**
  115568. * Alpha blending mode used to apply the blur. Default is combine.
  115569. */
  115570. alphaBlendingMode: number;
  115571. /**
  115572. * The camera attached to the layer.
  115573. */
  115574. camera: Nullable<Camera>;
  115575. /**
  115576. * Should we display highlight as a solid stroke?
  115577. */
  115578. isStroke?: boolean;
  115579. /**
  115580. * The rendering group to draw the layer in.
  115581. */
  115582. renderingGroupId: number;
  115583. }
  115584. /**
  115585. * The highlight layer Helps adding a glow effect around a mesh.
  115586. *
  115587. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115588. * glowy meshes to your scene.
  115589. *
  115590. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115591. */
  115592. export class HighlightLayer extends EffectLayer {
  115593. name: string;
  115594. /**
  115595. * Effect Name of the highlight layer.
  115596. */
  115597. static readonly EffectName: string;
  115598. /**
  115599. * The neutral color used during the preparation of the glow effect.
  115600. * This is black by default as the blend operation is a blend operation.
  115601. */
  115602. static NeutralColor: Color4;
  115603. /**
  115604. * Stencil value used for glowing meshes.
  115605. */
  115606. static GlowingMeshStencilReference: number;
  115607. /**
  115608. * Stencil value used for the other meshes in the scene.
  115609. */
  115610. static NormalMeshStencilReference: number;
  115611. /**
  115612. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115613. */
  115614. innerGlow: boolean;
  115615. /**
  115616. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115617. */
  115618. outerGlow: boolean;
  115619. /**
  115620. * Specifies the horizontal size of the blur.
  115621. */
  115622. /**
  115623. * Gets the horizontal size of the blur.
  115624. */
  115625. blurHorizontalSize: number;
  115626. /**
  115627. * Specifies the vertical size of the blur.
  115628. */
  115629. /**
  115630. * Gets the vertical size of the blur.
  115631. */
  115632. blurVerticalSize: number;
  115633. /**
  115634. * An event triggered when the highlight layer is being blurred.
  115635. */
  115636. onBeforeBlurObservable: Observable<HighlightLayer>;
  115637. /**
  115638. * An event triggered when the highlight layer has been blurred.
  115639. */
  115640. onAfterBlurObservable: Observable<HighlightLayer>;
  115641. private _instanceGlowingMeshStencilReference;
  115642. private _options;
  115643. private _downSamplePostprocess;
  115644. private _horizontalBlurPostprocess;
  115645. private _verticalBlurPostprocess;
  115646. private _blurTexture;
  115647. private _meshes;
  115648. private _excludedMeshes;
  115649. /**
  115650. * Instantiates a new highlight Layer and references it to the scene..
  115651. * @param name The name of the layer
  115652. * @param scene The scene to use the layer in
  115653. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115654. */
  115655. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115656. /**
  115657. * Get the effect name of the layer.
  115658. * @return The effect name
  115659. */
  115660. getEffectName(): string;
  115661. /**
  115662. * Create the merge effect. This is the shader use to blit the information back
  115663. * to the main canvas at the end of the scene rendering.
  115664. */
  115665. protected _createMergeEffect(): Effect;
  115666. /**
  115667. * Creates the render target textures and post processes used in the highlight layer.
  115668. */
  115669. protected _createTextureAndPostProcesses(): void;
  115670. /**
  115671. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115672. */
  115673. needStencil(): boolean;
  115674. /**
  115675. * Checks for the readiness of the element composing the layer.
  115676. * @param subMesh the mesh to check for
  115677. * @param useInstances specify wether or not to use instances to render the mesh
  115678. * @param emissiveTexture the associated emissive texture used to generate the glow
  115679. * @return true if ready otherwise, false
  115680. */
  115681. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115682. /**
  115683. * Implementation specific of rendering the generating effect on the main canvas.
  115684. * @param effect The effect used to render through
  115685. */
  115686. protected _internalRender(effect: Effect): void;
  115687. /**
  115688. * Returns true if the layer contains information to display, otherwise false.
  115689. */
  115690. shouldRender(): boolean;
  115691. /**
  115692. * Returns true if the mesh should render, otherwise false.
  115693. * @param mesh The mesh to render
  115694. * @returns true if it should render otherwise false
  115695. */
  115696. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115697. /**
  115698. * Sets the required values for both the emissive texture and and the main color.
  115699. */
  115700. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115701. /**
  115702. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115703. * @param mesh The mesh to exclude from the highlight layer
  115704. */
  115705. addExcludedMesh(mesh: Mesh): void;
  115706. /**
  115707. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115708. * @param mesh The mesh to highlight
  115709. */
  115710. removeExcludedMesh(mesh: Mesh): void;
  115711. /**
  115712. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115713. * @param mesh mesh to test
  115714. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115715. */
  115716. hasMesh(mesh: AbstractMesh): boolean;
  115717. /**
  115718. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115719. * @param mesh The mesh to highlight
  115720. * @param color The color of the highlight
  115721. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115722. */
  115723. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115724. /**
  115725. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115726. * @param mesh The mesh to highlight
  115727. */
  115728. removeMesh(mesh: Mesh): void;
  115729. /**
  115730. * Force the stencil to the normal expected value for none glowing parts
  115731. */
  115732. private _defaultStencilReference;
  115733. /**
  115734. * Free any resources and references associated to a mesh.
  115735. * Internal use
  115736. * @param mesh The mesh to free.
  115737. * @hidden
  115738. */
  115739. _disposeMesh(mesh: Mesh): void;
  115740. /**
  115741. * Dispose the highlight layer and free resources.
  115742. */
  115743. dispose(): void;
  115744. /**
  115745. * Gets the class name of the effect layer
  115746. * @returns the string with the class name of the effect layer
  115747. */
  115748. getClassName(): string;
  115749. /**
  115750. * Serializes this Highlight layer
  115751. * @returns a serialized Highlight layer object
  115752. */
  115753. serialize(): any;
  115754. /**
  115755. * Creates a Highlight layer from parsed Highlight layer data
  115756. * @param parsedHightlightLayer defines the Highlight layer data
  115757. * @param scene defines the current scene
  115758. * @param rootUrl defines the root URL containing the Highlight layer information
  115759. * @returns a parsed Highlight layer
  115760. */
  115761. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115762. }
  115763. }
  115764. declare module BABYLON {
  115765. interface AbstractScene {
  115766. /**
  115767. * The list of layers (background and foreground) of the scene
  115768. */
  115769. layers: Array<Layer>;
  115770. }
  115771. /**
  115772. * Defines the layer scene component responsible to manage any layers
  115773. * in a given scene.
  115774. */
  115775. export class LayerSceneComponent implements ISceneComponent {
  115776. /**
  115777. * The component name helpfull to identify the component in the list of scene components.
  115778. */
  115779. readonly name: string;
  115780. /**
  115781. * The scene the component belongs to.
  115782. */
  115783. scene: Scene;
  115784. private _engine;
  115785. /**
  115786. * Creates a new instance of the component for the given scene
  115787. * @param scene Defines the scene to register the component in
  115788. */
  115789. constructor(scene: Scene);
  115790. /**
  115791. * Registers the component in a given scene
  115792. */
  115793. register(): void;
  115794. /**
  115795. * Rebuilds the elements related to this component in case of
  115796. * context lost for instance.
  115797. */
  115798. rebuild(): void;
  115799. /**
  115800. * Disposes the component and the associated ressources.
  115801. */
  115802. dispose(): void;
  115803. private _draw;
  115804. private _drawCameraPredicate;
  115805. private _drawCameraBackground;
  115806. private _drawCameraForeground;
  115807. private _drawRenderTargetPredicate;
  115808. private _drawRenderTargetBackground;
  115809. private _drawRenderTargetForeground;
  115810. /**
  115811. * Adds all the elements from the container to the scene
  115812. * @param container the container holding the elements
  115813. */
  115814. addFromContainer(container: AbstractScene): void;
  115815. /**
  115816. * Removes all the elements in the container from the scene
  115817. * @param container contains the elements to remove
  115818. * @param dispose if the removed element should be disposed (default: false)
  115819. */
  115820. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115821. }
  115822. }
  115823. declare module BABYLON {
  115824. /** @hidden */
  115825. export var layerPixelShader: {
  115826. name: string;
  115827. shader: string;
  115828. };
  115829. }
  115830. declare module BABYLON {
  115831. /** @hidden */
  115832. export var layerVertexShader: {
  115833. name: string;
  115834. shader: string;
  115835. };
  115836. }
  115837. declare module BABYLON {
  115838. /**
  115839. * This represents a full screen 2d layer.
  115840. * This can be useful to display a picture in the background of your scene for instance.
  115841. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115842. */
  115843. export class Layer {
  115844. /**
  115845. * Define the name of the layer.
  115846. */
  115847. name: string;
  115848. /**
  115849. * Define the texture the layer should display.
  115850. */
  115851. texture: Nullable<Texture>;
  115852. /**
  115853. * Is the layer in background or foreground.
  115854. */
  115855. isBackground: boolean;
  115856. /**
  115857. * Define the color of the layer (instead of texture).
  115858. */
  115859. color: Color4;
  115860. /**
  115861. * Define the scale of the layer in order to zoom in out of the texture.
  115862. */
  115863. scale: Vector2;
  115864. /**
  115865. * Define an offset for the layer in order to shift the texture.
  115866. */
  115867. offset: Vector2;
  115868. /**
  115869. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115870. */
  115871. alphaBlendingMode: number;
  115872. /**
  115873. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115874. * Alpha test will not mix with the background color in case of transparency.
  115875. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115876. */
  115877. alphaTest: boolean;
  115878. /**
  115879. * Define a mask to restrict the layer to only some of the scene cameras.
  115880. */
  115881. layerMask: number;
  115882. /**
  115883. * Define the list of render target the layer is visible into.
  115884. */
  115885. renderTargetTextures: RenderTargetTexture[];
  115886. /**
  115887. * Define if the layer is only used in renderTarget or if it also
  115888. * renders in the main frame buffer of the canvas.
  115889. */
  115890. renderOnlyInRenderTargetTextures: boolean;
  115891. private _scene;
  115892. private _vertexBuffers;
  115893. private _indexBuffer;
  115894. private _effect;
  115895. private _alphaTestEffect;
  115896. /**
  115897. * An event triggered when the layer is disposed.
  115898. */
  115899. onDisposeObservable: Observable<Layer>;
  115900. private _onDisposeObserver;
  115901. /**
  115902. * Back compatibility with callback before the onDisposeObservable existed.
  115903. * The set callback will be triggered when the layer has been disposed.
  115904. */
  115905. onDispose: () => void;
  115906. /**
  115907. * An event triggered before rendering the scene
  115908. */
  115909. onBeforeRenderObservable: Observable<Layer>;
  115910. private _onBeforeRenderObserver;
  115911. /**
  115912. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115913. * The set callback will be triggered just before rendering the layer.
  115914. */
  115915. onBeforeRender: () => void;
  115916. /**
  115917. * An event triggered after rendering the scene
  115918. */
  115919. onAfterRenderObservable: Observable<Layer>;
  115920. private _onAfterRenderObserver;
  115921. /**
  115922. * Back compatibility with callback before the onAfterRenderObservable existed.
  115923. * The set callback will be triggered just after rendering the layer.
  115924. */
  115925. onAfterRender: () => void;
  115926. /**
  115927. * Instantiates a new layer.
  115928. * This represents a full screen 2d layer.
  115929. * This can be useful to display a picture in the background of your scene for instance.
  115930. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115931. * @param name Define the name of the layer in the scene
  115932. * @param imgUrl Define the url of the texture to display in the layer
  115933. * @param scene Define the scene the layer belongs to
  115934. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115935. * @param color Defines a color for the layer
  115936. */
  115937. constructor(
  115938. /**
  115939. * Define the name of the layer.
  115940. */
  115941. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115942. private _createIndexBuffer;
  115943. /** @hidden */
  115944. _rebuild(): void;
  115945. /**
  115946. * Renders the layer in the scene.
  115947. */
  115948. render(): void;
  115949. /**
  115950. * Disposes and releases the associated ressources.
  115951. */
  115952. dispose(): void;
  115953. }
  115954. }
  115955. declare module BABYLON {
  115956. /** @hidden */
  115957. export var lensFlarePixelShader: {
  115958. name: string;
  115959. shader: string;
  115960. };
  115961. }
  115962. declare module BABYLON {
  115963. /** @hidden */
  115964. export var lensFlareVertexShader: {
  115965. name: string;
  115966. shader: string;
  115967. };
  115968. }
  115969. declare module BABYLON {
  115970. /**
  115971. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115972. * It is usually composed of several `lensFlare`.
  115973. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115974. */
  115975. export class LensFlareSystem {
  115976. /**
  115977. * Define the name of the lens flare system
  115978. */
  115979. name: string;
  115980. /**
  115981. * List of lens flares used in this system.
  115982. */
  115983. lensFlares: LensFlare[];
  115984. /**
  115985. * Define a limit from the border the lens flare can be visible.
  115986. */
  115987. borderLimit: number;
  115988. /**
  115989. * Define a viewport border we do not want to see the lens flare in.
  115990. */
  115991. viewportBorder: number;
  115992. /**
  115993. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115994. */
  115995. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115996. /**
  115997. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115998. */
  115999. layerMask: number;
  116000. /**
  116001. * Define the id of the lens flare system in the scene.
  116002. * (equal to name by default)
  116003. */
  116004. id: string;
  116005. private _scene;
  116006. private _emitter;
  116007. private _vertexBuffers;
  116008. private _indexBuffer;
  116009. private _effect;
  116010. private _positionX;
  116011. private _positionY;
  116012. private _isEnabled;
  116013. /** @hidden */
  116014. static _SceneComponentInitialization: (scene: Scene) => void;
  116015. /**
  116016. * Instantiates a lens flare system.
  116017. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116018. * It is usually composed of several `lensFlare`.
  116019. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116020. * @param name Define the name of the lens flare system in the scene
  116021. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  116022. * @param scene Define the scene the lens flare system belongs to
  116023. */
  116024. constructor(
  116025. /**
  116026. * Define the name of the lens flare system
  116027. */
  116028. name: string, emitter: any, scene: Scene);
  116029. /**
  116030. * Define if the lens flare system is enabled.
  116031. */
  116032. isEnabled: boolean;
  116033. /**
  116034. * Get the scene the effects belongs to.
  116035. * @returns the scene holding the lens flare system
  116036. */
  116037. getScene(): Scene;
  116038. /**
  116039. * Get the emitter of the lens flare system.
  116040. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116041. * @returns the emitter of the lens flare system
  116042. */
  116043. getEmitter(): any;
  116044. /**
  116045. * Set the emitter of the lens flare system.
  116046. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116047. * @param newEmitter Define the new emitter of the system
  116048. */
  116049. setEmitter(newEmitter: any): void;
  116050. /**
  116051. * Get the lens flare system emitter position.
  116052. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  116053. * @returns the position
  116054. */
  116055. getEmitterPosition(): Vector3;
  116056. /**
  116057. * @hidden
  116058. */
  116059. computeEffectivePosition(globalViewport: Viewport): boolean;
  116060. /** @hidden */
  116061. _isVisible(): boolean;
  116062. /**
  116063. * @hidden
  116064. */
  116065. render(): boolean;
  116066. /**
  116067. * Dispose and release the lens flare with its associated resources.
  116068. */
  116069. dispose(): void;
  116070. /**
  116071. * Parse a lens flare system from a JSON repressentation
  116072. * @param parsedLensFlareSystem Define the JSON to parse
  116073. * @param scene Define the scene the parsed system should be instantiated in
  116074. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  116075. * @returns the parsed system
  116076. */
  116077. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  116078. /**
  116079. * Serialize the current Lens Flare System into a JSON representation.
  116080. * @returns the serialized JSON
  116081. */
  116082. serialize(): any;
  116083. }
  116084. }
  116085. declare module BABYLON {
  116086. /**
  116087. * This represents one of the lens effect in a `lensFlareSystem`.
  116088. * It controls one of the indiviual texture used in the effect.
  116089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116090. */
  116091. export class LensFlare {
  116092. /**
  116093. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116094. */
  116095. size: number;
  116096. /**
  116097. * 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.
  116098. */
  116099. position: number;
  116100. /**
  116101. * Define the lens color.
  116102. */
  116103. color: Color3;
  116104. /**
  116105. * Define the lens texture.
  116106. */
  116107. texture: Nullable<Texture>;
  116108. /**
  116109. * Define the alpha mode to render this particular lens.
  116110. */
  116111. alphaMode: number;
  116112. private _system;
  116113. /**
  116114. * Creates a new Lens Flare.
  116115. * This represents one of the lens effect in a `lensFlareSystem`.
  116116. * It controls one of the indiviual texture used in the effect.
  116117. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116118. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  116119. * @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.
  116120. * @param color Define the lens color
  116121. * @param imgUrl Define the lens texture url
  116122. * @param system Define the `lensFlareSystem` this flare is part of
  116123. * @returns The newly created Lens Flare
  116124. */
  116125. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  116126. /**
  116127. * Instantiates a new Lens Flare.
  116128. * This represents one of the lens effect in a `lensFlareSystem`.
  116129. * It controls one of the indiviual texture used in the effect.
  116130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116131. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  116132. * @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.
  116133. * @param color Define the lens color
  116134. * @param imgUrl Define the lens texture url
  116135. * @param system Define the `lensFlareSystem` this flare is part of
  116136. */
  116137. constructor(
  116138. /**
  116139. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116140. */
  116141. size: number,
  116142. /**
  116143. * 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.
  116144. */
  116145. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  116146. /**
  116147. * Dispose and release the lens flare with its associated resources.
  116148. */
  116149. dispose(): void;
  116150. }
  116151. }
  116152. declare module BABYLON {
  116153. interface AbstractScene {
  116154. /**
  116155. * The list of lens flare system added to the scene
  116156. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116157. */
  116158. lensFlareSystems: Array<LensFlareSystem>;
  116159. /**
  116160. * Removes the given lens flare system from this scene.
  116161. * @param toRemove The lens flare system to remove
  116162. * @returns The index of the removed lens flare system
  116163. */
  116164. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  116165. /**
  116166. * Adds the given lens flare system to this scene
  116167. * @param newLensFlareSystem The lens flare system to add
  116168. */
  116169. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  116170. /**
  116171. * Gets a lens flare system using its name
  116172. * @param name defines the name to look for
  116173. * @returns the lens flare system or null if not found
  116174. */
  116175. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  116176. /**
  116177. * Gets a lens flare system using its id
  116178. * @param id defines the id to look for
  116179. * @returns the lens flare system or null if not found
  116180. */
  116181. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  116182. }
  116183. /**
  116184. * Defines the lens flare scene component responsible to manage any lens flares
  116185. * in a given scene.
  116186. */
  116187. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  116188. /**
  116189. * The component name helpfull to identify the component in the list of scene components.
  116190. */
  116191. readonly name: string;
  116192. /**
  116193. * The scene the component belongs to.
  116194. */
  116195. scene: Scene;
  116196. /**
  116197. * Creates a new instance of the component for the given scene
  116198. * @param scene Defines the scene to register the component in
  116199. */
  116200. constructor(scene: Scene);
  116201. /**
  116202. * Registers the component in a given scene
  116203. */
  116204. register(): void;
  116205. /**
  116206. * Rebuilds the elements related to this component in case of
  116207. * context lost for instance.
  116208. */
  116209. rebuild(): void;
  116210. /**
  116211. * Adds all the elements from the container to the scene
  116212. * @param container the container holding the elements
  116213. */
  116214. addFromContainer(container: AbstractScene): void;
  116215. /**
  116216. * Removes all the elements in the container from the scene
  116217. * @param container contains the elements to remove
  116218. * @param dispose if the removed element should be disposed (default: false)
  116219. */
  116220. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116221. /**
  116222. * Serializes the component data to the specified json object
  116223. * @param serializationObject The object to serialize to
  116224. */
  116225. serialize(serializationObject: any): void;
  116226. /**
  116227. * Disposes the component and the associated ressources.
  116228. */
  116229. dispose(): void;
  116230. private _draw;
  116231. }
  116232. }
  116233. declare module BABYLON {
  116234. /**
  116235. * Defines the shadow generator component responsible to manage any shadow generators
  116236. * in a given scene.
  116237. */
  116238. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  116239. /**
  116240. * The component name helpfull to identify the component in the list of scene components.
  116241. */
  116242. readonly name: string;
  116243. /**
  116244. * The scene the component belongs to.
  116245. */
  116246. scene: Scene;
  116247. /**
  116248. * Creates a new instance of the component for the given scene
  116249. * @param scene Defines the scene to register the component in
  116250. */
  116251. constructor(scene: Scene);
  116252. /**
  116253. * Registers the component in a given scene
  116254. */
  116255. register(): void;
  116256. /**
  116257. * Rebuilds the elements related to this component in case of
  116258. * context lost for instance.
  116259. */
  116260. rebuild(): void;
  116261. /**
  116262. * Serializes the component data to the specified json object
  116263. * @param serializationObject The object to serialize to
  116264. */
  116265. serialize(serializationObject: any): void;
  116266. /**
  116267. * Adds all the elements from the container to the scene
  116268. * @param container the container holding the elements
  116269. */
  116270. addFromContainer(container: AbstractScene): void;
  116271. /**
  116272. * Removes all the elements in the container from the scene
  116273. * @param container contains the elements to remove
  116274. * @param dispose if the removed element should be disposed (default: false)
  116275. */
  116276. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116277. /**
  116278. * Rebuilds the elements related to this component in case of
  116279. * context lost for instance.
  116280. */
  116281. dispose(): void;
  116282. private _gatherRenderTargets;
  116283. }
  116284. }
  116285. declare module BABYLON {
  116286. /**
  116287. * A point light is a light defined by an unique point in world space.
  116288. * The light is emitted in every direction from this point.
  116289. * A good example of a point light is a standard light bulb.
  116290. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116291. */
  116292. export class PointLight extends ShadowLight {
  116293. private _shadowAngle;
  116294. /**
  116295. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116296. * This specifies what angle the shadow will use to be created.
  116297. *
  116298. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116299. */
  116300. /**
  116301. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116302. * This specifies what angle the shadow will use to be created.
  116303. *
  116304. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116305. */
  116306. shadowAngle: number;
  116307. /**
  116308. * Gets the direction if it has been set.
  116309. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116310. */
  116311. /**
  116312. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116313. */
  116314. direction: Vector3;
  116315. /**
  116316. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  116317. * A PointLight emits the light in every direction.
  116318. * It can cast shadows.
  116319. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  116320. * ```javascript
  116321. * var pointLight = new PointLight("pl", camera.position, scene);
  116322. * ```
  116323. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116324. * @param name The light friendly name
  116325. * @param position The position of the point light in the scene
  116326. * @param scene The scene the lights belongs to
  116327. */
  116328. constructor(name: string, position: Vector3, scene: Scene);
  116329. /**
  116330. * Returns the string "PointLight"
  116331. * @returns the class name
  116332. */
  116333. getClassName(): string;
  116334. /**
  116335. * Returns the integer 0.
  116336. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116337. */
  116338. getTypeID(): number;
  116339. /**
  116340. * Specifies wether or not the shadowmap should be a cube texture.
  116341. * @returns true if the shadowmap needs to be a cube texture.
  116342. */
  116343. needCube(): boolean;
  116344. /**
  116345. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  116346. * @param faceIndex The index of the face we are computed the direction to generate shadow
  116347. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  116348. */
  116349. getShadowDirection(faceIndex?: number): Vector3;
  116350. /**
  116351. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  116352. * - fov = PI / 2
  116353. * - aspect ratio : 1.0
  116354. * - z-near and far equal to the active camera minZ and maxZ.
  116355. * Returns the PointLight.
  116356. */
  116357. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116358. protected _buildUniformLayout(): void;
  116359. /**
  116360. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  116361. * @param effect The effect to update
  116362. * @param lightIndex The index of the light in the effect to update
  116363. * @returns The point light
  116364. */
  116365. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  116366. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116367. /**
  116368. * Prepares the list of defines specific to the light type.
  116369. * @param defines the list of defines
  116370. * @param lightIndex defines the index of the light for the effect
  116371. */
  116372. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116373. }
  116374. }
  116375. declare module BABYLON {
  116376. /**
  116377. * Header information of HDR texture files.
  116378. */
  116379. export interface HDRInfo {
  116380. /**
  116381. * The height of the texture in pixels.
  116382. */
  116383. height: number;
  116384. /**
  116385. * The width of the texture in pixels.
  116386. */
  116387. width: number;
  116388. /**
  116389. * The index of the beginning of the data in the binary file.
  116390. */
  116391. dataPosition: number;
  116392. }
  116393. /**
  116394. * This groups tools to convert HDR texture to native colors array.
  116395. */
  116396. export class HDRTools {
  116397. private static Ldexp;
  116398. private static Rgbe2float;
  116399. private static readStringLine;
  116400. /**
  116401. * Reads header information from an RGBE texture stored in a native array.
  116402. * More information on this format are available here:
  116403. * https://en.wikipedia.org/wiki/RGBE_image_format
  116404. *
  116405. * @param uint8array The binary file stored in native array.
  116406. * @return The header information.
  116407. */
  116408. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  116409. /**
  116410. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  116411. * This RGBE texture needs to store the information as a panorama.
  116412. *
  116413. * More information on this format are available here:
  116414. * https://en.wikipedia.org/wiki/RGBE_image_format
  116415. *
  116416. * @param buffer The binary file stored in an array buffer.
  116417. * @param size The expected size of the extracted cubemap.
  116418. * @return The Cube Map information.
  116419. */
  116420. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  116421. /**
  116422. * Returns the pixels data extracted from an RGBE texture.
  116423. * This pixels will be stored left to right up to down in the R G B order in one array.
  116424. *
  116425. * More information on this format are available here:
  116426. * https://en.wikipedia.org/wiki/RGBE_image_format
  116427. *
  116428. * @param uint8array The binary file stored in an array buffer.
  116429. * @param hdrInfo The header information of the file.
  116430. * @return The pixels data in RGB right to left up to down order.
  116431. */
  116432. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  116433. private static RGBE_ReadPixels_RLE;
  116434. }
  116435. }
  116436. declare module BABYLON {
  116437. /**
  116438. * This represents a texture coming from an HDR input.
  116439. *
  116440. * The only supported format is currently panorama picture stored in RGBE format.
  116441. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116442. */
  116443. export class HDRCubeTexture extends BaseTexture {
  116444. private static _facesMapping;
  116445. private _generateHarmonics;
  116446. private _noMipmap;
  116447. private _textureMatrix;
  116448. private _size;
  116449. private _onLoad;
  116450. private _onError;
  116451. /**
  116452. * The texture URL.
  116453. */
  116454. url: string;
  116455. /**
  116456. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116457. */
  116458. coordinatesMode: number;
  116459. protected _isBlocking: boolean;
  116460. /**
  116461. * Sets wether or not the texture is blocking during loading.
  116462. */
  116463. /**
  116464. * Gets wether or not the texture is blocking during loading.
  116465. */
  116466. isBlocking: boolean;
  116467. protected _rotationY: number;
  116468. /**
  116469. * Sets texture matrix rotation angle around Y axis in radians.
  116470. */
  116471. /**
  116472. * Gets texture matrix rotation angle around Y axis radians.
  116473. */
  116474. rotationY: number;
  116475. /**
  116476. * Gets or sets the center of the bounding box associated with the cube texture
  116477. * It must define where the camera used to render the texture was set
  116478. */
  116479. boundingBoxPosition: Vector3;
  116480. private _boundingBoxSize;
  116481. /**
  116482. * Gets or sets the size of the bounding box associated with the cube texture
  116483. * When defined, the cubemap will switch to local mode
  116484. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116485. * @example https://www.babylonjs-playground.com/#RNASML
  116486. */
  116487. boundingBoxSize: Vector3;
  116488. /**
  116489. * Instantiates an HDRTexture from the following parameters.
  116490. *
  116491. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116492. * @param scene The scene the texture will be used in
  116493. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116494. * @param noMipmap Forces to not generate the mipmap if true
  116495. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116496. * @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)
  116497. * @param reserved Reserved flag for internal use.
  116498. */
  116499. 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>);
  116500. /**
  116501. * Get the current class name of the texture useful for serialization or dynamic coding.
  116502. * @returns "HDRCubeTexture"
  116503. */
  116504. getClassName(): string;
  116505. /**
  116506. * Occurs when the file is raw .hdr file.
  116507. */
  116508. private loadTexture;
  116509. clone(): HDRCubeTexture;
  116510. delayLoad(): void;
  116511. /**
  116512. * Get the texture reflection matrix used to rotate/transform the reflection.
  116513. * @returns the reflection matrix
  116514. */
  116515. getReflectionTextureMatrix(): Matrix;
  116516. /**
  116517. * Set the texture reflection matrix used to rotate/transform the reflection.
  116518. * @param value Define the reflection matrix to set
  116519. */
  116520. setReflectionTextureMatrix(value: Matrix): void;
  116521. /**
  116522. * Parses a JSON representation of an HDR Texture in order to create the texture
  116523. * @param parsedTexture Define the JSON representation
  116524. * @param scene Define the scene the texture should be created in
  116525. * @param rootUrl Define the root url in case we need to load relative dependencies
  116526. * @returns the newly created texture after parsing
  116527. */
  116528. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116529. serialize(): any;
  116530. }
  116531. }
  116532. declare module BABYLON {
  116533. /**
  116534. * Class used to control physics engine
  116535. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116536. */
  116537. export class PhysicsEngine implements IPhysicsEngine {
  116538. private _physicsPlugin;
  116539. /**
  116540. * Global value used to control the smallest number supported by the simulation
  116541. */
  116542. static Epsilon: number;
  116543. private _impostors;
  116544. private _joints;
  116545. /**
  116546. * Gets the gravity vector used by the simulation
  116547. */
  116548. gravity: Vector3;
  116549. /**
  116550. * Factory used to create the default physics plugin.
  116551. * @returns The default physics plugin
  116552. */
  116553. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116554. /**
  116555. * Creates a new Physics Engine
  116556. * @param gravity defines the gravity vector used by the simulation
  116557. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116558. */
  116559. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116560. /**
  116561. * Sets the gravity vector used by the simulation
  116562. * @param gravity defines the gravity vector to use
  116563. */
  116564. setGravity(gravity: Vector3): void;
  116565. /**
  116566. * Set the time step of the physics engine.
  116567. * Default is 1/60.
  116568. * To slow it down, enter 1/600 for example.
  116569. * To speed it up, 1/30
  116570. * @param newTimeStep defines the new timestep to apply to this world.
  116571. */
  116572. setTimeStep(newTimeStep?: number): void;
  116573. /**
  116574. * Get the time step of the physics engine.
  116575. * @returns the current time step
  116576. */
  116577. getTimeStep(): number;
  116578. /**
  116579. * Release all resources
  116580. */
  116581. dispose(): void;
  116582. /**
  116583. * Gets the name of the current physics plugin
  116584. * @returns the name of the plugin
  116585. */
  116586. getPhysicsPluginName(): string;
  116587. /**
  116588. * Adding a new impostor for the impostor tracking.
  116589. * This will be done by the impostor itself.
  116590. * @param impostor the impostor to add
  116591. */
  116592. addImpostor(impostor: PhysicsImpostor): void;
  116593. /**
  116594. * Remove an impostor from the engine.
  116595. * This impostor and its mesh will not longer be updated by the physics engine.
  116596. * @param impostor the impostor to remove
  116597. */
  116598. removeImpostor(impostor: PhysicsImpostor): void;
  116599. /**
  116600. * Add a joint to the physics engine
  116601. * @param mainImpostor defines the main impostor to which the joint is added.
  116602. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116603. * @param joint defines the joint that will connect both impostors.
  116604. */
  116605. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116606. /**
  116607. * Removes a joint from the simulation
  116608. * @param mainImpostor defines the impostor used with the joint
  116609. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116610. * @param joint defines the joint to remove
  116611. */
  116612. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116613. /**
  116614. * Called by the scene. No need to call it.
  116615. * @param delta defines the timespam between frames
  116616. */
  116617. _step(delta: number): void;
  116618. /**
  116619. * Gets the current plugin used to run the simulation
  116620. * @returns current plugin
  116621. */
  116622. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116623. /**
  116624. * Gets the list of physic impostors
  116625. * @returns an array of PhysicsImpostor
  116626. */
  116627. getImpostors(): Array<PhysicsImpostor>;
  116628. /**
  116629. * Gets the impostor for a physics enabled object
  116630. * @param object defines the object impersonated by the impostor
  116631. * @returns the PhysicsImpostor or null if not found
  116632. */
  116633. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116634. /**
  116635. * Gets the impostor for a physics body object
  116636. * @param body defines physics body used by the impostor
  116637. * @returns the PhysicsImpostor or null if not found
  116638. */
  116639. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116640. /**
  116641. * Does a raycast in the physics world
  116642. * @param from when should the ray start?
  116643. * @param to when should the ray end?
  116644. * @returns PhysicsRaycastResult
  116645. */
  116646. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116647. }
  116648. }
  116649. declare module BABYLON {
  116650. /** @hidden */
  116651. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116652. private _useDeltaForWorldStep;
  116653. world: any;
  116654. name: string;
  116655. private _physicsMaterials;
  116656. private _fixedTimeStep;
  116657. private _cannonRaycastResult;
  116658. private _raycastResult;
  116659. private _physicsBodysToRemoveAfterStep;
  116660. BJSCANNON: any;
  116661. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116662. setGravity(gravity: Vector3): void;
  116663. setTimeStep(timeStep: number): void;
  116664. getTimeStep(): number;
  116665. executeStep(delta: number): void;
  116666. private _removeMarkedPhysicsBodiesFromWorld;
  116667. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116668. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116669. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116670. private _processChildMeshes;
  116671. removePhysicsBody(impostor: PhysicsImpostor): void;
  116672. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116673. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116674. private _addMaterial;
  116675. private _checkWithEpsilon;
  116676. private _createShape;
  116677. private _createHeightmap;
  116678. private _minus90X;
  116679. private _plus90X;
  116680. private _tmpPosition;
  116681. private _tmpDeltaPosition;
  116682. private _tmpUnityRotation;
  116683. private _updatePhysicsBodyTransformation;
  116684. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116685. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116686. isSupported(): boolean;
  116687. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116688. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116689. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116690. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116691. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116692. getBodyMass(impostor: PhysicsImpostor): number;
  116693. getBodyFriction(impostor: PhysicsImpostor): number;
  116694. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116695. getBodyRestitution(impostor: PhysicsImpostor): number;
  116696. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116697. sleepBody(impostor: PhysicsImpostor): void;
  116698. wakeUpBody(impostor: PhysicsImpostor): void;
  116699. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116700. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116701. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116702. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116703. getRadius(impostor: PhysicsImpostor): number;
  116704. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116705. dispose(): void;
  116706. private _extendNamespace;
  116707. /**
  116708. * Does a raycast in the physics world
  116709. * @param from when should the ray start?
  116710. * @param to when should the ray end?
  116711. * @returns PhysicsRaycastResult
  116712. */
  116713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116714. }
  116715. }
  116716. declare module BABYLON {
  116717. /** @hidden */
  116718. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116719. world: any;
  116720. name: string;
  116721. BJSOIMO: any;
  116722. private _raycastResult;
  116723. constructor(iterations?: number, oimoInjection?: any);
  116724. setGravity(gravity: Vector3): void;
  116725. setTimeStep(timeStep: number): void;
  116726. getTimeStep(): number;
  116727. private _tmpImpostorsArray;
  116728. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116729. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116730. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116731. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116732. private _tmpPositionVector;
  116733. removePhysicsBody(impostor: PhysicsImpostor): void;
  116734. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116735. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116736. isSupported(): boolean;
  116737. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116738. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116739. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116740. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116741. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116742. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116743. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116744. getBodyMass(impostor: PhysicsImpostor): number;
  116745. getBodyFriction(impostor: PhysicsImpostor): number;
  116746. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116747. getBodyRestitution(impostor: PhysicsImpostor): number;
  116748. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116749. sleepBody(impostor: PhysicsImpostor): void;
  116750. wakeUpBody(impostor: PhysicsImpostor): void;
  116751. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116752. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116753. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116754. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116755. getRadius(impostor: PhysicsImpostor): number;
  116756. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116757. dispose(): void;
  116758. /**
  116759. * Does a raycast in the physics world
  116760. * @param from when should the ray start?
  116761. * @param to when should the ray end?
  116762. * @returns PhysicsRaycastResult
  116763. */
  116764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116765. }
  116766. }
  116767. declare module BABYLON {
  116768. /**
  116769. * Class containing static functions to help procedurally build meshes
  116770. */
  116771. export class RibbonBuilder {
  116772. /**
  116773. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116774. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116775. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116776. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116777. * * 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
  116778. * * 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
  116779. * * 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
  116780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116783. * * 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
  116784. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116785. * * 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
  116786. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116788. * @param name defines the name of the mesh
  116789. * @param options defines the options used to create the mesh
  116790. * @param scene defines the hosting scene
  116791. * @returns the ribbon mesh
  116792. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116794. */
  116795. static CreateRibbon(name: string, options: {
  116796. pathArray: Vector3[][];
  116797. closeArray?: boolean;
  116798. closePath?: boolean;
  116799. offset?: number;
  116800. updatable?: boolean;
  116801. sideOrientation?: number;
  116802. frontUVs?: Vector4;
  116803. backUVs?: Vector4;
  116804. instance?: Mesh;
  116805. invertUV?: boolean;
  116806. uvs?: Vector2[];
  116807. colors?: Color4[];
  116808. }, scene?: Nullable<Scene>): Mesh;
  116809. }
  116810. }
  116811. declare module BABYLON {
  116812. /**
  116813. * Class containing static functions to help procedurally build meshes
  116814. */
  116815. export class ShapeBuilder {
  116816. /**
  116817. * 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.
  116818. * * 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.
  116819. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116820. * * 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.
  116821. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116822. * * 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
  116823. * * 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
  116824. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116829. * @param name defines the name of the mesh
  116830. * @param options defines the options used to create the mesh
  116831. * @param scene defines the hosting scene
  116832. * @returns the extruded shape mesh
  116833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116835. */
  116836. static ExtrudeShape(name: string, options: {
  116837. shape: Vector3[];
  116838. path: Vector3[];
  116839. scale?: number;
  116840. rotation?: number;
  116841. cap?: number;
  116842. updatable?: boolean;
  116843. sideOrientation?: number;
  116844. frontUVs?: Vector4;
  116845. backUVs?: Vector4;
  116846. instance?: Mesh;
  116847. invertUV?: boolean;
  116848. }, scene?: Nullable<Scene>): Mesh;
  116849. /**
  116850. * Creates an custom extruded shape mesh.
  116851. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116852. * * 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.
  116853. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116854. * * 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
  116855. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116856. * * 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
  116857. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116858. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116859. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116860. * * 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
  116861. * * 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
  116862. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116867. * @param name defines the name of the mesh
  116868. * @param options defines the options used to create the mesh
  116869. * @param scene defines the hosting scene
  116870. * @returns the custom extruded shape mesh
  116871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116874. */
  116875. static ExtrudeShapeCustom(name: string, options: {
  116876. shape: Vector3[];
  116877. path: Vector3[];
  116878. scaleFunction?: any;
  116879. rotationFunction?: any;
  116880. ribbonCloseArray?: boolean;
  116881. ribbonClosePath?: boolean;
  116882. cap?: number;
  116883. updatable?: boolean;
  116884. sideOrientation?: number;
  116885. frontUVs?: Vector4;
  116886. backUVs?: Vector4;
  116887. instance?: Mesh;
  116888. invertUV?: boolean;
  116889. }, scene?: Nullable<Scene>): Mesh;
  116890. private static _ExtrudeShapeGeneric;
  116891. }
  116892. }
  116893. declare module BABYLON {
  116894. /**
  116895. * AmmoJS Physics plugin
  116896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116897. * @see https://github.com/kripken/ammo.js/
  116898. */
  116899. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116900. private _useDeltaForWorldStep;
  116901. /**
  116902. * Reference to the Ammo library
  116903. */
  116904. bjsAMMO: any;
  116905. /**
  116906. * Created ammoJS world which physics bodies are added to
  116907. */
  116908. world: any;
  116909. /**
  116910. * Name of the plugin
  116911. */
  116912. name: string;
  116913. private _timeStep;
  116914. private _fixedTimeStep;
  116915. private _maxSteps;
  116916. private _tmpQuaternion;
  116917. private _tmpAmmoTransform;
  116918. private _tmpAmmoQuaternion;
  116919. private _tmpAmmoConcreteContactResultCallback;
  116920. private _collisionConfiguration;
  116921. private _dispatcher;
  116922. private _overlappingPairCache;
  116923. private _solver;
  116924. private _softBodySolver;
  116925. private _tmpAmmoVectorA;
  116926. private _tmpAmmoVectorB;
  116927. private _tmpAmmoVectorC;
  116928. private _tmpAmmoVectorD;
  116929. private _tmpContactCallbackResult;
  116930. private _tmpAmmoVectorRCA;
  116931. private _tmpAmmoVectorRCB;
  116932. private _raycastResult;
  116933. private static readonly DISABLE_COLLISION_FLAG;
  116934. private static readonly KINEMATIC_FLAG;
  116935. private static readonly DISABLE_DEACTIVATION_FLAG;
  116936. /**
  116937. * Initializes the ammoJS plugin
  116938. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116939. * @param ammoInjection can be used to inject your own ammo reference
  116940. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116941. */
  116942. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116943. /**
  116944. * Sets the gravity of the physics world (m/(s^2))
  116945. * @param gravity Gravity to set
  116946. */
  116947. setGravity(gravity: Vector3): void;
  116948. /**
  116949. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116950. * @param timeStep timestep to use in seconds
  116951. */
  116952. setTimeStep(timeStep: number): void;
  116953. /**
  116954. * 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)
  116955. * @param fixedTimeStep fixedTimeStep to use in seconds
  116956. */
  116957. setFixedTimeStep(fixedTimeStep: number): void;
  116958. /**
  116959. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116960. * @param maxSteps the maximum number of steps by the physics engine per frame
  116961. */
  116962. setMaxSteps(maxSteps: number): void;
  116963. /**
  116964. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116965. * @returns the current timestep in seconds
  116966. */
  116967. getTimeStep(): number;
  116968. private _isImpostorInContact;
  116969. private _isImpostorPairInContact;
  116970. private _stepSimulation;
  116971. /**
  116972. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116973. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116974. * After the step the babylon meshes are set to the position of the physics imposters
  116975. * @param delta amount of time to step forward
  116976. * @param impostors array of imposters to update before/after the step
  116977. */
  116978. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116979. /**
  116980. * Update babylon mesh to match physics world object
  116981. * @param impostor imposter to match
  116982. */
  116983. private _afterSoftStep;
  116984. /**
  116985. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116986. * @param impostor imposter to match
  116987. */
  116988. private _ropeStep;
  116989. /**
  116990. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116991. * @param impostor imposter to match
  116992. */
  116993. private _softbodyOrClothStep;
  116994. private _tmpVector;
  116995. private _tmpMatrix;
  116996. /**
  116997. * Applies an impulse on the imposter
  116998. * @param impostor imposter to apply impulse to
  116999. * @param force amount of force to be applied to the imposter
  117000. * @param contactPoint the location to apply the impulse on the imposter
  117001. */
  117002. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117003. /**
  117004. * Applies a force on the imposter
  117005. * @param impostor imposter to apply force
  117006. * @param force amount of force to be applied to the imposter
  117007. * @param contactPoint the location to apply the force on the imposter
  117008. */
  117009. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117010. /**
  117011. * Creates a physics body using the plugin
  117012. * @param impostor the imposter to create the physics body on
  117013. */
  117014. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117015. /**
  117016. * Removes the physics body from the imposter and disposes of the body's memory
  117017. * @param impostor imposter to remove the physics body from
  117018. */
  117019. removePhysicsBody(impostor: PhysicsImpostor): void;
  117020. /**
  117021. * Generates a joint
  117022. * @param impostorJoint the imposter joint to create the joint with
  117023. */
  117024. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117025. /**
  117026. * Removes a joint
  117027. * @param impostorJoint the imposter joint to remove the joint from
  117028. */
  117029. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117030. private _addMeshVerts;
  117031. /**
  117032. * Initialise the soft body vertices to match its object's (mesh) vertices
  117033. * Softbody vertices (nodes) are in world space and to match this
  117034. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  117035. * @param impostor to create the softbody for
  117036. */
  117037. private _softVertexData;
  117038. /**
  117039. * Create an impostor's soft body
  117040. * @param impostor to create the softbody for
  117041. */
  117042. private _createSoftbody;
  117043. /**
  117044. * Create cloth for an impostor
  117045. * @param impostor to create the softbody for
  117046. */
  117047. private _createCloth;
  117048. /**
  117049. * Create rope for an impostor
  117050. * @param impostor to create the softbody for
  117051. */
  117052. private _createRope;
  117053. private _addHullVerts;
  117054. private _createShape;
  117055. /**
  117056. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  117057. * @param impostor imposter containing the physics body and babylon object
  117058. */
  117059. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117060. /**
  117061. * Sets the babylon object's position/rotation from the physics body's position/rotation
  117062. * @param impostor imposter containing the physics body and babylon object
  117063. * @param newPosition new position
  117064. * @param newRotation new rotation
  117065. */
  117066. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117067. /**
  117068. * If this plugin is supported
  117069. * @returns true if its supported
  117070. */
  117071. isSupported(): boolean;
  117072. /**
  117073. * Sets the linear velocity of the physics body
  117074. * @param impostor imposter to set the velocity on
  117075. * @param velocity velocity to set
  117076. */
  117077. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117078. /**
  117079. * Sets the angular velocity of the physics body
  117080. * @param impostor imposter to set the velocity on
  117081. * @param velocity velocity to set
  117082. */
  117083. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117084. /**
  117085. * gets the linear velocity
  117086. * @param impostor imposter to get linear velocity from
  117087. * @returns linear velocity
  117088. */
  117089. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117090. /**
  117091. * gets the angular velocity
  117092. * @param impostor imposter to get angular velocity from
  117093. * @returns angular velocity
  117094. */
  117095. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117096. /**
  117097. * Sets the mass of physics body
  117098. * @param impostor imposter to set the mass on
  117099. * @param mass mass to set
  117100. */
  117101. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117102. /**
  117103. * Gets the mass of the physics body
  117104. * @param impostor imposter to get the mass from
  117105. * @returns mass
  117106. */
  117107. getBodyMass(impostor: PhysicsImpostor): number;
  117108. /**
  117109. * Gets friction of the impostor
  117110. * @param impostor impostor to get friction from
  117111. * @returns friction value
  117112. */
  117113. getBodyFriction(impostor: PhysicsImpostor): number;
  117114. /**
  117115. * Sets friction of the impostor
  117116. * @param impostor impostor to set friction on
  117117. * @param friction friction value
  117118. */
  117119. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117120. /**
  117121. * Gets restitution of the impostor
  117122. * @param impostor impostor to get restitution from
  117123. * @returns restitution value
  117124. */
  117125. getBodyRestitution(impostor: PhysicsImpostor): number;
  117126. /**
  117127. * Sets resitution of the impostor
  117128. * @param impostor impostor to set resitution on
  117129. * @param restitution resitution value
  117130. */
  117131. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117132. /**
  117133. * Gets pressure inside the impostor
  117134. * @param impostor impostor to get pressure from
  117135. * @returns pressure value
  117136. */
  117137. getBodyPressure(impostor: PhysicsImpostor): number;
  117138. /**
  117139. * Sets pressure inside a soft body impostor
  117140. * Cloth and rope must remain 0 pressure
  117141. * @param impostor impostor to set pressure on
  117142. * @param pressure pressure value
  117143. */
  117144. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  117145. /**
  117146. * Gets stiffness of the impostor
  117147. * @param impostor impostor to get stiffness from
  117148. * @returns pressure value
  117149. */
  117150. getBodyStiffness(impostor: PhysicsImpostor): number;
  117151. /**
  117152. * Sets stiffness of the impostor
  117153. * @param impostor impostor to set stiffness on
  117154. * @param stiffness stiffness value from 0 to 1
  117155. */
  117156. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  117157. /**
  117158. * Gets velocityIterations of the impostor
  117159. * @param impostor impostor to get velocity iterations from
  117160. * @returns velocityIterations value
  117161. */
  117162. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  117163. /**
  117164. * Sets velocityIterations of the impostor
  117165. * @param impostor impostor to set velocity iterations on
  117166. * @param velocityIterations velocityIterations value
  117167. */
  117168. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  117169. /**
  117170. * Gets positionIterations of the impostor
  117171. * @param impostor impostor to get position iterations from
  117172. * @returns positionIterations value
  117173. */
  117174. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  117175. /**
  117176. * Sets positionIterations of the impostor
  117177. * @param impostor impostor to set position on
  117178. * @param positionIterations positionIterations value
  117179. */
  117180. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  117181. /**
  117182. * Append an anchor to a cloth object
  117183. * @param impostor is the cloth impostor to add anchor to
  117184. * @param otherImpostor is the rigid impostor to anchor to
  117185. * @param width ratio across width from 0 to 1
  117186. * @param height ratio up height from 0 to 1
  117187. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117188. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117189. */
  117190. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  117191. /**
  117192. * Append an hook to a rope object
  117193. * @param impostor is the rope impostor to add hook to
  117194. * @param otherImpostor is the rigid impostor to hook to
  117195. * @param length ratio along the rope from 0 to 1
  117196. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  117197. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117198. */
  117199. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  117200. /**
  117201. * Sleeps the physics body and stops it from being active
  117202. * @param impostor impostor to sleep
  117203. */
  117204. sleepBody(impostor: PhysicsImpostor): void;
  117205. /**
  117206. * Activates the physics body
  117207. * @param impostor impostor to activate
  117208. */
  117209. wakeUpBody(impostor: PhysicsImpostor): void;
  117210. /**
  117211. * Updates the distance parameters of the joint
  117212. * @param joint joint to update
  117213. * @param maxDistance maximum distance of the joint
  117214. * @param minDistance minimum distance of the joint
  117215. */
  117216. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117217. /**
  117218. * Sets a motor on the joint
  117219. * @param joint joint to set motor on
  117220. * @param speed speed of the motor
  117221. * @param maxForce maximum force of the motor
  117222. * @param motorIndex index of the motor
  117223. */
  117224. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117225. /**
  117226. * Sets the motors limit
  117227. * @param joint joint to set limit on
  117228. * @param upperLimit upper limit
  117229. * @param lowerLimit lower limit
  117230. */
  117231. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117232. /**
  117233. * Syncs the position and rotation of a mesh with the impostor
  117234. * @param mesh mesh to sync
  117235. * @param impostor impostor to update the mesh with
  117236. */
  117237. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117238. /**
  117239. * Gets the radius of the impostor
  117240. * @param impostor impostor to get radius from
  117241. * @returns the radius
  117242. */
  117243. getRadius(impostor: PhysicsImpostor): number;
  117244. /**
  117245. * Gets the box size of the impostor
  117246. * @param impostor impostor to get box size from
  117247. * @param result the resulting box size
  117248. */
  117249. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117250. /**
  117251. * Disposes of the impostor
  117252. */
  117253. dispose(): void;
  117254. /**
  117255. * Does a raycast in the physics world
  117256. * @param from when should the ray start?
  117257. * @param to when should the ray end?
  117258. * @returns PhysicsRaycastResult
  117259. */
  117260. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117261. }
  117262. }
  117263. declare module BABYLON {
  117264. interface AbstractScene {
  117265. /**
  117266. * The list of reflection probes added to the scene
  117267. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  117268. */
  117269. reflectionProbes: Array<ReflectionProbe>;
  117270. /**
  117271. * Removes the given reflection probe from this scene.
  117272. * @param toRemove The reflection probe to remove
  117273. * @returns The index of the removed reflection probe
  117274. */
  117275. removeReflectionProbe(toRemove: ReflectionProbe): number;
  117276. /**
  117277. * Adds the given reflection probe to this scene.
  117278. * @param newReflectionProbe The reflection probe to add
  117279. */
  117280. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  117281. }
  117282. /**
  117283. * Class used to generate realtime reflection / refraction cube textures
  117284. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  117285. */
  117286. export class ReflectionProbe {
  117287. /** defines the name of the probe */
  117288. name: string;
  117289. private _scene;
  117290. private _renderTargetTexture;
  117291. private _projectionMatrix;
  117292. private _viewMatrix;
  117293. private _target;
  117294. private _add;
  117295. private _attachedMesh;
  117296. private _invertYAxis;
  117297. /** Gets or sets probe position (center of the cube map) */
  117298. position: Vector3;
  117299. /**
  117300. * Creates a new reflection probe
  117301. * @param name defines the name of the probe
  117302. * @param size defines the texture resolution (for each face)
  117303. * @param scene defines the hosting scene
  117304. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  117305. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  117306. */
  117307. constructor(
  117308. /** defines the name of the probe */
  117309. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  117310. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  117311. samples: number;
  117312. /** Gets or sets the refresh rate to use (on every frame by default) */
  117313. refreshRate: number;
  117314. /**
  117315. * Gets the hosting scene
  117316. * @returns a Scene
  117317. */
  117318. getScene(): Scene;
  117319. /** Gets the internal CubeTexture used to render to */
  117320. readonly cubeTexture: RenderTargetTexture;
  117321. /** Gets the list of meshes to render */
  117322. readonly renderList: Nullable<AbstractMesh[]>;
  117323. /**
  117324. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  117325. * @param mesh defines the mesh to attach to
  117326. */
  117327. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  117328. /**
  117329. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  117330. * @param renderingGroupId The rendering group id corresponding to its index
  117331. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117332. */
  117333. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  117334. /**
  117335. * Clean all associated resources
  117336. */
  117337. dispose(): void;
  117338. /**
  117339. * Converts the reflection probe information to a readable string for debug purpose.
  117340. * @param fullDetails Supports for multiple levels of logging within scene loading
  117341. * @returns the human readable reflection probe info
  117342. */
  117343. toString(fullDetails?: boolean): string;
  117344. /**
  117345. * Get the class name of the relfection probe.
  117346. * @returns "ReflectionProbe"
  117347. */
  117348. getClassName(): string;
  117349. /**
  117350. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  117351. * @returns The JSON representation of the texture
  117352. */
  117353. serialize(): any;
  117354. /**
  117355. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  117356. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  117357. * @param scene Define the scene the parsed reflection probe should be instantiated in
  117358. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  117359. * @returns The parsed reflection probe if successful
  117360. */
  117361. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  117362. }
  117363. }
  117364. declare module BABYLON {
  117365. /** @hidden */
  117366. export var _BabylonLoaderRegistered: boolean;
  117367. }
  117368. declare module BABYLON {
  117369. /**
  117370. * The Physically based simple base material of BJS.
  117371. *
  117372. * This enables better naming and convention enforcements on top of the pbrMaterial.
  117373. * It is used as the base class for both the specGloss and metalRough conventions.
  117374. */
  117375. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  117376. /**
  117377. * Number of Simultaneous lights allowed on the material.
  117378. */
  117379. maxSimultaneousLights: number;
  117380. /**
  117381. * If sets to true, disables all the lights affecting the material.
  117382. */
  117383. disableLighting: boolean;
  117384. /**
  117385. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  117386. */
  117387. environmentTexture: BaseTexture;
  117388. /**
  117389. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117390. */
  117391. invertNormalMapX: boolean;
  117392. /**
  117393. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117394. */
  117395. invertNormalMapY: boolean;
  117396. /**
  117397. * Normal map used in the model.
  117398. */
  117399. normalTexture: BaseTexture;
  117400. /**
  117401. * Emissivie color used to self-illuminate the model.
  117402. */
  117403. emissiveColor: Color3;
  117404. /**
  117405. * Emissivie texture used to self-illuminate the model.
  117406. */
  117407. emissiveTexture: BaseTexture;
  117408. /**
  117409. * Occlusion Channel Strenght.
  117410. */
  117411. occlusionStrength: number;
  117412. /**
  117413. * Occlusion Texture of the material (adding extra occlusion effects).
  117414. */
  117415. occlusionTexture: BaseTexture;
  117416. /**
  117417. * Defines the alpha limits in alpha test mode.
  117418. */
  117419. alphaCutOff: number;
  117420. /**
  117421. * Gets the current double sided mode.
  117422. */
  117423. /**
  117424. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117425. */
  117426. doubleSided: boolean;
  117427. /**
  117428. * Stores the pre-calculated light information of a mesh in a texture.
  117429. */
  117430. lightmapTexture: BaseTexture;
  117431. /**
  117432. * If true, the light map contains occlusion information instead of lighting info.
  117433. */
  117434. useLightmapAsShadowmap: boolean;
  117435. /**
  117436. * Instantiates a new PBRMaterial instance.
  117437. *
  117438. * @param name The material name
  117439. * @param scene The scene the material will be use in.
  117440. */
  117441. constructor(name: string, scene: Scene);
  117442. getClassName(): string;
  117443. }
  117444. }
  117445. declare module BABYLON {
  117446. /**
  117447. * The PBR material of BJS following the metal roughness convention.
  117448. *
  117449. * This fits to the PBR convention in the GLTF definition:
  117450. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117451. */
  117452. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117453. /**
  117454. * The base color has two different interpretations depending on the value of metalness.
  117455. * When the material is a metal, the base color is the specific measured reflectance value
  117456. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117457. * of the material.
  117458. */
  117459. baseColor: Color3;
  117460. /**
  117461. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117462. * well as opacity information in the alpha channel.
  117463. */
  117464. baseTexture: BaseTexture;
  117465. /**
  117466. * Specifies the metallic scalar value of the material.
  117467. * Can also be used to scale the metalness values of the metallic texture.
  117468. */
  117469. metallic: number;
  117470. /**
  117471. * Specifies the roughness scalar value of the material.
  117472. * Can also be used to scale the roughness values of the metallic texture.
  117473. */
  117474. roughness: number;
  117475. /**
  117476. * Texture containing both the metallic value in the B channel and the
  117477. * roughness value in the G channel to keep better precision.
  117478. */
  117479. metallicRoughnessTexture: BaseTexture;
  117480. /**
  117481. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117482. *
  117483. * @param name The material name
  117484. * @param scene The scene the material will be use in.
  117485. */
  117486. constructor(name: string, scene: Scene);
  117487. /**
  117488. * Return the currrent class name of the material.
  117489. */
  117490. getClassName(): string;
  117491. /**
  117492. * Makes a duplicate of the current material.
  117493. * @param name - name to use for the new material.
  117494. */
  117495. clone(name: string): PBRMetallicRoughnessMaterial;
  117496. /**
  117497. * Serialize the material to a parsable JSON object.
  117498. */
  117499. serialize(): any;
  117500. /**
  117501. * Parses a JSON object correponding to the serialize function.
  117502. */
  117503. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117504. }
  117505. }
  117506. declare module BABYLON {
  117507. /**
  117508. * The PBR material of BJS following the specular glossiness convention.
  117509. *
  117510. * This fits to the PBR convention in the GLTF definition:
  117511. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117512. */
  117513. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117514. /**
  117515. * Specifies the diffuse color of the material.
  117516. */
  117517. diffuseColor: Color3;
  117518. /**
  117519. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117520. * channel.
  117521. */
  117522. diffuseTexture: BaseTexture;
  117523. /**
  117524. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117525. */
  117526. specularColor: Color3;
  117527. /**
  117528. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117529. */
  117530. glossiness: number;
  117531. /**
  117532. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117533. */
  117534. specularGlossinessTexture: BaseTexture;
  117535. /**
  117536. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117537. *
  117538. * @param name The material name
  117539. * @param scene The scene the material will be use in.
  117540. */
  117541. constructor(name: string, scene: Scene);
  117542. /**
  117543. * Return the currrent class name of the material.
  117544. */
  117545. getClassName(): string;
  117546. /**
  117547. * Makes a duplicate of the current material.
  117548. * @param name - name to use for the new material.
  117549. */
  117550. clone(name: string): PBRSpecularGlossinessMaterial;
  117551. /**
  117552. * Serialize the material to a parsable JSON object.
  117553. */
  117554. serialize(): any;
  117555. /**
  117556. * Parses a JSON object correponding to the serialize function.
  117557. */
  117558. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117559. }
  117560. }
  117561. declare module BABYLON {
  117562. /**
  117563. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117564. * It can help converting any input color in a desired output one. This can then be used to create effects
  117565. * from sepia, black and white to sixties or futuristic rendering...
  117566. *
  117567. * The only supported format is currently 3dl.
  117568. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117569. */
  117570. export class ColorGradingTexture extends BaseTexture {
  117571. /**
  117572. * The current texture matrix. (will always be identity in color grading texture)
  117573. */
  117574. private _textureMatrix;
  117575. /**
  117576. * The texture URL.
  117577. */
  117578. url: string;
  117579. /**
  117580. * Empty line regex stored for GC.
  117581. */
  117582. private static _noneEmptyLineRegex;
  117583. private _engine;
  117584. /**
  117585. * Instantiates a ColorGradingTexture from the following parameters.
  117586. *
  117587. * @param url The location of the color gradind data (currently only supporting 3dl)
  117588. * @param scene The scene the texture will be used in
  117589. */
  117590. constructor(url: string, scene: Scene);
  117591. /**
  117592. * Returns the texture matrix used in most of the material.
  117593. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117594. */
  117595. getTextureMatrix(): Matrix;
  117596. /**
  117597. * Occurs when the file being loaded is a .3dl LUT file.
  117598. */
  117599. private load3dlTexture;
  117600. /**
  117601. * Starts the loading process of the texture.
  117602. */
  117603. private loadTexture;
  117604. /**
  117605. * Clones the color gradind texture.
  117606. */
  117607. clone(): ColorGradingTexture;
  117608. /**
  117609. * Called during delayed load for textures.
  117610. */
  117611. delayLoad(): void;
  117612. /**
  117613. * Parses a color grading texture serialized by Babylon.
  117614. * @param parsedTexture The texture information being parsedTexture
  117615. * @param scene The scene to load the texture in
  117616. * @param rootUrl The root url of the data assets to load
  117617. * @return A color gradind texture
  117618. */
  117619. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117620. /**
  117621. * Serializes the LUT texture to json format.
  117622. */
  117623. serialize(): any;
  117624. }
  117625. }
  117626. declare module BABYLON {
  117627. /**
  117628. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117629. */
  117630. export class EquiRectangularCubeTexture extends BaseTexture {
  117631. /** The six faces of the cube. */
  117632. private static _FacesMapping;
  117633. private _noMipmap;
  117634. private _onLoad;
  117635. private _onError;
  117636. /** The size of the cubemap. */
  117637. private _size;
  117638. /** The buffer of the image. */
  117639. private _buffer;
  117640. /** The width of the input image. */
  117641. private _width;
  117642. /** The height of the input image. */
  117643. private _height;
  117644. /** The URL to the image. */
  117645. url: string;
  117646. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117647. coordinatesMode: number;
  117648. /**
  117649. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117650. * @param url The location of the image
  117651. * @param scene The scene the texture will be used in
  117652. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117653. * @param noMipmap Forces to not generate the mipmap if true
  117654. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117655. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117656. * @param onLoad — defines a callback called when texture is loaded
  117657. * @param onError — defines a callback called if there is an error
  117658. */
  117659. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117660. /**
  117661. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117662. */
  117663. private loadImage;
  117664. /**
  117665. * Convert the image buffer into a cubemap and create a CubeTexture.
  117666. */
  117667. private loadTexture;
  117668. /**
  117669. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117670. * @param buffer The ArrayBuffer that should be converted.
  117671. * @returns The buffer as Float32Array.
  117672. */
  117673. private getFloat32ArrayFromArrayBuffer;
  117674. /**
  117675. * Get the current class name of the texture useful for serialization or dynamic coding.
  117676. * @returns "EquiRectangularCubeTexture"
  117677. */
  117678. getClassName(): string;
  117679. /**
  117680. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117681. * @returns A clone of the current EquiRectangularCubeTexture.
  117682. */
  117683. clone(): EquiRectangularCubeTexture;
  117684. }
  117685. }
  117686. declare module BABYLON {
  117687. /**
  117688. * Based on jsTGALoader - Javascript loader for TGA file
  117689. * By Vincent Thibault
  117690. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117691. */
  117692. export class TGATools {
  117693. private static _TYPE_INDEXED;
  117694. private static _TYPE_RGB;
  117695. private static _TYPE_GREY;
  117696. private static _TYPE_RLE_INDEXED;
  117697. private static _TYPE_RLE_RGB;
  117698. private static _TYPE_RLE_GREY;
  117699. private static _ORIGIN_MASK;
  117700. private static _ORIGIN_SHIFT;
  117701. private static _ORIGIN_BL;
  117702. private static _ORIGIN_BR;
  117703. private static _ORIGIN_UL;
  117704. private static _ORIGIN_UR;
  117705. /**
  117706. * Gets the header of a TGA file
  117707. * @param data defines the TGA data
  117708. * @returns the header
  117709. */
  117710. static GetTGAHeader(data: Uint8Array): any;
  117711. /**
  117712. * Uploads TGA content to a Babylon Texture
  117713. * @hidden
  117714. */
  117715. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117716. /** @hidden */
  117717. 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;
  117718. /** @hidden */
  117719. 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;
  117720. /** @hidden */
  117721. 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;
  117722. /** @hidden */
  117723. 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;
  117724. /** @hidden */
  117725. 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;
  117726. /** @hidden */
  117727. 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;
  117728. }
  117729. }
  117730. declare module BABYLON {
  117731. /**
  117732. * Implementation of the TGA Texture Loader.
  117733. * @hidden
  117734. */
  117735. export class _TGATextureLoader implements IInternalTextureLoader {
  117736. /**
  117737. * Defines wether the loader supports cascade loading the different faces.
  117738. */
  117739. readonly supportCascades: boolean;
  117740. /**
  117741. * This returns if the loader support the current file information.
  117742. * @param extension defines the file extension of the file being loaded
  117743. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117744. * @param fallback defines the fallback internal texture if any
  117745. * @param isBase64 defines whether the texture is encoded as a base64
  117746. * @param isBuffer defines whether the texture data are stored as a buffer
  117747. * @returns true if the loader can load the specified file
  117748. */
  117749. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117750. /**
  117751. * Transform the url before loading if required.
  117752. * @param rootUrl the url of the texture
  117753. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117754. * @returns the transformed texture
  117755. */
  117756. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117757. /**
  117758. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117759. * @param rootUrl the url of the texture
  117760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117761. * @returns the fallback texture
  117762. */
  117763. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117764. /**
  117765. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117766. * @param data contains the texture data
  117767. * @param texture defines the BabylonJS internal texture
  117768. * @param createPolynomials will be true if polynomials have been requested
  117769. * @param onLoad defines the callback to trigger once the texture is ready
  117770. * @param onError defines the callback to trigger in case of error
  117771. */
  117772. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117773. /**
  117774. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117775. * @param data contains the texture data
  117776. * @param texture defines the BabylonJS internal texture
  117777. * @param callback defines the method to call once ready to upload
  117778. */
  117779. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117780. }
  117781. }
  117782. declare module BABYLON {
  117783. /**
  117784. * Info about the .basis files
  117785. */
  117786. class BasisFileInfo {
  117787. /**
  117788. * If the file has alpha
  117789. */
  117790. hasAlpha: boolean;
  117791. /**
  117792. * Info about each image of the basis file
  117793. */
  117794. images: Array<{
  117795. levels: Array<{
  117796. width: number;
  117797. height: number;
  117798. transcodedPixels: ArrayBufferView;
  117799. }>;
  117800. }>;
  117801. }
  117802. /**
  117803. * Result of transcoding a basis file
  117804. */
  117805. class TranscodeResult {
  117806. /**
  117807. * Info about the .basis file
  117808. */
  117809. fileInfo: BasisFileInfo;
  117810. /**
  117811. * Format to use when loading the file
  117812. */
  117813. format: number;
  117814. }
  117815. /**
  117816. * Configuration options for the Basis transcoder
  117817. */
  117818. export class BasisTranscodeConfiguration {
  117819. /**
  117820. * Supported compression formats used to determine the supported output format of the transcoder
  117821. */
  117822. supportedCompressionFormats?: {
  117823. /**
  117824. * etc1 compression format
  117825. */
  117826. etc1?: boolean;
  117827. /**
  117828. * s3tc compression format
  117829. */
  117830. s3tc?: boolean;
  117831. /**
  117832. * pvrtc compression format
  117833. */
  117834. pvrtc?: boolean;
  117835. /**
  117836. * etc2 compression format
  117837. */
  117838. etc2?: boolean;
  117839. };
  117840. /**
  117841. * If mipmap levels should be loaded for transcoded images (Default: true)
  117842. */
  117843. loadMipmapLevels?: boolean;
  117844. /**
  117845. * Index of a single image to load (Default: all images)
  117846. */
  117847. loadSingleImage?: number;
  117848. }
  117849. /**
  117850. * Used to load .Basis files
  117851. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117852. */
  117853. export class BasisTools {
  117854. private static _IgnoreSupportedFormats;
  117855. /**
  117856. * URL to use when loading the basis transcoder
  117857. */
  117858. static JSModuleURL: string;
  117859. /**
  117860. * URL to use when loading the wasm module for the transcoder
  117861. */
  117862. static WasmModuleURL: string;
  117863. /**
  117864. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117865. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117866. * @returns internal format corresponding to the Basis format
  117867. */
  117868. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117869. private static _WorkerPromise;
  117870. private static _Worker;
  117871. private static _actionId;
  117872. private static _CreateWorkerAsync;
  117873. /**
  117874. * Transcodes a loaded image file to compressed pixel data
  117875. * @param imageData image data to transcode
  117876. * @param config configuration options for the transcoding
  117877. * @returns a promise resulting in the transcoded image
  117878. */
  117879. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117880. /**
  117881. * Loads a texture from the transcode result
  117882. * @param texture texture load to
  117883. * @param transcodeResult the result of transcoding the basis file to load from
  117884. */
  117885. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117886. }
  117887. }
  117888. declare module BABYLON {
  117889. /**
  117890. * Loader for .basis file format
  117891. */
  117892. export class _BasisTextureLoader implements IInternalTextureLoader {
  117893. /**
  117894. * Defines whether the loader supports cascade loading the different faces.
  117895. */
  117896. readonly supportCascades: boolean;
  117897. /**
  117898. * This returns if the loader support the current file information.
  117899. * @param extension defines the file extension of the file being loaded
  117900. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117901. * @param fallback defines the fallback internal texture if any
  117902. * @param isBase64 defines whether the texture is encoded as a base64
  117903. * @param isBuffer defines whether the texture data are stored as a buffer
  117904. * @returns true if the loader can load the specified file
  117905. */
  117906. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117907. /**
  117908. * Transform the url before loading if required.
  117909. * @param rootUrl the url of the texture
  117910. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117911. * @returns the transformed texture
  117912. */
  117913. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117914. /**
  117915. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117916. * @param rootUrl the url of the texture
  117917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117918. * @returns the fallback texture
  117919. */
  117920. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117921. /**
  117922. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117923. * @param data contains the texture data
  117924. * @param texture defines the BabylonJS internal texture
  117925. * @param createPolynomials will be true if polynomials have been requested
  117926. * @param onLoad defines the callback to trigger once the texture is ready
  117927. * @param onError defines the callback to trigger in case of error
  117928. */
  117929. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117930. /**
  117931. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117932. * @param data contains the texture data
  117933. * @param texture defines the BabylonJS internal texture
  117934. * @param callback defines the method to call once ready to upload
  117935. */
  117936. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117937. }
  117938. }
  117939. declare module BABYLON {
  117940. /**
  117941. * 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.
  117942. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117943. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117944. */
  117945. export class CustomProceduralTexture extends ProceduralTexture {
  117946. private _animate;
  117947. private _time;
  117948. private _config;
  117949. private _texturePath;
  117950. /**
  117951. * Instantiates a new Custom Procedural Texture.
  117952. * 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.
  117953. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117954. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117955. * @param name Define the name of the texture
  117956. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117957. * @param size Define the size of the texture to create
  117958. * @param scene Define the scene the texture belongs to
  117959. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117960. * @param generateMipMaps Define if the texture should creates mip maps or not
  117961. */
  117962. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117963. private _loadJson;
  117964. /**
  117965. * Is the texture ready to be used ? (rendered at least once)
  117966. * @returns true if ready, otherwise, false.
  117967. */
  117968. isReady(): boolean;
  117969. /**
  117970. * Render the texture to its associated render target.
  117971. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117972. */
  117973. render(useCameraPostProcess?: boolean): void;
  117974. /**
  117975. * Update the list of dependant textures samplers in the shader.
  117976. */
  117977. updateTextures(): void;
  117978. /**
  117979. * Update the uniform values of the procedural texture in the shader.
  117980. */
  117981. updateShaderUniforms(): void;
  117982. /**
  117983. * Define if the texture animates or not.
  117984. */
  117985. animate: boolean;
  117986. }
  117987. }
  117988. declare module BABYLON {
  117989. /** @hidden */
  117990. export var noisePixelShader: {
  117991. name: string;
  117992. shader: string;
  117993. };
  117994. }
  117995. declare module BABYLON {
  117996. /**
  117997. * Class used to generate noise procedural textures
  117998. */
  117999. export class NoiseProceduralTexture extends ProceduralTexture {
  118000. private _time;
  118001. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  118002. brightness: number;
  118003. /** Defines the number of octaves to process */
  118004. octaves: number;
  118005. /** Defines the level of persistence (0.8 by default) */
  118006. persistence: number;
  118007. /** Gets or sets animation speed factor (default is 1) */
  118008. animationSpeedFactor: number;
  118009. /**
  118010. * Creates a new NoiseProceduralTexture
  118011. * @param name defines the name fo the texture
  118012. * @param size defines the size of the texture (default is 256)
  118013. * @param scene defines the hosting scene
  118014. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  118015. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  118016. */
  118017. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118018. private _updateShaderUniforms;
  118019. protected _getDefines(): string;
  118020. /** Generate the current state of the procedural texture */
  118021. render(useCameraPostProcess?: boolean): void;
  118022. /**
  118023. * Serializes this noise procedural texture
  118024. * @returns a serialized noise procedural texture object
  118025. */
  118026. serialize(): any;
  118027. /**
  118028. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  118029. * @param parsedTexture defines parsed texture data
  118030. * @param scene defines the current scene
  118031. * @param rootUrl defines the root URL containing noise procedural texture information
  118032. * @returns a parsed NoiseProceduralTexture
  118033. */
  118034. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  118035. }
  118036. }
  118037. declare module BABYLON {
  118038. /**
  118039. * Raw cube texture where the raw buffers are passed in
  118040. */
  118041. export class RawCubeTexture extends CubeTexture {
  118042. /**
  118043. * Creates a cube texture where the raw buffers are passed in.
  118044. * @param scene defines the scene the texture is attached to
  118045. * @param data defines the array of data to use to create each face
  118046. * @param size defines the size of the textures
  118047. * @param format defines the format of the data
  118048. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  118049. * @param generateMipMaps defines if the engine should generate the mip levels
  118050. * @param invertY defines if data must be stored with Y axis inverted
  118051. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  118052. * @param compression defines the compression used (null by default)
  118053. */
  118054. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  118055. /**
  118056. * Updates the raw cube texture.
  118057. * @param data defines the data to store
  118058. * @param format defines the data format
  118059. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118060. * @param invertY defines if data must be stored with Y axis inverted
  118061. * @param compression defines the compression used (null by default)
  118062. * @param level defines which level of the texture to update
  118063. */
  118064. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  118065. /**
  118066. * Updates a raw cube texture with RGBD encoded data.
  118067. * @param data defines the array of data [mipmap][face] to use to create each face
  118068. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  118069. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  118070. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  118071. * @returns a promsie that resolves when the operation is complete
  118072. */
  118073. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  118074. /**
  118075. * Clones the raw cube texture.
  118076. * @return a new cube texture
  118077. */
  118078. clone(): CubeTexture;
  118079. /** @hidden */
  118080. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  118081. }
  118082. }
  118083. declare module BABYLON {
  118084. /**
  118085. * Class used to store 3D textures containing user data
  118086. */
  118087. export class RawTexture3D extends Texture {
  118088. /** Gets or sets the texture format to use */
  118089. format: number;
  118090. private _engine;
  118091. /**
  118092. * Create a new RawTexture3D
  118093. * @param data defines the data of the texture
  118094. * @param width defines the width of the texture
  118095. * @param height defines the height of the texture
  118096. * @param depth defines the depth of the texture
  118097. * @param format defines the texture format to use
  118098. * @param scene defines the hosting scene
  118099. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  118100. * @param invertY defines if texture must be stored with Y axis inverted
  118101. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  118102. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  118103. */
  118104. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  118105. /** Gets or sets the texture format to use */
  118106. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  118107. /**
  118108. * Update the texture with new data
  118109. * @param data defines the data to store in the texture
  118110. */
  118111. update(data: ArrayBufferView): void;
  118112. }
  118113. }
  118114. declare module BABYLON {
  118115. /**
  118116. * Creates a refraction texture used by refraction channel of the standard material.
  118117. * It is like a mirror but to see through a material.
  118118. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118119. */
  118120. export class RefractionTexture extends RenderTargetTexture {
  118121. /**
  118122. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  118123. * 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.
  118124. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118125. */
  118126. refractionPlane: Plane;
  118127. /**
  118128. * Define how deep under the surface we should see.
  118129. */
  118130. depth: number;
  118131. /**
  118132. * Creates a refraction texture used by refraction channel of the standard material.
  118133. * It is like a mirror but to see through a material.
  118134. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118135. * @param name Define the texture name
  118136. * @param size Define the size of the underlying texture
  118137. * @param scene Define the scene the refraction belongs to
  118138. * @param generateMipMaps Define if we need to generate mips level for the refraction
  118139. */
  118140. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  118141. /**
  118142. * Clone the refraction texture.
  118143. * @returns the cloned texture
  118144. */
  118145. clone(): RefractionTexture;
  118146. /**
  118147. * Serialize the texture to a JSON representation you could use in Parse later on
  118148. * @returns the serialized JSON representation
  118149. */
  118150. serialize(): any;
  118151. }
  118152. }
  118153. declare module BABYLON {
  118154. /**
  118155. * Defines the options related to the creation of an HtmlElementTexture
  118156. */
  118157. export interface IHtmlElementTextureOptions {
  118158. /**
  118159. * Defines wether mip maps should be created or not.
  118160. */
  118161. generateMipMaps?: boolean;
  118162. /**
  118163. * Defines the sampling mode of the texture.
  118164. */
  118165. samplingMode?: number;
  118166. /**
  118167. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  118168. */
  118169. engine: Nullable<Engine>;
  118170. /**
  118171. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  118172. */
  118173. scene: Nullable<Scene>;
  118174. }
  118175. /**
  118176. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  118177. * To be as efficient as possible depending on your constraints nothing aside the first upload
  118178. * is automatically managed.
  118179. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  118180. * in your application.
  118181. *
  118182. * As the update is not automatic, you need to call them manually.
  118183. */
  118184. export class HtmlElementTexture extends BaseTexture {
  118185. /**
  118186. * The texture URL.
  118187. */
  118188. element: HTMLVideoElement | HTMLCanvasElement;
  118189. private static readonly DefaultOptions;
  118190. private _textureMatrix;
  118191. private _engine;
  118192. private _isVideo;
  118193. private _generateMipMaps;
  118194. private _samplingMode;
  118195. /**
  118196. * Instantiates a HtmlElementTexture from the following parameters.
  118197. *
  118198. * @param name Defines the name of the texture
  118199. * @param element Defines the video or canvas the texture is filled with
  118200. * @param options Defines the other none mandatory texture creation options
  118201. */
  118202. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  118203. private _createInternalTexture;
  118204. /**
  118205. * Returns the texture matrix used in most of the material.
  118206. */
  118207. getTextureMatrix(): Matrix;
  118208. /**
  118209. * Updates the content of the texture.
  118210. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  118211. */
  118212. update(invertY?: Nullable<boolean>): void;
  118213. }
  118214. }
  118215. declare module BABYLON {
  118216. /**
  118217. * Enum used to define the target of a block
  118218. */
  118219. export enum NodeMaterialBlockTargets {
  118220. /** Vertex shader */
  118221. Vertex = 1,
  118222. /** Fragment shader */
  118223. Fragment = 2,
  118224. /** Neutral */
  118225. Neutral = 4,
  118226. /** Vertex and Fragment */
  118227. VertexAndFragment = 3
  118228. }
  118229. }
  118230. declare module BABYLON {
  118231. /**
  118232. * Defines the kind of connection point for node based material
  118233. */
  118234. export enum NodeMaterialBlockConnectionPointTypes {
  118235. /** Float */
  118236. Float = 1,
  118237. /** Int */
  118238. Int = 2,
  118239. /** Vector2 */
  118240. Vector2 = 4,
  118241. /** Vector3 */
  118242. Vector3 = 8,
  118243. /** Vector4 */
  118244. Vector4 = 16,
  118245. /** Color3 */
  118246. Color3 = 32,
  118247. /** Color4 */
  118248. Color4 = 64,
  118249. /** Matrix */
  118250. Matrix = 128,
  118251. /** Detect type based on connection */
  118252. AutoDetect = 1024,
  118253. /** Output type that will be defined by input type */
  118254. BasedOnInput = 2048
  118255. }
  118256. }
  118257. declare module BABYLON {
  118258. /**
  118259. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118260. */
  118261. export enum NodeMaterialBlockConnectionPointMode {
  118262. /** Value is an uniform */
  118263. Uniform = 0,
  118264. /** Value is a mesh attribute */
  118265. Attribute = 1,
  118266. /** Value is a varying between vertex and fragment shaders */
  118267. Varying = 2,
  118268. /** Mode is undefined */
  118269. Undefined = 3
  118270. }
  118271. }
  118272. declare module BABYLON {
  118273. /**
  118274. * Enum used to define system values e.g. values automatically provided by the system
  118275. */
  118276. export enum NodeMaterialSystemValues {
  118277. /** World */
  118278. World = 1,
  118279. /** View */
  118280. View = 2,
  118281. /** Projection */
  118282. Projection = 3,
  118283. /** ViewProjection */
  118284. ViewProjection = 4,
  118285. /** WorldView */
  118286. WorldView = 5,
  118287. /** WorldViewProjection */
  118288. WorldViewProjection = 6,
  118289. /** CameraPosition */
  118290. CameraPosition = 7,
  118291. /** Fog Color */
  118292. FogColor = 8
  118293. }
  118294. }
  118295. declare module BABYLON {
  118296. /**
  118297. * Root class for all node material optimizers
  118298. */
  118299. export class NodeMaterialOptimizer {
  118300. /**
  118301. * Function used to optimize a NodeMaterial graph
  118302. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  118303. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  118304. */
  118305. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  118306. }
  118307. }
  118308. declare module BABYLON {
  118309. /**
  118310. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  118311. */
  118312. export class TransformBlock extends NodeMaterialBlock {
  118313. /**
  118314. * Defines the value to use to complement W value to transform it to a Vector4
  118315. */
  118316. complementW: number;
  118317. /**
  118318. * Defines the value to use to complement z value to transform it to a Vector4
  118319. */
  118320. complementZ: number;
  118321. /**
  118322. * Creates a new TransformBlock
  118323. * @param name defines the block name
  118324. */
  118325. constructor(name: string);
  118326. /**
  118327. * Gets the current class name
  118328. * @returns the class name
  118329. */
  118330. getClassName(): string;
  118331. /**
  118332. * Gets the vector input
  118333. */
  118334. readonly vector: NodeMaterialConnectionPoint;
  118335. /**
  118336. * Gets the output component
  118337. */
  118338. readonly output: NodeMaterialConnectionPoint;
  118339. /**
  118340. * Gets the matrix transform input
  118341. */
  118342. readonly transform: NodeMaterialConnectionPoint;
  118343. protected _buildBlock(state: NodeMaterialBuildState): this;
  118344. serialize(): any;
  118345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118346. protected _dumpPropertiesCode(): string;
  118347. }
  118348. }
  118349. declare module BABYLON {
  118350. /**
  118351. * Block used to output the vertex position
  118352. */
  118353. export class VertexOutputBlock extends NodeMaterialBlock {
  118354. /**
  118355. * Creates a new VertexOutputBlock
  118356. * @param name defines the block name
  118357. */
  118358. constructor(name: string);
  118359. /**
  118360. * Gets the current class name
  118361. * @returns the class name
  118362. */
  118363. getClassName(): string;
  118364. /**
  118365. * Gets the vector input component
  118366. */
  118367. readonly vector: NodeMaterialConnectionPoint;
  118368. protected _buildBlock(state: NodeMaterialBuildState): this;
  118369. }
  118370. }
  118371. declare module BABYLON {
  118372. /**
  118373. * Block used to output the final color
  118374. */
  118375. export class FragmentOutputBlock extends NodeMaterialBlock {
  118376. /**
  118377. * Create a new FragmentOutputBlock
  118378. * @param name defines the block name
  118379. */
  118380. constructor(name: string);
  118381. /**
  118382. * Gets the current class name
  118383. * @returns the class name
  118384. */
  118385. getClassName(): string;
  118386. /**
  118387. * Gets the rgba input component
  118388. */
  118389. readonly rgba: NodeMaterialConnectionPoint;
  118390. /**
  118391. * Gets the rgb input component
  118392. */
  118393. readonly rgb: NodeMaterialConnectionPoint;
  118394. /**
  118395. * Gets the a input component
  118396. */
  118397. readonly a: NodeMaterialConnectionPoint;
  118398. protected _buildBlock(state: NodeMaterialBuildState): this;
  118399. }
  118400. }
  118401. declare module BABYLON {
  118402. /**
  118403. * Block used to read a reflection texture from a sampler
  118404. */
  118405. export class ReflectionTextureBlock extends NodeMaterialBlock {
  118406. private _define3DName;
  118407. private _defineCubicName;
  118408. private _defineExplicitName;
  118409. private _defineProjectionName;
  118410. private _defineLocalCubicName;
  118411. private _defineSphericalName;
  118412. private _definePlanarName;
  118413. private _defineEquirectangularName;
  118414. private _defineMirroredEquirectangularFixedName;
  118415. private _defineEquirectangularFixedName;
  118416. private _defineSkyboxName;
  118417. private _cubeSamplerName;
  118418. private _2DSamplerName;
  118419. private _positionUVWName;
  118420. private _directionWName;
  118421. private _reflectionCoordsName;
  118422. private _reflection2DCoordsName;
  118423. private _reflectionColorName;
  118424. private _reflectionMatrixName;
  118425. /**
  118426. * Gets or sets the texture associated with the node
  118427. */
  118428. texture: Nullable<BaseTexture>;
  118429. /**
  118430. * Create a new TextureBlock
  118431. * @param name defines the block name
  118432. */
  118433. constructor(name: string);
  118434. /**
  118435. * Gets the current class name
  118436. * @returns the class name
  118437. */
  118438. getClassName(): string;
  118439. /**
  118440. * Gets the world position input component
  118441. */
  118442. readonly position: NodeMaterialConnectionPoint;
  118443. /**
  118444. * Gets the world position input component
  118445. */
  118446. readonly worldPosition: NodeMaterialConnectionPoint;
  118447. /**
  118448. * Gets the world normal input component
  118449. */
  118450. readonly worldNormal: NodeMaterialConnectionPoint;
  118451. /**
  118452. * Gets the world input component
  118453. */
  118454. readonly world: NodeMaterialConnectionPoint;
  118455. /**
  118456. * Gets the camera (or eye) position component
  118457. */
  118458. readonly cameraPosition: NodeMaterialConnectionPoint;
  118459. /**
  118460. * Gets the view input component
  118461. */
  118462. readonly view: NodeMaterialConnectionPoint;
  118463. /**
  118464. * Gets the rgb output component
  118465. */
  118466. readonly rgb: NodeMaterialConnectionPoint;
  118467. /**
  118468. * Gets the r output component
  118469. */
  118470. readonly r: NodeMaterialConnectionPoint;
  118471. /**
  118472. * Gets the g output component
  118473. */
  118474. readonly g: NodeMaterialConnectionPoint;
  118475. /**
  118476. * Gets the b output component
  118477. */
  118478. readonly b: NodeMaterialConnectionPoint;
  118479. autoConfigure(material: NodeMaterial): void;
  118480. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118481. isReady(): boolean;
  118482. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118483. private _injectVertexCode;
  118484. private _writeOutput;
  118485. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118486. serialize(): any;
  118487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118488. }
  118489. }
  118490. declare module BABYLON {
  118491. /**
  118492. * Interface used to configure the node material editor
  118493. */
  118494. export interface INodeMaterialEditorOptions {
  118495. /** Define the URl to load node editor script */
  118496. editorURL?: string;
  118497. }
  118498. /** @hidden */
  118499. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118500. /** BONES */
  118501. NUM_BONE_INFLUENCERS: number;
  118502. BonesPerMesh: number;
  118503. BONETEXTURE: boolean;
  118504. /** MORPH TARGETS */
  118505. MORPHTARGETS: boolean;
  118506. MORPHTARGETS_NORMAL: boolean;
  118507. MORPHTARGETS_TANGENT: boolean;
  118508. MORPHTARGETS_UV: boolean;
  118509. NUM_MORPH_INFLUENCERS: number;
  118510. /** IMAGE PROCESSING */
  118511. IMAGEPROCESSING: boolean;
  118512. VIGNETTE: boolean;
  118513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118514. VIGNETTEBLENDMODEOPAQUE: boolean;
  118515. TONEMAPPING: boolean;
  118516. TONEMAPPING_ACES: boolean;
  118517. CONTRAST: boolean;
  118518. EXPOSURE: boolean;
  118519. COLORCURVES: boolean;
  118520. COLORGRADING: boolean;
  118521. COLORGRADING3D: boolean;
  118522. SAMPLER3DGREENDEPTH: boolean;
  118523. SAMPLER3DBGRMAP: boolean;
  118524. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118525. /** MISC. */
  118526. BUMPDIRECTUV: number;
  118527. constructor();
  118528. setValue(name: string, value: boolean): void;
  118529. }
  118530. /**
  118531. * Class used to configure NodeMaterial
  118532. */
  118533. export interface INodeMaterialOptions {
  118534. /**
  118535. * Defines if blocks should emit comments
  118536. */
  118537. emitComments: boolean;
  118538. }
  118539. /**
  118540. * Class used to create a node based material built by assembling shader blocks
  118541. */
  118542. export class NodeMaterial extends PushMaterial {
  118543. private static _BuildIdGenerator;
  118544. private _options;
  118545. private _vertexCompilationState;
  118546. private _fragmentCompilationState;
  118547. private _sharedData;
  118548. private _buildId;
  118549. private _buildWasSuccessful;
  118550. private _cachedWorldViewMatrix;
  118551. private _cachedWorldViewProjectionMatrix;
  118552. private _optimizers;
  118553. private _animationFrame;
  118554. /** Define the URl to load node editor script */
  118555. static EditorURL: string;
  118556. private BJSNODEMATERIALEDITOR;
  118557. /** Get the inspector from bundle or global */
  118558. private _getGlobalNodeMaterialEditor;
  118559. /**
  118560. * 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)
  118561. */
  118562. ignoreAlpha: boolean;
  118563. /**
  118564. * Defines the maximum number of lights that can be used in the material
  118565. */
  118566. maxSimultaneousLights: number;
  118567. /**
  118568. * Observable raised when the material is built
  118569. */
  118570. onBuildObservable: Observable<NodeMaterial>;
  118571. /**
  118572. * Gets or sets the root nodes of the material vertex shader
  118573. */
  118574. _vertexOutputNodes: NodeMaterialBlock[];
  118575. /**
  118576. * Gets or sets the root nodes of the material fragment (pixel) shader
  118577. */
  118578. _fragmentOutputNodes: NodeMaterialBlock[];
  118579. /** Gets or sets options to control the node material overall behavior */
  118580. options: INodeMaterialOptions;
  118581. /**
  118582. * Default configuration related to image processing available in the standard Material.
  118583. */
  118584. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118585. /**
  118586. * Gets the image processing configuration used either in this material.
  118587. */
  118588. /**
  118589. * Sets the Default image processing configuration used either in the this material.
  118590. *
  118591. * If sets to null, the scene one is in use.
  118592. */
  118593. imageProcessingConfiguration: ImageProcessingConfiguration;
  118594. /**
  118595. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118596. */
  118597. attachedBlocks: NodeMaterialBlock[];
  118598. /**
  118599. * Create a new node based material
  118600. * @param name defines the material name
  118601. * @param scene defines the hosting scene
  118602. * @param options defines creation option
  118603. */
  118604. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118605. /**
  118606. * Gets the current class name of the material e.g. "NodeMaterial"
  118607. * @returns the class name
  118608. */
  118609. getClassName(): string;
  118610. /**
  118611. * Keep track of the image processing observer to allow dispose and replace.
  118612. */
  118613. private _imageProcessingObserver;
  118614. /**
  118615. * Attaches a new image processing configuration to the Standard Material.
  118616. * @param configuration
  118617. */
  118618. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118619. /**
  118620. * Get a block by its name
  118621. * @param name defines the name of the block to retrieve
  118622. * @returns the required block or null if not found
  118623. */
  118624. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118625. /**
  118626. * Get a block by its name
  118627. * @param predicate defines the predicate used to find the good candidate
  118628. * @returns the required block or null if not found
  118629. */
  118630. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118631. /**
  118632. * Get an input block by its name
  118633. * @param predicate defines the predicate used to find the good candidate
  118634. * @returns the required input block or null if not found
  118635. */
  118636. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118637. /**
  118638. * Gets the list of input blocks attached to this material
  118639. * @returns an array of InputBlocks
  118640. */
  118641. getInputBlocks(): InputBlock[];
  118642. /**
  118643. * Adds a new optimizer to the list of optimizers
  118644. * @param optimizer defines the optimizers to add
  118645. * @returns the current material
  118646. */
  118647. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118648. /**
  118649. * Remove an optimizer from the list of optimizers
  118650. * @param optimizer defines the optimizers to remove
  118651. * @returns the current material
  118652. */
  118653. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118654. /**
  118655. * Add a new block to the list of output nodes
  118656. * @param node defines the node to add
  118657. * @returns the current material
  118658. */
  118659. addOutputNode(node: NodeMaterialBlock): this;
  118660. /**
  118661. * Remove a block from the list of root nodes
  118662. * @param node defines the node to remove
  118663. * @returns the current material
  118664. */
  118665. removeOutputNode(node: NodeMaterialBlock): this;
  118666. private _addVertexOutputNode;
  118667. private _removeVertexOutputNode;
  118668. private _addFragmentOutputNode;
  118669. private _removeFragmentOutputNode;
  118670. /**
  118671. * Specifies if the material will require alpha blending
  118672. * @returns a boolean specifying if alpha blending is needed
  118673. */
  118674. needAlphaBlending(): boolean;
  118675. /**
  118676. * Specifies if this material should be rendered in alpha test mode
  118677. * @returns a boolean specifying if an alpha test is needed.
  118678. */
  118679. needAlphaTesting(): boolean;
  118680. private _initializeBlock;
  118681. private _resetDualBlocks;
  118682. /**
  118683. * Build the material and generates the inner effect
  118684. * @param verbose defines if the build should log activity
  118685. */
  118686. build(verbose?: boolean): void;
  118687. /**
  118688. * Runs an otpimization phase to try to improve the shader code
  118689. */
  118690. optimize(): void;
  118691. private _prepareDefinesForAttributes;
  118692. /**
  118693. * Get if the submesh is ready to be used and all its information available.
  118694. * Child classes can use it to update shaders
  118695. * @param mesh defines the mesh to check
  118696. * @param subMesh defines which submesh to check
  118697. * @param useInstances specifies that instances should be used
  118698. * @returns a boolean indicating that the submesh is ready or not
  118699. */
  118700. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118701. /**
  118702. * Get a string representing the shaders built by the current node graph
  118703. */
  118704. readonly compiledShaders: string;
  118705. /**
  118706. * Binds the world matrix to the material
  118707. * @param world defines the world transformation matrix
  118708. */
  118709. bindOnlyWorldMatrix(world: Matrix): void;
  118710. /**
  118711. * Binds the submesh to this material by preparing the effect and shader to draw
  118712. * @param world defines the world transformation matrix
  118713. * @param mesh defines the mesh containing the submesh
  118714. * @param subMesh defines the submesh to bind the material to
  118715. */
  118716. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118717. /**
  118718. * Gets the active textures from the material
  118719. * @returns an array of textures
  118720. */
  118721. getActiveTextures(): BaseTexture[];
  118722. /**
  118723. * Gets the list of texture blocks
  118724. * @returns an array of texture blocks
  118725. */
  118726. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118727. /**
  118728. * Specifies if the material uses a texture
  118729. * @param texture defines the texture to check against the material
  118730. * @returns a boolean specifying if the material uses the texture
  118731. */
  118732. hasTexture(texture: BaseTexture): boolean;
  118733. /**
  118734. * Disposes the material
  118735. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118736. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118737. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118738. */
  118739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118740. /** Creates the node editor window. */
  118741. private _createNodeEditor;
  118742. /**
  118743. * Launch the node material editor
  118744. * @param config Define the configuration of the editor
  118745. * @return a promise fulfilled when the node editor is visible
  118746. */
  118747. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118748. /**
  118749. * Clear the current material
  118750. */
  118751. clear(): void;
  118752. /**
  118753. * Clear the current material and set it to a default state
  118754. */
  118755. setToDefault(): void;
  118756. /**
  118757. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118758. * @param url defines the url to load from
  118759. * @returns a promise that will fullfil when the material is fully loaded
  118760. */
  118761. loadAsync(url: string): Promise<unknown>;
  118762. private _gatherBlocks;
  118763. /**
  118764. * Generate a string containing the code declaration required to create an equivalent of this material
  118765. * @returns a string
  118766. */
  118767. generateCode(): string;
  118768. /**
  118769. * Serializes this material in a JSON representation
  118770. * @returns the serialized material object
  118771. */
  118772. serialize(): any;
  118773. private _restoreConnections;
  118774. /**
  118775. * Clear the current graph and load a new one from a serialization object
  118776. * @param source defines the JSON representation of the material
  118777. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118778. */
  118779. loadFromSerialization(source: any, rootUrl?: string): void;
  118780. /**
  118781. * Creates a node material from parsed material data
  118782. * @param source defines the JSON representation of the material
  118783. * @param scene defines the hosting scene
  118784. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118785. * @returns a new node material
  118786. */
  118787. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118788. /**
  118789. * Creates a new node material set to default basic configuration
  118790. * @param name defines the name of the material
  118791. * @param scene defines the hosting scene
  118792. * @returns a new NodeMaterial
  118793. */
  118794. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118795. }
  118796. }
  118797. declare module BABYLON {
  118798. /**
  118799. * Block used to read a texture from a sampler
  118800. */
  118801. export class TextureBlock extends NodeMaterialBlock {
  118802. private _defineName;
  118803. private _samplerName;
  118804. private _transformedUVName;
  118805. private _textureTransformName;
  118806. private _textureInfoName;
  118807. private _mainUVName;
  118808. private _mainUVDefineName;
  118809. /**
  118810. * Gets or sets the texture associated with the node
  118811. */
  118812. texture: Nullable<Texture>;
  118813. /**
  118814. * Create a new TextureBlock
  118815. * @param name defines the block name
  118816. */
  118817. constructor(name: string);
  118818. /**
  118819. * Gets the current class name
  118820. * @returns the class name
  118821. */
  118822. getClassName(): string;
  118823. /**
  118824. * Gets the uv input component
  118825. */
  118826. readonly uv: NodeMaterialConnectionPoint;
  118827. /**
  118828. * Gets the rgba output component
  118829. */
  118830. readonly rgba: NodeMaterialConnectionPoint;
  118831. /**
  118832. * Gets the rgb output component
  118833. */
  118834. readonly rgb: NodeMaterialConnectionPoint;
  118835. /**
  118836. * Gets the r output component
  118837. */
  118838. readonly r: NodeMaterialConnectionPoint;
  118839. /**
  118840. * Gets the g output component
  118841. */
  118842. readonly g: NodeMaterialConnectionPoint;
  118843. /**
  118844. * Gets the b output component
  118845. */
  118846. readonly b: NodeMaterialConnectionPoint;
  118847. /**
  118848. * Gets the a output component
  118849. */
  118850. readonly a: NodeMaterialConnectionPoint;
  118851. readonly target: NodeMaterialBlockTargets;
  118852. autoConfigure(material: NodeMaterial): void;
  118853. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118855. isReady(): boolean;
  118856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118857. private readonly _isMixed;
  118858. private _injectVertexCode;
  118859. private _writeOutput;
  118860. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118861. protected _dumpPropertiesCode(): string;
  118862. serialize(): any;
  118863. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118864. }
  118865. }
  118866. declare module BABYLON {
  118867. /**
  118868. * Class used to store shared data between 2 NodeMaterialBuildState
  118869. */
  118870. export class NodeMaterialBuildStateSharedData {
  118871. /**
  118872. * Gets the list of emitted varyings
  118873. */
  118874. temps: string[];
  118875. /**
  118876. * Gets the list of emitted varyings
  118877. */
  118878. varyings: string[];
  118879. /**
  118880. * Gets the varying declaration string
  118881. */
  118882. varyingDeclaration: string;
  118883. /**
  118884. * Input blocks
  118885. */
  118886. inputBlocks: InputBlock[];
  118887. /**
  118888. * Input blocks
  118889. */
  118890. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118891. /**
  118892. * Bindable blocks (Blocks that need to set data to the effect)
  118893. */
  118894. bindableBlocks: NodeMaterialBlock[];
  118895. /**
  118896. * List of blocks that can provide a compilation fallback
  118897. */
  118898. blocksWithFallbacks: NodeMaterialBlock[];
  118899. /**
  118900. * List of blocks that can provide a define update
  118901. */
  118902. blocksWithDefines: NodeMaterialBlock[];
  118903. /**
  118904. * List of blocks that can provide a repeatable content
  118905. */
  118906. repeatableContentBlocks: NodeMaterialBlock[];
  118907. /**
  118908. * List of blocks that can provide a dynamic list of uniforms
  118909. */
  118910. dynamicUniformBlocks: NodeMaterialBlock[];
  118911. /**
  118912. * List of blocks that can block the isReady function for the material
  118913. */
  118914. blockingBlocks: NodeMaterialBlock[];
  118915. /**
  118916. * Gets the list of animated inputs
  118917. */
  118918. animatedInputs: InputBlock[];
  118919. /**
  118920. * Build Id used to avoid multiple recompilations
  118921. */
  118922. buildId: number;
  118923. /** List of emitted variables */
  118924. variableNames: {
  118925. [key: string]: number;
  118926. };
  118927. /** List of emitted defines */
  118928. defineNames: {
  118929. [key: string]: number;
  118930. };
  118931. /** Should emit comments? */
  118932. emitComments: boolean;
  118933. /** Emit build activity */
  118934. verbose: boolean;
  118935. /** Gets or sets the hosting scene */
  118936. scene: Scene;
  118937. /**
  118938. * Gets the compilation hints emitted at compilation time
  118939. */
  118940. hints: {
  118941. needWorldViewMatrix: boolean;
  118942. needWorldViewProjectionMatrix: boolean;
  118943. needAlphaBlending: boolean;
  118944. needAlphaTesting: boolean;
  118945. };
  118946. /**
  118947. * List of compilation checks
  118948. */
  118949. checks: {
  118950. emitVertex: boolean;
  118951. emitFragment: boolean;
  118952. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118953. };
  118954. /** Creates a new shared data */
  118955. constructor();
  118956. /**
  118957. * Emits console errors and exceptions if there is a failing check
  118958. */
  118959. emitErrors(): void;
  118960. }
  118961. }
  118962. declare module BABYLON {
  118963. /**
  118964. * Class used to store node based material build state
  118965. */
  118966. export class NodeMaterialBuildState {
  118967. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118968. supportUniformBuffers: boolean;
  118969. /**
  118970. * Gets the list of emitted attributes
  118971. */
  118972. attributes: string[];
  118973. /**
  118974. * Gets the list of emitted uniforms
  118975. */
  118976. uniforms: string[];
  118977. /**
  118978. * Gets the list of emitted constants
  118979. */
  118980. constants: string[];
  118981. /**
  118982. * Gets the list of emitted uniform buffers
  118983. */
  118984. uniformBuffers: string[];
  118985. /**
  118986. * Gets the list of emitted samplers
  118987. */
  118988. samplers: string[];
  118989. /**
  118990. * Gets the list of emitted functions
  118991. */
  118992. functions: {
  118993. [key: string]: string;
  118994. };
  118995. /**
  118996. * Gets the list of emitted extensions
  118997. */
  118998. extensions: {
  118999. [key: string]: string;
  119000. };
  119001. /**
  119002. * Gets the target of the compilation state
  119003. */
  119004. target: NodeMaterialBlockTargets;
  119005. /**
  119006. * Gets the list of emitted counters
  119007. */
  119008. counters: {
  119009. [key: string]: number;
  119010. };
  119011. /**
  119012. * Shared data between multiple NodeMaterialBuildState instances
  119013. */
  119014. sharedData: NodeMaterialBuildStateSharedData;
  119015. /** @hidden */
  119016. _vertexState: NodeMaterialBuildState;
  119017. /** @hidden */
  119018. _attributeDeclaration: string;
  119019. /** @hidden */
  119020. _uniformDeclaration: string;
  119021. /** @hidden */
  119022. _constantDeclaration: string;
  119023. /** @hidden */
  119024. _samplerDeclaration: string;
  119025. /** @hidden */
  119026. _varyingTransfer: string;
  119027. private _repeatableContentAnchorIndex;
  119028. /** @hidden */
  119029. _builtCompilationString: string;
  119030. /**
  119031. * Gets the emitted compilation strings
  119032. */
  119033. compilationString: string;
  119034. /**
  119035. * Finalize the compilation strings
  119036. * @param state defines the current compilation state
  119037. */
  119038. finalize(state: NodeMaterialBuildState): void;
  119039. /** @hidden */
  119040. readonly _repeatableContentAnchor: string;
  119041. /** @hidden */
  119042. _getFreeVariableName(prefix: string): string;
  119043. /** @hidden */
  119044. _getFreeDefineName(prefix: string): string;
  119045. /** @hidden */
  119046. _excludeVariableName(name: string): void;
  119047. /** @hidden */
  119048. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  119049. /** @hidden */
  119050. _emitExtension(name: string, extension: string): void;
  119051. /** @hidden */
  119052. _emitFunction(name: string, code: string, comments: string): void;
  119053. /** @hidden */
  119054. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  119055. replaceStrings?: {
  119056. search: RegExp;
  119057. replace: string;
  119058. }[];
  119059. repeatKey?: string;
  119060. }): string;
  119061. /** @hidden */
  119062. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  119063. repeatKey?: string;
  119064. removeAttributes?: boolean;
  119065. removeUniforms?: boolean;
  119066. removeVaryings?: boolean;
  119067. removeIfDef?: boolean;
  119068. replaceStrings?: {
  119069. search: RegExp;
  119070. replace: string;
  119071. }[];
  119072. }, storeKey?: string): void;
  119073. /** @hidden */
  119074. _registerTempVariable(name: string): boolean;
  119075. /** @hidden */
  119076. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  119077. /** @hidden */
  119078. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  119079. }
  119080. }
  119081. declare module BABYLON {
  119082. /**
  119083. * Defines a block that can be used inside a node based material
  119084. */
  119085. export class NodeMaterialBlock {
  119086. private _buildId;
  119087. private _buildTarget;
  119088. private _target;
  119089. private _isFinalMerger;
  119090. private _isInput;
  119091. /** @hidden */
  119092. _codeVariableName: string;
  119093. /** @hidden */
  119094. _inputs: NodeMaterialConnectionPoint[];
  119095. /** @hidden */
  119096. _outputs: NodeMaterialConnectionPoint[];
  119097. /** @hidden */
  119098. _preparationId: number;
  119099. /**
  119100. * Gets or sets the name of the block
  119101. */
  119102. name: string;
  119103. /**
  119104. * Gets or sets the unique id of the node
  119105. */
  119106. uniqueId: number;
  119107. /**
  119108. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  119109. */
  119110. readonly isFinalMerger: boolean;
  119111. /**
  119112. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  119113. */
  119114. readonly isInput: boolean;
  119115. /**
  119116. * Gets or sets the build Id
  119117. */
  119118. buildId: number;
  119119. /**
  119120. * Gets or sets the target of the block
  119121. */
  119122. target: NodeMaterialBlockTargets;
  119123. /**
  119124. * Gets the list of input points
  119125. */
  119126. readonly inputs: NodeMaterialConnectionPoint[];
  119127. /** Gets the list of output points */
  119128. readonly outputs: NodeMaterialConnectionPoint[];
  119129. /**
  119130. * Find an input by its name
  119131. * @param name defines the name of the input to look for
  119132. * @returns the input or null if not found
  119133. */
  119134. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  119135. /**
  119136. * Find an output by its name
  119137. * @param name defines the name of the outputto look for
  119138. * @returns the output or null if not found
  119139. */
  119140. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  119141. /**
  119142. * Creates a new NodeMaterialBlock
  119143. * @param name defines the block name
  119144. * @param target defines the target of that block (Vertex by default)
  119145. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  119146. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  119147. */
  119148. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  119149. /**
  119150. * Initialize the block and prepare the context for build
  119151. * @param state defines the state that will be used for the build
  119152. */
  119153. initialize(state: NodeMaterialBuildState): void;
  119154. /**
  119155. * Bind data to effect. Will only be called for blocks with isBindable === true
  119156. * @param effect defines the effect to bind data to
  119157. * @param nodeMaterial defines the hosting NodeMaterial
  119158. * @param mesh defines the mesh that will be rendered
  119159. */
  119160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119161. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  119162. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  119163. protected _writeFloat(value: number): string;
  119164. /**
  119165. * Gets the current class name e.g. "NodeMaterialBlock"
  119166. * @returns the class name
  119167. */
  119168. getClassName(): string;
  119169. /**
  119170. * Register a new input. Must be called inside a block constructor
  119171. * @param name defines the connection point name
  119172. * @param type defines the connection point type
  119173. * @param isOptional defines a boolean indicating that this input can be omitted
  119174. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  119175. * @returns the current block
  119176. */
  119177. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  119178. /**
  119179. * Register a new output. Must be called inside a block constructor
  119180. * @param name defines the connection point name
  119181. * @param type defines the connection point type
  119182. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  119183. * @returns the current block
  119184. */
  119185. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  119186. /**
  119187. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  119188. * @param forOutput defines an optional connection point to check compatibility with
  119189. * @returns the first available input or null
  119190. */
  119191. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  119192. /**
  119193. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  119194. * @param forBlock defines an optional block to check compatibility with
  119195. * @returns the first available input or null
  119196. */
  119197. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  119198. /**
  119199. * Gets the sibling of the given output
  119200. * @param current defines the current output
  119201. * @returns the next output in the list or null
  119202. */
  119203. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  119204. /**
  119205. * Connect current block with another block
  119206. * @param other defines the block to connect with
  119207. * @param options define the various options to help pick the right connections
  119208. * @returns the current block
  119209. */
  119210. connectTo(other: NodeMaterialBlock, options?: {
  119211. input?: string;
  119212. output?: string;
  119213. outputSwizzle?: string;
  119214. }): this | undefined;
  119215. protected _buildBlock(state: NodeMaterialBuildState): void;
  119216. /**
  119217. * Add uniforms, samplers and uniform buffers at compilation time
  119218. * @param state defines the state to update
  119219. * @param nodeMaterial defines the node material requesting the update
  119220. * @param defines defines the material defines to update
  119221. */
  119222. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119223. /**
  119224. * Add potential fallbacks if shader compilation fails
  119225. * @param mesh defines the mesh to be rendered
  119226. * @param fallbacks defines the current prioritized list of fallbacks
  119227. */
  119228. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119229. /**
  119230. * Initialize defines for shader compilation
  119231. * @param mesh defines the mesh to be rendered
  119232. * @param nodeMaterial defines the node material requesting the update
  119233. * @param defines defines the material defines to update
  119234. * @param useInstances specifies that instances should be used
  119235. */
  119236. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119237. /**
  119238. * Update defines for shader compilation
  119239. * @param mesh defines the mesh to be rendered
  119240. * @param nodeMaterial defines the node material requesting the update
  119241. * @param defines defines the material defines to update
  119242. * @param useInstances specifies that instances should be used
  119243. */
  119244. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119245. /**
  119246. * Lets the block try to connect some inputs automatically
  119247. * @param material defines the hosting NodeMaterial
  119248. */
  119249. autoConfigure(material: NodeMaterial): void;
  119250. /**
  119251. * Function called when a block is declared as repeatable content generator
  119252. * @param vertexShaderState defines the current compilation state for the vertex shader
  119253. * @param fragmentShaderState defines the current compilation state for the fragment shader
  119254. * @param mesh defines the mesh to be rendered
  119255. * @param defines defines the material defines to update
  119256. */
  119257. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119258. /**
  119259. * Checks if the block is ready
  119260. * @param mesh defines the mesh to be rendered
  119261. * @param nodeMaterial defines the node material requesting the update
  119262. * @param defines defines the material defines to update
  119263. * @param useInstances specifies that instances should be used
  119264. * @returns true if the block is ready
  119265. */
  119266. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  119267. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  119268. private _processBuild;
  119269. /**
  119270. * Compile the current node and generate the shader code
  119271. * @param state defines the current compilation state (uniforms, samplers, current string)
  119272. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  119273. * @returns true if already built
  119274. */
  119275. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  119276. protected _inputRename(name: string): string;
  119277. protected _outputRename(name: string): string;
  119278. protected _dumpPropertiesCode(): string;
  119279. /** @hidden */
  119280. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  119281. /**
  119282. * Clone the current block to a new identical block
  119283. * @param scene defines the hosting scene
  119284. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119285. * @returns a copy of the current block
  119286. */
  119287. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  119288. /**
  119289. * Serializes this block in a JSON representation
  119290. * @returns the serialized block object
  119291. */
  119292. serialize(): any;
  119293. /** @hidden */
  119294. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119295. }
  119296. }
  119297. declare module BABYLON {
  119298. /**
  119299. * Enum defining the type of animations supported by InputBlock
  119300. */
  119301. export enum AnimatedInputBlockTypes {
  119302. /** No animation */
  119303. None = 0,
  119304. /** Time based animation. Will only work for floats */
  119305. Time = 1
  119306. }
  119307. }
  119308. declare module BABYLON {
  119309. /**
  119310. * Block used to expose an input value
  119311. */
  119312. export class InputBlock extends NodeMaterialBlock {
  119313. private _mode;
  119314. private _associatedVariableName;
  119315. private _storedValue;
  119316. private _valueCallback;
  119317. private _type;
  119318. private _animationType;
  119319. /** Gets or set a value used to limit the range of float values */
  119320. min: number;
  119321. /** Gets or set a value used to limit the range of float values */
  119322. max: number;
  119323. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  119324. matrixMode: number;
  119325. /** @hidden */
  119326. _systemValue: Nullable<NodeMaterialSystemValues>;
  119327. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  119328. visibleInInspector: boolean;
  119329. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  119330. isConstant: boolean;
  119331. /**
  119332. * Gets or sets the connection point type (default is float)
  119333. */
  119334. readonly type: NodeMaterialBlockConnectionPointTypes;
  119335. /**
  119336. * Creates a new InputBlock
  119337. * @param name defines the block name
  119338. * @param target defines the target of that block (Vertex by default)
  119339. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  119340. */
  119341. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  119342. /**
  119343. * Gets the output component
  119344. */
  119345. readonly output: NodeMaterialConnectionPoint;
  119346. /**
  119347. * Set the source of this connection point to a vertex attribute
  119348. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  119349. * @returns the current connection point
  119350. */
  119351. setAsAttribute(attributeName?: string): InputBlock;
  119352. /**
  119353. * Set the source of this connection point to a system value
  119354. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  119355. * @returns the current connection point
  119356. */
  119357. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  119358. /**
  119359. * Gets or sets the value of that point.
  119360. * Please note that this value will be ignored if valueCallback is defined
  119361. */
  119362. value: any;
  119363. /**
  119364. * Gets or sets a callback used to get the value of that point.
  119365. * Please note that setting this value will force the connection point to ignore the value property
  119366. */
  119367. valueCallback: () => any;
  119368. /**
  119369. * Gets or sets the associated variable name in the shader
  119370. */
  119371. associatedVariableName: string;
  119372. /** Gets or sets the type of animation applied to the input */
  119373. animationType: AnimatedInputBlockTypes;
  119374. /**
  119375. * Gets a boolean indicating that this connection point not defined yet
  119376. */
  119377. readonly isUndefined: boolean;
  119378. /**
  119379. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  119380. * In this case the connection point name must be the name of the uniform to use.
  119381. * Can only be set on inputs
  119382. */
  119383. isUniform: boolean;
  119384. /**
  119385. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  119386. * In this case the connection point name must be the name of the attribute to use
  119387. * Can only be set on inputs
  119388. */
  119389. isAttribute: boolean;
  119390. /**
  119391. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  119392. * Can only be set on exit points
  119393. */
  119394. isVarying: boolean;
  119395. /**
  119396. * Gets a boolean indicating that the current connection point is a system value
  119397. */
  119398. readonly isSystemValue: boolean;
  119399. /**
  119400. * Gets or sets the current well known value or null if not defined as a system value
  119401. */
  119402. systemValue: Nullable<NodeMaterialSystemValues>;
  119403. /**
  119404. * Gets the current class name
  119405. * @returns the class name
  119406. */
  119407. getClassName(): string;
  119408. /**
  119409. * Animate the input if animationType !== None
  119410. * @param scene defines the rendering scene
  119411. */
  119412. animate(scene: Scene): void;
  119413. private _emitDefine;
  119414. initialize(state: NodeMaterialBuildState): void;
  119415. /**
  119416. * Set the input block to its default value (based on its type)
  119417. */
  119418. setDefaultValue(): void;
  119419. private _emitConstant;
  119420. private _emit;
  119421. /** @hidden */
  119422. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  119423. /** @hidden */
  119424. _transmit(effect: Effect, scene: Scene): void;
  119425. protected _buildBlock(state: NodeMaterialBuildState): void;
  119426. protected _dumpPropertiesCode(): string;
  119427. serialize(): any;
  119428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119429. }
  119430. }
  119431. declare module BABYLON {
  119432. /**
  119433. * Defines a connection point for a block
  119434. */
  119435. export class NodeMaterialConnectionPoint {
  119436. /** @hidden */
  119437. _ownerBlock: NodeMaterialBlock;
  119438. /** @hidden */
  119439. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119440. private _endpoints;
  119441. private _associatedVariableName;
  119442. /** @hidden */
  119443. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119444. /** @hidden */
  119445. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119446. private _type;
  119447. /** @hidden */
  119448. _enforceAssociatedVariableName: boolean;
  119449. /**
  119450. * Gets or sets the additional types supported by this connection point
  119451. */
  119452. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119453. /**
  119454. * Gets or sets the additional types excluded by this connection point
  119455. */
  119456. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119457. /**
  119458. * Gets or sets the associated variable name in the shader
  119459. */
  119460. associatedVariableName: string;
  119461. /**
  119462. * Gets or sets the connection point type (default is float)
  119463. */
  119464. type: NodeMaterialBlockConnectionPointTypes;
  119465. /**
  119466. * Gets or sets the connection point name
  119467. */
  119468. name: string;
  119469. /**
  119470. * Gets or sets a boolean indicating that this connection point can be omitted
  119471. */
  119472. isOptional: boolean;
  119473. /**
  119474. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119475. */
  119476. define: string;
  119477. /** Gets or sets the target of that connection point */
  119478. target: NodeMaterialBlockTargets;
  119479. /**
  119480. * Gets a boolean indicating that the current point is connected
  119481. */
  119482. readonly isConnected: boolean;
  119483. /**
  119484. * Gets a boolean indicating that the current point is connected to an input block
  119485. */
  119486. readonly isConnectedToInputBlock: boolean;
  119487. /**
  119488. * Gets a the connected input block (if any)
  119489. */
  119490. readonly connectInputBlock: Nullable<InputBlock>;
  119491. /** Get the other side of the connection (if any) */
  119492. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119493. /** Get the block that owns this connection point */
  119494. readonly ownerBlock: NodeMaterialBlock;
  119495. /** Get the block connected on the other side of this connection (if any) */
  119496. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119497. /** Get the block connected on the endpoints of this connection (if any) */
  119498. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119499. /** Gets the list of connected endpoints */
  119500. readonly endpoints: NodeMaterialConnectionPoint[];
  119501. /** Gets a boolean indicating if that output point is connected to at least one input */
  119502. readonly hasEndpoints: boolean;
  119503. /**
  119504. * Creates a new connection point
  119505. * @param name defines the connection point name
  119506. * @param ownerBlock defines the block hosting this connection point
  119507. */
  119508. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119509. /**
  119510. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119511. * @returns the class name
  119512. */
  119513. getClassName(): string;
  119514. /**
  119515. * Gets an boolean indicating if the current point can be connected to another point
  119516. * @param connectionPoint defines the other connection point
  119517. * @returns true if the connection is possible
  119518. */
  119519. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119520. /**
  119521. * Connect this point to another connection point
  119522. * @param connectionPoint defines the other connection point
  119523. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119524. * @returns the current connection point
  119525. */
  119526. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119527. /**
  119528. * Disconnect this point from one of his endpoint
  119529. * @param endpoint defines the other connection point
  119530. * @returns the current connection point
  119531. */
  119532. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119533. /**
  119534. * Serializes this point in a JSON representation
  119535. * @returns the serialized point object
  119536. */
  119537. serialize(): any;
  119538. }
  119539. }
  119540. declare module BABYLON {
  119541. /**
  119542. * Block used to add support for vertex skinning (bones)
  119543. */
  119544. export class BonesBlock extends NodeMaterialBlock {
  119545. /**
  119546. * Creates a new BonesBlock
  119547. * @param name defines the block name
  119548. */
  119549. constructor(name: string);
  119550. /**
  119551. * Initialize the block and prepare the context for build
  119552. * @param state defines the state that will be used for the build
  119553. */
  119554. initialize(state: NodeMaterialBuildState): void;
  119555. /**
  119556. * Gets the current class name
  119557. * @returns the class name
  119558. */
  119559. getClassName(): string;
  119560. /**
  119561. * Gets the matrix indices input component
  119562. */
  119563. readonly matricesIndices: NodeMaterialConnectionPoint;
  119564. /**
  119565. * Gets the matrix weights input component
  119566. */
  119567. readonly matricesWeights: NodeMaterialConnectionPoint;
  119568. /**
  119569. * Gets the extra matrix indices input component
  119570. */
  119571. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119572. /**
  119573. * Gets the extra matrix weights input component
  119574. */
  119575. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119576. /**
  119577. * Gets the world input component
  119578. */
  119579. readonly world: NodeMaterialConnectionPoint;
  119580. /**
  119581. * Gets the output component
  119582. */
  119583. readonly output: NodeMaterialConnectionPoint;
  119584. autoConfigure(material: NodeMaterial): void;
  119585. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119586. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119588. protected _buildBlock(state: NodeMaterialBuildState): this;
  119589. }
  119590. }
  119591. declare module BABYLON {
  119592. /**
  119593. * Block used to add support for instances
  119594. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119595. */
  119596. export class InstancesBlock extends NodeMaterialBlock {
  119597. /**
  119598. * Creates a new InstancesBlock
  119599. * @param name defines the block name
  119600. */
  119601. constructor(name: string);
  119602. /**
  119603. * Gets the current class name
  119604. * @returns the class name
  119605. */
  119606. getClassName(): string;
  119607. /**
  119608. * Gets the first world row input component
  119609. */
  119610. readonly world0: NodeMaterialConnectionPoint;
  119611. /**
  119612. * Gets the second world row input component
  119613. */
  119614. readonly world1: NodeMaterialConnectionPoint;
  119615. /**
  119616. * Gets the third world row input component
  119617. */
  119618. readonly world2: NodeMaterialConnectionPoint;
  119619. /**
  119620. * Gets the forth world row input component
  119621. */
  119622. readonly world3: NodeMaterialConnectionPoint;
  119623. /**
  119624. * Gets the world input component
  119625. */
  119626. readonly world: NodeMaterialConnectionPoint;
  119627. /**
  119628. * Gets the output component
  119629. */
  119630. readonly output: NodeMaterialConnectionPoint;
  119631. autoConfigure(material: NodeMaterial): void;
  119632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119633. protected _buildBlock(state: NodeMaterialBuildState): this;
  119634. }
  119635. }
  119636. declare module BABYLON {
  119637. /**
  119638. * Block used to add morph targets support to vertex shader
  119639. */
  119640. export class MorphTargetsBlock extends NodeMaterialBlock {
  119641. private _repeatableContentAnchor;
  119642. private _repeatebleContentGenerated;
  119643. /**
  119644. * Create a new MorphTargetsBlock
  119645. * @param name defines the block name
  119646. */
  119647. constructor(name: string);
  119648. /**
  119649. * Gets the current class name
  119650. * @returns the class name
  119651. */
  119652. getClassName(): string;
  119653. /**
  119654. * Gets the position input component
  119655. */
  119656. readonly position: NodeMaterialConnectionPoint;
  119657. /**
  119658. * Gets the normal input component
  119659. */
  119660. readonly normal: NodeMaterialConnectionPoint;
  119661. /**
  119662. * Gets the tangent input component
  119663. */
  119664. readonly tangent: NodeMaterialConnectionPoint;
  119665. /**
  119666. * Gets the tangent input component
  119667. */
  119668. readonly uv: NodeMaterialConnectionPoint;
  119669. /**
  119670. * Gets the position output component
  119671. */
  119672. readonly positionOutput: NodeMaterialConnectionPoint;
  119673. /**
  119674. * Gets the normal output component
  119675. */
  119676. readonly normalOutput: NodeMaterialConnectionPoint;
  119677. /**
  119678. * Gets the tangent output component
  119679. */
  119680. readonly tangentOutput: NodeMaterialConnectionPoint;
  119681. /**
  119682. * Gets the tangent output component
  119683. */
  119684. readonly uvOutput: NodeMaterialConnectionPoint;
  119685. initialize(state: NodeMaterialBuildState): void;
  119686. autoConfigure(material: NodeMaterial): void;
  119687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119688. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119689. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119690. protected _buildBlock(state: NodeMaterialBuildState): this;
  119691. }
  119692. }
  119693. declare module BABYLON {
  119694. /**
  119695. * Block used to get data information from a light
  119696. */
  119697. export class LightInformationBlock extends NodeMaterialBlock {
  119698. private _lightDataUniformName;
  119699. private _lightColorUniformName;
  119700. private _lightTypeDefineName;
  119701. /**
  119702. * Gets or sets the light associated with this block
  119703. */
  119704. light: Nullable<Light>;
  119705. /**
  119706. * Creates a new LightInformationBlock
  119707. * @param name defines the block name
  119708. */
  119709. constructor(name: string);
  119710. /**
  119711. * Gets the current class name
  119712. * @returns the class name
  119713. */
  119714. getClassName(): string;
  119715. /**
  119716. * Gets the world position input component
  119717. */
  119718. readonly worldPosition: NodeMaterialConnectionPoint;
  119719. /**
  119720. * Gets the direction output component
  119721. */
  119722. readonly direction: NodeMaterialConnectionPoint;
  119723. /**
  119724. * Gets the direction output component
  119725. */
  119726. readonly color: NodeMaterialConnectionPoint;
  119727. /**
  119728. * Gets the direction output component
  119729. */
  119730. readonly intensity: NodeMaterialConnectionPoint;
  119731. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119733. protected _buildBlock(state: NodeMaterialBuildState): this;
  119734. serialize(): any;
  119735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119736. }
  119737. }
  119738. declare module BABYLON {
  119739. /**
  119740. * Block used to add image processing support to fragment shader
  119741. */
  119742. export class ImageProcessingBlock extends NodeMaterialBlock {
  119743. /**
  119744. * Create a new ImageProcessingBlock
  119745. * @param name defines the block name
  119746. */
  119747. constructor(name: string);
  119748. /**
  119749. * Gets the current class name
  119750. * @returns the class name
  119751. */
  119752. getClassName(): string;
  119753. /**
  119754. * Gets the color input component
  119755. */
  119756. readonly color: NodeMaterialConnectionPoint;
  119757. /**
  119758. * Gets the output component
  119759. */
  119760. readonly output: NodeMaterialConnectionPoint;
  119761. /**
  119762. * Initialize the block and prepare the context for build
  119763. * @param state defines the state that will be used for the build
  119764. */
  119765. initialize(state: NodeMaterialBuildState): void;
  119766. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119769. protected _buildBlock(state: NodeMaterialBuildState): this;
  119770. }
  119771. }
  119772. declare module BABYLON {
  119773. /**
  119774. * Block used to pertub normals based on a normal map
  119775. */
  119776. export class PerturbNormalBlock extends NodeMaterialBlock {
  119777. private _tangentSpaceParameterName;
  119778. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119779. invertX: boolean;
  119780. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119781. invertY: boolean;
  119782. /**
  119783. * Create a new PerturbNormalBlock
  119784. * @param name defines the block name
  119785. */
  119786. constructor(name: string);
  119787. /**
  119788. * Gets the current class name
  119789. * @returns the class name
  119790. */
  119791. getClassName(): string;
  119792. /**
  119793. * Gets the world position input component
  119794. */
  119795. readonly worldPosition: NodeMaterialConnectionPoint;
  119796. /**
  119797. * Gets the world normal input component
  119798. */
  119799. readonly worldNormal: NodeMaterialConnectionPoint;
  119800. /**
  119801. * Gets the uv input component
  119802. */
  119803. readonly uv: NodeMaterialConnectionPoint;
  119804. /**
  119805. * Gets the normal map color input component
  119806. */
  119807. readonly normalMapColor: NodeMaterialConnectionPoint;
  119808. /**
  119809. * Gets the strength input component
  119810. */
  119811. readonly strength: NodeMaterialConnectionPoint;
  119812. /**
  119813. * Gets the output component
  119814. */
  119815. readonly output: NodeMaterialConnectionPoint;
  119816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119818. autoConfigure(material: NodeMaterial): void;
  119819. protected _buildBlock(state: NodeMaterialBuildState): this;
  119820. protected _dumpPropertiesCode(): string;
  119821. serialize(): any;
  119822. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119823. }
  119824. }
  119825. declare module BABYLON {
  119826. /**
  119827. * Block used to discard a pixel if a value is smaller than a cutoff
  119828. */
  119829. export class DiscardBlock extends NodeMaterialBlock {
  119830. /**
  119831. * Create a new DiscardBlock
  119832. * @param name defines the block name
  119833. */
  119834. constructor(name: string);
  119835. /**
  119836. * Gets the current class name
  119837. * @returns the class name
  119838. */
  119839. getClassName(): string;
  119840. /**
  119841. * Gets the color input component
  119842. */
  119843. readonly value: NodeMaterialConnectionPoint;
  119844. /**
  119845. * Gets the cutoff input component
  119846. */
  119847. readonly cutoff: NodeMaterialConnectionPoint;
  119848. protected _buildBlock(state: NodeMaterialBuildState): this;
  119849. }
  119850. }
  119851. declare module BABYLON {
  119852. /**
  119853. * Block used to add support for scene fog
  119854. */
  119855. export class FogBlock extends NodeMaterialBlock {
  119856. private _fogDistanceName;
  119857. private _fogParameters;
  119858. /**
  119859. * Create a new FogBlock
  119860. * @param name defines the block name
  119861. */
  119862. constructor(name: string);
  119863. /**
  119864. * Gets the current class name
  119865. * @returns the class name
  119866. */
  119867. getClassName(): string;
  119868. /**
  119869. * Gets the world position input component
  119870. */
  119871. readonly worldPosition: NodeMaterialConnectionPoint;
  119872. /**
  119873. * Gets the view input component
  119874. */
  119875. readonly view: NodeMaterialConnectionPoint;
  119876. /**
  119877. * Gets the color input component
  119878. */
  119879. readonly input: NodeMaterialConnectionPoint;
  119880. /**
  119881. * Gets the fog color input component
  119882. */
  119883. readonly fogColor: NodeMaterialConnectionPoint;
  119884. /**
  119885. * Gets the output component
  119886. */
  119887. readonly output: NodeMaterialConnectionPoint;
  119888. autoConfigure(material: NodeMaterial): void;
  119889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119890. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119891. protected _buildBlock(state: NodeMaterialBuildState): this;
  119892. }
  119893. }
  119894. declare module BABYLON {
  119895. /**
  119896. * Block used to add light in the fragment shader
  119897. */
  119898. export class LightBlock extends NodeMaterialBlock {
  119899. private _lightId;
  119900. /**
  119901. * Gets or sets the light associated with this block
  119902. */
  119903. light: Nullable<Light>;
  119904. /**
  119905. * Create a new LightBlock
  119906. * @param name defines the block name
  119907. */
  119908. constructor(name: string);
  119909. /**
  119910. * Gets the current class name
  119911. * @returns the class name
  119912. */
  119913. getClassName(): string;
  119914. /**
  119915. * Gets the world position input component
  119916. */
  119917. readonly worldPosition: NodeMaterialConnectionPoint;
  119918. /**
  119919. * Gets the world normal input component
  119920. */
  119921. readonly worldNormal: NodeMaterialConnectionPoint;
  119922. /**
  119923. * Gets the camera (or eye) position component
  119924. */
  119925. readonly cameraPosition: NodeMaterialConnectionPoint;
  119926. /**
  119927. * Gets the diffuse output component
  119928. */
  119929. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119930. /**
  119931. * Gets the specular output component
  119932. */
  119933. readonly specularOutput: NodeMaterialConnectionPoint;
  119934. autoConfigure(material: NodeMaterial): void;
  119935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119936. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119937. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119938. private _injectVertexCode;
  119939. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119940. serialize(): any;
  119941. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119942. }
  119943. }
  119944. declare module BABYLON {
  119945. /**
  119946. * Block used to multiply 2 values
  119947. */
  119948. export class MultiplyBlock extends NodeMaterialBlock {
  119949. /**
  119950. * Creates a new MultiplyBlock
  119951. * @param name defines the block name
  119952. */
  119953. constructor(name: string);
  119954. /**
  119955. * Gets the current class name
  119956. * @returns the class name
  119957. */
  119958. getClassName(): string;
  119959. /**
  119960. * Gets the left operand input component
  119961. */
  119962. readonly left: NodeMaterialConnectionPoint;
  119963. /**
  119964. * Gets the right operand input component
  119965. */
  119966. readonly right: NodeMaterialConnectionPoint;
  119967. /**
  119968. * Gets the output component
  119969. */
  119970. readonly output: NodeMaterialConnectionPoint;
  119971. protected _buildBlock(state: NodeMaterialBuildState): this;
  119972. }
  119973. }
  119974. declare module BABYLON {
  119975. /**
  119976. * Block used to add 2 vectors
  119977. */
  119978. export class AddBlock extends NodeMaterialBlock {
  119979. /**
  119980. * Creates a new AddBlock
  119981. * @param name defines the block name
  119982. */
  119983. constructor(name: string);
  119984. /**
  119985. * Gets the current class name
  119986. * @returns the class name
  119987. */
  119988. getClassName(): string;
  119989. /**
  119990. * Gets the left operand input component
  119991. */
  119992. readonly left: NodeMaterialConnectionPoint;
  119993. /**
  119994. * Gets the right operand input component
  119995. */
  119996. readonly right: NodeMaterialConnectionPoint;
  119997. /**
  119998. * Gets the output component
  119999. */
  120000. readonly output: NodeMaterialConnectionPoint;
  120001. protected _buildBlock(state: NodeMaterialBuildState): this;
  120002. }
  120003. }
  120004. declare module BABYLON {
  120005. /**
  120006. * Block used to scale a vector by a float
  120007. */
  120008. export class ScaleBlock extends NodeMaterialBlock {
  120009. /**
  120010. * Creates a new ScaleBlock
  120011. * @param name defines the block name
  120012. */
  120013. constructor(name: string);
  120014. /**
  120015. * Gets the current class name
  120016. * @returns the class name
  120017. */
  120018. getClassName(): string;
  120019. /**
  120020. * Gets the input component
  120021. */
  120022. readonly input: NodeMaterialConnectionPoint;
  120023. /**
  120024. * Gets the factor input component
  120025. */
  120026. readonly factor: NodeMaterialConnectionPoint;
  120027. /**
  120028. * Gets the output component
  120029. */
  120030. readonly output: NodeMaterialConnectionPoint;
  120031. protected _buildBlock(state: NodeMaterialBuildState): this;
  120032. }
  120033. }
  120034. declare module BABYLON {
  120035. /**
  120036. * Block used to clamp a float
  120037. */
  120038. export class ClampBlock extends NodeMaterialBlock {
  120039. /** Gets or sets the minimum range */
  120040. minimum: number;
  120041. /** Gets or sets the maximum range */
  120042. maximum: number;
  120043. /**
  120044. * Creates a new ClampBlock
  120045. * @param name defines the block name
  120046. */
  120047. constructor(name: string);
  120048. /**
  120049. * Gets the current class name
  120050. * @returns the class name
  120051. */
  120052. getClassName(): string;
  120053. /**
  120054. * Gets the value input component
  120055. */
  120056. readonly value: NodeMaterialConnectionPoint;
  120057. /**
  120058. * Gets the output component
  120059. */
  120060. readonly output: NodeMaterialConnectionPoint;
  120061. protected _buildBlock(state: NodeMaterialBuildState): this;
  120062. protected _dumpPropertiesCode(): string;
  120063. serialize(): any;
  120064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120065. }
  120066. }
  120067. declare module BABYLON {
  120068. /**
  120069. * Block used to apply a cross product between 2 vectors
  120070. */
  120071. export class CrossBlock extends NodeMaterialBlock {
  120072. /**
  120073. * Creates a new CrossBlock
  120074. * @param name defines the block name
  120075. */
  120076. constructor(name: string);
  120077. /**
  120078. * Gets the current class name
  120079. * @returns the class name
  120080. */
  120081. getClassName(): string;
  120082. /**
  120083. * Gets the left operand input component
  120084. */
  120085. readonly left: NodeMaterialConnectionPoint;
  120086. /**
  120087. * Gets the right operand input component
  120088. */
  120089. readonly right: NodeMaterialConnectionPoint;
  120090. /**
  120091. * Gets the output component
  120092. */
  120093. readonly output: NodeMaterialConnectionPoint;
  120094. protected _buildBlock(state: NodeMaterialBuildState): this;
  120095. }
  120096. }
  120097. declare module BABYLON {
  120098. /**
  120099. * Block used to apply a dot product between 2 vectors
  120100. */
  120101. export class DotBlock extends NodeMaterialBlock {
  120102. /**
  120103. * Creates a new DotBlock
  120104. * @param name defines the block name
  120105. */
  120106. constructor(name: string);
  120107. /**
  120108. * Gets the current class name
  120109. * @returns the class name
  120110. */
  120111. getClassName(): string;
  120112. /**
  120113. * Gets the left operand input component
  120114. */
  120115. readonly left: NodeMaterialConnectionPoint;
  120116. /**
  120117. * Gets the right operand input component
  120118. */
  120119. readonly right: NodeMaterialConnectionPoint;
  120120. /**
  120121. * Gets the output component
  120122. */
  120123. readonly output: NodeMaterialConnectionPoint;
  120124. protected _buildBlock(state: NodeMaterialBuildState): this;
  120125. }
  120126. }
  120127. declare module BABYLON {
  120128. /**
  120129. * Block used to remap a float from a range to a new one
  120130. */
  120131. export class RemapBlock extends NodeMaterialBlock {
  120132. /**
  120133. * Gets or sets the source range
  120134. */
  120135. sourceRange: Vector2;
  120136. /**
  120137. * Gets or sets the target range
  120138. */
  120139. targetRange: Vector2;
  120140. /**
  120141. * Creates a new RemapBlock
  120142. * @param name defines the block name
  120143. */
  120144. constructor(name: string);
  120145. /**
  120146. * Gets the current class name
  120147. * @returns the class name
  120148. */
  120149. getClassName(): string;
  120150. /**
  120151. * Gets the input component
  120152. */
  120153. readonly input: NodeMaterialConnectionPoint;
  120154. /**
  120155. * Gets the source min input component
  120156. */
  120157. readonly sourceMin: NodeMaterialConnectionPoint;
  120158. /**
  120159. * Gets the source max input component
  120160. */
  120161. readonly sourceMax: NodeMaterialConnectionPoint;
  120162. /**
  120163. * Gets the target min input component
  120164. */
  120165. readonly targetMin: NodeMaterialConnectionPoint;
  120166. /**
  120167. * Gets the target max input component
  120168. */
  120169. readonly targetMax: NodeMaterialConnectionPoint;
  120170. /**
  120171. * Gets the output component
  120172. */
  120173. readonly output: NodeMaterialConnectionPoint;
  120174. protected _buildBlock(state: NodeMaterialBuildState): this;
  120175. protected _dumpPropertiesCode(): string;
  120176. serialize(): any;
  120177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120178. }
  120179. }
  120180. declare module BABYLON {
  120181. /**
  120182. * Block used to normalize a vector
  120183. */
  120184. export class NormalizeBlock extends NodeMaterialBlock {
  120185. /**
  120186. * Creates a new NormalizeBlock
  120187. * @param name defines the block name
  120188. */
  120189. constructor(name: string);
  120190. /**
  120191. * Gets the current class name
  120192. * @returns the class name
  120193. */
  120194. getClassName(): string;
  120195. /**
  120196. * Gets the input component
  120197. */
  120198. readonly input: NodeMaterialConnectionPoint;
  120199. /**
  120200. * Gets the output component
  120201. */
  120202. readonly output: NodeMaterialConnectionPoint;
  120203. protected _buildBlock(state: NodeMaterialBuildState): this;
  120204. }
  120205. }
  120206. declare module BABYLON {
  120207. /**
  120208. * Operations supported by the Trigonometry block
  120209. */
  120210. export enum TrigonometryBlockOperations {
  120211. /** Cos */
  120212. Cos = 0,
  120213. /** Sin */
  120214. Sin = 1,
  120215. /** Abs */
  120216. Abs = 2,
  120217. /** Exp */
  120218. Exp = 3,
  120219. /** Exp2 */
  120220. Exp2 = 4,
  120221. /** Round */
  120222. Round = 5,
  120223. /** Floor */
  120224. Floor = 6,
  120225. /** Ceiling */
  120226. Ceiling = 7,
  120227. /** Square root */
  120228. Sqrt = 8
  120229. }
  120230. /**
  120231. * Block used to apply trigonometry operation to floats
  120232. */
  120233. export class TrigonometryBlock extends NodeMaterialBlock {
  120234. /**
  120235. * Gets or sets the operation applied by the block
  120236. */
  120237. operation: TrigonometryBlockOperations;
  120238. /**
  120239. * Creates a new TrigonometryBlock
  120240. * @param name defines the block name
  120241. */
  120242. constructor(name: string);
  120243. /**
  120244. * Gets the current class name
  120245. * @returns the class name
  120246. */
  120247. getClassName(): string;
  120248. /**
  120249. * Gets the input component
  120250. */
  120251. readonly input: NodeMaterialConnectionPoint;
  120252. /**
  120253. * Gets the output component
  120254. */
  120255. readonly output: NodeMaterialConnectionPoint;
  120256. protected _buildBlock(state: NodeMaterialBuildState): this;
  120257. serialize(): any;
  120258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120259. }
  120260. }
  120261. declare module BABYLON {
  120262. /**
  120263. * Block used to create a Color3/4 out of individual inputs (one for each component)
  120264. */
  120265. export class ColorMergerBlock extends NodeMaterialBlock {
  120266. /**
  120267. * Create a new ColorMergerBlock
  120268. * @param name defines the block name
  120269. */
  120270. constructor(name: string);
  120271. /**
  120272. * Gets the current class name
  120273. * @returns the class name
  120274. */
  120275. getClassName(): string;
  120276. /**
  120277. * Gets the r component (input)
  120278. */
  120279. readonly r: NodeMaterialConnectionPoint;
  120280. /**
  120281. * Gets the g component (input)
  120282. */
  120283. readonly g: NodeMaterialConnectionPoint;
  120284. /**
  120285. * Gets the b component (input)
  120286. */
  120287. readonly b: NodeMaterialConnectionPoint;
  120288. /**
  120289. * Gets the a component (input)
  120290. */
  120291. readonly a: NodeMaterialConnectionPoint;
  120292. /**
  120293. * Gets the rgba component (output)
  120294. */
  120295. readonly rgba: NodeMaterialConnectionPoint;
  120296. /**
  120297. * Gets the rgb component (output)
  120298. */
  120299. readonly rgb: NodeMaterialConnectionPoint;
  120300. protected _buildBlock(state: NodeMaterialBuildState): this;
  120301. }
  120302. }
  120303. declare module BABYLON {
  120304. /**
  120305. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  120306. */
  120307. export class VectorMergerBlock extends NodeMaterialBlock {
  120308. /**
  120309. * Create a new VectorMergerBlock
  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 x component (input)
  120320. */
  120321. readonly x: NodeMaterialConnectionPoint;
  120322. /**
  120323. * Gets the y component (input)
  120324. */
  120325. readonly y: NodeMaterialConnectionPoint;
  120326. /**
  120327. * Gets the z component (input)
  120328. */
  120329. readonly z: NodeMaterialConnectionPoint;
  120330. /**
  120331. * Gets the w component (input)
  120332. */
  120333. readonly w: NodeMaterialConnectionPoint;
  120334. /**
  120335. * Gets the xyzw component (output)
  120336. */
  120337. readonly xyzw: NodeMaterialConnectionPoint;
  120338. /**
  120339. * Gets the xyz component (output)
  120340. */
  120341. readonly xyz: NodeMaterialConnectionPoint;
  120342. /**
  120343. * Gets the xy component (output)
  120344. */
  120345. readonly xy: NodeMaterialConnectionPoint;
  120346. protected _buildBlock(state: NodeMaterialBuildState): this;
  120347. }
  120348. }
  120349. declare module BABYLON {
  120350. /**
  120351. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  120352. */
  120353. export class ColorSplitterBlock extends NodeMaterialBlock {
  120354. /**
  120355. * Create a new ColorSplitterBlock
  120356. * @param name defines the block name
  120357. */
  120358. constructor(name: string);
  120359. /**
  120360. * Gets the current class name
  120361. * @returns the class name
  120362. */
  120363. getClassName(): string;
  120364. /**
  120365. * Gets the rgba component (input)
  120366. */
  120367. readonly rgba: NodeMaterialConnectionPoint;
  120368. /**
  120369. * Gets the rgb component (input)
  120370. */
  120371. readonly rgbIn: NodeMaterialConnectionPoint;
  120372. /**
  120373. * Gets the rgb component (output)
  120374. */
  120375. readonly rgbOut: NodeMaterialConnectionPoint;
  120376. /**
  120377. * Gets the r component (output)
  120378. */
  120379. readonly r: NodeMaterialConnectionPoint;
  120380. /**
  120381. * Gets the g component (output)
  120382. */
  120383. readonly g: NodeMaterialConnectionPoint;
  120384. /**
  120385. * Gets the b component (output)
  120386. */
  120387. readonly b: NodeMaterialConnectionPoint;
  120388. /**
  120389. * Gets the a component (output)
  120390. */
  120391. readonly a: NodeMaterialConnectionPoint;
  120392. protected _inputRename(name: string): string;
  120393. protected _outputRename(name: string): string;
  120394. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120395. }
  120396. }
  120397. declare module BABYLON {
  120398. /**
  120399. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  120400. */
  120401. export class VectorSplitterBlock extends NodeMaterialBlock {
  120402. /**
  120403. * Create a new VectorSplitterBlock
  120404. * @param name defines the block name
  120405. */
  120406. constructor(name: string);
  120407. /**
  120408. * Gets the current class name
  120409. * @returns the class name
  120410. */
  120411. getClassName(): string;
  120412. /**
  120413. * Gets the xyzw component (input)
  120414. */
  120415. readonly xyzw: NodeMaterialConnectionPoint;
  120416. /**
  120417. * Gets the xyz component (input)
  120418. */
  120419. readonly xyzIn: NodeMaterialConnectionPoint;
  120420. /**
  120421. * Gets the xy component (input)
  120422. */
  120423. readonly xyIn: NodeMaterialConnectionPoint;
  120424. /**
  120425. * Gets the xyz component (output)
  120426. */
  120427. readonly xyzOut: NodeMaterialConnectionPoint;
  120428. /**
  120429. * Gets the xy component (output)
  120430. */
  120431. readonly xyOut: NodeMaterialConnectionPoint;
  120432. /**
  120433. * Gets the x component (output)
  120434. */
  120435. readonly x: NodeMaterialConnectionPoint;
  120436. /**
  120437. * Gets the y component (output)
  120438. */
  120439. readonly y: NodeMaterialConnectionPoint;
  120440. /**
  120441. * Gets the z component (output)
  120442. */
  120443. readonly z: NodeMaterialConnectionPoint;
  120444. /**
  120445. * Gets the w component (output)
  120446. */
  120447. readonly w: NodeMaterialConnectionPoint;
  120448. protected _inputRename(name: string): string;
  120449. protected _outputRename(name: string): string;
  120450. protected _buildBlock(state: NodeMaterialBuildState): this;
  120451. }
  120452. }
  120453. declare module BABYLON {
  120454. /**
  120455. * Block used to lerp 2 values
  120456. */
  120457. export class LerpBlock extends NodeMaterialBlock {
  120458. /**
  120459. * Creates a new LerpBlock
  120460. * @param name defines the block name
  120461. */
  120462. constructor(name: string);
  120463. /**
  120464. * Gets the current class name
  120465. * @returns the class name
  120466. */
  120467. getClassName(): string;
  120468. /**
  120469. * Gets the left operand input component
  120470. */
  120471. readonly left: NodeMaterialConnectionPoint;
  120472. /**
  120473. * Gets the right operand input component
  120474. */
  120475. readonly right: NodeMaterialConnectionPoint;
  120476. /**
  120477. * Gets the gradient operand input component
  120478. */
  120479. readonly gradient: NodeMaterialConnectionPoint;
  120480. /**
  120481. * Gets the output component
  120482. */
  120483. readonly output: NodeMaterialConnectionPoint;
  120484. protected _buildBlock(state: NodeMaterialBuildState): this;
  120485. }
  120486. }
  120487. declare module BABYLON {
  120488. /**
  120489. * Block used to divide 2 vectors
  120490. */
  120491. export class DivideBlock extends NodeMaterialBlock {
  120492. /**
  120493. * Creates a new DivideBlock
  120494. * @param name defines the block name
  120495. */
  120496. constructor(name: string);
  120497. /**
  120498. * Gets the current class name
  120499. * @returns the class name
  120500. */
  120501. getClassName(): string;
  120502. /**
  120503. * Gets the left operand input component
  120504. */
  120505. readonly left: NodeMaterialConnectionPoint;
  120506. /**
  120507. * Gets the right operand input component
  120508. */
  120509. readonly right: NodeMaterialConnectionPoint;
  120510. /**
  120511. * Gets the output component
  120512. */
  120513. readonly output: NodeMaterialConnectionPoint;
  120514. protected _buildBlock(state: NodeMaterialBuildState): this;
  120515. }
  120516. }
  120517. declare module BABYLON {
  120518. /**
  120519. * Block used to subtract 2 vectors
  120520. */
  120521. export class SubtractBlock extends NodeMaterialBlock {
  120522. /**
  120523. * Creates a new SubtractBlock
  120524. * @param name defines the block name
  120525. */
  120526. constructor(name: string);
  120527. /**
  120528. * Gets the current class name
  120529. * @returns the class name
  120530. */
  120531. getClassName(): string;
  120532. /**
  120533. * Gets the left operand input component
  120534. */
  120535. readonly left: NodeMaterialConnectionPoint;
  120536. /**
  120537. * Gets the right operand input component
  120538. */
  120539. readonly right: NodeMaterialConnectionPoint;
  120540. /**
  120541. * Gets the output component
  120542. */
  120543. readonly output: NodeMaterialConnectionPoint;
  120544. protected _buildBlock(state: NodeMaterialBuildState): this;
  120545. }
  120546. }
  120547. declare module BABYLON {
  120548. /**
  120549. * Block used to step a value
  120550. */
  120551. export class StepBlock extends NodeMaterialBlock {
  120552. /**
  120553. * Creates a new AddBlock
  120554. * @param name defines the block name
  120555. */
  120556. constructor(name: string);
  120557. /**
  120558. * Gets the current class name
  120559. * @returns the class name
  120560. */
  120561. getClassName(): string;
  120562. /**
  120563. * Gets the value operand input component
  120564. */
  120565. readonly value: NodeMaterialConnectionPoint;
  120566. /**
  120567. * Gets the edge operand input component
  120568. */
  120569. readonly edge: NodeMaterialConnectionPoint;
  120570. /**
  120571. * Gets the output component
  120572. */
  120573. readonly output: NodeMaterialConnectionPoint;
  120574. protected _buildBlock(state: NodeMaterialBuildState): this;
  120575. }
  120576. }
  120577. declare module BABYLON {
  120578. /**
  120579. * Block used to get the opposite (1 - x) of a value
  120580. */
  120581. export class OneMinusBlock extends NodeMaterialBlock {
  120582. /**
  120583. * Creates a new OneMinusBlock
  120584. * @param name defines the block name
  120585. */
  120586. constructor(name: string);
  120587. /**
  120588. * Gets the current class name
  120589. * @returns the class name
  120590. */
  120591. getClassName(): string;
  120592. /**
  120593. * Gets the input component
  120594. */
  120595. readonly input: NodeMaterialConnectionPoint;
  120596. /**
  120597. * Gets the output component
  120598. */
  120599. readonly output: NodeMaterialConnectionPoint;
  120600. protected _buildBlock(state: NodeMaterialBuildState): this;
  120601. }
  120602. }
  120603. declare module BABYLON {
  120604. /**
  120605. * Block used to get the view direction
  120606. */
  120607. export class ViewDirectionBlock extends NodeMaterialBlock {
  120608. /**
  120609. * Creates a new ViewDirectionBlock
  120610. * @param name defines the block name
  120611. */
  120612. constructor(name: string);
  120613. /**
  120614. * Gets the current class name
  120615. * @returns the class name
  120616. */
  120617. getClassName(): string;
  120618. /**
  120619. * Gets the world position component
  120620. */
  120621. readonly worldPosition: NodeMaterialConnectionPoint;
  120622. /**
  120623. * Gets the camera position component
  120624. */
  120625. readonly cameraPosition: NodeMaterialConnectionPoint;
  120626. /**
  120627. * Gets the output component
  120628. */
  120629. readonly output: NodeMaterialConnectionPoint;
  120630. autoConfigure(material: NodeMaterial): void;
  120631. protected _buildBlock(state: NodeMaterialBuildState): this;
  120632. }
  120633. }
  120634. declare module BABYLON {
  120635. /**
  120636. * Block used to compute fresnel value
  120637. */
  120638. export class FresnelBlock extends NodeMaterialBlock {
  120639. /**
  120640. * Create a new FresnelBlock
  120641. * @param name defines the block name
  120642. */
  120643. constructor(name: string);
  120644. /**
  120645. * Gets the current class name
  120646. * @returns the class name
  120647. */
  120648. getClassName(): string;
  120649. /**
  120650. * Gets the world normal input component
  120651. */
  120652. readonly worldNormal: NodeMaterialConnectionPoint;
  120653. /**
  120654. * Gets the view direction input component
  120655. */
  120656. readonly viewDirection: NodeMaterialConnectionPoint;
  120657. /**
  120658. * Gets the bias input component
  120659. */
  120660. readonly bias: NodeMaterialConnectionPoint;
  120661. /**
  120662. * Gets the camera (or eye) position component
  120663. */
  120664. readonly power: NodeMaterialConnectionPoint;
  120665. /**
  120666. * Gets the fresnel output component
  120667. */
  120668. readonly fresnel: NodeMaterialConnectionPoint;
  120669. autoConfigure(material: NodeMaterial): void;
  120670. protected _buildBlock(state: NodeMaterialBuildState): this;
  120671. }
  120672. }
  120673. declare module BABYLON {
  120674. /**
  120675. * Block used to get the max of 2 values
  120676. */
  120677. export class MaxBlock extends NodeMaterialBlock {
  120678. /**
  120679. * Creates a new MaxBlock
  120680. * @param name defines the block name
  120681. */
  120682. constructor(name: string);
  120683. /**
  120684. * Gets the current class name
  120685. * @returns the class name
  120686. */
  120687. getClassName(): string;
  120688. /**
  120689. * Gets the left operand input component
  120690. */
  120691. readonly left: NodeMaterialConnectionPoint;
  120692. /**
  120693. * Gets the right operand input component
  120694. */
  120695. readonly right: NodeMaterialConnectionPoint;
  120696. /**
  120697. * Gets the output component
  120698. */
  120699. readonly output: NodeMaterialConnectionPoint;
  120700. protected _buildBlock(state: NodeMaterialBuildState): this;
  120701. }
  120702. }
  120703. declare module BABYLON {
  120704. /**
  120705. * Block used to get the min of 2 values
  120706. */
  120707. export class MinBlock extends NodeMaterialBlock {
  120708. /**
  120709. * Creates a new MinBlock
  120710. * @param name defines the block name
  120711. */
  120712. constructor(name: string);
  120713. /**
  120714. * Gets the current class name
  120715. * @returns the class name
  120716. */
  120717. getClassName(): string;
  120718. /**
  120719. * Gets the left operand input component
  120720. */
  120721. readonly left: NodeMaterialConnectionPoint;
  120722. /**
  120723. * Gets the right operand input component
  120724. */
  120725. readonly right: NodeMaterialConnectionPoint;
  120726. /**
  120727. * Gets the output component
  120728. */
  120729. readonly output: NodeMaterialConnectionPoint;
  120730. protected _buildBlock(state: NodeMaterialBuildState): this;
  120731. }
  120732. }
  120733. declare module BABYLON {
  120734. /**
  120735. * Block used to get the distance between 2 values
  120736. */
  120737. export class DistanceBlock extends NodeMaterialBlock {
  120738. /**
  120739. * Creates a new DistanceBlock
  120740. * @param name defines the block name
  120741. */
  120742. constructor(name: string);
  120743. /**
  120744. * Gets the current class name
  120745. * @returns the class name
  120746. */
  120747. getClassName(): string;
  120748. /**
  120749. * Gets the left operand input component
  120750. */
  120751. readonly left: NodeMaterialConnectionPoint;
  120752. /**
  120753. * Gets the right operand input component
  120754. */
  120755. readonly right: NodeMaterialConnectionPoint;
  120756. /**
  120757. * Gets the output component
  120758. */
  120759. readonly output: NodeMaterialConnectionPoint;
  120760. protected _buildBlock(state: NodeMaterialBuildState): this;
  120761. }
  120762. }
  120763. declare module BABYLON {
  120764. /**
  120765. * Block used to get the length of a vector
  120766. */
  120767. export class LengthBlock extends NodeMaterialBlock {
  120768. /**
  120769. * Creates a new LengthBlock
  120770. * @param name defines the block name
  120771. */
  120772. constructor(name: string);
  120773. /**
  120774. * Gets the current class name
  120775. * @returns the class name
  120776. */
  120777. getClassName(): string;
  120778. /**
  120779. * Gets the value input component
  120780. */
  120781. readonly value: NodeMaterialConnectionPoint;
  120782. /**
  120783. * Gets the output component
  120784. */
  120785. readonly output: NodeMaterialConnectionPoint;
  120786. protected _buildBlock(state: NodeMaterialBuildState): this;
  120787. }
  120788. }
  120789. declare module BABYLON {
  120790. /**
  120791. * Block used to get negative version of a value (i.e. x * -1)
  120792. */
  120793. export class NegateBlock extends NodeMaterialBlock {
  120794. /**
  120795. * Creates a new NegateBlock
  120796. * @param name defines the block name
  120797. */
  120798. constructor(name: string);
  120799. /**
  120800. * Gets the current class name
  120801. * @returns the class name
  120802. */
  120803. getClassName(): string;
  120804. /**
  120805. * Gets the value input component
  120806. */
  120807. readonly value: NodeMaterialConnectionPoint;
  120808. /**
  120809. * Gets the output component
  120810. */
  120811. readonly output: NodeMaterialConnectionPoint;
  120812. protected _buildBlock(state: NodeMaterialBuildState): this;
  120813. }
  120814. }
  120815. declare module BABYLON {
  120816. /**
  120817. * Block used to get the value of the first parameter raised to the power of the second
  120818. */
  120819. export class PowBlock extends NodeMaterialBlock {
  120820. /**
  120821. * Creates a new PowBlock
  120822. * @param name defines the block name
  120823. */
  120824. constructor(name: string);
  120825. /**
  120826. * Gets the current class name
  120827. * @returns the class name
  120828. */
  120829. getClassName(): string;
  120830. /**
  120831. * Gets the value operand input component
  120832. */
  120833. readonly value: NodeMaterialConnectionPoint;
  120834. /**
  120835. * Gets the power operand input component
  120836. */
  120837. readonly power: NodeMaterialConnectionPoint;
  120838. /**
  120839. * Gets the output component
  120840. */
  120841. readonly output: NodeMaterialConnectionPoint;
  120842. protected _buildBlock(state: NodeMaterialBuildState): this;
  120843. }
  120844. }
  120845. declare module BABYLON {
  120846. /**
  120847. * Block used to get a random number
  120848. */
  120849. export class RandomNumberBlock extends NodeMaterialBlock {
  120850. /**
  120851. * Creates a new RandomNumberBlock
  120852. * @param name defines the block name
  120853. */
  120854. constructor(name: string);
  120855. /**
  120856. * Gets the current class name
  120857. * @returns the class name
  120858. */
  120859. getClassName(): string;
  120860. /**
  120861. * Gets the seed input component
  120862. */
  120863. readonly seed: NodeMaterialConnectionPoint;
  120864. /**
  120865. * Gets the output component
  120866. */
  120867. readonly output: NodeMaterialConnectionPoint;
  120868. protected _buildBlock(state: NodeMaterialBuildState): this;
  120869. }
  120870. }
  120871. declare module BABYLON {
  120872. /**
  120873. * Effect Render Options
  120874. */
  120875. export interface IEffectRendererOptions {
  120876. /**
  120877. * Defines the vertices positions.
  120878. */
  120879. positions?: number[];
  120880. /**
  120881. * Defines the indices.
  120882. */
  120883. indices?: number[];
  120884. }
  120885. /**
  120886. * Helper class to render one or more effects
  120887. */
  120888. export class EffectRenderer {
  120889. private engine;
  120890. private static _DefaultOptions;
  120891. private _vertexBuffers;
  120892. private _indexBuffer;
  120893. private _ringBufferIndex;
  120894. private _ringScreenBuffer;
  120895. private _fullscreenViewport;
  120896. private _getNextFrameBuffer;
  120897. /**
  120898. * Creates an effect renderer
  120899. * @param engine the engine to use for rendering
  120900. * @param options defines the options of the effect renderer
  120901. */
  120902. constructor(engine: Engine, options?: IEffectRendererOptions);
  120903. /**
  120904. * Sets the current viewport in normalized coordinates 0-1
  120905. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120906. */
  120907. setViewport(viewport?: Viewport): void;
  120908. /**
  120909. * Binds the embedded attributes buffer to the effect.
  120910. * @param effect Defines the effect to bind the attributes for
  120911. */
  120912. bindBuffers(effect: Effect): void;
  120913. /**
  120914. * Sets the current effect wrapper to use during draw.
  120915. * The effect needs to be ready before calling this api.
  120916. * This also sets the default full screen position attribute.
  120917. * @param effectWrapper Defines the effect to draw with
  120918. */
  120919. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120920. /**
  120921. * Draws a full screen quad.
  120922. */
  120923. draw(): void;
  120924. /**
  120925. * renders one or more effects to a specified texture
  120926. * @param effectWrappers list of effects to renderer
  120927. * @param outputTexture texture to draw to, if null it will render to the screen
  120928. */
  120929. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120930. /**
  120931. * Disposes of the effect renderer
  120932. */
  120933. dispose(): void;
  120934. }
  120935. /**
  120936. * Options to create an EffectWrapper
  120937. */
  120938. interface EffectWrapperCreationOptions {
  120939. /**
  120940. * Engine to use to create the effect
  120941. */
  120942. engine: Engine;
  120943. /**
  120944. * Fragment shader for the effect
  120945. */
  120946. fragmentShader: string;
  120947. /**
  120948. * Vertex shader for the effect
  120949. */
  120950. vertexShader?: string;
  120951. /**
  120952. * Attributes to use in the shader
  120953. */
  120954. attributeNames?: Array<string>;
  120955. /**
  120956. * Uniforms to use in the shader
  120957. */
  120958. uniformNames?: Array<string>;
  120959. /**
  120960. * Texture sampler names to use in the shader
  120961. */
  120962. samplerNames?: Array<string>;
  120963. /**
  120964. * The friendly name of the effect displayed in Spector.
  120965. */
  120966. name?: string;
  120967. }
  120968. /**
  120969. * Wraps an effect to be used for rendering
  120970. */
  120971. export class EffectWrapper {
  120972. /**
  120973. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120974. */
  120975. onApplyObservable: Observable<{}>;
  120976. /**
  120977. * The underlying effect
  120978. */
  120979. effect: Effect;
  120980. /**
  120981. * Creates an effect to be renderer
  120982. * @param creationOptions options to create the effect
  120983. */
  120984. constructor(creationOptions: EffectWrapperCreationOptions);
  120985. /**
  120986. * Disposes of the effect wrapper
  120987. */
  120988. dispose(): void;
  120989. }
  120990. }
  120991. declare module BABYLON {
  120992. /**
  120993. * Helper class to push actions to a pool of workers.
  120994. */
  120995. export class WorkerPool implements IDisposable {
  120996. private _workerInfos;
  120997. private _pendingActions;
  120998. /**
  120999. * Constructor
  121000. * @param workers Array of workers to use for actions
  121001. */
  121002. constructor(workers: Array<Worker>);
  121003. /**
  121004. * Terminates all workers and clears any pending actions.
  121005. */
  121006. dispose(): void;
  121007. /**
  121008. * Pushes an action to the worker pool. If all the workers are active, the action will be
  121009. * pended until a worker has completed its action.
  121010. * @param action The action to perform. Call onComplete when the action is complete.
  121011. */
  121012. push(action: (worker: Worker, onComplete: () => void) => void): void;
  121013. private _execute;
  121014. }
  121015. }
  121016. declare module BABYLON {
  121017. /**
  121018. * Configuration for Draco compression
  121019. */
  121020. export interface IDracoCompressionConfiguration {
  121021. /**
  121022. * Configuration for the decoder.
  121023. */
  121024. decoder: {
  121025. /**
  121026. * The url to the WebAssembly module.
  121027. */
  121028. wasmUrl?: string;
  121029. /**
  121030. * The url to the WebAssembly binary.
  121031. */
  121032. wasmBinaryUrl?: string;
  121033. /**
  121034. * The url to the fallback JavaScript module.
  121035. */
  121036. fallbackUrl?: string;
  121037. };
  121038. }
  121039. /**
  121040. * Draco compression (https://google.github.io/draco/)
  121041. *
  121042. * This class wraps the Draco module.
  121043. *
  121044. * **Encoder**
  121045. *
  121046. * The encoder is not currently implemented.
  121047. *
  121048. * **Decoder**
  121049. *
  121050. * 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.
  121051. *
  121052. * To update the configuration, use the following code:
  121053. * ```javascript
  121054. * DracoCompression.Configuration = {
  121055. * decoder: {
  121056. * wasmUrl: "<url to the WebAssembly library>",
  121057. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  121058. * fallbackUrl: "<url to the fallback JavaScript library>",
  121059. * }
  121060. * };
  121061. * ```
  121062. *
  121063. * 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.
  121064. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  121065. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  121066. *
  121067. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  121068. * ```javascript
  121069. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  121070. * ```
  121071. *
  121072. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  121073. */
  121074. export class DracoCompression implements IDisposable {
  121075. private _workerPoolPromise?;
  121076. private _decoderModulePromise?;
  121077. /**
  121078. * The configuration. Defaults to the following urls:
  121079. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  121080. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  121081. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  121082. */
  121083. static Configuration: IDracoCompressionConfiguration;
  121084. /**
  121085. * Returns true if the decoder configuration is available.
  121086. */
  121087. static readonly DecoderAvailable: boolean;
  121088. /**
  121089. * Default number of workers to create when creating the draco compression object.
  121090. */
  121091. static DefaultNumWorkers: number;
  121092. private static GetDefaultNumWorkers;
  121093. private static _Default;
  121094. /**
  121095. * Default instance for the draco compression object.
  121096. */
  121097. static readonly Default: DracoCompression;
  121098. /**
  121099. * Constructor
  121100. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  121101. */
  121102. constructor(numWorkers?: number);
  121103. /**
  121104. * Stop all async operations and release resources.
  121105. */
  121106. dispose(): void;
  121107. /**
  121108. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  121109. * @returns a promise that resolves when ready
  121110. */
  121111. whenReadyAsync(): Promise<void>;
  121112. /**
  121113. * Decode Draco compressed mesh data to vertex data.
  121114. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  121115. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  121116. * @returns A promise that resolves with the decoded vertex data
  121117. */
  121118. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  121119. [kind: string]: number;
  121120. }): Promise<VertexData>;
  121121. }
  121122. }
  121123. declare module BABYLON {
  121124. /**
  121125. * Class for building Constructive Solid Geometry
  121126. */
  121127. export class CSG {
  121128. private polygons;
  121129. /**
  121130. * The world matrix
  121131. */
  121132. matrix: Matrix;
  121133. /**
  121134. * Stores the position
  121135. */
  121136. position: Vector3;
  121137. /**
  121138. * Stores the rotation
  121139. */
  121140. rotation: Vector3;
  121141. /**
  121142. * Stores the rotation quaternion
  121143. */
  121144. rotationQuaternion: Nullable<Quaternion>;
  121145. /**
  121146. * Stores the scaling vector
  121147. */
  121148. scaling: Vector3;
  121149. /**
  121150. * Convert the Mesh to CSG
  121151. * @param mesh The Mesh to convert to CSG
  121152. * @returns A new CSG from the Mesh
  121153. */
  121154. static FromMesh(mesh: Mesh): CSG;
  121155. /**
  121156. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  121157. * @param polygons Polygons used to construct a CSG solid
  121158. */
  121159. private static FromPolygons;
  121160. /**
  121161. * Clones, or makes a deep copy, of the CSG
  121162. * @returns A new CSG
  121163. */
  121164. clone(): CSG;
  121165. /**
  121166. * Unions this CSG with another CSG
  121167. * @param csg The CSG to union against this CSG
  121168. * @returns The unioned CSG
  121169. */
  121170. union(csg: CSG): CSG;
  121171. /**
  121172. * Unions this CSG with another CSG in place
  121173. * @param csg The CSG to union against this CSG
  121174. */
  121175. unionInPlace(csg: CSG): void;
  121176. /**
  121177. * Subtracts this CSG with another CSG
  121178. * @param csg The CSG to subtract against this CSG
  121179. * @returns A new CSG
  121180. */
  121181. subtract(csg: CSG): CSG;
  121182. /**
  121183. * Subtracts this CSG with another CSG in place
  121184. * @param csg The CSG to subtact against this CSG
  121185. */
  121186. subtractInPlace(csg: CSG): void;
  121187. /**
  121188. * Intersect this CSG with another CSG
  121189. * @param csg The CSG to intersect against this CSG
  121190. * @returns A new CSG
  121191. */
  121192. intersect(csg: CSG): CSG;
  121193. /**
  121194. * Intersects this CSG with another CSG in place
  121195. * @param csg The CSG to intersect against this CSG
  121196. */
  121197. intersectInPlace(csg: CSG): void;
  121198. /**
  121199. * Return a new CSG solid with solid and empty space switched. This solid is
  121200. * not modified.
  121201. * @returns A new CSG solid with solid and empty space switched
  121202. */
  121203. inverse(): CSG;
  121204. /**
  121205. * Inverses the CSG in place
  121206. */
  121207. inverseInPlace(): void;
  121208. /**
  121209. * This is used to keep meshes transformations so they can be restored
  121210. * when we build back a Babylon Mesh
  121211. * NB : All CSG operations are performed in world coordinates
  121212. * @param csg The CSG to copy the transform attributes from
  121213. * @returns This CSG
  121214. */
  121215. copyTransformAttributes(csg: CSG): CSG;
  121216. /**
  121217. * Build Raw mesh from CSG
  121218. * Coordinates here are in world space
  121219. * @param name The name of the mesh geometry
  121220. * @param scene The Scene
  121221. * @param keepSubMeshes Specifies if the submeshes should be kept
  121222. * @returns A new Mesh
  121223. */
  121224. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  121225. /**
  121226. * Build Mesh from CSG taking material and transforms into account
  121227. * @param name The name of the Mesh
  121228. * @param material The material of the Mesh
  121229. * @param scene The Scene
  121230. * @param keepSubMeshes Specifies if submeshes should be kept
  121231. * @returns The new Mesh
  121232. */
  121233. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  121234. }
  121235. }
  121236. declare module BABYLON {
  121237. /**
  121238. * Class used to create a trail following a mesh
  121239. */
  121240. export class TrailMesh extends Mesh {
  121241. private _generator;
  121242. private _autoStart;
  121243. private _running;
  121244. private _diameter;
  121245. private _length;
  121246. private _sectionPolygonPointsCount;
  121247. private _sectionVectors;
  121248. private _sectionNormalVectors;
  121249. private _beforeRenderObserver;
  121250. /**
  121251. * @constructor
  121252. * @param name The value used by scene.getMeshByName() to do a lookup.
  121253. * @param generator The mesh to generate a trail.
  121254. * @param scene The scene to add this mesh to.
  121255. * @param diameter Diameter of trailing mesh. Default is 1.
  121256. * @param length Length of trailing mesh. Default is 60.
  121257. * @param autoStart Automatically start trailing mesh. Default true.
  121258. */
  121259. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  121260. /**
  121261. * "TrailMesh"
  121262. * @returns "TrailMesh"
  121263. */
  121264. getClassName(): string;
  121265. private _createMesh;
  121266. /**
  121267. * Start trailing mesh.
  121268. */
  121269. start(): void;
  121270. /**
  121271. * Stop trailing mesh.
  121272. */
  121273. stop(): void;
  121274. /**
  121275. * Update trailing mesh geometry.
  121276. */
  121277. update(): void;
  121278. /**
  121279. * Returns a new TrailMesh object.
  121280. * @param name is a string, the name given to the new mesh
  121281. * @param newGenerator use new generator object for cloned trail mesh
  121282. * @returns a new mesh
  121283. */
  121284. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  121285. /**
  121286. * Serializes this trail mesh
  121287. * @param serializationObject object to write serialization to
  121288. */
  121289. serialize(serializationObject: any): void;
  121290. /**
  121291. * Parses a serialized trail mesh
  121292. * @param parsedMesh the serialized mesh
  121293. * @param scene the scene to create the trail mesh in
  121294. * @returns the created trail mesh
  121295. */
  121296. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  121297. }
  121298. }
  121299. declare module BABYLON {
  121300. /**
  121301. * Class containing static functions to help procedurally build meshes
  121302. */
  121303. export class TiledBoxBuilder {
  121304. /**
  121305. * Creates a box mesh
  121306. * 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)
  121307. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121311. * @param name defines the name of the mesh
  121312. * @param options defines the options used to create the mesh
  121313. * @param scene defines the hosting scene
  121314. * @returns the box mesh
  121315. */
  121316. static CreateTiledBox(name: string, options: {
  121317. pattern?: number;
  121318. width?: number;
  121319. height?: number;
  121320. depth?: number;
  121321. tileSize?: number;
  121322. tileWidth?: number;
  121323. tileHeight?: number;
  121324. alignHorizontal?: number;
  121325. alignVertical?: number;
  121326. faceUV?: Vector4[];
  121327. faceColors?: Color4[];
  121328. sideOrientation?: number;
  121329. updatable?: boolean;
  121330. }, scene?: Nullable<Scene>): Mesh;
  121331. }
  121332. }
  121333. declare module BABYLON {
  121334. /**
  121335. * Class containing static functions to help procedurally build meshes
  121336. */
  121337. export class TorusKnotBuilder {
  121338. /**
  121339. * Creates a torus knot mesh
  121340. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121341. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121342. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121343. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121347. * @param name defines the name of the mesh
  121348. * @param options defines the options used to create the mesh
  121349. * @param scene defines the hosting scene
  121350. * @returns the torus knot mesh
  121351. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121352. */
  121353. static CreateTorusKnot(name: string, options: {
  121354. radius?: number;
  121355. tube?: number;
  121356. radialSegments?: number;
  121357. tubularSegments?: number;
  121358. p?: number;
  121359. q?: number;
  121360. updatable?: boolean;
  121361. sideOrientation?: number;
  121362. frontUVs?: Vector4;
  121363. backUVs?: Vector4;
  121364. }, scene: any): Mesh;
  121365. }
  121366. }
  121367. declare module BABYLON {
  121368. /**
  121369. * Polygon
  121370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  121371. */
  121372. export class Polygon {
  121373. /**
  121374. * Creates a rectangle
  121375. * @param xmin bottom X coord
  121376. * @param ymin bottom Y coord
  121377. * @param xmax top X coord
  121378. * @param ymax top Y coord
  121379. * @returns points that make the resulting rectation
  121380. */
  121381. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  121382. /**
  121383. * Creates a circle
  121384. * @param radius radius of circle
  121385. * @param cx scale in x
  121386. * @param cy scale in y
  121387. * @param numberOfSides number of sides that make up the circle
  121388. * @returns points that make the resulting circle
  121389. */
  121390. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  121391. /**
  121392. * Creates a polygon from input string
  121393. * @param input Input polygon data
  121394. * @returns the parsed points
  121395. */
  121396. static Parse(input: string): Vector2[];
  121397. /**
  121398. * Starts building a polygon from x and y coordinates
  121399. * @param x x coordinate
  121400. * @param y y coordinate
  121401. * @returns the started path2
  121402. */
  121403. static StartingAt(x: number, y: number): Path2;
  121404. }
  121405. /**
  121406. * Builds a polygon
  121407. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  121408. */
  121409. export class PolygonMeshBuilder {
  121410. private _points;
  121411. private _outlinepoints;
  121412. private _holes;
  121413. private _name;
  121414. private _scene;
  121415. private _epoints;
  121416. private _eholes;
  121417. private _addToepoint;
  121418. /**
  121419. * Babylon reference to the earcut plugin.
  121420. */
  121421. bjsEarcut: any;
  121422. /**
  121423. * Creates a PolygonMeshBuilder
  121424. * @param name name of the builder
  121425. * @param contours Path of the polygon
  121426. * @param scene scene to add to when creating the mesh
  121427. * @param earcutInjection can be used to inject your own earcut reference
  121428. */
  121429. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  121430. /**
  121431. * Adds a whole within the polygon
  121432. * @param hole Array of points defining the hole
  121433. * @returns this
  121434. */
  121435. addHole(hole: Vector2[]): PolygonMeshBuilder;
  121436. /**
  121437. * Creates the polygon
  121438. * @param updatable If the mesh should be updatable
  121439. * @param depth The depth of the mesh created
  121440. * @returns the created mesh
  121441. */
  121442. build(updatable?: boolean, depth?: number): Mesh;
  121443. /**
  121444. * Creates the polygon
  121445. * @param depth The depth of the mesh created
  121446. * @returns the created VertexData
  121447. */
  121448. buildVertexData(depth?: number): VertexData;
  121449. /**
  121450. * Adds a side to the polygon
  121451. * @param positions points that make the polygon
  121452. * @param normals normals of the polygon
  121453. * @param uvs uvs of the polygon
  121454. * @param indices indices of the polygon
  121455. * @param bounds bounds of the polygon
  121456. * @param points points of the polygon
  121457. * @param depth depth of the polygon
  121458. * @param flip flip of the polygon
  121459. */
  121460. private addSide;
  121461. }
  121462. }
  121463. declare module BABYLON {
  121464. /**
  121465. * Class containing static functions to help procedurally build meshes
  121466. */
  121467. export class PolygonBuilder {
  121468. /**
  121469. * Creates a polygon mesh
  121470. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121471. * * 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
  121472. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121475. * * Remember you can only change the shape positions, not their number when updating a polygon
  121476. * @param name defines the name of the mesh
  121477. * @param options defines the options used to create the mesh
  121478. * @param scene defines the hosting scene
  121479. * @param earcutInjection can be used to inject your own earcut reference
  121480. * @returns the polygon mesh
  121481. */
  121482. static CreatePolygon(name: string, options: {
  121483. shape: Vector3[];
  121484. holes?: Vector3[][];
  121485. depth?: number;
  121486. faceUV?: Vector4[];
  121487. faceColors?: Color4[];
  121488. updatable?: boolean;
  121489. sideOrientation?: number;
  121490. frontUVs?: Vector4;
  121491. backUVs?: Vector4;
  121492. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121493. /**
  121494. * Creates an extruded polygon mesh, with depth in the Y direction.
  121495. * * 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)
  121496. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121497. * @param name defines the name of the mesh
  121498. * @param options defines the options used to create the mesh
  121499. * @param scene defines the hosting scene
  121500. * @param earcutInjection can be used to inject your own earcut reference
  121501. * @returns the polygon mesh
  121502. */
  121503. static ExtrudePolygon(name: string, options: {
  121504. shape: Vector3[];
  121505. holes?: Vector3[][];
  121506. depth?: number;
  121507. faceUV?: Vector4[];
  121508. faceColors?: Color4[];
  121509. updatable?: boolean;
  121510. sideOrientation?: number;
  121511. frontUVs?: Vector4;
  121512. backUVs?: Vector4;
  121513. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121514. }
  121515. }
  121516. declare module BABYLON {
  121517. /**
  121518. * Class containing static functions to help procedurally build meshes
  121519. */
  121520. export class LatheBuilder {
  121521. /**
  121522. * Creates lathe mesh.
  121523. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121524. * * 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
  121525. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121526. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121527. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121528. * * 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
  121529. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121530. * * 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
  121531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121535. * @param name defines the name of the mesh
  121536. * @param options defines the options used to create the mesh
  121537. * @param scene defines the hosting scene
  121538. * @returns the lathe mesh
  121539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121540. */
  121541. static CreateLathe(name: string, options: {
  121542. shape: Vector3[];
  121543. radius?: number;
  121544. tessellation?: number;
  121545. clip?: number;
  121546. arc?: number;
  121547. closed?: boolean;
  121548. updatable?: boolean;
  121549. sideOrientation?: number;
  121550. frontUVs?: Vector4;
  121551. backUVs?: Vector4;
  121552. cap?: number;
  121553. invertUV?: boolean;
  121554. }, scene?: Nullable<Scene>): Mesh;
  121555. }
  121556. }
  121557. declare module BABYLON {
  121558. /**
  121559. * Class containing static functions to help procedurally build meshes
  121560. */
  121561. export class TiledPlaneBuilder {
  121562. /**
  121563. * Creates a tiled plane mesh
  121564. * * The parameter `pattern` will, depending on value, do nothing or
  121565. * * * flip (reflect about central vertical) alternate tiles across and up
  121566. * * * flip every tile on alternate rows
  121567. * * * rotate (180 degs) alternate tiles across and up
  121568. * * * rotate every tile on alternate rows
  121569. * * * flip and rotate alternate tiles across and up
  121570. * * * flip and rotate every tile on alternate rows
  121571. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121572. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121574. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121575. * * 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)
  121576. * * 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)
  121577. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121578. * @param name defines the name of the mesh
  121579. * @param options defines the options used to create the mesh
  121580. * @param scene defines the hosting scene
  121581. * @returns the box mesh
  121582. */
  121583. static CreateTiledPlane(name: string, options: {
  121584. pattern?: number;
  121585. tileSize?: number;
  121586. tileWidth?: number;
  121587. tileHeight?: number;
  121588. size?: number;
  121589. width?: number;
  121590. height?: number;
  121591. alignHorizontal?: number;
  121592. alignVertical?: number;
  121593. sideOrientation?: number;
  121594. frontUVs?: Vector4;
  121595. backUVs?: Vector4;
  121596. updatable?: boolean;
  121597. }, scene?: Nullable<Scene>): Mesh;
  121598. }
  121599. }
  121600. declare module BABYLON {
  121601. /**
  121602. * Class containing static functions to help procedurally build meshes
  121603. */
  121604. export class TubeBuilder {
  121605. /**
  121606. * Creates a tube mesh.
  121607. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121608. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121609. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121610. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121611. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121612. * * 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)
  121613. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121614. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  121615. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  121616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121618. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121620. * @param name defines the name of the mesh
  121621. * @param options defines the options used to create the mesh
  121622. * @param scene defines the hosting scene
  121623. * @returns the tube mesh
  121624. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121625. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121626. */
  121627. static CreateTube(name: string, options: {
  121628. path: Vector3[];
  121629. radius?: number;
  121630. tessellation?: number;
  121631. radiusFunction?: {
  121632. (i: number, distance: number): number;
  121633. };
  121634. cap?: number;
  121635. arc?: number;
  121636. updatable?: boolean;
  121637. sideOrientation?: number;
  121638. frontUVs?: Vector4;
  121639. backUVs?: Vector4;
  121640. instance?: Mesh;
  121641. invertUV?: boolean;
  121642. }, scene?: Nullable<Scene>): Mesh;
  121643. }
  121644. }
  121645. declare module BABYLON {
  121646. /**
  121647. * Class containing static functions to help procedurally build meshes
  121648. */
  121649. export class IcoSphereBuilder {
  121650. /**
  121651. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121652. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121653. * * 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`)
  121654. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121655. * * 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
  121656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121659. * @param name defines the name of the mesh
  121660. * @param options defines the options used to create the mesh
  121661. * @param scene defines the hosting scene
  121662. * @returns the icosahedron mesh
  121663. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121664. */
  121665. static CreateIcoSphere(name: string, options: {
  121666. radius?: number;
  121667. radiusX?: number;
  121668. radiusY?: number;
  121669. radiusZ?: number;
  121670. flat?: boolean;
  121671. subdivisions?: number;
  121672. sideOrientation?: number;
  121673. frontUVs?: Vector4;
  121674. backUVs?: Vector4;
  121675. updatable?: boolean;
  121676. }, scene?: Nullable<Scene>): Mesh;
  121677. }
  121678. }
  121679. declare module BABYLON {
  121680. /**
  121681. * Class containing static functions to help procedurally build meshes
  121682. */
  121683. export class DecalBuilder {
  121684. /**
  121685. * Creates a decal mesh.
  121686. * 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
  121687. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121688. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121689. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121690. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121691. * @param name defines the name of the mesh
  121692. * @param sourceMesh defines the mesh where the decal must be applied
  121693. * @param options defines the options used to create the mesh
  121694. * @param scene defines the hosting scene
  121695. * @returns the decal mesh
  121696. * @see https://doc.babylonjs.com/how_to/decals
  121697. */
  121698. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121699. position?: Vector3;
  121700. normal?: Vector3;
  121701. size?: Vector3;
  121702. angle?: number;
  121703. }): Mesh;
  121704. }
  121705. }
  121706. declare module BABYLON {
  121707. /**
  121708. * Class containing static functions to help procedurally build meshes
  121709. */
  121710. export class MeshBuilder {
  121711. /**
  121712. * Creates a box mesh
  121713. * * The parameter `size` sets the size (float) of each box side (default 1)
  121714. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121715. * * 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)
  121716. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121720. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121721. * @param name defines the name of the mesh
  121722. * @param options defines the options used to create the mesh
  121723. * @param scene defines the hosting scene
  121724. * @returns the box mesh
  121725. */
  121726. static CreateBox(name: string, options: {
  121727. size?: number;
  121728. width?: number;
  121729. height?: number;
  121730. depth?: number;
  121731. faceUV?: Vector4[];
  121732. faceColors?: Color4[];
  121733. sideOrientation?: number;
  121734. frontUVs?: Vector4;
  121735. backUVs?: Vector4;
  121736. updatable?: boolean;
  121737. }, scene?: Nullable<Scene>): Mesh;
  121738. /**
  121739. * Creates a tiled box mesh
  121740. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121742. * @param name defines the name of the mesh
  121743. * @param options defines the options used to create the mesh
  121744. * @param scene defines the hosting scene
  121745. * @returns the tiled box mesh
  121746. */
  121747. static CreateTiledBox(name: string, options: {
  121748. pattern?: number;
  121749. size?: number;
  121750. width?: number;
  121751. height?: number;
  121752. depth: number;
  121753. tileSize?: number;
  121754. tileWidth?: number;
  121755. tileHeight?: number;
  121756. faceUV?: Vector4[];
  121757. faceColors?: Color4[];
  121758. alignHorizontal?: number;
  121759. alignVertical?: number;
  121760. sideOrientation?: number;
  121761. updatable?: boolean;
  121762. }, scene?: Nullable<Scene>): Mesh;
  121763. /**
  121764. * Creates a sphere mesh
  121765. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121766. * * 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`)
  121767. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121768. * * 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
  121769. * * 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)
  121770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121773. * @param name defines the name of the mesh
  121774. * @param options defines the options used to create the mesh
  121775. * @param scene defines the hosting scene
  121776. * @returns the sphere mesh
  121777. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121778. */
  121779. static CreateSphere(name: string, options: {
  121780. segments?: number;
  121781. diameter?: number;
  121782. diameterX?: number;
  121783. diameterY?: number;
  121784. diameterZ?: number;
  121785. arc?: number;
  121786. slice?: number;
  121787. sideOrientation?: number;
  121788. frontUVs?: Vector4;
  121789. backUVs?: Vector4;
  121790. updatable?: boolean;
  121791. }, scene?: Nullable<Scene>): Mesh;
  121792. /**
  121793. * Creates a plane polygonal mesh. By default, this is a disc
  121794. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121795. * * 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
  121796. * * 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
  121797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121800. * @param name defines the name of the mesh
  121801. * @param options defines the options used to create the mesh
  121802. * @param scene defines the hosting scene
  121803. * @returns the plane polygonal mesh
  121804. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121805. */
  121806. static CreateDisc(name: string, options: {
  121807. radius?: number;
  121808. tessellation?: number;
  121809. arc?: number;
  121810. updatable?: boolean;
  121811. sideOrientation?: number;
  121812. frontUVs?: Vector4;
  121813. backUVs?: Vector4;
  121814. }, scene?: Nullable<Scene>): Mesh;
  121815. /**
  121816. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121817. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121818. * * 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`)
  121819. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121820. * * 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
  121821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121824. * @param name defines the name of the mesh
  121825. * @param options defines the options used to create the mesh
  121826. * @param scene defines the hosting scene
  121827. * @returns the icosahedron mesh
  121828. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121829. */
  121830. static CreateIcoSphere(name: string, options: {
  121831. radius?: number;
  121832. radiusX?: number;
  121833. radiusY?: number;
  121834. radiusZ?: number;
  121835. flat?: boolean;
  121836. subdivisions?: number;
  121837. sideOrientation?: number;
  121838. frontUVs?: Vector4;
  121839. backUVs?: Vector4;
  121840. updatable?: boolean;
  121841. }, scene?: Nullable<Scene>): Mesh;
  121842. /**
  121843. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121844. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121845. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121846. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121847. * * 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
  121848. * * 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
  121849. * * 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
  121850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121853. * * 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
  121854. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121855. * * 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
  121856. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121858. * @param name defines the name of the mesh
  121859. * @param options defines the options used to create the mesh
  121860. * @param scene defines the hosting scene
  121861. * @returns the ribbon mesh
  121862. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121863. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121864. */
  121865. static CreateRibbon(name: string, options: {
  121866. pathArray: Vector3[][];
  121867. closeArray?: boolean;
  121868. closePath?: boolean;
  121869. offset?: number;
  121870. updatable?: boolean;
  121871. sideOrientation?: number;
  121872. frontUVs?: Vector4;
  121873. backUVs?: Vector4;
  121874. instance?: Mesh;
  121875. invertUV?: boolean;
  121876. uvs?: Vector2[];
  121877. colors?: Color4[];
  121878. }, scene?: Nullable<Scene>): Mesh;
  121879. /**
  121880. * Creates a cylinder or a cone mesh
  121881. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121882. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121883. * * 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.
  121884. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121885. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121886. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121887. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121888. * * 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).
  121889. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121890. * * 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).
  121891. * * 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
  121892. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121893. * * 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
  121894. * * 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.
  121895. * * If `enclose` is false, a ring surface is one element.
  121896. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121897. * * 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
  121898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121901. * @param name defines the name of the mesh
  121902. * @param options defines the options used to create the mesh
  121903. * @param scene defines the hosting scene
  121904. * @returns the cylinder mesh
  121905. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121906. */
  121907. static CreateCylinder(name: string, options: {
  121908. height?: number;
  121909. diameterTop?: number;
  121910. diameterBottom?: number;
  121911. diameter?: number;
  121912. tessellation?: number;
  121913. subdivisions?: number;
  121914. arc?: number;
  121915. faceColors?: Color4[];
  121916. faceUV?: Vector4[];
  121917. updatable?: boolean;
  121918. hasRings?: boolean;
  121919. enclose?: boolean;
  121920. cap?: number;
  121921. sideOrientation?: number;
  121922. frontUVs?: Vector4;
  121923. backUVs?: Vector4;
  121924. }, scene?: Nullable<Scene>): Mesh;
  121925. /**
  121926. * Creates a torus mesh
  121927. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121928. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121929. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121933. * @param name defines the name of the mesh
  121934. * @param options defines the options used to create the mesh
  121935. * @param scene defines the hosting scene
  121936. * @returns the torus mesh
  121937. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121938. */
  121939. static CreateTorus(name: string, options: {
  121940. diameter?: number;
  121941. thickness?: number;
  121942. tessellation?: number;
  121943. updatable?: boolean;
  121944. sideOrientation?: number;
  121945. frontUVs?: Vector4;
  121946. backUVs?: Vector4;
  121947. }, scene?: Nullable<Scene>): Mesh;
  121948. /**
  121949. * Creates a torus knot mesh
  121950. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121951. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121952. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121953. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121957. * @param name defines the name of the mesh
  121958. * @param options defines the options used to create the mesh
  121959. * @param scene defines the hosting scene
  121960. * @returns the torus knot mesh
  121961. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121962. */
  121963. static CreateTorusKnot(name: string, options: {
  121964. radius?: number;
  121965. tube?: number;
  121966. radialSegments?: number;
  121967. tubularSegments?: number;
  121968. p?: number;
  121969. q?: number;
  121970. updatable?: boolean;
  121971. sideOrientation?: number;
  121972. frontUVs?: Vector4;
  121973. backUVs?: Vector4;
  121974. }, scene?: Nullable<Scene>): Mesh;
  121975. /**
  121976. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121977. * * 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
  121978. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121979. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121980. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121981. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121982. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121983. * * 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
  121984. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121987. * @param name defines the name of the new line system
  121988. * @param options defines the options used to create the line system
  121989. * @param scene defines the hosting scene
  121990. * @returns a new line system mesh
  121991. */
  121992. static CreateLineSystem(name: string, options: {
  121993. lines: Vector3[][];
  121994. updatable?: boolean;
  121995. instance?: Nullable<LinesMesh>;
  121996. colors?: Nullable<Color4[][]>;
  121997. useVertexAlpha?: boolean;
  121998. }, scene: Nullable<Scene>): LinesMesh;
  121999. /**
  122000. * Creates a line mesh
  122001. * 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
  122002. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  122003. * * The parameter `points` is an array successive Vector3
  122004. * * 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
  122005. * * The optional parameter `colors` is an array of successive Color4, one per line point
  122006. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  122007. * * When updating an instance, remember that only point positions can change, not the number of points
  122008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122009. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  122010. * @param name defines the name of the new line system
  122011. * @param options defines the options used to create the line system
  122012. * @param scene defines the hosting scene
  122013. * @returns a new line mesh
  122014. */
  122015. static CreateLines(name: string, options: {
  122016. points: Vector3[];
  122017. updatable?: boolean;
  122018. instance?: Nullable<LinesMesh>;
  122019. colors?: Color4[];
  122020. useVertexAlpha?: boolean;
  122021. }, scene?: Nullable<Scene>): LinesMesh;
  122022. /**
  122023. * Creates a dashed line mesh
  122024. * * 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
  122025. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  122026. * * The parameter `points` is an array successive Vector3
  122027. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  122028. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  122029. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  122030. * * 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
  122031. * * When updating an instance, remember that only point positions can change, not the number of points
  122032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122033. * @param name defines the name of the mesh
  122034. * @param options defines the options used to create the mesh
  122035. * @param scene defines the hosting scene
  122036. * @returns the dashed line mesh
  122037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  122038. */
  122039. static CreateDashedLines(name: string, options: {
  122040. points: Vector3[];
  122041. dashSize?: number;
  122042. gapSize?: number;
  122043. dashNb?: number;
  122044. updatable?: boolean;
  122045. instance?: LinesMesh;
  122046. }, scene?: Nullable<Scene>): LinesMesh;
  122047. /**
  122048. * 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.
  122049. * * 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.
  122050. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  122051. * * 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.
  122052. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  122053. * * 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
  122054. * * 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
  122055. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  122056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  122059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122060. * @param name defines the name of the mesh
  122061. * @param options defines the options used to create the mesh
  122062. * @param scene defines the hosting scene
  122063. * @returns the extruded shape mesh
  122064. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  122066. */
  122067. static ExtrudeShape(name: string, options: {
  122068. shape: Vector3[];
  122069. path: Vector3[];
  122070. scale?: number;
  122071. rotation?: number;
  122072. cap?: number;
  122073. updatable?: boolean;
  122074. sideOrientation?: number;
  122075. frontUVs?: Vector4;
  122076. backUVs?: Vector4;
  122077. instance?: Mesh;
  122078. invertUV?: boolean;
  122079. }, scene?: Nullable<Scene>): Mesh;
  122080. /**
  122081. * Creates an custom extruded shape mesh.
  122082. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  122083. * * 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.
  122084. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  122085. * * 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
  122086. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  122087. * * 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
  122088. * * It must returns a float value that will be the scale value applied to the shape on each path point
  122089. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  122090. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  122091. * * 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
  122092. * * 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
  122093. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  122094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122098. * @param name defines the name of the mesh
  122099. * @param options defines the options used to create the mesh
  122100. * @param scene defines the hosting scene
  122101. * @returns the custom extruded shape mesh
  122102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  122103. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  122105. */
  122106. static ExtrudeShapeCustom(name: string, options: {
  122107. shape: Vector3[];
  122108. path: Vector3[];
  122109. scaleFunction?: any;
  122110. rotationFunction?: any;
  122111. ribbonCloseArray?: boolean;
  122112. ribbonClosePath?: boolean;
  122113. cap?: number;
  122114. updatable?: boolean;
  122115. sideOrientation?: number;
  122116. frontUVs?: Vector4;
  122117. backUVs?: Vector4;
  122118. instance?: Mesh;
  122119. invertUV?: boolean;
  122120. }, scene?: Nullable<Scene>): Mesh;
  122121. /**
  122122. * Creates lathe mesh.
  122123. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122124. * * 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
  122125. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122126. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122127. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122128. * * 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
  122129. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122130. * * 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
  122131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122133. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122135. * @param name defines the name of the mesh
  122136. * @param options defines the options used to create the mesh
  122137. * @param scene defines the hosting scene
  122138. * @returns the lathe mesh
  122139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122140. */
  122141. static CreateLathe(name: string, options: {
  122142. shape: Vector3[];
  122143. radius?: number;
  122144. tessellation?: number;
  122145. clip?: number;
  122146. arc?: number;
  122147. closed?: boolean;
  122148. updatable?: boolean;
  122149. sideOrientation?: number;
  122150. frontUVs?: Vector4;
  122151. backUVs?: Vector4;
  122152. cap?: number;
  122153. invertUV?: boolean;
  122154. }, scene?: Nullable<Scene>): Mesh;
  122155. /**
  122156. * Creates a tiled plane mesh
  122157. * * You can set a limited pattern arrangement with the tiles
  122158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122161. * @param name defines the name of the mesh
  122162. * @param options defines the options used to create the mesh
  122163. * @param scene defines the hosting scene
  122164. * @returns the plane mesh
  122165. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122166. */
  122167. static CreateTiledPlane(name: string, options: {
  122168. pattern?: number;
  122169. tileSize?: number;
  122170. tileWidth?: number;
  122171. tileHeight?: number;
  122172. size?: number;
  122173. width?: number;
  122174. height?: number;
  122175. alignHorizontal?: number;
  122176. alignVertical?: number;
  122177. sideOrientation?: number;
  122178. frontUVs?: Vector4;
  122179. backUVs?: Vector4;
  122180. updatable?: boolean;
  122181. }, scene?: Nullable<Scene>): Mesh;
  122182. /**
  122183. * Creates a plane mesh
  122184. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122185. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122186. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122190. * @param name defines the name of the mesh
  122191. * @param options defines the options used to create the mesh
  122192. * @param scene defines the hosting scene
  122193. * @returns the plane mesh
  122194. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122195. */
  122196. static CreatePlane(name: string, options: {
  122197. size?: number;
  122198. width?: number;
  122199. height?: number;
  122200. sideOrientation?: number;
  122201. frontUVs?: Vector4;
  122202. backUVs?: Vector4;
  122203. updatable?: boolean;
  122204. sourcePlane?: Plane;
  122205. }, scene?: Nullable<Scene>): Mesh;
  122206. /**
  122207. * Creates a ground mesh
  122208. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122209. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122211. * @param name defines the name of the mesh
  122212. * @param options defines the options used to create the mesh
  122213. * @param scene defines the hosting scene
  122214. * @returns the ground mesh
  122215. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122216. */
  122217. static CreateGround(name: string, options: {
  122218. width?: number;
  122219. height?: number;
  122220. subdivisions?: number;
  122221. subdivisionsX?: number;
  122222. subdivisionsY?: number;
  122223. updatable?: boolean;
  122224. }, scene?: Nullable<Scene>): Mesh;
  122225. /**
  122226. * Creates a tiled ground mesh
  122227. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122228. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122229. * * 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
  122230. * * 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
  122231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122232. * @param name defines the name of the mesh
  122233. * @param options defines the options used to create the mesh
  122234. * @param scene defines the hosting scene
  122235. * @returns the tiled ground mesh
  122236. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122237. */
  122238. static CreateTiledGround(name: string, options: {
  122239. xmin: number;
  122240. zmin: number;
  122241. xmax: number;
  122242. zmax: number;
  122243. subdivisions?: {
  122244. w: number;
  122245. h: number;
  122246. };
  122247. precision?: {
  122248. w: number;
  122249. h: number;
  122250. };
  122251. updatable?: boolean;
  122252. }, scene?: Nullable<Scene>): Mesh;
  122253. /**
  122254. * Creates a ground mesh from a height map
  122255. * * The parameter `url` sets the URL of the height map image resource.
  122256. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122257. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122258. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122259. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122260. * * 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.
  122261. * * 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).
  122262. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122264. * @param name defines the name of the mesh
  122265. * @param url defines the url to the height map
  122266. * @param options defines the options used to create the mesh
  122267. * @param scene defines the hosting scene
  122268. * @returns the ground mesh
  122269. * @see https://doc.babylonjs.com/babylon101/height_map
  122270. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122271. */
  122272. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122273. width?: number;
  122274. height?: number;
  122275. subdivisions?: number;
  122276. minHeight?: number;
  122277. maxHeight?: number;
  122278. colorFilter?: Color3;
  122279. alphaFilter?: number;
  122280. updatable?: boolean;
  122281. onReady?: (mesh: GroundMesh) => void;
  122282. }, scene?: Nullable<Scene>): GroundMesh;
  122283. /**
  122284. * Creates a polygon mesh
  122285. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122286. * * 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
  122287. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122290. * * Remember you can only change the shape positions, not their number when updating a polygon
  122291. * @param name defines the name of the mesh
  122292. * @param options defines the options used to create the mesh
  122293. * @param scene defines the hosting scene
  122294. * @param earcutInjection can be used to inject your own earcut reference
  122295. * @returns the polygon mesh
  122296. */
  122297. static CreatePolygon(name: string, options: {
  122298. shape: Vector3[];
  122299. holes?: Vector3[][];
  122300. depth?: number;
  122301. faceUV?: Vector4[];
  122302. faceColors?: Color4[];
  122303. updatable?: boolean;
  122304. sideOrientation?: number;
  122305. frontUVs?: Vector4;
  122306. backUVs?: Vector4;
  122307. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122308. /**
  122309. * Creates an extruded polygon mesh, with depth in the Y direction.
  122310. * * 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)
  122311. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122312. * @param name defines the name of the mesh
  122313. * @param options defines the options used to create the mesh
  122314. * @param scene defines the hosting scene
  122315. * @param earcutInjection can be used to inject your own earcut reference
  122316. * @returns the polygon mesh
  122317. */
  122318. static ExtrudePolygon(name: string, options: {
  122319. shape: Vector3[];
  122320. holes?: Vector3[][];
  122321. depth?: number;
  122322. faceUV?: Vector4[];
  122323. faceColors?: Color4[];
  122324. updatable?: boolean;
  122325. sideOrientation?: number;
  122326. frontUVs?: Vector4;
  122327. backUVs?: Vector4;
  122328. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122329. /**
  122330. * Creates a tube mesh.
  122331. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122332. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122333. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122334. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122335. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122336. * * 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)
  122337. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122338. * * 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
  122339. * * 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
  122340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122342. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122344. * @param name defines the name of the mesh
  122345. * @param options defines the options used to create the mesh
  122346. * @param scene defines the hosting scene
  122347. * @returns the tube mesh
  122348. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122349. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122350. */
  122351. static CreateTube(name: string, options: {
  122352. path: Vector3[];
  122353. radius?: number;
  122354. tessellation?: number;
  122355. radiusFunction?: {
  122356. (i: number, distance: number): number;
  122357. };
  122358. cap?: number;
  122359. arc?: number;
  122360. updatable?: boolean;
  122361. sideOrientation?: number;
  122362. frontUVs?: Vector4;
  122363. backUVs?: Vector4;
  122364. instance?: Mesh;
  122365. invertUV?: boolean;
  122366. }, scene?: Nullable<Scene>): Mesh;
  122367. /**
  122368. * Creates a polyhedron mesh
  122369. * * 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
  122370. * * The parameter `size` (positive float, default 1) sets the polygon size
  122371. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122372. * * 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`
  122373. * * 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
  122374. * * 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)`)
  122375. * * 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
  122376. * * 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
  122377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122380. * @param name defines the name of the mesh
  122381. * @param options defines the options used to create the mesh
  122382. * @param scene defines the hosting scene
  122383. * @returns the polyhedron mesh
  122384. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122385. */
  122386. static CreatePolyhedron(name: string, options: {
  122387. type?: number;
  122388. size?: number;
  122389. sizeX?: number;
  122390. sizeY?: number;
  122391. sizeZ?: number;
  122392. custom?: any;
  122393. faceUV?: Vector4[];
  122394. faceColors?: Color4[];
  122395. flat?: boolean;
  122396. updatable?: boolean;
  122397. sideOrientation?: number;
  122398. frontUVs?: Vector4;
  122399. backUVs?: Vector4;
  122400. }, scene?: Nullable<Scene>): Mesh;
  122401. /**
  122402. * Creates a decal mesh.
  122403. * 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
  122404. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122405. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122406. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122407. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122408. * @param name defines the name of the mesh
  122409. * @param sourceMesh defines the mesh where the decal must be applied
  122410. * @param options defines the options used to create the mesh
  122411. * @param scene defines the hosting scene
  122412. * @returns the decal mesh
  122413. * @see https://doc.babylonjs.com/how_to/decals
  122414. */
  122415. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122416. position?: Vector3;
  122417. normal?: Vector3;
  122418. size?: Vector3;
  122419. angle?: number;
  122420. }): Mesh;
  122421. }
  122422. }
  122423. declare module BABYLON {
  122424. /**
  122425. * A simplifier interface for future simplification implementations
  122426. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122427. */
  122428. export interface ISimplifier {
  122429. /**
  122430. * Simplification of a given mesh according to the given settings.
  122431. * Since this requires computation, it is assumed that the function runs async.
  122432. * @param settings The settings of the simplification, including quality and distance
  122433. * @param successCallback A callback that will be called after the mesh was simplified.
  122434. * @param errorCallback in case of an error, this callback will be called. optional.
  122435. */
  122436. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  122437. }
  122438. /**
  122439. * Expected simplification settings.
  122440. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  122441. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122442. */
  122443. export interface ISimplificationSettings {
  122444. /**
  122445. * Gets or sets the expected quality
  122446. */
  122447. quality: number;
  122448. /**
  122449. * Gets or sets the distance when this optimized version should be used
  122450. */
  122451. distance: number;
  122452. /**
  122453. * Gets an already optimized mesh
  122454. */
  122455. optimizeMesh?: boolean;
  122456. }
  122457. /**
  122458. * Class used to specify simplification options
  122459. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122460. */
  122461. export class SimplificationSettings implements ISimplificationSettings {
  122462. /** expected quality */
  122463. quality: number;
  122464. /** distance when this optimized version should be used */
  122465. distance: number;
  122466. /** already optimized mesh */
  122467. optimizeMesh?: boolean | undefined;
  122468. /**
  122469. * Creates a SimplificationSettings
  122470. * @param quality expected quality
  122471. * @param distance distance when this optimized version should be used
  122472. * @param optimizeMesh already optimized mesh
  122473. */
  122474. constructor(
  122475. /** expected quality */
  122476. quality: number,
  122477. /** distance when this optimized version should be used */
  122478. distance: number,
  122479. /** already optimized mesh */
  122480. optimizeMesh?: boolean | undefined);
  122481. }
  122482. /**
  122483. * Interface used to define a simplification task
  122484. */
  122485. export interface ISimplificationTask {
  122486. /**
  122487. * Array of settings
  122488. */
  122489. settings: Array<ISimplificationSettings>;
  122490. /**
  122491. * Simplification type
  122492. */
  122493. simplificationType: SimplificationType;
  122494. /**
  122495. * Mesh to simplify
  122496. */
  122497. mesh: Mesh;
  122498. /**
  122499. * Callback called on success
  122500. */
  122501. successCallback?: () => void;
  122502. /**
  122503. * Defines if parallel processing can be used
  122504. */
  122505. parallelProcessing: boolean;
  122506. }
  122507. /**
  122508. * Queue used to order the simplification tasks
  122509. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122510. */
  122511. export class SimplificationQueue {
  122512. private _simplificationArray;
  122513. /**
  122514. * Gets a boolean indicating that the process is still running
  122515. */
  122516. running: boolean;
  122517. /**
  122518. * Creates a new queue
  122519. */
  122520. constructor();
  122521. /**
  122522. * Adds a new simplification task
  122523. * @param task defines a task to add
  122524. */
  122525. addTask(task: ISimplificationTask): void;
  122526. /**
  122527. * Execute next task
  122528. */
  122529. executeNext(): void;
  122530. /**
  122531. * Execute a simplification task
  122532. * @param task defines the task to run
  122533. */
  122534. runSimplification(task: ISimplificationTask): void;
  122535. private getSimplifier;
  122536. }
  122537. /**
  122538. * The implemented types of simplification
  122539. * At the moment only Quadratic Error Decimation is implemented
  122540. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122541. */
  122542. export enum SimplificationType {
  122543. /** Quadratic error decimation */
  122544. QUADRATIC = 0
  122545. }
  122546. }
  122547. declare module BABYLON {
  122548. interface Scene {
  122549. /** @hidden (Backing field) */
  122550. _simplificationQueue: SimplificationQueue;
  122551. /**
  122552. * Gets or sets the simplification queue attached to the scene
  122553. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122554. */
  122555. simplificationQueue: SimplificationQueue;
  122556. }
  122557. interface Mesh {
  122558. /**
  122559. * Simplify the mesh according to the given array of settings.
  122560. * Function will return immediately and will simplify async
  122561. * @param settings a collection of simplification settings
  122562. * @param parallelProcessing should all levels calculate parallel or one after the other
  122563. * @param simplificationType the type of simplification to run
  122564. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122565. * @returns the current mesh
  122566. */
  122567. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122568. }
  122569. /**
  122570. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122571. * created in a scene
  122572. */
  122573. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122574. /**
  122575. * The component name helpfull to identify the component in the list of scene components.
  122576. */
  122577. readonly name: string;
  122578. /**
  122579. * The scene the component belongs to.
  122580. */
  122581. scene: Scene;
  122582. /**
  122583. * Creates a new instance of the component for the given scene
  122584. * @param scene Defines the scene to register the component in
  122585. */
  122586. constructor(scene: Scene);
  122587. /**
  122588. * Registers the component in a given scene
  122589. */
  122590. register(): void;
  122591. /**
  122592. * Rebuilds the elements related to this component in case of
  122593. * context lost for instance.
  122594. */
  122595. rebuild(): void;
  122596. /**
  122597. * Disposes the component and the associated ressources
  122598. */
  122599. dispose(): void;
  122600. private _beforeCameraUpdate;
  122601. }
  122602. }
  122603. declare module BABYLON {
  122604. /**
  122605. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122606. */
  122607. export interface INavigationEnginePlugin {
  122608. /**
  122609. * plugin name
  122610. */
  122611. name: string;
  122612. /**
  122613. * Creates a navigation mesh
  122614. * @param meshes array of all the geometry used to compute the navigatio mesh
  122615. * @param parameters bunch of parameters used to filter geometry
  122616. */
  122617. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122618. /**
  122619. * Create a navigation mesh debug mesh
  122620. * @param scene is where the mesh will be added
  122621. * @returns debug display mesh
  122622. */
  122623. createDebugNavMesh(scene: Scene): Mesh;
  122624. /**
  122625. * Get a navigation mesh constrained position, closest to the parameter position
  122626. * @param position world position
  122627. * @returns the closest point to position constrained by the navigation mesh
  122628. */
  122629. getClosestPoint(position: Vector3): Vector3;
  122630. /**
  122631. * Get a navigation mesh constrained position, within a particular radius
  122632. * @param position world position
  122633. * @param maxRadius the maximum distance to the constrained world position
  122634. * @returns the closest point to position constrained by the navigation mesh
  122635. */
  122636. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122637. /**
  122638. * Compute the final position from a segment made of destination-position
  122639. * @param position world position
  122640. * @param destination world position
  122641. * @returns the resulting point along the navmesh
  122642. */
  122643. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122644. /**
  122645. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122646. * @param start world position
  122647. * @param end world position
  122648. * @returns array containing world position composing the path
  122649. */
  122650. computePath(start: Vector3, end: Vector3): Vector3[];
  122651. /**
  122652. * If this plugin is supported
  122653. * @returns true if plugin is supported
  122654. */
  122655. isSupported(): boolean;
  122656. /**
  122657. * Create a new Crowd so you can add agents
  122658. * @param maxAgents the maximum agent count in the crowd
  122659. * @param maxAgentRadius the maximum radius an agent can have
  122660. * @param scene to attach the crowd to
  122661. * @returns the crowd you can add agents to
  122662. */
  122663. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122664. /**
  122665. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122666. * The queries will try to find a solution within those bounds
  122667. * default is (1,1,1)
  122668. * @param extent x,y,z value that define the extent around the queries point of reference
  122669. */
  122670. setDefaultQueryExtent(extent: Vector3): void;
  122671. /**
  122672. * Get the Bounding box extent specified by setDefaultQueryExtent
  122673. * @returns the box extent values
  122674. */
  122675. getDefaultQueryExtent(): Vector3;
  122676. /**
  122677. * Release all resources
  122678. */
  122679. dispose(): void;
  122680. }
  122681. /**
  122682. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122683. */
  122684. export interface ICrowd {
  122685. /**
  122686. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122687. * You can attach anything to that node. The node position is updated in the scene update tick.
  122688. * @param pos world position that will be constrained by the navigation mesh
  122689. * @param parameters agent parameters
  122690. * @param transform hooked to the agent that will be update by the scene
  122691. * @returns agent index
  122692. */
  122693. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122694. /**
  122695. * Returns the agent position in world space
  122696. * @param index agent index returned by addAgent
  122697. * @returns world space position
  122698. */
  122699. getAgentPosition(index: number): Vector3;
  122700. /**
  122701. * Gets the agent velocity in world space
  122702. * @param index agent index returned by addAgent
  122703. * @returns world space velocity
  122704. */
  122705. getAgentVelocity(index: number): Vector3;
  122706. /**
  122707. * remove a particular agent previously created
  122708. * @param index agent index returned by addAgent
  122709. */
  122710. removeAgent(index: number): void;
  122711. /**
  122712. * get the list of all agents attached to this crowd
  122713. * @returns list of agent indices
  122714. */
  122715. getAgents(): number[];
  122716. /**
  122717. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122718. * @param deltaTime in seconds
  122719. */
  122720. update(deltaTime: number): void;
  122721. /**
  122722. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122723. * @param index agent index returned by addAgent
  122724. * @param destination targeted world position
  122725. */
  122726. agentGoto(index: number, destination: Vector3): void;
  122727. /**
  122728. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122729. * The queries will try to find a solution within those bounds
  122730. * default is (1,1,1)
  122731. * @param extent x,y,z value that define the extent around the queries point of reference
  122732. */
  122733. setDefaultQueryExtent(extent: Vector3): void;
  122734. /**
  122735. * Get the Bounding box extent specified by setDefaultQueryExtent
  122736. * @returns the box extent values
  122737. */
  122738. getDefaultQueryExtent(): Vector3;
  122739. /**
  122740. * Release all resources
  122741. */
  122742. dispose(): void;
  122743. }
  122744. /**
  122745. * Configures an agent
  122746. */
  122747. export interface IAgentParameters {
  122748. /**
  122749. * Agent radius. [Limit: >= 0]
  122750. */
  122751. radius: number;
  122752. /**
  122753. * Agent height. [Limit: > 0]
  122754. */
  122755. height: number;
  122756. /**
  122757. * Maximum allowed acceleration. [Limit: >= 0]
  122758. */
  122759. maxAcceleration: number;
  122760. /**
  122761. * Maximum allowed speed. [Limit: >= 0]
  122762. */
  122763. maxSpeed: number;
  122764. /**
  122765. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122766. */
  122767. collisionQueryRange: number;
  122768. /**
  122769. * The path visibility optimization range. [Limit: > 0]
  122770. */
  122771. pathOptimizationRange: number;
  122772. /**
  122773. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122774. */
  122775. separationWeight: number;
  122776. }
  122777. /**
  122778. * Configures the navigation mesh creation
  122779. */
  122780. export interface INavMeshParameters {
  122781. /**
  122782. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122783. */
  122784. cs: number;
  122785. /**
  122786. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122787. */
  122788. ch: number;
  122789. /**
  122790. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122791. */
  122792. walkableSlopeAngle: number;
  122793. /**
  122794. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122795. * be considered walkable. [Limit: >= 3] [Units: vx]
  122796. */
  122797. walkableHeight: number;
  122798. /**
  122799. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122800. */
  122801. walkableClimb: number;
  122802. /**
  122803. * The distance to erode/shrink the walkable area of the heightfield away from
  122804. * obstructions. [Limit: >=0] [Units: vx]
  122805. */
  122806. walkableRadius: number;
  122807. /**
  122808. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122809. */
  122810. maxEdgeLen: number;
  122811. /**
  122812. * The maximum distance a simplfied contour's border edges should deviate
  122813. * the original raw contour. [Limit: >=0] [Units: vx]
  122814. */
  122815. maxSimplificationError: number;
  122816. /**
  122817. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122818. */
  122819. minRegionArea: number;
  122820. /**
  122821. * Any regions with a span count smaller than this value will, if possible,
  122822. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122823. */
  122824. mergeRegionArea: number;
  122825. /**
  122826. * The maximum number of vertices allowed for polygons generated during the
  122827. * contour to polygon conversion process. [Limit: >= 3]
  122828. */
  122829. maxVertsPerPoly: number;
  122830. /**
  122831. * Sets the sampling distance to use when generating the detail mesh.
  122832. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122833. */
  122834. detailSampleDist: number;
  122835. /**
  122836. * The maximum distance the detail mesh surface should deviate from heightfield
  122837. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122838. */
  122839. detailSampleMaxError: number;
  122840. }
  122841. }
  122842. declare module BABYLON {
  122843. /**
  122844. * RecastJS navigation plugin
  122845. */
  122846. export class RecastJSPlugin implements INavigationEnginePlugin {
  122847. /**
  122848. * Reference to the Recast library
  122849. */
  122850. bjsRECAST: any;
  122851. /**
  122852. * plugin name
  122853. */
  122854. name: string;
  122855. /**
  122856. * the first navmesh created. We might extend this to support multiple navmeshes
  122857. */
  122858. navMesh: any;
  122859. /**
  122860. * Initializes the recastJS plugin
  122861. * @param recastInjection can be used to inject your own recast reference
  122862. */
  122863. constructor(recastInjection?: any);
  122864. /**
  122865. * Creates a navigation mesh
  122866. * @param meshes array of all the geometry used to compute the navigatio mesh
  122867. * @param parameters bunch of parameters used to filter geometry
  122868. */
  122869. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122870. /**
  122871. * Create a navigation mesh debug mesh
  122872. * @param scene is where the mesh will be added
  122873. * @returns debug display mesh
  122874. */
  122875. createDebugNavMesh(scene: Scene): Mesh;
  122876. /**
  122877. * Get a navigation mesh constrained position, closest to the parameter position
  122878. * @param position world position
  122879. * @returns the closest point to position constrained by the navigation mesh
  122880. */
  122881. getClosestPoint(position: Vector3): Vector3;
  122882. /**
  122883. * Get a navigation mesh constrained position, within a particular radius
  122884. * @param position world position
  122885. * @param maxRadius the maximum distance to the constrained world position
  122886. * @returns the closest point to position constrained by the navigation mesh
  122887. */
  122888. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122889. /**
  122890. * Compute the final position from a segment made of destination-position
  122891. * @param position world position
  122892. * @param destination world position
  122893. * @returns the resulting point along the navmesh
  122894. */
  122895. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122896. /**
  122897. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122898. * @param start world position
  122899. * @param end world position
  122900. * @returns array containing world position composing the path
  122901. */
  122902. computePath(start: Vector3, end: Vector3): Vector3[];
  122903. /**
  122904. * Create a new Crowd so you can add agents
  122905. * @param maxAgents the maximum agent count in the crowd
  122906. * @param maxAgentRadius the maximum radius an agent can have
  122907. * @param scene to attach the crowd to
  122908. * @returns the crowd you can add agents to
  122909. */
  122910. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122911. /**
  122912. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122913. * The queries will try to find a solution within those bounds
  122914. * default is (1,1,1)
  122915. * @param extent x,y,z value that define the extent around the queries point of reference
  122916. */
  122917. setDefaultQueryExtent(extent: Vector3): void;
  122918. /**
  122919. * Get the Bounding box extent specified by setDefaultQueryExtent
  122920. * @returns the box extent values
  122921. */
  122922. getDefaultQueryExtent(): Vector3;
  122923. /**
  122924. * Disposes
  122925. */
  122926. dispose(): void;
  122927. /**
  122928. * If this plugin is supported
  122929. * @returns true if plugin is supported
  122930. */
  122931. isSupported(): boolean;
  122932. }
  122933. /**
  122934. * Recast detour crowd implementation
  122935. */
  122936. export class RecastJSCrowd implements ICrowd {
  122937. /**
  122938. * Recast/detour plugin
  122939. */
  122940. bjsRECASTPlugin: RecastJSPlugin;
  122941. /**
  122942. * Link to the detour crowd
  122943. */
  122944. recastCrowd: any;
  122945. /**
  122946. * One transform per agent
  122947. */
  122948. transforms: TransformNode[];
  122949. /**
  122950. * All agents created
  122951. */
  122952. agents: number[];
  122953. /**
  122954. * Link to the scene is kept to unregister the crowd from the scene
  122955. */
  122956. private _scene;
  122957. /**
  122958. * Observer for crowd updates
  122959. */
  122960. private _onBeforeAnimationsObserver;
  122961. /**
  122962. * Constructor
  122963. * @param plugin recastJS plugin
  122964. * @param maxAgents the maximum agent count in the crowd
  122965. * @param maxAgentRadius the maximum radius an agent can have
  122966. * @param scene to attach the crowd to
  122967. * @returns the crowd you can add agents to
  122968. */
  122969. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122970. /**
  122971. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122972. * You can attach anything to that node. The node position is updated in the scene update tick.
  122973. * @param pos world position that will be constrained by the navigation mesh
  122974. * @param parameters agent parameters
  122975. * @param transform hooked to the agent that will be update by the scene
  122976. * @returns agent index
  122977. */
  122978. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122979. /**
  122980. * Returns the agent position in world space
  122981. * @param index agent index returned by addAgent
  122982. * @returns world space position
  122983. */
  122984. getAgentPosition(index: number): Vector3;
  122985. /**
  122986. * Returns the agent velocity in world space
  122987. * @param index agent index returned by addAgent
  122988. * @returns world space velocity
  122989. */
  122990. getAgentVelocity(index: number): Vector3;
  122991. /**
  122992. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122993. * @param index agent index returned by addAgent
  122994. * @param destination targeted world position
  122995. */
  122996. agentGoto(index: number, destination: Vector3): void;
  122997. /**
  122998. * remove a particular agent previously created
  122999. * @param index agent index returned by addAgent
  123000. */
  123001. removeAgent(index: number): void;
  123002. /**
  123003. * get the list of all agents attached to this crowd
  123004. * @returns list of agent indices
  123005. */
  123006. getAgents(): number[];
  123007. /**
  123008. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123009. * @param deltaTime in seconds
  123010. */
  123011. update(deltaTime: number): void;
  123012. /**
  123013. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123014. * The queries will try to find a solution within those bounds
  123015. * default is (1,1,1)
  123016. * @param extent x,y,z value that define the extent around the queries point of reference
  123017. */
  123018. setDefaultQueryExtent(extent: Vector3): void;
  123019. /**
  123020. * Get the Bounding box extent specified by setDefaultQueryExtent
  123021. * @returns the box extent values
  123022. */
  123023. getDefaultQueryExtent(): Vector3;
  123024. /**
  123025. * Release all resources
  123026. */
  123027. dispose(): void;
  123028. }
  123029. }
  123030. declare module BABYLON {
  123031. /**
  123032. * Class used to enable access to IndexedDB
  123033. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123034. */
  123035. export class Database implements IOfflineProvider {
  123036. private _callbackManifestChecked;
  123037. private _currentSceneUrl;
  123038. private _db;
  123039. private _enableSceneOffline;
  123040. private _enableTexturesOffline;
  123041. private _manifestVersionFound;
  123042. private _mustUpdateRessources;
  123043. private _hasReachedQuota;
  123044. private _isSupported;
  123045. private _idbFactory;
  123046. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  123047. private static IsUASupportingBlobStorage;
  123048. /**
  123049. * Gets a boolean indicating if Database storate is enabled (off by default)
  123050. */
  123051. static IDBStorageEnabled: boolean;
  123052. /**
  123053. * Gets a boolean indicating if scene must be saved in the database
  123054. */
  123055. readonly enableSceneOffline: boolean;
  123056. /**
  123057. * Gets a boolean indicating if textures must be saved in the database
  123058. */
  123059. readonly enableTexturesOffline: boolean;
  123060. /**
  123061. * Creates a new Database
  123062. * @param urlToScene defines the url to load the scene
  123063. * @param callbackManifestChecked defines the callback to use when manifest is checked
  123064. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  123065. */
  123066. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  123067. private static _ParseURL;
  123068. private static _ReturnFullUrlLocation;
  123069. private _checkManifestFile;
  123070. /**
  123071. * Open the database and make it available
  123072. * @param successCallback defines the callback to call on success
  123073. * @param errorCallback defines the callback to call on error
  123074. */
  123075. open(successCallback: () => void, errorCallback: () => void): void;
  123076. /**
  123077. * Loads an image from the database
  123078. * @param url defines the url to load from
  123079. * @param image defines the target DOM image
  123080. */
  123081. loadImage(url: string, image: HTMLImageElement): void;
  123082. private _loadImageFromDBAsync;
  123083. private _saveImageIntoDBAsync;
  123084. private _checkVersionFromDB;
  123085. private _loadVersionFromDBAsync;
  123086. private _saveVersionIntoDBAsync;
  123087. /**
  123088. * Loads a file from database
  123089. * @param url defines the URL to load from
  123090. * @param sceneLoaded defines a callback to call on success
  123091. * @param progressCallBack defines a callback to call when progress changed
  123092. * @param errorCallback defines a callback to call on error
  123093. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  123094. */
  123095. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  123096. private _loadFileAsync;
  123097. private _saveFileAsync;
  123098. /**
  123099. * Validates if xhr data is correct
  123100. * @param xhr defines the request to validate
  123101. * @param dataType defines the expected data type
  123102. * @returns true if data is correct
  123103. */
  123104. private static _ValidateXHRData;
  123105. }
  123106. }
  123107. declare module BABYLON {
  123108. /** @hidden */
  123109. export var gpuUpdateParticlesPixelShader: {
  123110. name: string;
  123111. shader: string;
  123112. };
  123113. }
  123114. declare module BABYLON {
  123115. /** @hidden */
  123116. export var gpuUpdateParticlesVertexShader: {
  123117. name: string;
  123118. shader: string;
  123119. };
  123120. }
  123121. declare module BABYLON {
  123122. /** @hidden */
  123123. export var clipPlaneFragmentDeclaration2: {
  123124. name: string;
  123125. shader: string;
  123126. };
  123127. }
  123128. declare module BABYLON {
  123129. /** @hidden */
  123130. export var gpuRenderParticlesPixelShader: {
  123131. name: string;
  123132. shader: string;
  123133. };
  123134. }
  123135. declare module BABYLON {
  123136. /** @hidden */
  123137. export var clipPlaneVertexDeclaration2: {
  123138. name: string;
  123139. shader: string;
  123140. };
  123141. }
  123142. declare module BABYLON {
  123143. /** @hidden */
  123144. export var gpuRenderParticlesVertexShader: {
  123145. name: string;
  123146. shader: string;
  123147. };
  123148. }
  123149. declare module BABYLON {
  123150. /**
  123151. * This represents a GPU particle system in Babylon
  123152. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  123153. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  123154. */
  123155. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  123156. /**
  123157. * The layer mask we are rendering the particles through.
  123158. */
  123159. layerMask: number;
  123160. private _capacity;
  123161. private _activeCount;
  123162. private _currentActiveCount;
  123163. private _accumulatedCount;
  123164. private _renderEffect;
  123165. private _updateEffect;
  123166. private _buffer0;
  123167. private _buffer1;
  123168. private _spriteBuffer;
  123169. private _updateVAO;
  123170. private _renderVAO;
  123171. private _targetIndex;
  123172. private _sourceBuffer;
  123173. private _targetBuffer;
  123174. private _engine;
  123175. private _currentRenderId;
  123176. private _started;
  123177. private _stopped;
  123178. private _timeDelta;
  123179. private _randomTexture;
  123180. private _randomTexture2;
  123181. private _attributesStrideSize;
  123182. private _updateEffectOptions;
  123183. private _randomTextureSize;
  123184. private _actualFrame;
  123185. private readonly _rawTextureWidth;
  123186. /**
  123187. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  123188. */
  123189. static readonly IsSupported: boolean;
  123190. /**
  123191. * An event triggered when the system is disposed.
  123192. */
  123193. onDisposeObservable: Observable<GPUParticleSystem>;
  123194. /**
  123195. * Gets the maximum number of particles active at the same time.
  123196. * @returns The max number of active particles.
  123197. */
  123198. getCapacity(): number;
  123199. /**
  123200. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  123201. * to override the particles.
  123202. */
  123203. forceDepthWrite: boolean;
  123204. /**
  123205. * Gets or set the number of active particles
  123206. */
  123207. activeParticleCount: number;
  123208. private _preWarmDone;
  123209. /**
  123210. * Is this system ready to be used/rendered
  123211. * @return true if the system is ready
  123212. */
  123213. isReady(): boolean;
  123214. /**
  123215. * Gets if the system has been started. (Note: this will still be true after stop is called)
  123216. * @returns True if it has been started, otherwise false.
  123217. */
  123218. isStarted(): boolean;
  123219. /**
  123220. * Starts the particle system and begins to emit
  123221. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  123222. */
  123223. start(delay?: number): void;
  123224. /**
  123225. * Stops the particle system.
  123226. */
  123227. stop(): void;
  123228. /**
  123229. * Remove all active particles
  123230. */
  123231. reset(): void;
  123232. /**
  123233. * Returns the string "GPUParticleSystem"
  123234. * @returns a string containing the class name
  123235. */
  123236. getClassName(): string;
  123237. private _colorGradientsTexture;
  123238. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  123239. /**
  123240. * Adds a new color gradient
  123241. * @param gradient defines the gradient to use (between 0 and 1)
  123242. * @param color1 defines the color to affect to the specified gradient
  123243. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  123244. * @returns the current particle system
  123245. */
  123246. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  123247. /**
  123248. * Remove a specific color gradient
  123249. * @param gradient defines the gradient to remove
  123250. * @returns the current particle system
  123251. */
  123252. removeColorGradient(gradient: number): GPUParticleSystem;
  123253. private _angularSpeedGradientsTexture;
  123254. private _sizeGradientsTexture;
  123255. private _velocityGradientsTexture;
  123256. private _limitVelocityGradientsTexture;
  123257. private _dragGradientsTexture;
  123258. private _addFactorGradient;
  123259. /**
  123260. * Adds a new size gradient
  123261. * @param gradient defines the gradient to use (between 0 and 1)
  123262. * @param factor defines the size factor to affect to the specified gradient
  123263. * @returns the current particle system
  123264. */
  123265. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  123266. /**
  123267. * Remove a specific size gradient
  123268. * @param gradient defines the gradient to remove
  123269. * @returns the current particle system
  123270. */
  123271. removeSizeGradient(gradient: number): GPUParticleSystem;
  123272. /**
  123273. * Adds a new angular speed gradient
  123274. * @param gradient defines the gradient to use (between 0 and 1)
  123275. * @param factor defines the angular speed to affect to the specified gradient
  123276. * @returns the current particle system
  123277. */
  123278. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  123279. /**
  123280. * Remove a specific angular speed gradient
  123281. * @param gradient defines the gradient to remove
  123282. * @returns the current particle system
  123283. */
  123284. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  123285. /**
  123286. * Adds a new velocity gradient
  123287. * @param gradient defines the gradient to use (between 0 and 1)
  123288. * @param factor defines the velocity to affect to the specified gradient
  123289. * @returns the current particle system
  123290. */
  123291. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123292. /**
  123293. * Remove a specific velocity gradient
  123294. * @param gradient defines the gradient to remove
  123295. * @returns the current particle system
  123296. */
  123297. removeVelocityGradient(gradient: number): GPUParticleSystem;
  123298. /**
  123299. * Adds a new limit velocity gradient
  123300. * @param gradient defines the gradient to use (between 0 and 1)
  123301. * @param factor defines the limit velocity value to affect to the specified gradient
  123302. * @returns the current particle system
  123303. */
  123304. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123305. /**
  123306. * Remove a specific limit velocity gradient
  123307. * @param gradient defines the gradient to remove
  123308. * @returns the current particle system
  123309. */
  123310. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  123311. /**
  123312. * Adds a new drag gradient
  123313. * @param gradient defines the gradient to use (between 0 and 1)
  123314. * @param factor defines the drag value to affect to the specified gradient
  123315. * @returns the current particle system
  123316. */
  123317. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  123318. /**
  123319. * Remove a specific drag gradient
  123320. * @param gradient defines the gradient to remove
  123321. * @returns the current particle system
  123322. */
  123323. removeDragGradient(gradient: number): GPUParticleSystem;
  123324. /**
  123325. * Not supported by GPUParticleSystem
  123326. * @param gradient defines the gradient to use (between 0 and 1)
  123327. * @param factor defines the emit rate value to affect to the specified gradient
  123328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123329. * @returns the current particle system
  123330. */
  123331. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123332. /**
  123333. * Not supported by GPUParticleSystem
  123334. * @param gradient defines the gradient to remove
  123335. * @returns the current particle system
  123336. */
  123337. removeEmitRateGradient(gradient: number): IParticleSystem;
  123338. /**
  123339. * Not supported by GPUParticleSystem
  123340. * @param gradient defines the gradient to use (between 0 and 1)
  123341. * @param factor defines the start size value to affect to the specified gradient
  123342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123343. * @returns the current particle system
  123344. */
  123345. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123346. /**
  123347. * Not supported by GPUParticleSystem
  123348. * @param gradient defines the gradient to remove
  123349. * @returns the current particle system
  123350. */
  123351. removeStartSizeGradient(gradient: number): IParticleSystem;
  123352. /**
  123353. * Not supported by GPUParticleSystem
  123354. * @param gradient defines the gradient to use (between 0 and 1)
  123355. * @param min defines the color remap minimal range
  123356. * @param max defines the color remap maximal range
  123357. * @returns the current particle system
  123358. */
  123359. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123360. /**
  123361. * Not supported by GPUParticleSystem
  123362. * @param gradient defines the gradient to remove
  123363. * @returns the current particle system
  123364. */
  123365. removeColorRemapGradient(): IParticleSystem;
  123366. /**
  123367. * Not supported by GPUParticleSystem
  123368. * @param gradient defines the gradient to use (between 0 and 1)
  123369. * @param min defines the alpha remap minimal range
  123370. * @param max defines the alpha remap maximal range
  123371. * @returns the current particle system
  123372. */
  123373. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123374. /**
  123375. * Not supported by GPUParticleSystem
  123376. * @param gradient defines the gradient to remove
  123377. * @returns the current particle system
  123378. */
  123379. removeAlphaRemapGradient(): IParticleSystem;
  123380. /**
  123381. * Not supported by GPUParticleSystem
  123382. * @param gradient defines the gradient to use (between 0 and 1)
  123383. * @param color defines the color to affect to the specified gradient
  123384. * @returns the current particle system
  123385. */
  123386. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  123387. /**
  123388. * Not supported by GPUParticleSystem
  123389. * @param gradient defines the gradient to remove
  123390. * @returns the current particle system
  123391. */
  123392. removeRampGradient(): IParticleSystem;
  123393. /**
  123394. * Not supported by GPUParticleSystem
  123395. * @returns the list of ramp gradients
  123396. */
  123397. getRampGradients(): Nullable<Array<Color3Gradient>>;
  123398. /**
  123399. * Not supported by GPUParticleSystem
  123400. * Gets or sets a boolean indicating that ramp gradients must be used
  123401. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  123402. */
  123403. useRampGradients: boolean;
  123404. /**
  123405. * Not supported by GPUParticleSystem
  123406. * @param gradient defines the gradient to use (between 0 and 1)
  123407. * @param factor defines the life time factor to affect to the specified gradient
  123408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123409. * @returns the current particle system
  123410. */
  123411. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123412. /**
  123413. * Not supported by GPUParticleSystem
  123414. * @param gradient defines the gradient to remove
  123415. * @returns the current particle system
  123416. */
  123417. removeLifeTimeGradient(gradient: number): IParticleSystem;
  123418. /**
  123419. * Instantiates a GPU particle system.
  123420. * 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.
  123421. * @param name The name of the particle system
  123422. * @param options The options used to create the system
  123423. * @param scene The scene the particle system belongs to
  123424. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  123425. */
  123426. constructor(name: string, options: Partial<{
  123427. capacity: number;
  123428. randomTextureSize: number;
  123429. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  123430. protected _reset(): void;
  123431. private _createUpdateVAO;
  123432. private _createRenderVAO;
  123433. private _initialize;
  123434. /** @hidden */
  123435. _recreateUpdateEffect(): void;
  123436. /** @hidden */
  123437. _recreateRenderEffect(): void;
  123438. /**
  123439. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  123440. * @param preWarm defines if we are in the pre-warmimg phase
  123441. */
  123442. animate(preWarm?: boolean): void;
  123443. private _createFactorGradientTexture;
  123444. private _createSizeGradientTexture;
  123445. private _createAngularSpeedGradientTexture;
  123446. private _createVelocityGradientTexture;
  123447. private _createLimitVelocityGradientTexture;
  123448. private _createDragGradientTexture;
  123449. private _createColorGradientTexture;
  123450. /**
  123451. * Renders the particle system in its current state
  123452. * @param preWarm defines if the system should only update the particles but not render them
  123453. * @returns the current number of particles
  123454. */
  123455. render(preWarm?: boolean): number;
  123456. /**
  123457. * Rebuilds the particle system
  123458. */
  123459. rebuild(): void;
  123460. private _releaseBuffers;
  123461. private _releaseVAOs;
  123462. /**
  123463. * Disposes the particle system and free the associated resources
  123464. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  123465. */
  123466. dispose(disposeTexture?: boolean): void;
  123467. /**
  123468. * Clones the particle system.
  123469. * @param name The name of the cloned object
  123470. * @param newEmitter The new emitter to use
  123471. * @returns the cloned particle system
  123472. */
  123473. clone(name: string, newEmitter: any): GPUParticleSystem;
  123474. /**
  123475. * Serializes the particle system to a JSON object.
  123476. * @returns the JSON object
  123477. */
  123478. serialize(): any;
  123479. /**
  123480. * Parses a JSON object to create a GPU particle system.
  123481. * @param parsedParticleSystem The JSON object to parse
  123482. * @param scene The scene to create the particle system in
  123483. * @param rootUrl The root url to use to load external dependencies like texture
  123484. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123485. * @returns the parsed GPU particle system
  123486. */
  123487. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123488. }
  123489. }
  123490. declare module BABYLON {
  123491. /**
  123492. * Represents a set of particle systems working together to create a specific effect
  123493. */
  123494. export class ParticleSystemSet implements IDisposable {
  123495. private _emitterCreationOptions;
  123496. private _emitterNode;
  123497. /**
  123498. * Gets the particle system list
  123499. */
  123500. systems: IParticleSystem[];
  123501. /**
  123502. * Gets the emitter node used with this set
  123503. */
  123504. readonly emitterNode: Nullable<TransformNode>;
  123505. /**
  123506. * Creates a new emitter mesh as a sphere
  123507. * @param options defines the options used to create the sphere
  123508. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123509. * @param scene defines the hosting scene
  123510. */
  123511. setEmitterAsSphere(options: {
  123512. diameter: number;
  123513. segments: number;
  123514. color: Color3;
  123515. }, renderingGroupId: number, scene: Scene): void;
  123516. /**
  123517. * Starts all particle systems of the set
  123518. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123519. */
  123520. start(emitter?: AbstractMesh): void;
  123521. /**
  123522. * Release all associated resources
  123523. */
  123524. dispose(): void;
  123525. /**
  123526. * Serialize the set into a JSON compatible object
  123527. * @returns a JSON compatible representation of the set
  123528. */
  123529. serialize(): any;
  123530. /**
  123531. * Parse a new ParticleSystemSet from a serialized source
  123532. * @param data defines a JSON compatible representation of the set
  123533. * @param scene defines the hosting scene
  123534. * @param gpu defines if we want GPU particles or CPU particles
  123535. * @returns a new ParticleSystemSet
  123536. */
  123537. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123538. }
  123539. }
  123540. declare module BABYLON {
  123541. /**
  123542. * This class is made for on one-liner static method to help creating particle system set.
  123543. */
  123544. export class ParticleHelper {
  123545. /**
  123546. * Gets or sets base Assets URL
  123547. */
  123548. static BaseAssetsUrl: string;
  123549. /**
  123550. * Create a default particle system that you can tweak
  123551. * @param emitter defines the emitter to use
  123552. * @param capacity defines the system capacity (default is 500 particles)
  123553. * @param scene defines the hosting scene
  123554. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123555. * @returns the new Particle system
  123556. */
  123557. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123558. /**
  123559. * This is the main static method (one-liner) of this helper to create different particle systems
  123560. * @param type This string represents the type to the particle system to create
  123561. * @param scene The scene where the particle system should live
  123562. * @param gpu If the system will use gpu
  123563. * @returns the ParticleSystemSet created
  123564. */
  123565. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123566. /**
  123567. * Static function used to export a particle system to a ParticleSystemSet variable.
  123568. * Please note that the emitter shape is not exported
  123569. * @param systems defines the particle systems to export
  123570. * @returns the created particle system set
  123571. */
  123572. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123573. }
  123574. }
  123575. declare module BABYLON {
  123576. interface Engine {
  123577. /**
  123578. * Create an effect to use with particle systems.
  123579. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123580. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123581. * @param uniformsNames defines a list of attribute names
  123582. * @param samplers defines an array of string used to represent textures
  123583. * @param defines defines the string containing the defines to use to compile the shaders
  123584. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123585. * @param onCompiled defines a function to call when the effect creation is successful
  123586. * @param onError defines a function to call when the effect creation has failed
  123587. * @returns the new Effect
  123588. */
  123589. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123590. }
  123591. interface Mesh {
  123592. /**
  123593. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123594. * @returns an array of IParticleSystem
  123595. */
  123596. getEmittedParticleSystems(): IParticleSystem[];
  123597. /**
  123598. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123599. * @returns an array of IParticleSystem
  123600. */
  123601. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123602. }
  123603. /**
  123604. * @hidden
  123605. */
  123606. export var _IDoNeedToBeInTheBuild: number;
  123607. }
  123608. declare module BABYLON {
  123609. interface Scene {
  123610. /** @hidden (Backing field) */
  123611. _physicsEngine: Nullable<IPhysicsEngine>;
  123612. /**
  123613. * Gets the current physics engine
  123614. * @returns a IPhysicsEngine or null if none attached
  123615. */
  123616. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123617. /**
  123618. * Enables physics to the current scene
  123619. * @param gravity defines the scene's gravity for the physics engine
  123620. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123621. * @return a boolean indicating if the physics engine was initialized
  123622. */
  123623. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123624. /**
  123625. * Disables and disposes the physics engine associated with the scene
  123626. */
  123627. disablePhysicsEngine(): void;
  123628. /**
  123629. * Gets a boolean indicating if there is an active physics engine
  123630. * @returns a boolean indicating if there is an active physics engine
  123631. */
  123632. isPhysicsEnabled(): boolean;
  123633. /**
  123634. * Deletes a physics compound impostor
  123635. * @param compound defines the compound to delete
  123636. */
  123637. deleteCompoundImpostor(compound: any): void;
  123638. /**
  123639. * An event triggered when physic simulation is about to be run
  123640. */
  123641. onBeforePhysicsObservable: Observable<Scene>;
  123642. /**
  123643. * An event triggered when physic simulation has been done
  123644. */
  123645. onAfterPhysicsObservable: Observable<Scene>;
  123646. }
  123647. interface AbstractMesh {
  123648. /** @hidden */
  123649. _physicsImpostor: Nullable<PhysicsImpostor>;
  123650. /**
  123651. * Gets or sets impostor used for physic simulation
  123652. * @see http://doc.babylonjs.com/features/physics_engine
  123653. */
  123654. physicsImpostor: Nullable<PhysicsImpostor>;
  123655. /**
  123656. * Gets the current physics impostor
  123657. * @see http://doc.babylonjs.com/features/physics_engine
  123658. * @returns a physics impostor or null
  123659. */
  123660. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123661. /** Apply a physic impulse to the mesh
  123662. * @param force defines the force to apply
  123663. * @param contactPoint defines where to apply the force
  123664. * @returns the current mesh
  123665. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123666. */
  123667. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123668. /**
  123669. * Creates a physic joint between two meshes
  123670. * @param otherMesh defines the other mesh to use
  123671. * @param pivot1 defines the pivot to use on this mesh
  123672. * @param pivot2 defines the pivot to use on the other mesh
  123673. * @param options defines additional options (can be plugin dependent)
  123674. * @returns the current mesh
  123675. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123676. */
  123677. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123678. /** @hidden */
  123679. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123680. }
  123681. /**
  123682. * Defines the physics engine scene component responsible to manage a physics engine
  123683. */
  123684. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123685. /**
  123686. * The component name helpful to identify the component in the list of scene components.
  123687. */
  123688. readonly name: string;
  123689. /**
  123690. * The scene the component belongs to.
  123691. */
  123692. scene: Scene;
  123693. /**
  123694. * Creates a new instance of the component for the given scene
  123695. * @param scene Defines the scene to register the component in
  123696. */
  123697. constructor(scene: Scene);
  123698. /**
  123699. * Registers the component in a given scene
  123700. */
  123701. register(): void;
  123702. /**
  123703. * Rebuilds the elements related to this component in case of
  123704. * context lost for instance.
  123705. */
  123706. rebuild(): void;
  123707. /**
  123708. * Disposes the component and the associated ressources
  123709. */
  123710. dispose(): void;
  123711. }
  123712. }
  123713. declare module BABYLON {
  123714. /**
  123715. * A helper for physics simulations
  123716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123717. */
  123718. export class PhysicsHelper {
  123719. private _scene;
  123720. private _physicsEngine;
  123721. /**
  123722. * Initializes the Physics helper
  123723. * @param scene Babylon.js scene
  123724. */
  123725. constructor(scene: Scene);
  123726. /**
  123727. * Applies a radial explosion impulse
  123728. * @param origin the origin of the explosion
  123729. * @param radiusOrEventOptions the radius or the options of radial explosion
  123730. * @param strength the explosion strength
  123731. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123732. * @returns A physics radial explosion event, or null
  123733. */
  123734. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123735. /**
  123736. * Applies a radial explosion force
  123737. * @param origin the origin of the explosion
  123738. * @param radiusOrEventOptions the radius or the options of radial explosion
  123739. * @param strength the explosion strength
  123740. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123741. * @returns A physics radial explosion event, or null
  123742. */
  123743. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123744. /**
  123745. * Creates a gravitational field
  123746. * @param origin the origin of the explosion
  123747. * @param radiusOrEventOptions the radius or the options of radial explosion
  123748. * @param strength the explosion strength
  123749. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123750. * @returns A physics gravitational field event, or null
  123751. */
  123752. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123753. /**
  123754. * Creates a physics updraft event
  123755. * @param origin the origin of the updraft
  123756. * @param radiusOrEventOptions the radius or the options of the updraft
  123757. * @param strength the strength of the updraft
  123758. * @param height the height of the updraft
  123759. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123760. * @returns A physics updraft event, or null
  123761. */
  123762. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123763. /**
  123764. * Creates a physics vortex event
  123765. * @param origin the of the vortex
  123766. * @param radiusOrEventOptions the radius or the options of the vortex
  123767. * @param strength the strength of the vortex
  123768. * @param height the height of the vortex
  123769. * @returns a Physics vortex event, or null
  123770. * A physics vortex event or null
  123771. */
  123772. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123773. }
  123774. /**
  123775. * Represents a physics radial explosion event
  123776. */
  123777. class PhysicsRadialExplosionEvent {
  123778. private _scene;
  123779. private _options;
  123780. private _sphere;
  123781. private _dataFetched;
  123782. /**
  123783. * Initializes a radial explosioin event
  123784. * @param _scene BabylonJS scene
  123785. * @param _options The options for the vortex event
  123786. */
  123787. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123788. /**
  123789. * Returns the data related to the radial explosion event (sphere).
  123790. * @returns The radial explosion event data
  123791. */
  123792. getData(): PhysicsRadialExplosionEventData;
  123793. /**
  123794. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123795. * @param impostor A physics imposter
  123796. * @param origin the origin of the explosion
  123797. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123798. */
  123799. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123800. /**
  123801. * Triggers affecterd impostors callbacks
  123802. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123803. */
  123804. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123805. /**
  123806. * Disposes the sphere.
  123807. * @param force Specifies if the sphere should be disposed by force
  123808. */
  123809. dispose(force?: boolean): void;
  123810. /*** Helpers ***/
  123811. private _prepareSphere;
  123812. private _intersectsWithSphere;
  123813. }
  123814. /**
  123815. * Represents a gravitational field event
  123816. */
  123817. class PhysicsGravitationalFieldEvent {
  123818. private _physicsHelper;
  123819. private _scene;
  123820. private _origin;
  123821. private _options;
  123822. private _tickCallback;
  123823. private _sphere;
  123824. private _dataFetched;
  123825. /**
  123826. * Initializes the physics gravitational field event
  123827. * @param _physicsHelper A physics helper
  123828. * @param _scene BabylonJS scene
  123829. * @param _origin The origin position of the gravitational field event
  123830. * @param _options The options for the vortex event
  123831. */
  123832. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123833. /**
  123834. * Returns the data related to the gravitational field event (sphere).
  123835. * @returns A gravitational field event
  123836. */
  123837. getData(): PhysicsGravitationalFieldEventData;
  123838. /**
  123839. * Enables the gravitational field.
  123840. */
  123841. enable(): void;
  123842. /**
  123843. * Disables the gravitational field.
  123844. */
  123845. disable(): void;
  123846. /**
  123847. * Disposes the sphere.
  123848. * @param force The force to dispose from the gravitational field event
  123849. */
  123850. dispose(force?: boolean): void;
  123851. private _tick;
  123852. }
  123853. /**
  123854. * Represents a physics updraft event
  123855. */
  123856. class PhysicsUpdraftEvent {
  123857. private _scene;
  123858. private _origin;
  123859. private _options;
  123860. private _physicsEngine;
  123861. private _originTop;
  123862. private _originDirection;
  123863. private _tickCallback;
  123864. private _cylinder;
  123865. private _cylinderPosition;
  123866. private _dataFetched;
  123867. /**
  123868. * Initializes the physics updraft event
  123869. * @param _scene BabylonJS scene
  123870. * @param _origin The origin position of the updraft
  123871. * @param _options The options for the updraft event
  123872. */
  123873. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123874. /**
  123875. * Returns the data related to the updraft event (cylinder).
  123876. * @returns A physics updraft event
  123877. */
  123878. getData(): PhysicsUpdraftEventData;
  123879. /**
  123880. * Enables the updraft.
  123881. */
  123882. enable(): void;
  123883. /**
  123884. * Disables the updraft.
  123885. */
  123886. disable(): void;
  123887. /**
  123888. * Disposes the cylinder.
  123889. * @param force Specifies if the updraft should be disposed by force
  123890. */
  123891. dispose(force?: boolean): void;
  123892. private getImpostorHitData;
  123893. private _tick;
  123894. /*** Helpers ***/
  123895. private _prepareCylinder;
  123896. private _intersectsWithCylinder;
  123897. }
  123898. /**
  123899. * Represents a physics vortex event
  123900. */
  123901. class PhysicsVortexEvent {
  123902. private _scene;
  123903. private _origin;
  123904. private _options;
  123905. private _physicsEngine;
  123906. private _originTop;
  123907. private _tickCallback;
  123908. private _cylinder;
  123909. private _cylinderPosition;
  123910. private _dataFetched;
  123911. /**
  123912. * Initializes the physics vortex event
  123913. * @param _scene The BabylonJS scene
  123914. * @param _origin The origin position of the vortex
  123915. * @param _options The options for the vortex event
  123916. */
  123917. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123918. /**
  123919. * Returns the data related to the vortex event (cylinder).
  123920. * @returns The physics vortex event data
  123921. */
  123922. getData(): PhysicsVortexEventData;
  123923. /**
  123924. * Enables the vortex.
  123925. */
  123926. enable(): void;
  123927. /**
  123928. * Disables the cortex.
  123929. */
  123930. disable(): void;
  123931. /**
  123932. * Disposes the sphere.
  123933. * @param force
  123934. */
  123935. dispose(force?: boolean): void;
  123936. private getImpostorHitData;
  123937. private _tick;
  123938. /*** Helpers ***/
  123939. private _prepareCylinder;
  123940. private _intersectsWithCylinder;
  123941. }
  123942. /**
  123943. * Options fot the radial explosion event
  123944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123945. */
  123946. export class PhysicsRadialExplosionEventOptions {
  123947. /**
  123948. * The radius of the sphere for the radial explosion.
  123949. */
  123950. radius: number;
  123951. /**
  123952. * The strenth of the explosion.
  123953. */
  123954. strength: number;
  123955. /**
  123956. * The strenght of the force in correspondence to the distance of the affected object
  123957. */
  123958. falloff: PhysicsRadialImpulseFalloff;
  123959. /**
  123960. * Sphere options for the radial explosion.
  123961. */
  123962. sphere: {
  123963. segments: number;
  123964. diameter: number;
  123965. };
  123966. /**
  123967. * Sphere options for the radial explosion.
  123968. */
  123969. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123970. }
  123971. /**
  123972. * Options fot the updraft event
  123973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123974. */
  123975. export class PhysicsUpdraftEventOptions {
  123976. /**
  123977. * The radius of the cylinder for the vortex
  123978. */
  123979. radius: number;
  123980. /**
  123981. * The strenth of the updraft.
  123982. */
  123983. strength: number;
  123984. /**
  123985. * The height of the cylinder for the updraft.
  123986. */
  123987. height: number;
  123988. /**
  123989. * The mode for the the updraft.
  123990. */
  123991. updraftMode: PhysicsUpdraftMode;
  123992. }
  123993. /**
  123994. * Options fot the vortex event
  123995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123996. */
  123997. export class PhysicsVortexEventOptions {
  123998. /**
  123999. * The radius of the cylinder for the vortex
  124000. */
  124001. radius: number;
  124002. /**
  124003. * The strenth of the vortex.
  124004. */
  124005. strength: number;
  124006. /**
  124007. * The height of the cylinder for the vortex.
  124008. */
  124009. height: number;
  124010. /**
  124011. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  124012. */
  124013. centripetalForceThreshold: number;
  124014. /**
  124015. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  124016. */
  124017. centripetalForceMultiplier: number;
  124018. /**
  124019. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  124020. */
  124021. centrifugalForceMultiplier: number;
  124022. /**
  124023. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  124024. */
  124025. updraftForceMultiplier: number;
  124026. }
  124027. /**
  124028. * The strenght of the force in correspondence to the distance of the affected object
  124029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124030. */
  124031. export enum PhysicsRadialImpulseFalloff {
  124032. /** Defines that impulse is constant in strength across it's whole radius */
  124033. Constant = 0,
  124034. /** Defines that impulse gets weaker if it's further from the origin */
  124035. Linear = 1
  124036. }
  124037. /**
  124038. * The strength of the force in correspondence to the distance of the affected object
  124039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124040. */
  124041. export enum PhysicsUpdraftMode {
  124042. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  124043. Center = 0,
  124044. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  124045. Perpendicular = 1
  124046. }
  124047. /**
  124048. * Interface for a physics hit data
  124049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124050. */
  124051. export interface PhysicsHitData {
  124052. /**
  124053. * The force applied at the contact point
  124054. */
  124055. force: Vector3;
  124056. /**
  124057. * The contact point
  124058. */
  124059. contactPoint: Vector3;
  124060. /**
  124061. * The distance from the origin to the contact point
  124062. */
  124063. distanceFromOrigin: number;
  124064. }
  124065. /**
  124066. * Interface for radial explosion event data
  124067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124068. */
  124069. export interface PhysicsRadialExplosionEventData {
  124070. /**
  124071. * A sphere used for the radial explosion event
  124072. */
  124073. sphere: Mesh;
  124074. }
  124075. /**
  124076. * Interface for gravitational field event data
  124077. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124078. */
  124079. export interface PhysicsGravitationalFieldEventData {
  124080. /**
  124081. * A sphere mesh used for the gravitational field event
  124082. */
  124083. sphere: Mesh;
  124084. }
  124085. /**
  124086. * Interface for updraft event data
  124087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124088. */
  124089. export interface PhysicsUpdraftEventData {
  124090. /**
  124091. * A cylinder used for the updraft event
  124092. */
  124093. cylinder: Mesh;
  124094. }
  124095. /**
  124096. * Interface for vortex event data
  124097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124098. */
  124099. export interface PhysicsVortexEventData {
  124100. /**
  124101. * A cylinder used for the vortex event
  124102. */
  124103. cylinder: Mesh;
  124104. }
  124105. /**
  124106. * Interface for an affected physics impostor
  124107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124108. */
  124109. export interface PhysicsAffectedImpostorWithData {
  124110. /**
  124111. * The impostor affected by the effect
  124112. */
  124113. impostor: PhysicsImpostor;
  124114. /**
  124115. * The data about the hit/horce from the explosion
  124116. */
  124117. hitData: PhysicsHitData;
  124118. }
  124119. }
  124120. declare module BABYLON {
  124121. /** @hidden */
  124122. export var blackAndWhitePixelShader: {
  124123. name: string;
  124124. shader: string;
  124125. };
  124126. }
  124127. declare module BABYLON {
  124128. /**
  124129. * Post process used to render in black and white
  124130. */
  124131. export class BlackAndWhitePostProcess extends PostProcess {
  124132. /**
  124133. * Linear about to convert he result to black and white (default: 1)
  124134. */
  124135. degree: number;
  124136. /**
  124137. * Creates a black and white post process
  124138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  124139. * @param name The name of the effect.
  124140. * @param options The required width/height ratio to downsize to before computing the render pass.
  124141. * @param camera The camera to apply the render pass to.
  124142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124143. * @param engine The engine which the post process will be applied. (default: current engine)
  124144. * @param reusable If the post process can be reused on the same frame. (default: false)
  124145. */
  124146. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124147. }
  124148. }
  124149. declare module BABYLON {
  124150. /**
  124151. * This represents a set of one or more post processes in Babylon.
  124152. * A post process can be used to apply a shader to a texture after it is rendered.
  124153. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124154. */
  124155. export class PostProcessRenderEffect {
  124156. private _postProcesses;
  124157. private _getPostProcesses;
  124158. private _singleInstance;
  124159. private _cameras;
  124160. private _indicesForCamera;
  124161. /**
  124162. * Name of the effect
  124163. * @hidden
  124164. */
  124165. _name: string;
  124166. /**
  124167. * Instantiates a post process render effect.
  124168. * A post process can be used to apply a shader to a texture after it is rendered.
  124169. * @param engine The engine the effect is tied to
  124170. * @param name The name of the effect
  124171. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  124172. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  124173. */
  124174. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  124175. /**
  124176. * Checks if all the post processes in the effect are supported.
  124177. */
  124178. readonly isSupported: boolean;
  124179. /**
  124180. * Updates the current state of the effect
  124181. * @hidden
  124182. */
  124183. _update(): void;
  124184. /**
  124185. * Attaches the effect on cameras
  124186. * @param cameras The camera to attach to.
  124187. * @hidden
  124188. */
  124189. _attachCameras(cameras: Camera): void;
  124190. /**
  124191. * Attaches the effect on cameras
  124192. * @param cameras The camera to attach to.
  124193. * @hidden
  124194. */
  124195. _attachCameras(cameras: Camera[]): void;
  124196. /**
  124197. * Detaches the effect on cameras
  124198. * @param cameras The camera to detatch from.
  124199. * @hidden
  124200. */
  124201. _detachCameras(cameras: Camera): void;
  124202. /**
  124203. * Detatches the effect on cameras
  124204. * @param cameras The camera to detatch from.
  124205. * @hidden
  124206. */
  124207. _detachCameras(cameras: Camera[]): void;
  124208. /**
  124209. * Enables the effect on given cameras
  124210. * @param cameras The camera to enable.
  124211. * @hidden
  124212. */
  124213. _enable(cameras: Camera): void;
  124214. /**
  124215. * Enables the effect on given cameras
  124216. * @param cameras The camera to enable.
  124217. * @hidden
  124218. */
  124219. _enable(cameras: Nullable<Camera[]>): void;
  124220. /**
  124221. * Disables the effect on the given cameras
  124222. * @param cameras The camera to disable.
  124223. * @hidden
  124224. */
  124225. _disable(cameras: Camera): void;
  124226. /**
  124227. * Disables the effect on the given cameras
  124228. * @param cameras The camera to disable.
  124229. * @hidden
  124230. */
  124231. _disable(cameras: Nullable<Camera[]>): void;
  124232. /**
  124233. * Gets a list of the post processes contained in the effect.
  124234. * @param camera The camera to get the post processes on.
  124235. * @returns The list of the post processes in the effect.
  124236. */
  124237. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  124238. }
  124239. }
  124240. declare module BABYLON {
  124241. /** @hidden */
  124242. export var extractHighlightsPixelShader: {
  124243. name: string;
  124244. shader: string;
  124245. };
  124246. }
  124247. declare module BABYLON {
  124248. /**
  124249. * 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.
  124250. */
  124251. export class ExtractHighlightsPostProcess extends PostProcess {
  124252. /**
  124253. * The luminance threshold, pixels below this value will be set to black.
  124254. */
  124255. threshold: number;
  124256. /** @hidden */
  124257. _exposure: number;
  124258. /**
  124259. * Post process which has the input texture to be used when performing highlight extraction
  124260. * @hidden
  124261. */
  124262. _inputPostProcess: Nullable<PostProcess>;
  124263. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124264. }
  124265. }
  124266. declare module BABYLON {
  124267. /** @hidden */
  124268. export var bloomMergePixelShader: {
  124269. name: string;
  124270. shader: string;
  124271. };
  124272. }
  124273. declare module BABYLON {
  124274. /**
  124275. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124276. */
  124277. export class BloomMergePostProcess extends PostProcess {
  124278. /** Weight of the bloom to be added to the original input. */
  124279. weight: number;
  124280. /**
  124281. * Creates a new instance of @see BloomMergePostProcess
  124282. * @param name The name of the effect.
  124283. * @param originalFromInput Post process which's input will be used for the merge.
  124284. * @param blurred Blurred highlights post process which's output will be used.
  124285. * @param weight Weight of the bloom to be added to the original input.
  124286. * @param options The required width/height ratio to downsize to before computing the render pass.
  124287. * @param camera The camera to apply the render pass to.
  124288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124289. * @param engine The engine which the post process will be applied. (default: current engine)
  124290. * @param reusable If the post process can be reused on the same frame. (default: false)
  124291. * @param textureType Type of textures used when performing the post process. (default: 0)
  124292. * @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)
  124293. */
  124294. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  124295. /** Weight of the bloom to be added to the original input. */
  124296. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124297. }
  124298. }
  124299. declare module BABYLON {
  124300. /**
  124301. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  124302. */
  124303. export class BloomEffect extends PostProcessRenderEffect {
  124304. private bloomScale;
  124305. /**
  124306. * @hidden Internal
  124307. */
  124308. _effects: Array<PostProcess>;
  124309. /**
  124310. * @hidden Internal
  124311. */
  124312. _downscale: ExtractHighlightsPostProcess;
  124313. private _blurX;
  124314. private _blurY;
  124315. private _merge;
  124316. /**
  124317. * The luminance threshold to find bright areas of the image to bloom.
  124318. */
  124319. threshold: number;
  124320. /**
  124321. * The strength of the bloom.
  124322. */
  124323. weight: number;
  124324. /**
  124325. * Specifies the size of the bloom blur kernel, relative to the final output size
  124326. */
  124327. kernel: number;
  124328. /**
  124329. * Creates a new instance of @see BloomEffect
  124330. * @param scene The scene the effect belongs to.
  124331. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  124332. * @param bloomKernel The size of the kernel to be used when applying the blur.
  124333. * @param bloomWeight The the strength of bloom.
  124334. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124335. * @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)
  124336. */
  124337. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  124338. /**
  124339. * Disposes each of the internal effects for a given camera.
  124340. * @param camera The camera to dispose the effect on.
  124341. */
  124342. disposeEffects(camera: Camera): void;
  124343. /**
  124344. * @hidden Internal
  124345. */
  124346. _updateEffects(): void;
  124347. /**
  124348. * Internal
  124349. * @returns if all the contained post processes are ready.
  124350. * @hidden
  124351. */
  124352. _isReady(): boolean;
  124353. }
  124354. }
  124355. declare module BABYLON {
  124356. /** @hidden */
  124357. export var chromaticAberrationPixelShader: {
  124358. name: string;
  124359. shader: string;
  124360. };
  124361. }
  124362. declare module BABYLON {
  124363. /**
  124364. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  124365. */
  124366. export class ChromaticAberrationPostProcess extends PostProcess {
  124367. /**
  124368. * The amount of seperation of rgb channels (default: 30)
  124369. */
  124370. aberrationAmount: number;
  124371. /**
  124372. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  124373. */
  124374. radialIntensity: number;
  124375. /**
  124376. * 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))
  124377. */
  124378. direction: Vector2;
  124379. /**
  124380. * 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))
  124381. */
  124382. centerPosition: Vector2;
  124383. /**
  124384. * Creates a new instance ChromaticAberrationPostProcess
  124385. * @param name The name of the effect.
  124386. * @param screenWidth The width of the screen to apply the effect on.
  124387. * @param screenHeight The height of the screen to apply the effect on.
  124388. * @param options The required width/height ratio to downsize to before computing the render pass.
  124389. * @param camera The camera to apply the render pass to.
  124390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124391. * @param engine The engine which the post process will be applied. (default: current engine)
  124392. * @param reusable If the post process can be reused on the same frame. (default: false)
  124393. * @param textureType Type of textures used when performing the post process. (default: 0)
  124394. * @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)
  124395. */
  124396. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124397. }
  124398. }
  124399. declare module BABYLON {
  124400. /** @hidden */
  124401. export var circleOfConfusionPixelShader: {
  124402. name: string;
  124403. shader: string;
  124404. };
  124405. }
  124406. declare module BABYLON {
  124407. /**
  124408. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  124409. */
  124410. export class CircleOfConfusionPostProcess extends PostProcess {
  124411. /**
  124412. * 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.
  124413. */
  124414. lensSize: number;
  124415. /**
  124416. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124417. */
  124418. fStop: number;
  124419. /**
  124420. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124421. */
  124422. focusDistance: number;
  124423. /**
  124424. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  124425. */
  124426. focalLength: number;
  124427. private _depthTexture;
  124428. /**
  124429. * Creates a new instance CircleOfConfusionPostProcess
  124430. * @param name The name of the effect.
  124431. * @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.
  124432. * @param options The required width/height ratio to downsize to before computing the render pass.
  124433. * @param camera The camera to apply the render pass to.
  124434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124435. * @param engine The engine which the post process will be applied. (default: current engine)
  124436. * @param reusable If the post process can be reused on the same frame. (default: false)
  124437. * @param textureType Type of textures used when performing the post process. (default: 0)
  124438. * @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)
  124439. */
  124440. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124441. /**
  124442. * 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.
  124443. */
  124444. depthTexture: RenderTargetTexture;
  124445. }
  124446. }
  124447. declare module BABYLON {
  124448. /** @hidden */
  124449. export var colorCorrectionPixelShader: {
  124450. name: string;
  124451. shader: string;
  124452. };
  124453. }
  124454. declare module BABYLON {
  124455. /**
  124456. *
  124457. * This post-process allows the modification of rendered colors by using
  124458. * a 'look-up table' (LUT). This effect is also called Color Grading.
  124459. *
  124460. * The object needs to be provided an url to a texture containing the color
  124461. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  124462. * Use an image editing software to tweak the LUT to match your needs.
  124463. *
  124464. * For an example of a color LUT, see here:
  124465. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  124466. * For explanations on color grading, see here:
  124467. * @see http://udn.epicgames.com/Three/ColorGrading.html
  124468. *
  124469. */
  124470. export class ColorCorrectionPostProcess extends PostProcess {
  124471. private _colorTableTexture;
  124472. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124473. }
  124474. }
  124475. declare module BABYLON {
  124476. /** @hidden */
  124477. export var convolutionPixelShader: {
  124478. name: string;
  124479. shader: string;
  124480. };
  124481. }
  124482. declare module BABYLON {
  124483. /**
  124484. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124485. * input texture to perform effects such as edge detection or sharpening
  124486. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124487. */
  124488. export class ConvolutionPostProcess extends PostProcess {
  124489. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124490. kernel: number[];
  124491. /**
  124492. * Creates a new instance ConvolutionPostProcess
  124493. * @param name The name of the effect.
  124494. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124495. * @param options The required width/height ratio to downsize to before computing the render pass.
  124496. * @param camera The camera to apply the render pass to.
  124497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124498. * @param engine The engine which the post process will be applied. (default: current engine)
  124499. * @param reusable If the post process can be reused on the same frame. (default: false)
  124500. * @param textureType Type of textures used when performing the post process. (default: 0)
  124501. */
  124502. constructor(name: string,
  124503. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124504. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124505. /**
  124506. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124507. */
  124508. static EdgeDetect0Kernel: number[];
  124509. /**
  124510. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124511. */
  124512. static EdgeDetect1Kernel: number[];
  124513. /**
  124514. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124515. */
  124516. static EdgeDetect2Kernel: number[];
  124517. /**
  124518. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124519. */
  124520. static SharpenKernel: number[];
  124521. /**
  124522. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124523. */
  124524. static EmbossKernel: number[];
  124525. /**
  124526. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124527. */
  124528. static GaussianKernel: number[];
  124529. }
  124530. }
  124531. declare module BABYLON {
  124532. /**
  124533. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124534. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124535. * based on samples that have a large difference in distance than the center pixel.
  124536. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124537. */
  124538. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124539. direction: Vector2;
  124540. /**
  124541. * Creates a new instance CircleOfConfusionPostProcess
  124542. * @param name The name of the effect.
  124543. * @param scene The scene the effect belongs to.
  124544. * @param direction The direction the blur should be applied.
  124545. * @param kernel The size of the kernel used to blur.
  124546. * @param options The required width/height ratio to downsize to before computing the render pass.
  124547. * @param camera The camera to apply the render pass to.
  124548. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124549. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124551. * @param engine The engine which the post process will be applied. (default: current engine)
  124552. * @param reusable If the post process can be reused on the same frame. (default: false)
  124553. * @param textureType Type of textures used when performing the post process. (default: 0)
  124554. * @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)
  124555. */
  124556. 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);
  124557. }
  124558. }
  124559. declare module BABYLON {
  124560. /** @hidden */
  124561. export var depthOfFieldMergePixelShader: {
  124562. name: string;
  124563. shader: string;
  124564. };
  124565. }
  124566. declare module BABYLON {
  124567. /**
  124568. * Options to be set when merging outputs from the default pipeline.
  124569. */
  124570. export class DepthOfFieldMergePostProcessOptions {
  124571. /**
  124572. * The original image to merge on top of
  124573. */
  124574. originalFromInput: PostProcess;
  124575. /**
  124576. * Parameters to perform the merge of the depth of field effect
  124577. */
  124578. depthOfField?: {
  124579. circleOfConfusion: PostProcess;
  124580. blurSteps: Array<PostProcess>;
  124581. };
  124582. /**
  124583. * Parameters to perform the merge of bloom effect
  124584. */
  124585. bloom?: {
  124586. blurred: PostProcess;
  124587. weight: number;
  124588. };
  124589. }
  124590. /**
  124591. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124592. */
  124593. export class DepthOfFieldMergePostProcess extends PostProcess {
  124594. private blurSteps;
  124595. /**
  124596. * Creates a new instance of DepthOfFieldMergePostProcess
  124597. * @param name The name of the effect.
  124598. * @param originalFromInput Post process which's input will be used for the merge.
  124599. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124600. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124601. * @param options The required width/height ratio to downsize to before computing the render pass.
  124602. * @param camera The camera to apply the render pass to.
  124603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124604. * @param engine The engine which the post process will be applied. (default: current engine)
  124605. * @param reusable If the post process can be reused on the same frame. (default: false)
  124606. * @param textureType Type of textures used when performing the post process. (default: 0)
  124607. * @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)
  124608. */
  124609. 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);
  124610. /**
  124611. * Updates the effect with the current post process compile time values and recompiles the shader.
  124612. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124613. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124614. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124615. * @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
  124616. * @param onCompiled Called when the shader has been compiled.
  124617. * @param onError Called if there is an error when compiling a shader.
  124618. */
  124619. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124620. }
  124621. }
  124622. declare module BABYLON {
  124623. /**
  124624. * Specifies the level of max blur that should be applied when using the depth of field effect
  124625. */
  124626. export enum DepthOfFieldEffectBlurLevel {
  124627. /**
  124628. * Subtle blur
  124629. */
  124630. Low = 0,
  124631. /**
  124632. * Medium blur
  124633. */
  124634. Medium = 1,
  124635. /**
  124636. * Large blur
  124637. */
  124638. High = 2
  124639. }
  124640. /**
  124641. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124642. */
  124643. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124644. private _circleOfConfusion;
  124645. /**
  124646. * @hidden Internal, blurs from high to low
  124647. */
  124648. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124649. private _depthOfFieldBlurY;
  124650. private _dofMerge;
  124651. /**
  124652. * @hidden Internal post processes in depth of field effect
  124653. */
  124654. _effects: Array<PostProcess>;
  124655. /**
  124656. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124657. */
  124658. focalLength: number;
  124659. /**
  124660. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124661. */
  124662. fStop: number;
  124663. /**
  124664. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124665. */
  124666. focusDistance: number;
  124667. /**
  124668. * 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.
  124669. */
  124670. lensSize: number;
  124671. /**
  124672. * Creates a new instance DepthOfFieldEffect
  124673. * @param scene The scene the effect belongs to.
  124674. * @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.
  124675. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124676. * @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)
  124677. */
  124678. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124679. /**
  124680. * Get the current class name of the current effet
  124681. * @returns "DepthOfFieldEffect"
  124682. */
  124683. getClassName(): string;
  124684. /**
  124685. * 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.
  124686. */
  124687. depthTexture: RenderTargetTexture;
  124688. /**
  124689. * Disposes each of the internal effects for a given camera.
  124690. * @param camera The camera to dispose the effect on.
  124691. */
  124692. disposeEffects(camera: Camera): void;
  124693. /**
  124694. * @hidden Internal
  124695. */
  124696. _updateEffects(): void;
  124697. /**
  124698. * Internal
  124699. * @returns if all the contained post processes are ready.
  124700. * @hidden
  124701. */
  124702. _isReady(): boolean;
  124703. }
  124704. }
  124705. declare module BABYLON {
  124706. /** @hidden */
  124707. export var displayPassPixelShader: {
  124708. name: string;
  124709. shader: string;
  124710. };
  124711. }
  124712. declare module BABYLON {
  124713. /**
  124714. * DisplayPassPostProcess which produces an output the same as it's input
  124715. */
  124716. export class DisplayPassPostProcess extends PostProcess {
  124717. /**
  124718. * Creates the DisplayPassPostProcess
  124719. * @param name The name of the effect.
  124720. * @param options The required width/height ratio to downsize to before computing the render pass.
  124721. * @param camera The camera to apply the render pass to.
  124722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124723. * @param engine The engine which the post process will be applied. (default: current engine)
  124724. * @param reusable If the post process can be reused on the same frame. (default: false)
  124725. */
  124726. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124727. }
  124728. }
  124729. declare module BABYLON {
  124730. /** @hidden */
  124731. export var filterPixelShader: {
  124732. name: string;
  124733. shader: string;
  124734. };
  124735. }
  124736. declare module BABYLON {
  124737. /**
  124738. * Applies a kernel filter to the image
  124739. */
  124740. export class FilterPostProcess extends PostProcess {
  124741. /** The matrix to be applied to the image */
  124742. kernelMatrix: Matrix;
  124743. /**
  124744. *
  124745. * @param name The name of the effect.
  124746. * @param kernelMatrix The matrix to be applied to the image
  124747. * @param options The required width/height ratio to downsize to before computing the render pass.
  124748. * @param camera The camera to apply the render pass to.
  124749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124750. * @param engine The engine which the post process will be applied. (default: current engine)
  124751. * @param reusable If the post process can be reused on the same frame. (default: false)
  124752. */
  124753. constructor(name: string,
  124754. /** The matrix to be applied to the image */
  124755. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124756. }
  124757. }
  124758. declare module BABYLON {
  124759. /** @hidden */
  124760. export var fxaaPixelShader: {
  124761. name: string;
  124762. shader: string;
  124763. };
  124764. }
  124765. declare module BABYLON {
  124766. /** @hidden */
  124767. export var fxaaVertexShader: {
  124768. name: string;
  124769. shader: string;
  124770. };
  124771. }
  124772. declare module BABYLON {
  124773. /**
  124774. * Fxaa post process
  124775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124776. */
  124777. export class FxaaPostProcess extends PostProcess {
  124778. /** @hidden */
  124779. texelWidth: number;
  124780. /** @hidden */
  124781. texelHeight: number;
  124782. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124783. private _getDefines;
  124784. }
  124785. }
  124786. declare module BABYLON {
  124787. /** @hidden */
  124788. export var grainPixelShader: {
  124789. name: string;
  124790. shader: string;
  124791. };
  124792. }
  124793. declare module BABYLON {
  124794. /**
  124795. * The GrainPostProcess adds noise to the image at mid luminance levels
  124796. */
  124797. export class GrainPostProcess extends PostProcess {
  124798. /**
  124799. * The intensity of the grain added (default: 30)
  124800. */
  124801. intensity: number;
  124802. /**
  124803. * If the grain should be randomized on every frame
  124804. */
  124805. animated: boolean;
  124806. /**
  124807. * Creates a new instance of @see GrainPostProcess
  124808. * @param name The name of the effect.
  124809. * @param options The required width/height ratio to downsize to before computing the render pass.
  124810. * @param camera The camera to apply the render pass to.
  124811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124812. * @param engine The engine which the post process will be applied. (default: current engine)
  124813. * @param reusable If the post process can be reused on the same frame. (default: false)
  124814. * @param textureType Type of textures used when performing the post process. (default: 0)
  124815. * @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)
  124816. */
  124817. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124818. }
  124819. }
  124820. declare module BABYLON {
  124821. /** @hidden */
  124822. export var highlightsPixelShader: {
  124823. name: string;
  124824. shader: string;
  124825. };
  124826. }
  124827. declare module BABYLON {
  124828. /**
  124829. * Extracts highlights from the image
  124830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124831. */
  124832. export class HighlightsPostProcess extends PostProcess {
  124833. /**
  124834. * Extracts highlights from the image
  124835. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124836. * @param name The name of the effect.
  124837. * @param options The required width/height ratio to downsize to before computing the render pass.
  124838. * @param camera The camera to apply the render pass to.
  124839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124840. * @param engine The engine which the post process will be applied. (default: current engine)
  124841. * @param reusable If the post process can be reused on the same frame. (default: false)
  124842. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124843. */
  124844. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124845. }
  124846. }
  124847. declare module BABYLON {
  124848. /** @hidden */
  124849. export var mrtFragmentDeclaration: {
  124850. name: string;
  124851. shader: string;
  124852. };
  124853. }
  124854. declare module BABYLON {
  124855. /** @hidden */
  124856. export var geometryPixelShader: {
  124857. name: string;
  124858. shader: string;
  124859. };
  124860. }
  124861. declare module BABYLON {
  124862. /** @hidden */
  124863. export var geometryVertexShader: {
  124864. name: string;
  124865. shader: string;
  124866. };
  124867. }
  124868. declare module BABYLON {
  124869. /** @hidden */
  124870. interface ISavedTransformationMatrix {
  124871. world: Matrix;
  124872. viewProjection: Matrix;
  124873. }
  124874. /**
  124875. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124876. */
  124877. export class GeometryBufferRenderer {
  124878. /**
  124879. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124880. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124881. */
  124882. static readonly POSITION_TEXTURE_TYPE: number;
  124883. /**
  124884. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124885. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124886. */
  124887. static readonly VELOCITY_TEXTURE_TYPE: number;
  124888. /**
  124889. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124890. * in order to compute objects velocities when enableVelocity is set to "true"
  124891. * @hidden
  124892. */
  124893. _previousTransformationMatrices: {
  124894. [index: number]: ISavedTransformationMatrix;
  124895. };
  124896. /**
  124897. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124898. * in order to compute objects velocities when enableVelocity is set to "true"
  124899. * @hidden
  124900. */
  124901. _previousBonesTransformationMatrices: {
  124902. [index: number]: Float32Array;
  124903. };
  124904. /**
  124905. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124906. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124907. */
  124908. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124909. private _scene;
  124910. private _multiRenderTarget;
  124911. private _ratio;
  124912. private _enablePosition;
  124913. private _enableVelocity;
  124914. private _positionIndex;
  124915. private _velocityIndex;
  124916. protected _effect: Effect;
  124917. protected _cachedDefines: string;
  124918. /**
  124919. * Set the render list (meshes to be rendered) used in the G buffer.
  124920. */
  124921. renderList: Mesh[];
  124922. /**
  124923. * Gets wether or not G buffer are supported by the running hardware.
  124924. * This requires draw buffer supports
  124925. */
  124926. readonly isSupported: boolean;
  124927. /**
  124928. * Returns the index of the given texture type in the G-Buffer textures array
  124929. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124930. * @returns the index of the given texture type in the G-Buffer textures array
  124931. */
  124932. getTextureIndex(textureType: number): number;
  124933. /**
  124934. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124935. */
  124936. /**
  124937. * Sets whether or not objects positions are enabled for the G buffer.
  124938. */
  124939. enablePosition: boolean;
  124940. /**
  124941. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124942. */
  124943. /**
  124944. * Sets wether or not objects velocities are enabled for the G buffer.
  124945. */
  124946. enableVelocity: boolean;
  124947. /**
  124948. * Gets the scene associated with the buffer.
  124949. */
  124950. readonly scene: Scene;
  124951. /**
  124952. * Gets the ratio used by the buffer during its creation.
  124953. * How big is the buffer related to the main canvas.
  124954. */
  124955. readonly ratio: number;
  124956. /** @hidden */
  124957. static _SceneComponentInitialization: (scene: Scene) => void;
  124958. /**
  124959. * Creates a new G Buffer for the scene
  124960. * @param scene The scene the buffer belongs to
  124961. * @param ratio How big is the buffer related to the main canvas.
  124962. */
  124963. constructor(scene: Scene, ratio?: number);
  124964. /**
  124965. * Checks wether everything is ready to render a submesh to the G buffer.
  124966. * @param subMesh the submesh to check readiness for
  124967. * @param useInstances is the mesh drawn using instance or not
  124968. * @returns true if ready otherwise false
  124969. */
  124970. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124971. /**
  124972. * Gets the current underlying G Buffer.
  124973. * @returns the buffer
  124974. */
  124975. getGBuffer(): MultiRenderTarget;
  124976. /**
  124977. * Gets the number of samples used to render the buffer (anti aliasing).
  124978. */
  124979. /**
  124980. * Sets the number of samples used to render the buffer (anti aliasing).
  124981. */
  124982. samples: number;
  124983. /**
  124984. * Disposes the renderer and frees up associated resources.
  124985. */
  124986. dispose(): void;
  124987. protected _createRenderTargets(): void;
  124988. private _copyBonesTransformationMatrices;
  124989. }
  124990. }
  124991. declare module BABYLON {
  124992. interface Scene {
  124993. /** @hidden (Backing field) */
  124994. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124995. /**
  124996. * Gets or Sets the current geometry buffer associated to the scene.
  124997. */
  124998. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124999. /**
  125000. * Enables a GeometryBufferRender and associates it with the scene
  125001. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  125002. * @returns the GeometryBufferRenderer
  125003. */
  125004. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  125005. /**
  125006. * Disables the GeometryBufferRender associated with the scene
  125007. */
  125008. disableGeometryBufferRenderer(): void;
  125009. }
  125010. /**
  125011. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  125012. * in several rendering techniques.
  125013. */
  125014. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  125015. /**
  125016. * The component name helpful to identify the component in the list of scene components.
  125017. */
  125018. readonly name: string;
  125019. /**
  125020. * The scene the component belongs to.
  125021. */
  125022. scene: Scene;
  125023. /**
  125024. * Creates a new instance of the component for the given scene
  125025. * @param scene Defines the scene to register the component in
  125026. */
  125027. constructor(scene: Scene);
  125028. /**
  125029. * Registers the component in a given scene
  125030. */
  125031. register(): void;
  125032. /**
  125033. * Rebuilds the elements related to this component in case of
  125034. * context lost for instance.
  125035. */
  125036. rebuild(): void;
  125037. /**
  125038. * Disposes the component and the associated ressources
  125039. */
  125040. dispose(): void;
  125041. private _gatherRenderTargets;
  125042. }
  125043. }
  125044. declare module BABYLON {
  125045. /** @hidden */
  125046. export var motionBlurPixelShader: {
  125047. name: string;
  125048. shader: string;
  125049. };
  125050. }
  125051. declare module BABYLON {
  125052. /**
  125053. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  125054. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  125055. * As an example, all you have to do is to create the post-process:
  125056. * var mb = new BABYLON.MotionBlurPostProcess(
  125057. * 'mb', // The name of the effect.
  125058. * scene, // The scene containing the objects to blur according to their velocity.
  125059. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  125060. * camera // The camera to apply the render pass to.
  125061. * );
  125062. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  125063. */
  125064. export class MotionBlurPostProcess extends PostProcess {
  125065. /**
  125066. * Defines how much the image is blurred by the movement. Default value is equal to 1
  125067. */
  125068. motionStrength: number;
  125069. /**
  125070. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  125071. */
  125072. /**
  125073. * Sets the number of iterations to be used for motion blur quality
  125074. */
  125075. motionBlurSamples: number;
  125076. private _motionBlurSamples;
  125077. private _geometryBufferRenderer;
  125078. /**
  125079. * Creates a new instance MotionBlurPostProcess
  125080. * @param name The name of the effect.
  125081. * @param scene The scene containing the objects to blur according to their velocity.
  125082. * @param options The required width/height ratio to downsize to before computing the render pass.
  125083. * @param camera The camera to apply the render pass to.
  125084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125085. * @param engine The engine which the post process will be applied. (default: current engine)
  125086. * @param reusable If the post process can be reused on the same frame. (default: false)
  125087. * @param textureType Type of textures used when performing the post process. (default: 0)
  125088. * @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)
  125089. */
  125090. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125091. /**
  125092. * Excludes the given skinned mesh from computing bones velocities.
  125093. * 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.
  125094. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  125095. */
  125096. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  125097. /**
  125098. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  125099. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  125100. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  125101. */
  125102. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  125103. /**
  125104. * Disposes the post process.
  125105. * @param camera The camera to dispose the post process on.
  125106. */
  125107. dispose(camera?: Camera): void;
  125108. }
  125109. }
  125110. declare module BABYLON {
  125111. /** @hidden */
  125112. export var refractionPixelShader: {
  125113. name: string;
  125114. shader: string;
  125115. };
  125116. }
  125117. declare module BABYLON {
  125118. /**
  125119. * Post process which applies a refractin texture
  125120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125121. */
  125122. export class RefractionPostProcess extends PostProcess {
  125123. /** the base color of the refraction (used to taint the rendering) */
  125124. color: Color3;
  125125. /** simulated refraction depth */
  125126. depth: number;
  125127. /** the coefficient of the base color (0 to remove base color tainting) */
  125128. colorLevel: number;
  125129. private _refTexture;
  125130. private _ownRefractionTexture;
  125131. /**
  125132. * Gets or sets the refraction texture
  125133. * Please note that you are responsible for disposing the texture if you set it manually
  125134. */
  125135. refractionTexture: Texture;
  125136. /**
  125137. * Initializes the RefractionPostProcess
  125138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125139. * @param name The name of the effect.
  125140. * @param refractionTextureUrl Url of the refraction texture to use
  125141. * @param color the base color of the refraction (used to taint the rendering)
  125142. * @param depth simulated refraction depth
  125143. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  125144. * @param camera The camera to apply the render pass to.
  125145. * @param options The required width/height ratio to downsize to before computing the render pass.
  125146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125147. * @param engine The engine which the post process will be applied. (default: current engine)
  125148. * @param reusable If the post process can be reused on the same frame. (default: false)
  125149. */
  125150. constructor(name: string, refractionTextureUrl: string,
  125151. /** the base color of the refraction (used to taint the rendering) */
  125152. color: Color3,
  125153. /** simulated refraction depth */
  125154. depth: number,
  125155. /** the coefficient of the base color (0 to remove base color tainting) */
  125156. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125157. /**
  125158. * Disposes of the post process
  125159. * @param camera Camera to dispose post process on
  125160. */
  125161. dispose(camera: Camera): void;
  125162. }
  125163. }
  125164. declare module BABYLON {
  125165. /** @hidden */
  125166. export var sharpenPixelShader: {
  125167. name: string;
  125168. shader: string;
  125169. };
  125170. }
  125171. declare module BABYLON {
  125172. /**
  125173. * The SharpenPostProcess applies a sharpen kernel to every pixel
  125174. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125175. */
  125176. export class SharpenPostProcess extends PostProcess {
  125177. /**
  125178. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  125179. */
  125180. colorAmount: number;
  125181. /**
  125182. * How much sharpness should be applied (default: 0.3)
  125183. */
  125184. edgeAmount: number;
  125185. /**
  125186. * Creates a new instance ConvolutionPostProcess
  125187. * @param name The name of the effect.
  125188. * @param options The required width/height ratio to downsize to before computing the render pass.
  125189. * @param camera The camera to apply the render pass to.
  125190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125191. * @param engine The engine which the post process will be applied. (default: current engine)
  125192. * @param reusable If the post process can be reused on the same frame. (default: false)
  125193. * @param textureType Type of textures used when performing the post process. (default: 0)
  125194. * @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)
  125195. */
  125196. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125197. }
  125198. }
  125199. declare module BABYLON {
  125200. /**
  125201. * PostProcessRenderPipeline
  125202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125203. */
  125204. export class PostProcessRenderPipeline {
  125205. private engine;
  125206. private _renderEffects;
  125207. private _renderEffectsForIsolatedPass;
  125208. /**
  125209. * List of inspectable custom properties (used by the Inspector)
  125210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  125211. */
  125212. inspectableCustomProperties: IInspectable[];
  125213. /**
  125214. * @hidden
  125215. */
  125216. protected _cameras: Camera[];
  125217. /** @hidden */
  125218. _name: string;
  125219. /**
  125220. * Gets pipeline name
  125221. */
  125222. readonly name: string;
  125223. /**
  125224. * Initializes a PostProcessRenderPipeline
  125225. * @param engine engine to add the pipeline to
  125226. * @param name name of the pipeline
  125227. */
  125228. constructor(engine: Engine, name: string);
  125229. /**
  125230. * Gets the class name
  125231. * @returns "PostProcessRenderPipeline"
  125232. */
  125233. getClassName(): string;
  125234. /**
  125235. * If all the render effects in the pipeline are supported
  125236. */
  125237. readonly isSupported: boolean;
  125238. /**
  125239. * Adds an effect to the pipeline
  125240. * @param renderEffect the effect to add
  125241. */
  125242. addEffect(renderEffect: PostProcessRenderEffect): void;
  125243. /** @hidden */
  125244. _rebuild(): void;
  125245. /** @hidden */
  125246. _enableEffect(renderEffectName: string, cameras: Camera): void;
  125247. /** @hidden */
  125248. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  125249. /** @hidden */
  125250. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  125251. /** @hidden */
  125252. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  125253. /** @hidden */
  125254. _attachCameras(cameras: Camera, unique: boolean): void;
  125255. /** @hidden */
  125256. _attachCameras(cameras: Camera[], unique: boolean): void;
  125257. /** @hidden */
  125258. _detachCameras(cameras: Camera): void;
  125259. /** @hidden */
  125260. _detachCameras(cameras: Nullable<Camera[]>): void;
  125261. /** @hidden */
  125262. _update(): void;
  125263. /** @hidden */
  125264. _reset(): void;
  125265. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  125266. /**
  125267. * Disposes of the pipeline
  125268. */
  125269. dispose(): void;
  125270. }
  125271. }
  125272. declare module BABYLON {
  125273. /**
  125274. * PostProcessRenderPipelineManager class
  125275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125276. */
  125277. export class PostProcessRenderPipelineManager {
  125278. private _renderPipelines;
  125279. /**
  125280. * Initializes a PostProcessRenderPipelineManager
  125281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125282. */
  125283. constructor();
  125284. /**
  125285. * Gets the list of supported render pipelines
  125286. */
  125287. readonly supportedPipelines: PostProcessRenderPipeline[];
  125288. /**
  125289. * Adds a pipeline to the manager
  125290. * @param renderPipeline The pipeline to add
  125291. */
  125292. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  125293. /**
  125294. * Attaches a camera to the pipeline
  125295. * @param renderPipelineName The name of the pipeline to attach to
  125296. * @param cameras the camera to attach
  125297. * @param unique if the camera can be attached multiple times to the pipeline
  125298. */
  125299. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  125300. /**
  125301. * Detaches a camera from the pipeline
  125302. * @param renderPipelineName The name of the pipeline to detach from
  125303. * @param cameras the camera to detach
  125304. */
  125305. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  125306. /**
  125307. * Enables an effect by name on a pipeline
  125308. * @param renderPipelineName the name of the pipeline to enable the effect in
  125309. * @param renderEffectName the name of the effect to enable
  125310. * @param cameras the cameras that the effect should be enabled on
  125311. */
  125312. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125313. /**
  125314. * Disables an effect by name on a pipeline
  125315. * @param renderPipelineName the name of the pipeline to disable the effect in
  125316. * @param renderEffectName the name of the effect to disable
  125317. * @param cameras the cameras that the effect should be disabled on
  125318. */
  125319. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125320. /**
  125321. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  125322. */
  125323. update(): void;
  125324. /** @hidden */
  125325. _rebuild(): void;
  125326. /**
  125327. * Disposes of the manager and pipelines
  125328. */
  125329. dispose(): void;
  125330. }
  125331. }
  125332. declare module BABYLON {
  125333. interface Scene {
  125334. /** @hidden (Backing field) */
  125335. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125336. /**
  125337. * Gets the postprocess render pipeline manager
  125338. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125339. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125340. */
  125341. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125342. }
  125343. /**
  125344. * Defines the Render Pipeline scene component responsible to rendering pipelines
  125345. */
  125346. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  125347. /**
  125348. * The component name helpfull to identify the component in the list of scene components.
  125349. */
  125350. readonly name: string;
  125351. /**
  125352. * The scene the component belongs to.
  125353. */
  125354. scene: Scene;
  125355. /**
  125356. * Creates a new instance of the component for the given scene
  125357. * @param scene Defines the scene to register the component in
  125358. */
  125359. constructor(scene: Scene);
  125360. /**
  125361. * Registers the component in a given scene
  125362. */
  125363. register(): void;
  125364. /**
  125365. * Rebuilds the elements related to this component in case of
  125366. * context lost for instance.
  125367. */
  125368. rebuild(): void;
  125369. /**
  125370. * Disposes the component and the associated ressources
  125371. */
  125372. dispose(): void;
  125373. private _gatherRenderTargets;
  125374. }
  125375. }
  125376. declare module BABYLON {
  125377. /**
  125378. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  125379. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125380. */
  125381. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125382. private _scene;
  125383. private _camerasToBeAttached;
  125384. /**
  125385. * ID of the sharpen post process,
  125386. */
  125387. private readonly SharpenPostProcessId;
  125388. /**
  125389. * @ignore
  125390. * ID of the image processing post process;
  125391. */
  125392. readonly ImageProcessingPostProcessId: string;
  125393. /**
  125394. * @ignore
  125395. * ID of the Fast Approximate Anti-Aliasing post process;
  125396. */
  125397. readonly FxaaPostProcessId: string;
  125398. /**
  125399. * ID of the chromatic aberration post process,
  125400. */
  125401. private readonly ChromaticAberrationPostProcessId;
  125402. /**
  125403. * ID of the grain post process
  125404. */
  125405. private readonly GrainPostProcessId;
  125406. /**
  125407. * Sharpen post process which will apply a sharpen convolution to enhance edges
  125408. */
  125409. sharpen: SharpenPostProcess;
  125410. private _sharpenEffect;
  125411. private bloom;
  125412. /**
  125413. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  125414. */
  125415. depthOfField: DepthOfFieldEffect;
  125416. /**
  125417. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125418. */
  125419. fxaa: FxaaPostProcess;
  125420. /**
  125421. * Image post processing pass used to perform operations such as tone mapping or color grading.
  125422. */
  125423. imageProcessing: ImageProcessingPostProcess;
  125424. /**
  125425. * Chromatic aberration post process which will shift rgb colors in the image
  125426. */
  125427. chromaticAberration: ChromaticAberrationPostProcess;
  125428. private _chromaticAberrationEffect;
  125429. /**
  125430. * Grain post process which add noise to the image
  125431. */
  125432. grain: GrainPostProcess;
  125433. private _grainEffect;
  125434. /**
  125435. * Glow post process which adds a glow to emissive areas of the image
  125436. */
  125437. private _glowLayer;
  125438. /**
  125439. * Animations which can be used to tweak settings over a period of time
  125440. */
  125441. animations: Animation[];
  125442. private _imageProcessingConfigurationObserver;
  125443. private _sharpenEnabled;
  125444. private _bloomEnabled;
  125445. private _depthOfFieldEnabled;
  125446. private _depthOfFieldBlurLevel;
  125447. private _fxaaEnabled;
  125448. private _imageProcessingEnabled;
  125449. private _defaultPipelineTextureType;
  125450. private _bloomScale;
  125451. private _chromaticAberrationEnabled;
  125452. private _grainEnabled;
  125453. private _buildAllowed;
  125454. /**
  125455. * Gets active scene
  125456. */
  125457. readonly scene: Scene;
  125458. /**
  125459. * Enable or disable the sharpen process from the pipeline
  125460. */
  125461. sharpenEnabled: boolean;
  125462. private _resizeObserver;
  125463. private _hardwareScaleLevel;
  125464. private _bloomKernel;
  125465. /**
  125466. * Specifies the size of the bloom blur kernel, relative to the final output size
  125467. */
  125468. bloomKernel: number;
  125469. /**
  125470. * Specifies the weight of the bloom in the final rendering
  125471. */
  125472. private _bloomWeight;
  125473. /**
  125474. * Specifies the luma threshold for the area that will be blurred by the bloom
  125475. */
  125476. private _bloomThreshold;
  125477. private _hdr;
  125478. /**
  125479. * The strength of the bloom.
  125480. */
  125481. bloomWeight: number;
  125482. /**
  125483. * The strength of the bloom.
  125484. */
  125485. bloomThreshold: number;
  125486. /**
  125487. * The scale of the bloom, lower value will provide better performance.
  125488. */
  125489. bloomScale: number;
  125490. /**
  125491. * Enable or disable the bloom from the pipeline
  125492. */
  125493. bloomEnabled: boolean;
  125494. private _rebuildBloom;
  125495. /**
  125496. * If the depth of field is enabled.
  125497. */
  125498. depthOfFieldEnabled: boolean;
  125499. /**
  125500. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125501. */
  125502. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125503. /**
  125504. * If the anti aliasing is enabled.
  125505. */
  125506. fxaaEnabled: boolean;
  125507. private _samples;
  125508. /**
  125509. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125510. */
  125511. samples: number;
  125512. /**
  125513. * If image processing is enabled.
  125514. */
  125515. imageProcessingEnabled: boolean;
  125516. /**
  125517. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125518. */
  125519. glowLayerEnabled: boolean;
  125520. /**
  125521. * Gets the glow layer (or null if not defined)
  125522. */
  125523. readonly glowLayer: Nullable<GlowLayer>;
  125524. /**
  125525. * Enable or disable the chromaticAberration process from the pipeline
  125526. */
  125527. chromaticAberrationEnabled: boolean;
  125528. /**
  125529. * Enable or disable the grain process from the pipeline
  125530. */
  125531. grainEnabled: boolean;
  125532. /**
  125533. * @constructor
  125534. * @param name - The rendering pipeline name (default: "")
  125535. * @param hdr - If high dynamic range textures should be used (default: true)
  125536. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125537. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125538. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125539. */
  125540. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125541. /**
  125542. * Get the class name
  125543. * @returns "DefaultRenderingPipeline"
  125544. */
  125545. getClassName(): string;
  125546. /**
  125547. * Force the compilation of the entire pipeline.
  125548. */
  125549. prepare(): void;
  125550. private _hasCleared;
  125551. private _prevPostProcess;
  125552. private _prevPrevPostProcess;
  125553. private _setAutoClearAndTextureSharing;
  125554. private _depthOfFieldSceneObserver;
  125555. private _buildPipeline;
  125556. private _disposePostProcesses;
  125557. /**
  125558. * Adds a camera to the pipeline
  125559. * @param camera the camera to be added
  125560. */
  125561. addCamera(camera: Camera): void;
  125562. /**
  125563. * Removes a camera from the pipeline
  125564. * @param camera the camera to remove
  125565. */
  125566. removeCamera(camera: Camera): void;
  125567. /**
  125568. * Dispose of the pipeline and stop all post processes
  125569. */
  125570. dispose(): void;
  125571. /**
  125572. * Serialize the rendering pipeline (Used when exporting)
  125573. * @returns the serialized object
  125574. */
  125575. serialize(): any;
  125576. /**
  125577. * Parse the serialized pipeline
  125578. * @param source Source pipeline.
  125579. * @param scene The scene to load the pipeline to.
  125580. * @param rootUrl The URL of the serialized pipeline.
  125581. * @returns An instantiated pipeline from the serialized object.
  125582. */
  125583. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125584. }
  125585. }
  125586. declare module BABYLON {
  125587. /** @hidden */
  125588. export var lensHighlightsPixelShader: {
  125589. name: string;
  125590. shader: string;
  125591. };
  125592. }
  125593. declare module BABYLON {
  125594. /** @hidden */
  125595. export var depthOfFieldPixelShader: {
  125596. name: string;
  125597. shader: string;
  125598. };
  125599. }
  125600. declare module BABYLON {
  125601. /**
  125602. * BABYLON.JS Chromatic Aberration GLSL Shader
  125603. * Author: Olivier Guyot
  125604. * Separates very slightly R, G and B colors on the edges of the screen
  125605. * Inspired by Francois Tarlier & Martins Upitis
  125606. */
  125607. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125608. /**
  125609. * @ignore
  125610. * The chromatic aberration PostProcess id in the pipeline
  125611. */
  125612. LensChromaticAberrationEffect: string;
  125613. /**
  125614. * @ignore
  125615. * The highlights enhancing PostProcess id in the pipeline
  125616. */
  125617. HighlightsEnhancingEffect: string;
  125618. /**
  125619. * @ignore
  125620. * The depth-of-field PostProcess id in the pipeline
  125621. */
  125622. LensDepthOfFieldEffect: string;
  125623. private _scene;
  125624. private _depthTexture;
  125625. private _grainTexture;
  125626. private _chromaticAberrationPostProcess;
  125627. private _highlightsPostProcess;
  125628. private _depthOfFieldPostProcess;
  125629. private _edgeBlur;
  125630. private _grainAmount;
  125631. private _chromaticAberration;
  125632. private _distortion;
  125633. private _highlightsGain;
  125634. private _highlightsThreshold;
  125635. private _dofDistance;
  125636. private _dofAperture;
  125637. private _dofDarken;
  125638. private _dofPentagon;
  125639. private _blurNoise;
  125640. /**
  125641. * @constructor
  125642. *
  125643. * Effect parameters are as follow:
  125644. * {
  125645. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125646. * edge_blur: number; // from 0 to x (1 for realism)
  125647. * distortion: number; // from 0 to x (1 for realism)
  125648. * grain_amount: number; // from 0 to 1
  125649. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125650. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125651. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125652. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125653. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125654. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125655. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125656. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125657. * }
  125658. * Note: if an effect parameter is unset, effect is disabled
  125659. *
  125660. * @param name The rendering pipeline name
  125661. * @param parameters - An object containing all parameters (see above)
  125662. * @param scene The scene linked to this pipeline
  125663. * @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)
  125664. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125665. */
  125666. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125667. /**
  125668. * Get the class name
  125669. * @returns "LensRenderingPipeline"
  125670. */
  125671. getClassName(): string;
  125672. /**
  125673. * Gets associated scene
  125674. */
  125675. readonly scene: Scene;
  125676. /**
  125677. * Gets or sets the edge blur
  125678. */
  125679. edgeBlur: number;
  125680. /**
  125681. * Gets or sets the grain amount
  125682. */
  125683. grainAmount: number;
  125684. /**
  125685. * Gets or sets the chromatic aberration amount
  125686. */
  125687. chromaticAberration: number;
  125688. /**
  125689. * Gets or sets the depth of field aperture
  125690. */
  125691. dofAperture: number;
  125692. /**
  125693. * Gets or sets the edge distortion
  125694. */
  125695. edgeDistortion: number;
  125696. /**
  125697. * Gets or sets the depth of field distortion
  125698. */
  125699. dofDistortion: number;
  125700. /**
  125701. * Gets or sets the darken out of focus amount
  125702. */
  125703. darkenOutOfFocus: number;
  125704. /**
  125705. * Gets or sets a boolean indicating if blur noise is enabled
  125706. */
  125707. blurNoise: boolean;
  125708. /**
  125709. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125710. */
  125711. pentagonBokeh: boolean;
  125712. /**
  125713. * Gets or sets the highlight grain amount
  125714. */
  125715. highlightsGain: number;
  125716. /**
  125717. * Gets or sets the highlight threshold
  125718. */
  125719. highlightsThreshold: number;
  125720. /**
  125721. * Sets the amount of blur at the edges
  125722. * @param amount blur amount
  125723. */
  125724. setEdgeBlur(amount: number): void;
  125725. /**
  125726. * Sets edge blur to 0
  125727. */
  125728. disableEdgeBlur(): void;
  125729. /**
  125730. * Sets the amout of grain
  125731. * @param amount Amount of grain
  125732. */
  125733. setGrainAmount(amount: number): void;
  125734. /**
  125735. * Set grain amount to 0
  125736. */
  125737. disableGrain(): void;
  125738. /**
  125739. * Sets the chromatic aberration amount
  125740. * @param amount amount of chromatic aberration
  125741. */
  125742. setChromaticAberration(amount: number): void;
  125743. /**
  125744. * Sets chromatic aberration amount to 0
  125745. */
  125746. disableChromaticAberration(): void;
  125747. /**
  125748. * Sets the EdgeDistortion amount
  125749. * @param amount amount of EdgeDistortion
  125750. */
  125751. setEdgeDistortion(amount: number): void;
  125752. /**
  125753. * Sets edge distortion to 0
  125754. */
  125755. disableEdgeDistortion(): void;
  125756. /**
  125757. * Sets the FocusDistance amount
  125758. * @param amount amount of FocusDistance
  125759. */
  125760. setFocusDistance(amount: number): void;
  125761. /**
  125762. * Disables depth of field
  125763. */
  125764. disableDepthOfField(): void;
  125765. /**
  125766. * Sets the Aperture amount
  125767. * @param amount amount of Aperture
  125768. */
  125769. setAperture(amount: number): void;
  125770. /**
  125771. * Sets the DarkenOutOfFocus amount
  125772. * @param amount amount of DarkenOutOfFocus
  125773. */
  125774. setDarkenOutOfFocus(amount: number): void;
  125775. private _pentagonBokehIsEnabled;
  125776. /**
  125777. * Creates a pentagon bokeh effect
  125778. */
  125779. enablePentagonBokeh(): void;
  125780. /**
  125781. * Disables the pentagon bokeh effect
  125782. */
  125783. disablePentagonBokeh(): void;
  125784. /**
  125785. * Enables noise blur
  125786. */
  125787. enableNoiseBlur(): void;
  125788. /**
  125789. * Disables noise blur
  125790. */
  125791. disableNoiseBlur(): void;
  125792. /**
  125793. * Sets the HighlightsGain amount
  125794. * @param amount amount of HighlightsGain
  125795. */
  125796. setHighlightsGain(amount: number): void;
  125797. /**
  125798. * Sets the HighlightsThreshold amount
  125799. * @param amount amount of HighlightsThreshold
  125800. */
  125801. setHighlightsThreshold(amount: number): void;
  125802. /**
  125803. * Disables highlights
  125804. */
  125805. disableHighlights(): void;
  125806. /**
  125807. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125808. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125809. */
  125810. dispose(disableDepthRender?: boolean): void;
  125811. private _createChromaticAberrationPostProcess;
  125812. private _createHighlightsPostProcess;
  125813. private _createDepthOfFieldPostProcess;
  125814. private _createGrainTexture;
  125815. }
  125816. }
  125817. declare module BABYLON {
  125818. /** @hidden */
  125819. export var ssao2PixelShader: {
  125820. name: string;
  125821. shader: string;
  125822. };
  125823. }
  125824. declare module BABYLON {
  125825. /** @hidden */
  125826. export var ssaoCombinePixelShader: {
  125827. name: string;
  125828. shader: string;
  125829. };
  125830. }
  125831. declare module BABYLON {
  125832. /**
  125833. * Render pipeline to produce ssao effect
  125834. */
  125835. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125836. /**
  125837. * @ignore
  125838. * The PassPostProcess id in the pipeline that contains the original scene color
  125839. */
  125840. SSAOOriginalSceneColorEffect: string;
  125841. /**
  125842. * @ignore
  125843. * The SSAO PostProcess id in the pipeline
  125844. */
  125845. SSAORenderEffect: string;
  125846. /**
  125847. * @ignore
  125848. * The horizontal blur PostProcess id in the pipeline
  125849. */
  125850. SSAOBlurHRenderEffect: string;
  125851. /**
  125852. * @ignore
  125853. * The vertical blur PostProcess id in the pipeline
  125854. */
  125855. SSAOBlurVRenderEffect: string;
  125856. /**
  125857. * @ignore
  125858. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125859. */
  125860. SSAOCombineRenderEffect: string;
  125861. /**
  125862. * The output strength of the SSAO post-process. Default value is 1.0.
  125863. */
  125864. totalStrength: number;
  125865. /**
  125866. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125867. */
  125868. maxZ: number;
  125869. /**
  125870. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125871. */
  125872. minZAspect: number;
  125873. private _samples;
  125874. /**
  125875. * Number of samples used for the SSAO calculations. Default value is 8
  125876. */
  125877. samples: number;
  125878. private _textureSamples;
  125879. /**
  125880. * Number of samples to use for antialiasing
  125881. */
  125882. textureSamples: number;
  125883. /**
  125884. * Ratio object used for SSAO ratio and blur ratio
  125885. */
  125886. private _ratio;
  125887. /**
  125888. * Dynamically generated sphere sampler.
  125889. */
  125890. private _sampleSphere;
  125891. /**
  125892. * Blur filter offsets
  125893. */
  125894. private _samplerOffsets;
  125895. private _expensiveBlur;
  125896. /**
  125897. * If bilateral blur should be used
  125898. */
  125899. expensiveBlur: boolean;
  125900. /**
  125901. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125902. */
  125903. radius: number;
  125904. /**
  125905. * The base color of the SSAO post-process
  125906. * The final result is "base + ssao" between [0, 1]
  125907. */
  125908. base: number;
  125909. /**
  125910. * Support test.
  125911. */
  125912. static readonly IsSupported: boolean;
  125913. private _scene;
  125914. private _depthTexture;
  125915. private _normalTexture;
  125916. private _randomTexture;
  125917. private _originalColorPostProcess;
  125918. private _ssaoPostProcess;
  125919. private _blurHPostProcess;
  125920. private _blurVPostProcess;
  125921. private _ssaoCombinePostProcess;
  125922. private _firstUpdate;
  125923. /**
  125924. * Gets active scene
  125925. */
  125926. readonly scene: Scene;
  125927. /**
  125928. * @constructor
  125929. * @param name The rendering pipeline name
  125930. * @param scene The scene linked to this pipeline
  125931. * @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 }
  125932. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125933. */
  125934. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125935. /**
  125936. * Get the class name
  125937. * @returns "SSAO2RenderingPipeline"
  125938. */
  125939. getClassName(): string;
  125940. /**
  125941. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125942. */
  125943. dispose(disableGeometryBufferRenderer?: boolean): void;
  125944. private _createBlurPostProcess;
  125945. /** @hidden */
  125946. _rebuild(): void;
  125947. private _bits;
  125948. private _radicalInverse_VdC;
  125949. private _hammersley;
  125950. private _hemisphereSample_uniform;
  125951. private _generateHemisphere;
  125952. private _createSSAOPostProcess;
  125953. private _createSSAOCombinePostProcess;
  125954. private _createRandomTexture;
  125955. /**
  125956. * Serialize the rendering pipeline (Used when exporting)
  125957. * @returns the serialized object
  125958. */
  125959. serialize(): any;
  125960. /**
  125961. * Parse the serialized pipeline
  125962. * @param source Source pipeline.
  125963. * @param scene The scene to load the pipeline to.
  125964. * @param rootUrl The URL of the serialized pipeline.
  125965. * @returns An instantiated pipeline from the serialized object.
  125966. */
  125967. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125968. }
  125969. }
  125970. declare module BABYLON {
  125971. /** @hidden */
  125972. export var ssaoPixelShader: {
  125973. name: string;
  125974. shader: string;
  125975. };
  125976. }
  125977. declare module BABYLON {
  125978. /**
  125979. * Render pipeline to produce ssao effect
  125980. */
  125981. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125982. /**
  125983. * @ignore
  125984. * The PassPostProcess id in the pipeline that contains the original scene color
  125985. */
  125986. SSAOOriginalSceneColorEffect: string;
  125987. /**
  125988. * @ignore
  125989. * The SSAO PostProcess id in the pipeline
  125990. */
  125991. SSAORenderEffect: string;
  125992. /**
  125993. * @ignore
  125994. * The horizontal blur PostProcess id in the pipeline
  125995. */
  125996. SSAOBlurHRenderEffect: string;
  125997. /**
  125998. * @ignore
  125999. * The vertical blur PostProcess id in the pipeline
  126000. */
  126001. SSAOBlurVRenderEffect: string;
  126002. /**
  126003. * @ignore
  126004. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  126005. */
  126006. SSAOCombineRenderEffect: string;
  126007. /**
  126008. * The output strength of the SSAO post-process. Default value is 1.0.
  126009. */
  126010. totalStrength: number;
  126011. /**
  126012. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  126013. */
  126014. radius: number;
  126015. /**
  126016. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  126017. * Must not be equal to fallOff and superior to fallOff.
  126018. * Default value is 0.0075
  126019. */
  126020. area: number;
  126021. /**
  126022. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  126023. * Must not be equal to area and inferior to area.
  126024. * Default value is 0.000001
  126025. */
  126026. fallOff: number;
  126027. /**
  126028. * The base color of the SSAO post-process
  126029. * The final result is "base + ssao" between [0, 1]
  126030. */
  126031. base: number;
  126032. private _scene;
  126033. private _depthTexture;
  126034. private _randomTexture;
  126035. private _originalColorPostProcess;
  126036. private _ssaoPostProcess;
  126037. private _blurHPostProcess;
  126038. private _blurVPostProcess;
  126039. private _ssaoCombinePostProcess;
  126040. private _firstUpdate;
  126041. /**
  126042. * Gets active scene
  126043. */
  126044. readonly scene: Scene;
  126045. /**
  126046. * @constructor
  126047. * @param name - The rendering pipeline name
  126048. * @param scene - The scene linked to this pipeline
  126049. * @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 }
  126050. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  126051. */
  126052. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  126053. /**
  126054. * Get the class name
  126055. * @returns "SSAORenderingPipeline"
  126056. */
  126057. getClassName(): string;
  126058. /**
  126059. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  126060. */
  126061. dispose(disableDepthRender?: boolean): void;
  126062. private _createBlurPostProcess;
  126063. /** @hidden */
  126064. _rebuild(): void;
  126065. private _createSSAOPostProcess;
  126066. private _createSSAOCombinePostProcess;
  126067. private _createRandomTexture;
  126068. }
  126069. }
  126070. declare module BABYLON {
  126071. /** @hidden */
  126072. export var standardPixelShader: {
  126073. name: string;
  126074. shader: string;
  126075. };
  126076. }
  126077. declare module BABYLON {
  126078. /**
  126079. * Standard rendering pipeline
  126080. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  126081. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  126082. */
  126083. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126084. /**
  126085. * Public members
  126086. */
  126087. /**
  126088. * Post-process which contains the original scene color before the pipeline applies all the effects
  126089. */
  126090. originalPostProcess: Nullable<PostProcess>;
  126091. /**
  126092. * Post-process used to down scale an image x4
  126093. */
  126094. downSampleX4PostProcess: Nullable<PostProcess>;
  126095. /**
  126096. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  126097. */
  126098. brightPassPostProcess: Nullable<PostProcess>;
  126099. /**
  126100. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  126101. */
  126102. blurHPostProcesses: PostProcess[];
  126103. /**
  126104. * Post-process array storing all the vertical blur post-processes used by the pipeline
  126105. */
  126106. blurVPostProcesses: PostProcess[];
  126107. /**
  126108. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  126109. */
  126110. textureAdderPostProcess: Nullable<PostProcess>;
  126111. /**
  126112. * Post-process used to create volumetric lighting effect
  126113. */
  126114. volumetricLightPostProcess: Nullable<PostProcess>;
  126115. /**
  126116. * Post-process used to smooth the previous volumetric light post-process on the X axis
  126117. */
  126118. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  126119. /**
  126120. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  126121. */
  126122. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  126123. /**
  126124. * Post-process used to merge the volumetric light effect and the real scene color
  126125. */
  126126. volumetricLightMergePostProces: Nullable<PostProcess>;
  126127. /**
  126128. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  126129. */
  126130. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  126131. /**
  126132. * Base post-process used to calculate the average luminance of the final image for HDR
  126133. */
  126134. luminancePostProcess: Nullable<PostProcess>;
  126135. /**
  126136. * Post-processes used to create down sample post-processes in order to get
  126137. * the average luminance of the final image for HDR
  126138. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  126139. */
  126140. luminanceDownSamplePostProcesses: PostProcess[];
  126141. /**
  126142. * Post-process used to create a HDR effect (light adaptation)
  126143. */
  126144. hdrPostProcess: Nullable<PostProcess>;
  126145. /**
  126146. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  126147. */
  126148. textureAdderFinalPostProcess: Nullable<PostProcess>;
  126149. /**
  126150. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  126151. */
  126152. lensFlareFinalPostProcess: Nullable<PostProcess>;
  126153. /**
  126154. * Post-process used to merge the final HDR post-process and the real scene color
  126155. */
  126156. hdrFinalPostProcess: Nullable<PostProcess>;
  126157. /**
  126158. * Post-process used to create a lens flare effect
  126159. */
  126160. lensFlarePostProcess: Nullable<PostProcess>;
  126161. /**
  126162. * Post-process that merges the result of the lens flare post-process and the real scene color
  126163. */
  126164. lensFlareComposePostProcess: Nullable<PostProcess>;
  126165. /**
  126166. * Post-process used to create a motion blur effect
  126167. */
  126168. motionBlurPostProcess: Nullable<PostProcess>;
  126169. /**
  126170. * Post-process used to create a depth of field effect
  126171. */
  126172. depthOfFieldPostProcess: Nullable<PostProcess>;
  126173. /**
  126174. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126175. */
  126176. fxaaPostProcess: Nullable<FxaaPostProcess>;
  126177. /**
  126178. * Represents the brightness threshold in order to configure the illuminated surfaces
  126179. */
  126180. brightThreshold: number;
  126181. /**
  126182. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  126183. */
  126184. blurWidth: number;
  126185. /**
  126186. * Sets if the blur for highlighted surfaces must be only horizontal
  126187. */
  126188. horizontalBlur: boolean;
  126189. /**
  126190. * Gets the overall exposure used by the pipeline
  126191. */
  126192. /**
  126193. * Sets the overall exposure used by the pipeline
  126194. */
  126195. exposure: number;
  126196. /**
  126197. * Texture used typically to simulate "dirty" on camera lens
  126198. */
  126199. lensTexture: Nullable<Texture>;
  126200. /**
  126201. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  126202. */
  126203. volumetricLightCoefficient: number;
  126204. /**
  126205. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  126206. */
  126207. volumetricLightPower: number;
  126208. /**
  126209. * Used the set the blur intensity to smooth the volumetric lights
  126210. */
  126211. volumetricLightBlurScale: number;
  126212. /**
  126213. * Light (spot or directional) used to generate the volumetric lights rays
  126214. * The source light must have a shadow generate so the pipeline can get its
  126215. * depth map
  126216. */
  126217. sourceLight: Nullable<SpotLight | DirectionalLight>;
  126218. /**
  126219. * For eye adaptation, represents the minimum luminance the eye can see
  126220. */
  126221. hdrMinimumLuminance: number;
  126222. /**
  126223. * For eye adaptation, represents the decrease luminance speed
  126224. */
  126225. hdrDecreaseRate: number;
  126226. /**
  126227. * For eye adaptation, represents the increase luminance speed
  126228. */
  126229. hdrIncreaseRate: number;
  126230. /**
  126231. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  126232. */
  126233. /**
  126234. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  126235. */
  126236. hdrAutoExposure: boolean;
  126237. /**
  126238. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  126239. */
  126240. lensColorTexture: Nullable<Texture>;
  126241. /**
  126242. * The overall strengh for the lens flare effect
  126243. */
  126244. lensFlareStrength: number;
  126245. /**
  126246. * Dispersion coefficient for lens flare ghosts
  126247. */
  126248. lensFlareGhostDispersal: number;
  126249. /**
  126250. * Main lens flare halo width
  126251. */
  126252. lensFlareHaloWidth: number;
  126253. /**
  126254. * Based on the lens distortion effect, defines how much the lens flare result
  126255. * is distorted
  126256. */
  126257. lensFlareDistortionStrength: number;
  126258. /**
  126259. * Configures the blur intensity used for for lens flare (halo)
  126260. */
  126261. lensFlareBlurWidth: number;
  126262. /**
  126263. * Lens star texture must be used to simulate rays on the flares and is available
  126264. * in the documentation
  126265. */
  126266. lensStarTexture: Nullable<Texture>;
  126267. /**
  126268. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  126269. * flare effect by taking account of the dirt texture
  126270. */
  126271. lensFlareDirtTexture: Nullable<Texture>;
  126272. /**
  126273. * Represents the focal length for the depth of field effect
  126274. */
  126275. depthOfFieldDistance: number;
  126276. /**
  126277. * Represents the blur intensity for the blurred part of the depth of field effect
  126278. */
  126279. depthOfFieldBlurWidth: number;
  126280. /**
  126281. * Gets how much the image is blurred by the movement while using the motion blur post-process
  126282. */
  126283. /**
  126284. * Sets how much the image is blurred by the movement while using the motion blur post-process
  126285. */
  126286. motionStrength: number;
  126287. /**
  126288. * Gets wether or not the motion blur post-process is object based or screen based.
  126289. */
  126290. /**
  126291. * Sets wether or not the motion blur post-process should be object based or screen based
  126292. */
  126293. objectBasedMotionBlur: boolean;
  126294. /**
  126295. * List of animations for the pipeline (IAnimatable implementation)
  126296. */
  126297. animations: Animation[];
  126298. /**
  126299. * Private members
  126300. */
  126301. private _scene;
  126302. private _currentDepthOfFieldSource;
  126303. private _basePostProcess;
  126304. private _fixedExposure;
  126305. private _currentExposure;
  126306. private _hdrAutoExposure;
  126307. private _hdrCurrentLuminance;
  126308. private _motionStrength;
  126309. private _isObjectBasedMotionBlur;
  126310. private _floatTextureType;
  126311. private _camerasToBeAttached;
  126312. private _ratio;
  126313. private _bloomEnabled;
  126314. private _depthOfFieldEnabled;
  126315. private _vlsEnabled;
  126316. private _lensFlareEnabled;
  126317. private _hdrEnabled;
  126318. private _motionBlurEnabled;
  126319. private _fxaaEnabled;
  126320. private _motionBlurSamples;
  126321. private _volumetricLightStepsCount;
  126322. private _samples;
  126323. /**
  126324. * @ignore
  126325. * Specifies if the bloom pipeline is enabled
  126326. */
  126327. BloomEnabled: boolean;
  126328. /**
  126329. * @ignore
  126330. * Specifies if the depth of field pipeline is enabed
  126331. */
  126332. DepthOfFieldEnabled: boolean;
  126333. /**
  126334. * @ignore
  126335. * Specifies if the lens flare pipeline is enabed
  126336. */
  126337. LensFlareEnabled: boolean;
  126338. /**
  126339. * @ignore
  126340. * Specifies if the HDR pipeline is enabled
  126341. */
  126342. HDREnabled: boolean;
  126343. /**
  126344. * @ignore
  126345. * Specifies if the volumetric lights scattering effect is enabled
  126346. */
  126347. VLSEnabled: boolean;
  126348. /**
  126349. * @ignore
  126350. * Specifies if the motion blur effect is enabled
  126351. */
  126352. MotionBlurEnabled: boolean;
  126353. /**
  126354. * Specifies if anti-aliasing is enabled
  126355. */
  126356. fxaaEnabled: boolean;
  126357. /**
  126358. * Specifies the number of steps used to calculate the volumetric lights
  126359. * Typically in interval [50, 200]
  126360. */
  126361. volumetricLightStepsCount: number;
  126362. /**
  126363. * Specifies the number of samples used for the motion blur effect
  126364. * Typically in interval [16, 64]
  126365. */
  126366. motionBlurSamples: number;
  126367. /**
  126368. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126369. */
  126370. samples: number;
  126371. /**
  126372. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  126373. * @constructor
  126374. * @param name The rendering pipeline name
  126375. * @param scene The scene linked to this pipeline
  126376. * @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)
  126377. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  126378. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126379. */
  126380. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  126381. private _buildPipeline;
  126382. private _createDownSampleX4PostProcess;
  126383. private _createBrightPassPostProcess;
  126384. private _createBlurPostProcesses;
  126385. private _createTextureAdderPostProcess;
  126386. private _createVolumetricLightPostProcess;
  126387. private _createLuminancePostProcesses;
  126388. private _createHdrPostProcess;
  126389. private _createLensFlarePostProcess;
  126390. private _createDepthOfFieldPostProcess;
  126391. private _createMotionBlurPostProcess;
  126392. private _getDepthTexture;
  126393. private _disposePostProcesses;
  126394. /**
  126395. * Dispose of the pipeline and stop all post processes
  126396. */
  126397. dispose(): void;
  126398. /**
  126399. * Serialize the rendering pipeline (Used when exporting)
  126400. * @returns the serialized object
  126401. */
  126402. serialize(): any;
  126403. /**
  126404. * Parse the serialized pipeline
  126405. * @param source Source pipeline.
  126406. * @param scene The scene to load the pipeline to.
  126407. * @param rootUrl The URL of the serialized pipeline.
  126408. * @returns An instantiated pipeline from the serialized object.
  126409. */
  126410. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  126411. /**
  126412. * Luminance steps
  126413. */
  126414. static LuminanceSteps: number;
  126415. }
  126416. }
  126417. declare module BABYLON {
  126418. /** @hidden */
  126419. export var tonemapPixelShader: {
  126420. name: string;
  126421. shader: string;
  126422. };
  126423. }
  126424. declare module BABYLON {
  126425. /** Defines operator used for tonemapping */
  126426. export enum TonemappingOperator {
  126427. /** Hable */
  126428. Hable = 0,
  126429. /** Reinhard */
  126430. Reinhard = 1,
  126431. /** HejiDawson */
  126432. HejiDawson = 2,
  126433. /** Photographic */
  126434. Photographic = 3
  126435. }
  126436. /**
  126437. * Defines a post process to apply tone mapping
  126438. */
  126439. export class TonemapPostProcess extends PostProcess {
  126440. private _operator;
  126441. /** Defines the required exposure adjustement */
  126442. exposureAdjustment: number;
  126443. /**
  126444. * Creates a new TonemapPostProcess
  126445. * @param name defines the name of the postprocess
  126446. * @param _operator defines the operator to use
  126447. * @param exposureAdjustment defines the required exposure adjustement
  126448. * @param camera defines the camera to use (can be null)
  126449. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  126450. * @param engine defines the hosting engine (can be ignore if camera is set)
  126451. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126452. */
  126453. constructor(name: string, _operator: TonemappingOperator,
  126454. /** Defines the required exposure adjustement */
  126455. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  126456. }
  126457. }
  126458. declare module BABYLON {
  126459. /** @hidden */
  126460. export var depthVertexShader: {
  126461. name: string;
  126462. shader: string;
  126463. };
  126464. }
  126465. declare module BABYLON {
  126466. /** @hidden */
  126467. export var volumetricLightScatteringPixelShader: {
  126468. name: string;
  126469. shader: string;
  126470. };
  126471. }
  126472. declare module BABYLON {
  126473. /** @hidden */
  126474. export var volumetricLightScatteringPassVertexShader: {
  126475. name: string;
  126476. shader: string;
  126477. };
  126478. }
  126479. declare module BABYLON {
  126480. /** @hidden */
  126481. export var volumetricLightScatteringPassPixelShader: {
  126482. name: string;
  126483. shader: string;
  126484. };
  126485. }
  126486. declare module BABYLON {
  126487. /**
  126488. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126489. */
  126490. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126491. private _volumetricLightScatteringPass;
  126492. private _volumetricLightScatteringRTT;
  126493. private _viewPort;
  126494. private _screenCoordinates;
  126495. private _cachedDefines;
  126496. /**
  126497. * If not undefined, the mesh position is computed from the attached node position
  126498. */
  126499. attachedNode: {
  126500. position: Vector3;
  126501. };
  126502. /**
  126503. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126504. */
  126505. customMeshPosition: Vector3;
  126506. /**
  126507. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126508. */
  126509. useCustomMeshPosition: boolean;
  126510. /**
  126511. * If the post-process should inverse the light scattering direction
  126512. */
  126513. invert: boolean;
  126514. /**
  126515. * The internal mesh used by the post-process
  126516. */
  126517. mesh: Mesh;
  126518. /**
  126519. * @hidden
  126520. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126521. */
  126522. useDiffuseColor: boolean;
  126523. /**
  126524. * Array containing the excluded meshes not rendered in the internal pass
  126525. */
  126526. excludedMeshes: AbstractMesh[];
  126527. /**
  126528. * Controls the overall intensity of the post-process
  126529. */
  126530. exposure: number;
  126531. /**
  126532. * Dissipates each sample's contribution in range [0, 1]
  126533. */
  126534. decay: number;
  126535. /**
  126536. * Controls the overall intensity of each sample
  126537. */
  126538. weight: number;
  126539. /**
  126540. * Controls the density of each sample
  126541. */
  126542. density: number;
  126543. /**
  126544. * @constructor
  126545. * @param name The post-process name
  126546. * @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)
  126547. * @param camera The camera that the post-process will be attached to
  126548. * @param mesh The mesh used to create the light scattering
  126549. * @param samples The post-process quality, default 100
  126550. * @param samplingModeThe post-process filtering mode
  126551. * @param engine The babylon engine
  126552. * @param reusable If the post-process is reusable
  126553. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126554. */
  126555. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126556. /**
  126557. * Returns the string "VolumetricLightScatteringPostProcess"
  126558. * @returns "VolumetricLightScatteringPostProcess"
  126559. */
  126560. getClassName(): string;
  126561. private _isReady;
  126562. /**
  126563. * Sets the new light position for light scattering effect
  126564. * @param position The new custom light position
  126565. */
  126566. setCustomMeshPosition(position: Vector3): void;
  126567. /**
  126568. * Returns the light position for light scattering effect
  126569. * @return Vector3 The custom light position
  126570. */
  126571. getCustomMeshPosition(): Vector3;
  126572. /**
  126573. * Disposes the internal assets and detaches the post-process from the camera
  126574. */
  126575. dispose(camera: Camera): void;
  126576. /**
  126577. * Returns the render target texture used by the post-process
  126578. * @return the render target texture used by the post-process
  126579. */
  126580. getPass(): RenderTargetTexture;
  126581. private _meshExcluded;
  126582. private _createPass;
  126583. private _updateMeshScreenCoordinates;
  126584. /**
  126585. * Creates a default mesh for the Volumeric Light Scattering post-process
  126586. * @param name The mesh name
  126587. * @param scene The scene where to create the mesh
  126588. * @return the default mesh
  126589. */
  126590. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126591. }
  126592. }
  126593. declare module BABYLON {
  126594. interface Scene {
  126595. /** @hidden (Backing field) */
  126596. _boundingBoxRenderer: BoundingBoxRenderer;
  126597. /** @hidden (Backing field) */
  126598. _forceShowBoundingBoxes: boolean;
  126599. /**
  126600. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126601. */
  126602. forceShowBoundingBoxes: boolean;
  126603. /**
  126604. * Gets the bounding box renderer associated with the scene
  126605. * @returns a BoundingBoxRenderer
  126606. */
  126607. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126608. }
  126609. interface AbstractMesh {
  126610. /** @hidden (Backing field) */
  126611. _showBoundingBox: boolean;
  126612. /**
  126613. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126614. */
  126615. showBoundingBox: boolean;
  126616. }
  126617. /**
  126618. * Component responsible of rendering the bounding box of the meshes in a scene.
  126619. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126620. */
  126621. export class BoundingBoxRenderer implements ISceneComponent {
  126622. /**
  126623. * The component name helpfull to identify the component in the list of scene components.
  126624. */
  126625. readonly name: string;
  126626. /**
  126627. * The scene the component belongs to.
  126628. */
  126629. scene: Scene;
  126630. /**
  126631. * Color of the bounding box lines placed in front of an object
  126632. */
  126633. frontColor: Color3;
  126634. /**
  126635. * Color of the bounding box lines placed behind an object
  126636. */
  126637. backColor: Color3;
  126638. /**
  126639. * Defines if the renderer should show the back lines or not
  126640. */
  126641. showBackLines: boolean;
  126642. /**
  126643. * @hidden
  126644. */
  126645. renderList: SmartArray<BoundingBox>;
  126646. private _colorShader;
  126647. private _vertexBuffers;
  126648. private _indexBuffer;
  126649. private _fillIndexBuffer;
  126650. private _fillIndexData;
  126651. /**
  126652. * Instantiates a new bounding box renderer in a scene.
  126653. * @param scene the scene the renderer renders in
  126654. */
  126655. constructor(scene: Scene);
  126656. /**
  126657. * Registers the component in a given scene
  126658. */
  126659. register(): void;
  126660. private _evaluateSubMesh;
  126661. private _activeMesh;
  126662. private _prepareRessources;
  126663. private _createIndexBuffer;
  126664. /**
  126665. * Rebuilds the elements related to this component in case of
  126666. * context lost for instance.
  126667. */
  126668. rebuild(): void;
  126669. /**
  126670. * @hidden
  126671. */
  126672. reset(): void;
  126673. /**
  126674. * Render the bounding boxes of a specific rendering group
  126675. * @param renderingGroupId defines the rendering group to render
  126676. */
  126677. render(renderingGroupId: number): void;
  126678. /**
  126679. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126680. * @param mesh Define the mesh to render the occlusion bounding box for
  126681. */
  126682. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126683. /**
  126684. * Dispose and release the resources attached to this renderer.
  126685. */
  126686. dispose(): void;
  126687. }
  126688. }
  126689. declare module BABYLON {
  126690. /** @hidden */
  126691. export var depthPixelShader: {
  126692. name: string;
  126693. shader: string;
  126694. };
  126695. }
  126696. declare module BABYLON {
  126697. /**
  126698. * This represents a depth renderer in Babylon.
  126699. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126700. */
  126701. export class DepthRenderer {
  126702. private _scene;
  126703. private _depthMap;
  126704. private _effect;
  126705. private readonly _storeNonLinearDepth;
  126706. private readonly _clearColor;
  126707. /** Get if the depth renderer is using packed depth or not */
  126708. readonly isPacked: boolean;
  126709. private _cachedDefines;
  126710. private _camera;
  126711. /**
  126712. * Specifiess that the depth renderer will only be used within
  126713. * the camera it is created for.
  126714. * This can help forcing its rendering during the camera processing.
  126715. */
  126716. useOnlyInActiveCamera: boolean;
  126717. /** @hidden */
  126718. static _SceneComponentInitialization: (scene: Scene) => void;
  126719. /**
  126720. * Instantiates a depth renderer
  126721. * @param scene The scene the renderer belongs to
  126722. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126723. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126724. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126725. */
  126726. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126727. /**
  126728. * Creates the depth rendering effect and checks if the effect is ready.
  126729. * @param subMesh The submesh to be used to render the depth map of
  126730. * @param useInstances If multiple world instances should be used
  126731. * @returns if the depth renderer is ready to render the depth map
  126732. */
  126733. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126734. /**
  126735. * Gets the texture which the depth map will be written to.
  126736. * @returns The depth map texture
  126737. */
  126738. getDepthMap(): RenderTargetTexture;
  126739. /**
  126740. * Disposes of the depth renderer.
  126741. */
  126742. dispose(): void;
  126743. }
  126744. }
  126745. declare module BABYLON {
  126746. interface Scene {
  126747. /** @hidden (Backing field) */
  126748. _depthRenderer: {
  126749. [id: string]: DepthRenderer;
  126750. };
  126751. /**
  126752. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126753. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126754. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126755. * @returns the created depth renderer
  126756. */
  126757. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126758. /**
  126759. * Disables a depth renderer for a given camera
  126760. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126761. */
  126762. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126763. }
  126764. /**
  126765. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126766. * in several rendering techniques.
  126767. */
  126768. export class DepthRendererSceneComponent implements ISceneComponent {
  126769. /**
  126770. * The component name helpfull to identify the component in the list of scene components.
  126771. */
  126772. readonly name: string;
  126773. /**
  126774. * The scene the component belongs to.
  126775. */
  126776. scene: Scene;
  126777. /**
  126778. * Creates a new instance of the component for the given scene
  126779. * @param scene Defines the scene to register the component in
  126780. */
  126781. constructor(scene: Scene);
  126782. /**
  126783. * Registers the component in a given scene
  126784. */
  126785. register(): void;
  126786. /**
  126787. * Rebuilds the elements related to this component in case of
  126788. * context lost for instance.
  126789. */
  126790. rebuild(): void;
  126791. /**
  126792. * Disposes the component and the associated ressources
  126793. */
  126794. dispose(): void;
  126795. private _gatherRenderTargets;
  126796. private _gatherActiveCameraRenderTargets;
  126797. }
  126798. }
  126799. declare module BABYLON {
  126800. /** @hidden */
  126801. export var outlinePixelShader: {
  126802. name: string;
  126803. shader: string;
  126804. };
  126805. }
  126806. declare module BABYLON {
  126807. /** @hidden */
  126808. export var outlineVertexShader: {
  126809. name: string;
  126810. shader: string;
  126811. };
  126812. }
  126813. declare module BABYLON {
  126814. interface Scene {
  126815. /** @hidden */
  126816. _outlineRenderer: OutlineRenderer;
  126817. /**
  126818. * Gets the outline renderer associated with the scene
  126819. * @returns a OutlineRenderer
  126820. */
  126821. getOutlineRenderer(): OutlineRenderer;
  126822. }
  126823. interface AbstractMesh {
  126824. /** @hidden (Backing field) */
  126825. _renderOutline: boolean;
  126826. /**
  126827. * Gets or sets a boolean indicating if the outline must be rendered as well
  126828. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126829. */
  126830. renderOutline: boolean;
  126831. /** @hidden (Backing field) */
  126832. _renderOverlay: boolean;
  126833. /**
  126834. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126835. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126836. */
  126837. renderOverlay: boolean;
  126838. }
  126839. /**
  126840. * This class is responsible to draw bothe outline/overlay of meshes.
  126841. * It should not be used directly but through the available method on mesh.
  126842. */
  126843. export class OutlineRenderer implements ISceneComponent {
  126844. /**
  126845. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126846. */
  126847. private static _StencilReference;
  126848. /**
  126849. * The name of the component. Each component must have a unique name.
  126850. */
  126851. name: string;
  126852. /**
  126853. * The scene the component belongs to.
  126854. */
  126855. scene: Scene;
  126856. /**
  126857. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126858. */
  126859. zOffset: number;
  126860. private _engine;
  126861. private _effect;
  126862. private _cachedDefines;
  126863. private _savedDepthWrite;
  126864. /**
  126865. * Instantiates a new outline renderer. (There could be only one per scene).
  126866. * @param scene Defines the scene it belongs to
  126867. */
  126868. constructor(scene: Scene);
  126869. /**
  126870. * Register the component to one instance of a scene.
  126871. */
  126872. register(): void;
  126873. /**
  126874. * Rebuilds the elements related to this component in case of
  126875. * context lost for instance.
  126876. */
  126877. rebuild(): void;
  126878. /**
  126879. * Disposes the component and the associated ressources.
  126880. */
  126881. dispose(): void;
  126882. /**
  126883. * Renders the outline in the canvas.
  126884. * @param subMesh Defines the sumesh to render
  126885. * @param batch Defines the batch of meshes in case of instances
  126886. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126887. */
  126888. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126889. /**
  126890. * Returns whether or not the outline renderer is ready for a given submesh.
  126891. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126892. * @param subMesh Defines the submesh to check readyness for
  126893. * @param useInstances Defines wheter wee are trying to render instances or not
  126894. * @returns true if ready otherwise false
  126895. */
  126896. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126897. private _beforeRenderingMesh;
  126898. private _afterRenderingMesh;
  126899. }
  126900. }
  126901. declare module BABYLON {
  126902. /**
  126903. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126904. * @see http://doc.babylonjs.com/babylon101/sprites
  126905. */
  126906. export class SpritePackedManager extends SpriteManager {
  126907. /** defines the packed manager's name */
  126908. name: string;
  126909. /**
  126910. * Creates a new sprite manager from a packed sprite sheet
  126911. * @param name defines the manager's name
  126912. * @param imgUrl defines the sprite sheet url
  126913. * @param capacity defines the maximum allowed number of sprites
  126914. * @param scene defines the hosting scene
  126915. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126916. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126917. * @param samplingMode defines the smapling mode to use with spritesheet
  126918. * @param fromPacked set to true; do not alter
  126919. */
  126920. constructor(
  126921. /** defines the packed manager's name */
  126922. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126923. }
  126924. }
  126925. declare module BABYLON {
  126926. /**
  126927. * Defines the list of states available for a task inside a AssetsManager
  126928. */
  126929. export enum AssetTaskState {
  126930. /**
  126931. * Initialization
  126932. */
  126933. INIT = 0,
  126934. /**
  126935. * Running
  126936. */
  126937. RUNNING = 1,
  126938. /**
  126939. * Done
  126940. */
  126941. DONE = 2,
  126942. /**
  126943. * Error
  126944. */
  126945. ERROR = 3
  126946. }
  126947. /**
  126948. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126949. */
  126950. export abstract class AbstractAssetTask {
  126951. /**
  126952. * Task name
  126953. */ name: string;
  126954. /**
  126955. * Callback called when the task is successful
  126956. */
  126957. onSuccess: (task: any) => void;
  126958. /**
  126959. * Callback called when the task is not successful
  126960. */
  126961. onError: (task: any, message?: string, exception?: any) => void;
  126962. /**
  126963. * Creates a new AssetsManager
  126964. * @param name defines the name of the task
  126965. */
  126966. constructor(
  126967. /**
  126968. * Task name
  126969. */ name: string);
  126970. private _isCompleted;
  126971. private _taskState;
  126972. private _errorObject;
  126973. /**
  126974. * Get if the task is completed
  126975. */
  126976. readonly isCompleted: boolean;
  126977. /**
  126978. * Gets the current state of the task
  126979. */
  126980. readonly taskState: AssetTaskState;
  126981. /**
  126982. * Gets the current error object (if task is in error)
  126983. */
  126984. readonly errorObject: {
  126985. message?: string;
  126986. exception?: any;
  126987. };
  126988. /**
  126989. * Internal only
  126990. * @hidden
  126991. */
  126992. _setErrorObject(message?: string, exception?: any): void;
  126993. /**
  126994. * Execute the current task
  126995. * @param scene defines the scene where you want your assets to be loaded
  126996. * @param onSuccess is a callback called when the task is successfully executed
  126997. * @param onError is a callback called if an error occurs
  126998. */
  126999. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127000. /**
  127001. * Execute the current task
  127002. * @param scene defines the scene where you want your assets to be loaded
  127003. * @param onSuccess is a callback called when the task is successfully executed
  127004. * @param onError is a callback called if an error occurs
  127005. */
  127006. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127007. /**
  127008. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  127009. * This can be used with failed tasks that have the reason for failure fixed.
  127010. */
  127011. reset(): void;
  127012. private onErrorCallback;
  127013. private onDoneCallback;
  127014. }
  127015. /**
  127016. * Define the interface used by progress events raised during assets loading
  127017. */
  127018. export interface IAssetsProgressEvent {
  127019. /**
  127020. * Defines the number of remaining tasks to process
  127021. */
  127022. remainingCount: number;
  127023. /**
  127024. * Defines the total number of tasks
  127025. */
  127026. totalCount: number;
  127027. /**
  127028. * Defines the task that was just processed
  127029. */
  127030. task: AbstractAssetTask;
  127031. }
  127032. /**
  127033. * Class used to share progress information about assets loading
  127034. */
  127035. export class AssetsProgressEvent implements IAssetsProgressEvent {
  127036. /**
  127037. * Defines the number of remaining tasks to process
  127038. */
  127039. remainingCount: number;
  127040. /**
  127041. * Defines the total number of tasks
  127042. */
  127043. totalCount: number;
  127044. /**
  127045. * Defines the task that was just processed
  127046. */
  127047. task: AbstractAssetTask;
  127048. /**
  127049. * Creates a AssetsProgressEvent
  127050. * @param remainingCount defines the number of remaining tasks to process
  127051. * @param totalCount defines the total number of tasks
  127052. * @param task defines the task that was just processed
  127053. */
  127054. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  127055. }
  127056. /**
  127057. * Define a task used by AssetsManager to load meshes
  127058. */
  127059. export class MeshAssetTask extends AbstractAssetTask {
  127060. /**
  127061. * Defines the name of the task
  127062. */
  127063. name: string;
  127064. /**
  127065. * Defines the list of mesh's names you want to load
  127066. */
  127067. meshesNames: any;
  127068. /**
  127069. * Defines the root url to use as a base to load your meshes and associated resources
  127070. */
  127071. rootUrl: string;
  127072. /**
  127073. * Defines the filename of the scene to load from
  127074. */
  127075. sceneFilename: string;
  127076. /**
  127077. * Gets the list of loaded meshes
  127078. */
  127079. loadedMeshes: Array<AbstractMesh>;
  127080. /**
  127081. * Gets the list of loaded particle systems
  127082. */
  127083. loadedParticleSystems: Array<IParticleSystem>;
  127084. /**
  127085. * Gets the list of loaded skeletons
  127086. */
  127087. loadedSkeletons: Array<Skeleton>;
  127088. /**
  127089. * Gets the list of loaded animation groups
  127090. */
  127091. loadedAnimationGroups: Array<AnimationGroup>;
  127092. /**
  127093. * Callback called when the task is successful
  127094. */
  127095. onSuccess: (task: MeshAssetTask) => void;
  127096. /**
  127097. * Callback called when the task is successful
  127098. */
  127099. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  127100. /**
  127101. * Creates a new MeshAssetTask
  127102. * @param name defines the name of the task
  127103. * @param meshesNames defines the list of mesh's names you want to load
  127104. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  127105. * @param sceneFilename defines the filename of the scene to load from
  127106. */
  127107. constructor(
  127108. /**
  127109. * Defines the name of the task
  127110. */
  127111. name: string,
  127112. /**
  127113. * Defines the list of mesh's names you want to load
  127114. */
  127115. meshesNames: any,
  127116. /**
  127117. * Defines the root url to use as a base to load your meshes and associated resources
  127118. */
  127119. rootUrl: string,
  127120. /**
  127121. * Defines the filename of the scene to load from
  127122. */
  127123. sceneFilename: string);
  127124. /**
  127125. * Execute the current task
  127126. * @param scene defines the scene where you want your assets to be loaded
  127127. * @param onSuccess is a callback called when the task is successfully executed
  127128. * @param onError is a callback called if an error occurs
  127129. */
  127130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127131. }
  127132. /**
  127133. * Define a task used by AssetsManager to load text content
  127134. */
  127135. export class TextFileAssetTask extends AbstractAssetTask {
  127136. /**
  127137. * Defines the name of the task
  127138. */
  127139. name: string;
  127140. /**
  127141. * Defines the location of the file to load
  127142. */
  127143. url: string;
  127144. /**
  127145. * Gets the loaded text string
  127146. */
  127147. text: string;
  127148. /**
  127149. * Callback called when the task is successful
  127150. */
  127151. onSuccess: (task: TextFileAssetTask) => void;
  127152. /**
  127153. * Callback called when the task is successful
  127154. */
  127155. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  127156. /**
  127157. * Creates a new TextFileAssetTask object
  127158. * @param name defines the name of the task
  127159. * @param url defines the location of the file to load
  127160. */
  127161. constructor(
  127162. /**
  127163. * Defines the name of the task
  127164. */
  127165. name: string,
  127166. /**
  127167. * Defines the location of the file to load
  127168. */
  127169. url: string);
  127170. /**
  127171. * Execute the current task
  127172. * @param scene defines the scene where you want your assets to be loaded
  127173. * @param onSuccess is a callback called when the task is successfully executed
  127174. * @param onError is a callback called if an error occurs
  127175. */
  127176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127177. }
  127178. /**
  127179. * Define a task used by AssetsManager to load binary data
  127180. */
  127181. export class BinaryFileAssetTask extends AbstractAssetTask {
  127182. /**
  127183. * Defines the name of the task
  127184. */
  127185. name: string;
  127186. /**
  127187. * Defines the location of the file to load
  127188. */
  127189. url: string;
  127190. /**
  127191. * Gets the lodaded data (as an array buffer)
  127192. */
  127193. data: ArrayBuffer;
  127194. /**
  127195. * Callback called when the task is successful
  127196. */
  127197. onSuccess: (task: BinaryFileAssetTask) => void;
  127198. /**
  127199. * Callback called when the task is successful
  127200. */
  127201. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  127202. /**
  127203. * Creates a new BinaryFileAssetTask object
  127204. * @param name defines the name of the new task
  127205. * @param url defines the location of the file to load
  127206. */
  127207. constructor(
  127208. /**
  127209. * Defines the name of the task
  127210. */
  127211. name: string,
  127212. /**
  127213. * Defines the location of the file to load
  127214. */
  127215. url: string);
  127216. /**
  127217. * Execute the current task
  127218. * @param scene defines the scene where you want your assets to be loaded
  127219. * @param onSuccess is a callback called when the task is successfully executed
  127220. * @param onError is a callback called if an error occurs
  127221. */
  127222. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127223. }
  127224. /**
  127225. * Define a task used by AssetsManager to load images
  127226. */
  127227. export class ImageAssetTask extends AbstractAssetTask {
  127228. /**
  127229. * Defines the name of the task
  127230. */
  127231. name: string;
  127232. /**
  127233. * Defines the location of the image to load
  127234. */
  127235. url: string;
  127236. /**
  127237. * Gets the loaded images
  127238. */
  127239. image: HTMLImageElement;
  127240. /**
  127241. * Callback called when the task is successful
  127242. */
  127243. onSuccess: (task: ImageAssetTask) => void;
  127244. /**
  127245. * Callback called when the task is successful
  127246. */
  127247. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  127248. /**
  127249. * Creates a new ImageAssetTask
  127250. * @param name defines the name of the task
  127251. * @param url defines the location of the image to load
  127252. */
  127253. constructor(
  127254. /**
  127255. * Defines the name of the task
  127256. */
  127257. name: string,
  127258. /**
  127259. * Defines the location of the image to load
  127260. */
  127261. url: string);
  127262. /**
  127263. * Execute the current task
  127264. * @param scene defines the scene where you want your assets to be loaded
  127265. * @param onSuccess is a callback called when the task is successfully executed
  127266. * @param onError is a callback called if an error occurs
  127267. */
  127268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127269. }
  127270. /**
  127271. * Defines the interface used by texture loading tasks
  127272. */
  127273. export interface ITextureAssetTask<TEX extends BaseTexture> {
  127274. /**
  127275. * Gets the loaded texture
  127276. */
  127277. texture: TEX;
  127278. }
  127279. /**
  127280. * Define a task used by AssetsManager to load 2D textures
  127281. */
  127282. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  127283. /**
  127284. * Defines the name of the task
  127285. */
  127286. name: string;
  127287. /**
  127288. * Defines the location of the file to load
  127289. */
  127290. url: string;
  127291. /**
  127292. * Defines if mipmap should not be generated (default is false)
  127293. */
  127294. noMipmap?: boolean | undefined;
  127295. /**
  127296. * Defines if texture must be inverted on Y axis (default is false)
  127297. */
  127298. invertY?: boolean | undefined;
  127299. /**
  127300. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127301. */
  127302. samplingMode: number;
  127303. /**
  127304. * Gets the loaded texture
  127305. */
  127306. texture: Texture;
  127307. /**
  127308. * Callback called when the task is successful
  127309. */
  127310. onSuccess: (task: TextureAssetTask) => void;
  127311. /**
  127312. * Callback called when the task is successful
  127313. */
  127314. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  127315. /**
  127316. * Creates a new TextureAssetTask object
  127317. * @param name defines the name of the task
  127318. * @param url defines the location of the file to load
  127319. * @param noMipmap defines if mipmap should not be generated (default is false)
  127320. * @param invertY defines if texture must be inverted on Y axis (default is false)
  127321. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127322. */
  127323. constructor(
  127324. /**
  127325. * Defines the name of the task
  127326. */
  127327. name: string,
  127328. /**
  127329. * Defines the location of the file to load
  127330. */
  127331. url: string,
  127332. /**
  127333. * Defines if mipmap should not be generated (default is false)
  127334. */
  127335. noMipmap?: boolean | undefined,
  127336. /**
  127337. * Defines if texture must be inverted on Y axis (default is false)
  127338. */
  127339. invertY?: boolean | undefined,
  127340. /**
  127341. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127342. */
  127343. samplingMode?: number);
  127344. /**
  127345. * Execute the current task
  127346. * @param scene defines the scene where you want your assets to be loaded
  127347. * @param onSuccess is a callback called when the task is successfully executed
  127348. * @param onError is a callback called if an error occurs
  127349. */
  127350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127351. }
  127352. /**
  127353. * Define a task used by AssetsManager to load cube textures
  127354. */
  127355. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  127356. /**
  127357. * Defines the name of the task
  127358. */
  127359. name: string;
  127360. /**
  127361. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127362. */
  127363. url: string;
  127364. /**
  127365. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127366. */
  127367. extensions?: string[] | undefined;
  127368. /**
  127369. * Defines if mipmaps should not be generated (default is false)
  127370. */
  127371. noMipmap?: boolean | undefined;
  127372. /**
  127373. * Defines the explicit list of files (undefined by default)
  127374. */
  127375. files?: string[] | undefined;
  127376. /**
  127377. * Gets the loaded texture
  127378. */
  127379. texture: CubeTexture;
  127380. /**
  127381. * Callback called when the task is successful
  127382. */
  127383. onSuccess: (task: CubeTextureAssetTask) => void;
  127384. /**
  127385. * Callback called when the task is successful
  127386. */
  127387. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  127388. /**
  127389. * Creates a new CubeTextureAssetTask
  127390. * @param name defines the name of the task
  127391. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127392. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127393. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127394. * @param files defines the explicit list of files (undefined by default)
  127395. */
  127396. constructor(
  127397. /**
  127398. * Defines the name of the task
  127399. */
  127400. name: string,
  127401. /**
  127402. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127403. */
  127404. url: string,
  127405. /**
  127406. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127407. */
  127408. extensions?: string[] | undefined,
  127409. /**
  127410. * Defines if mipmaps should not be generated (default is false)
  127411. */
  127412. noMipmap?: boolean | undefined,
  127413. /**
  127414. * Defines the explicit list of files (undefined by default)
  127415. */
  127416. files?: string[] | undefined);
  127417. /**
  127418. * Execute the current task
  127419. * @param scene defines the scene where you want your assets to be loaded
  127420. * @param onSuccess is a callback called when the task is successfully executed
  127421. * @param onError is a callback called if an error occurs
  127422. */
  127423. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127424. }
  127425. /**
  127426. * Define a task used by AssetsManager to load HDR cube textures
  127427. */
  127428. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  127429. /**
  127430. * Defines the name of the task
  127431. */
  127432. name: string;
  127433. /**
  127434. * Defines the location of the file to load
  127435. */
  127436. url: string;
  127437. /**
  127438. * Defines the desired size (the more it increases the longer the generation will be)
  127439. */
  127440. size: number;
  127441. /**
  127442. * Defines if mipmaps should not be generated (default is false)
  127443. */
  127444. noMipmap: boolean;
  127445. /**
  127446. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127447. */
  127448. generateHarmonics: boolean;
  127449. /**
  127450. * 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)
  127451. */
  127452. gammaSpace: boolean;
  127453. /**
  127454. * Internal Use Only
  127455. */
  127456. reserved: boolean;
  127457. /**
  127458. * Gets the loaded texture
  127459. */
  127460. texture: HDRCubeTexture;
  127461. /**
  127462. * Callback called when the task is successful
  127463. */
  127464. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  127465. /**
  127466. * Callback called when the task is successful
  127467. */
  127468. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127469. /**
  127470. * Creates a new HDRCubeTextureAssetTask object
  127471. * @param name defines the name of the task
  127472. * @param url defines the location of the file to load
  127473. * @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.
  127474. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127475. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127476. * @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)
  127477. * @param reserved Internal use only
  127478. */
  127479. constructor(
  127480. /**
  127481. * Defines the name of the task
  127482. */
  127483. name: string,
  127484. /**
  127485. * Defines the location of the file to load
  127486. */
  127487. url: string,
  127488. /**
  127489. * Defines the desired size (the more it increases the longer the generation will be)
  127490. */
  127491. size: number,
  127492. /**
  127493. * Defines if mipmaps should not be generated (default is false)
  127494. */
  127495. noMipmap?: boolean,
  127496. /**
  127497. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127498. */
  127499. generateHarmonics?: boolean,
  127500. /**
  127501. * 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)
  127502. */
  127503. gammaSpace?: boolean,
  127504. /**
  127505. * Internal Use Only
  127506. */
  127507. reserved?: boolean);
  127508. /**
  127509. * Execute the current task
  127510. * @param scene defines the scene where you want your assets to be loaded
  127511. * @param onSuccess is a callback called when the task is successfully executed
  127512. * @param onError is a callback called if an error occurs
  127513. */
  127514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127515. }
  127516. /**
  127517. * Define a task used by AssetsManager to load Equirectangular cube textures
  127518. */
  127519. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127520. /**
  127521. * Defines the name of the task
  127522. */
  127523. name: string;
  127524. /**
  127525. * Defines the location of the file to load
  127526. */
  127527. url: string;
  127528. /**
  127529. * Defines the desired size (the more it increases the longer the generation will be)
  127530. */
  127531. size: number;
  127532. /**
  127533. * Defines if mipmaps should not be generated (default is false)
  127534. */
  127535. noMipmap: boolean;
  127536. /**
  127537. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127538. * but the standard material would require them in Gamma space) (default is true)
  127539. */
  127540. gammaSpace: boolean;
  127541. /**
  127542. * Gets the loaded texture
  127543. */
  127544. texture: EquiRectangularCubeTexture;
  127545. /**
  127546. * Callback called when the task is successful
  127547. */
  127548. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127549. /**
  127550. * Callback called when the task is successful
  127551. */
  127552. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127553. /**
  127554. * Creates a new EquiRectangularCubeTextureAssetTask object
  127555. * @param name defines the name of the task
  127556. * @param url defines the location of the file to load
  127557. * @param size defines the desired size (the more it increases the longer the generation will be)
  127558. * If the size is omitted this implies you are using a preprocessed cubemap.
  127559. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127560. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127561. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127562. * (default is true)
  127563. */
  127564. constructor(
  127565. /**
  127566. * Defines the name of the task
  127567. */
  127568. name: string,
  127569. /**
  127570. * Defines the location of the file to load
  127571. */
  127572. url: string,
  127573. /**
  127574. * Defines the desired size (the more it increases the longer the generation will be)
  127575. */
  127576. size: number,
  127577. /**
  127578. * Defines if mipmaps should not be generated (default is false)
  127579. */
  127580. noMipmap?: boolean,
  127581. /**
  127582. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127583. * but the standard material would require them in Gamma space) (default is true)
  127584. */
  127585. gammaSpace?: boolean);
  127586. /**
  127587. * Execute the current task
  127588. * @param scene defines the scene where you want your assets to be loaded
  127589. * @param onSuccess is a callback called when the task is successfully executed
  127590. * @param onError is a callback called if an error occurs
  127591. */
  127592. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127593. }
  127594. /**
  127595. * This class can be used to easily import assets into a scene
  127596. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127597. */
  127598. export class AssetsManager {
  127599. private _scene;
  127600. private _isLoading;
  127601. protected _tasks: AbstractAssetTask[];
  127602. protected _waitingTasksCount: number;
  127603. protected _totalTasksCount: number;
  127604. /**
  127605. * Callback called when all tasks are processed
  127606. */
  127607. onFinish: (tasks: AbstractAssetTask[]) => void;
  127608. /**
  127609. * Callback called when a task is successful
  127610. */
  127611. onTaskSuccess: (task: AbstractAssetTask) => void;
  127612. /**
  127613. * Callback called when a task had an error
  127614. */
  127615. onTaskError: (task: AbstractAssetTask) => void;
  127616. /**
  127617. * Callback called when a task is done (whatever the result is)
  127618. */
  127619. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127620. /**
  127621. * Observable called when all tasks are processed
  127622. */
  127623. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127624. /**
  127625. * Observable called when a task had an error
  127626. */
  127627. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127628. /**
  127629. * Observable called when all tasks were executed
  127630. */
  127631. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127632. /**
  127633. * Observable called when a task is done (whatever the result is)
  127634. */
  127635. onProgressObservable: Observable<IAssetsProgressEvent>;
  127636. /**
  127637. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127638. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127639. */
  127640. useDefaultLoadingScreen: boolean;
  127641. /**
  127642. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127643. * when all assets have been downloaded.
  127644. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127645. */
  127646. autoHideLoadingUI: boolean;
  127647. /**
  127648. * Creates a new AssetsManager
  127649. * @param scene defines the scene to work on
  127650. */
  127651. constructor(scene: Scene);
  127652. /**
  127653. * Add a MeshAssetTask to the list of active tasks
  127654. * @param taskName defines the name of the new task
  127655. * @param meshesNames defines the name of meshes to load
  127656. * @param rootUrl defines the root url to use to locate files
  127657. * @param sceneFilename defines the filename of the scene file
  127658. * @returns a new MeshAssetTask object
  127659. */
  127660. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127661. /**
  127662. * Add a TextFileAssetTask to the list of active tasks
  127663. * @param taskName defines the name of the new task
  127664. * @param url defines the url of the file to load
  127665. * @returns a new TextFileAssetTask object
  127666. */
  127667. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127668. /**
  127669. * Add a BinaryFileAssetTask to the list of active tasks
  127670. * @param taskName defines the name of the new task
  127671. * @param url defines the url of the file to load
  127672. * @returns a new BinaryFileAssetTask object
  127673. */
  127674. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127675. /**
  127676. * Add a ImageAssetTask to the list of active tasks
  127677. * @param taskName defines the name of the new task
  127678. * @param url defines the url of the file to load
  127679. * @returns a new ImageAssetTask object
  127680. */
  127681. addImageTask(taskName: string, url: string): ImageAssetTask;
  127682. /**
  127683. * Add a TextureAssetTask to the list of active tasks
  127684. * @param taskName defines the name of the new task
  127685. * @param url defines the url of the file to load
  127686. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127687. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127688. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127689. * @returns a new TextureAssetTask object
  127690. */
  127691. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127692. /**
  127693. * Add a CubeTextureAssetTask to the list of active tasks
  127694. * @param taskName defines the name of the new task
  127695. * @param url defines the url of the file to load
  127696. * @param extensions defines the extension to use to load the cube map (can be null)
  127697. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127698. * @param files defines the list of files to load (can be null)
  127699. * @returns a new CubeTextureAssetTask object
  127700. */
  127701. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127702. /**
  127703. *
  127704. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127705. * @param taskName defines the name of the new task
  127706. * @param url defines the url of the file to load
  127707. * @param size defines the size you want for the cubemap (can be null)
  127708. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127709. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127710. * @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)
  127711. * @param reserved Internal use only
  127712. * @returns a new HDRCubeTextureAssetTask object
  127713. */
  127714. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127715. /**
  127716. *
  127717. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127718. * @param taskName defines the name of the new task
  127719. * @param url defines the url of the file to load
  127720. * @param size defines the size you want for the cubemap (can be null)
  127721. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127722. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127723. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127724. * @returns a new EquiRectangularCubeTextureAssetTask object
  127725. */
  127726. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127727. /**
  127728. * Remove a task from the assets manager.
  127729. * @param task the task to remove
  127730. */
  127731. removeTask(task: AbstractAssetTask): void;
  127732. private _decreaseWaitingTasksCount;
  127733. private _runTask;
  127734. /**
  127735. * Reset the AssetsManager and remove all tasks
  127736. * @return the current instance of the AssetsManager
  127737. */
  127738. reset(): AssetsManager;
  127739. /**
  127740. * Start the loading process
  127741. * @return the current instance of the AssetsManager
  127742. */
  127743. load(): AssetsManager;
  127744. /**
  127745. * Start the loading process as an async operation
  127746. * @return a promise returning the list of failed tasks
  127747. */
  127748. loadAsync(): Promise<void>;
  127749. }
  127750. }
  127751. declare module BABYLON {
  127752. /**
  127753. * Wrapper class for promise with external resolve and reject.
  127754. */
  127755. export class Deferred<T> {
  127756. /**
  127757. * The promise associated with this deferred object.
  127758. */
  127759. readonly promise: Promise<T>;
  127760. private _resolve;
  127761. private _reject;
  127762. /**
  127763. * The resolve method of the promise associated with this deferred object.
  127764. */
  127765. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127766. /**
  127767. * The reject method of the promise associated with this deferred object.
  127768. */
  127769. readonly reject: (reason?: any) => void;
  127770. /**
  127771. * Constructor for this deferred object.
  127772. */
  127773. constructor();
  127774. }
  127775. }
  127776. declare module BABYLON {
  127777. /**
  127778. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127779. */
  127780. export class MeshExploder {
  127781. private _centerMesh;
  127782. private _meshes;
  127783. private _meshesOrigins;
  127784. private _toCenterVectors;
  127785. private _scaledDirection;
  127786. private _newPosition;
  127787. private _centerPosition;
  127788. /**
  127789. * Explodes meshes from a center mesh.
  127790. * @param meshes The meshes to explode.
  127791. * @param centerMesh The mesh to be center of explosion.
  127792. */
  127793. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127794. private _setCenterMesh;
  127795. /**
  127796. * Get class name
  127797. * @returns "MeshExploder"
  127798. */
  127799. getClassName(): string;
  127800. /**
  127801. * "Exploded meshes"
  127802. * @returns Array of meshes with the centerMesh at index 0.
  127803. */
  127804. getMeshes(): Array<Mesh>;
  127805. /**
  127806. * Explodes meshes giving a specific direction
  127807. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127808. */
  127809. explode(direction?: number): void;
  127810. }
  127811. }
  127812. declare module BABYLON {
  127813. /**
  127814. * Class used to help managing file picking and drag'n'drop
  127815. */
  127816. export class FilesInput {
  127817. /**
  127818. * List of files ready to be loaded
  127819. */
  127820. static readonly FilesToLoad: {
  127821. [key: string]: File;
  127822. };
  127823. /**
  127824. * Callback called when a file is processed
  127825. */
  127826. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127827. private _engine;
  127828. private _currentScene;
  127829. private _sceneLoadedCallback;
  127830. private _progressCallback;
  127831. private _additionalRenderLoopLogicCallback;
  127832. private _textureLoadingCallback;
  127833. private _startingProcessingFilesCallback;
  127834. private _onReloadCallback;
  127835. private _errorCallback;
  127836. private _elementToMonitor;
  127837. private _sceneFileToLoad;
  127838. private _filesToLoad;
  127839. /**
  127840. * Creates a new FilesInput
  127841. * @param engine defines the rendering engine
  127842. * @param scene defines the hosting scene
  127843. * @param sceneLoadedCallback callback called when scene is loaded
  127844. * @param progressCallback callback called to track progress
  127845. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127846. * @param textureLoadingCallback callback called when a texture is loading
  127847. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127848. * @param onReloadCallback callback called when a reload is requested
  127849. * @param errorCallback callback call if an error occurs
  127850. */
  127851. 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);
  127852. private _dragEnterHandler;
  127853. private _dragOverHandler;
  127854. private _dropHandler;
  127855. /**
  127856. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127857. * @param elementToMonitor defines the DOM element to track
  127858. */
  127859. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127860. /**
  127861. * Release all associated resources
  127862. */
  127863. dispose(): void;
  127864. private renderFunction;
  127865. private drag;
  127866. private drop;
  127867. private _traverseFolder;
  127868. private _processFiles;
  127869. /**
  127870. * Load files from a drop event
  127871. * @param event defines the drop event to use as source
  127872. */
  127873. loadFiles(event: any): void;
  127874. private _processReload;
  127875. /**
  127876. * Reload the current scene from the loaded files
  127877. */
  127878. reload(): void;
  127879. }
  127880. }
  127881. declare module BABYLON {
  127882. /**
  127883. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  127884. */
  127885. export class PerformanceMonitor implements IPerformanceMonitor {
  127886. private _enabled;
  127887. private _rollingFrameTime;
  127888. private _lastFrameTimeMs;
  127889. /**
  127890. * constructor
  127891. * @param frameSampleSize The number of samples required to saturate the sliding window
  127892. */
  127893. constructor(frameSampleSize?: number);
  127894. /**
  127895. * Samples current frame
  127896. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  127897. */
  127898. sampleFrame(timeMs?: number): void;
  127899. /**
  127900. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  127901. */
  127902. readonly averageFrameTime: number;
  127903. /**
  127904. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  127905. */
  127906. readonly averageFrameTimeVariance: number;
  127907. /**
  127908. * Returns the frame time of the most recent frame
  127909. */
  127910. readonly instantaneousFrameTime: number;
  127911. /**
  127912. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  127913. */
  127914. readonly averageFPS: number;
  127915. /**
  127916. * Returns the average framerate in frames per second using the most recent frame time
  127917. */
  127918. readonly instantaneousFPS: number;
  127919. /**
  127920. * Returns true if enough samples have been taken to completely fill the sliding window
  127921. */
  127922. readonly isSaturated: boolean;
  127923. /**
  127924. * Enables contributions to the sliding window sample set
  127925. */
  127926. enable(): void;
  127927. /**
  127928. * Disables contributions to the sliding window sample set
  127929. * Samples will not be interpolated over the disabled period
  127930. */
  127931. disable(): void;
  127932. /**
  127933. * Returns true if sampling is enabled
  127934. */
  127935. readonly isEnabled: boolean;
  127936. /**
  127937. * Resets performance monitor
  127938. */
  127939. reset(): void;
  127940. }
  127941. /**
  127942. * RollingAverage
  127943. *
  127944. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  127945. */
  127946. export class RollingAverage {
  127947. /**
  127948. * Current average
  127949. */
  127950. average: number;
  127951. /**
  127952. * Current variance
  127953. */
  127954. variance: number;
  127955. protected _samples: Array<number>;
  127956. protected _sampleCount: number;
  127957. protected _pos: number;
  127958. protected _m2: number;
  127959. /**
  127960. * constructor
  127961. * @param length The number of samples required to saturate the sliding window
  127962. */
  127963. constructor(length: number);
  127964. /**
  127965. * Adds a sample to the sample set
  127966. * @param v The sample value
  127967. */
  127968. add(v: number): void;
  127969. /**
  127970. * Returns previously added values or null if outside of history or outside the sliding window domain
  127971. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  127972. * @return Value previously recorded with add() or null if outside of range
  127973. */
  127974. history(i: number): number;
  127975. /**
  127976. * Returns true if enough samples have been taken to completely fill the sliding window
  127977. * @return true if sample-set saturated
  127978. */
  127979. isSaturated(): boolean;
  127980. /**
  127981. * Resets the rolling average (equivalent to 0 samples taken so far)
  127982. */
  127983. reset(): void;
  127984. /**
  127985. * Wraps a value around the sample range boundaries
  127986. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  127987. * @return Wrapped position in sample range
  127988. */
  127989. protected _wrapPosition(i: number): number;
  127990. }
  127991. }
  127992. declare module BABYLON {
  127993. /**
  127994. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127996. */
  127997. export class SceneOptimization {
  127998. /**
  127999. * Defines the priority of this optimization (0 by default which means first in the list)
  128000. */
  128001. priority: number;
  128002. /**
  128003. * Gets a string describing the action executed by the current optimization
  128004. * @returns description string
  128005. */
  128006. getDescription(): string;
  128007. /**
  128008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128009. * @param scene defines the current scene where to apply this optimization
  128010. * @param optimizer defines the current optimizer
  128011. * @returns true if everything that can be done was applied
  128012. */
  128013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128014. /**
  128015. * Creates the SceneOptimization object
  128016. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128017. * @param desc defines the description associated with the optimization
  128018. */
  128019. constructor(
  128020. /**
  128021. * Defines the priority of this optimization (0 by default which means first in the list)
  128022. */
  128023. priority?: number);
  128024. }
  128025. /**
  128026. * Defines an optimization used to reduce the size of render target textures
  128027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128028. */
  128029. export class TextureOptimization extends SceneOptimization {
  128030. /**
  128031. * Defines the priority of this optimization (0 by default which means first in the list)
  128032. */
  128033. priority: number;
  128034. /**
  128035. * 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
  128036. */
  128037. maximumSize: number;
  128038. /**
  128039. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128040. */
  128041. step: number;
  128042. /**
  128043. * Gets a string describing the action executed by the current optimization
  128044. * @returns description string
  128045. */
  128046. getDescription(): string;
  128047. /**
  128048. * Creates the TextureOptimization object
  128049. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128050. * @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
  128051. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128052. */
  128053. constructor(
  128054. /**
  128055. * Defines the priority of this optimization (0 by default which means first in the list)
  128056. */
  128057. priority?: number,
  128058. /**
  128059. * 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
  128060. */
  128061. maximumSize?: number,
  128062. /**
  128063. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128064. */
  128065. step?: number);
  128066. /**
  128067. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128068. * @param scene defines the current scene where to apply this optimization
  128069. * @param optimizer defines the current optimizer
  128070. * @returns true if everything that can be done was applied
  128071. */
  128072. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128073. }
  128074. /**
  128075. * Defines an optimization used to increase or decrease the rendering resolution
  128076. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128077. */
  128078. export class HardwareScalingOptimization extends SceneOptimization {
  128079. /**
  128080. * Defines the priority of this optimization (0 by default which means first in the list)
  128081. */
  128082. priority: number;
  128083. /**
  128084. * Defines the maximum scale to use (2 by default)
  128085. */
  128086. maximumScale: number;
  128087. /**
  128088. * Defines the step to use between two passes (0.5 by default)
  128089. */
  128090. step: number;
  128091. private _currentScale;
  128092. private _directionOffset;
  128093. /**
  128094. * Gets a string describing the action executed by the current optimization
  128095. * @return description string
  128096. */
  128097. getDescription(): string;
  128098. /**
  128099. * Creates the HardwareScalingOptimization object
  128100. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128101. * @param maximumScale defines the maximum scale to use (2 by default)
  128102. * @param step defines the step to use between two passes (0.5 by default)
  128103. */
  128104. constructor(
  128105. /**
  128106. * Defines the priority of this optimization (0 by default which means first in the list)
  128107. */
  128108. priority?: number,
  128109. /**
  128110. * Defines the maximum scale to use (2 by default)
  128111. */
  128112. maximumScale?: number,
  128113. /**
  128114. * Defines the step to use between two passes (0.5 by default)
  128115. */
  128116. step?: number);
  128117. /**
  128118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128119. * @param scene defines the current scene where to apply this optimization
  128120. * @param optimizer defines the current optimizer
  128121. * @returns true if everything that can be done was applied
  128122. */
  128123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128124. }
  128125. /**
  128126. * Defines an optimization used to remove shadows
  128127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128128. */
  128129. export class ShadowsOptimization extends SceneOptimization {
  128130. /**
  128131. * Gets a string describing the action executed by the current optimization
  128132. * @return description string
  128133. */
  128134. getDescription(): string;
  128135. /**
  128136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128137. * @param scene defines the current scene where to apply this optimization
  128138. * @param optimizer defines the current optimizer
  128139. * @returns true if everything that can be done was applied
  128140. */
  128141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128142. }
  128143. /**
  128144. * Defines an optimization used to turn post-processes off
  128145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128146. */
  128147. export class PostProcessesOptimization extends SceneOptimization {
  128148. /**
  128149. * Gets a string describing the action executed by the current optimization
  128150. * @return description string
  128151. */
  128152. getDescription(): string;
  128153. /**
  128154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128155. * @param scene defines the current scene where to apply this optimization
  128156. * @param optimizer defines the current optimizer
  128157. * @returns true if everything that can be done was applied
  128158. */
  128159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128160. }
  128161. /**
  128162. * Defines an optimization used to turn lens flares off
  128163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128164. */
  128165. export class LensFlaresOptimization extends SceneOptimization {
  128166. /**
  128167. * Gets a string describing the action executed by the current optimization
  128168. * @return description string
  128169. */
  128170. getDescription(): string;
  128171. /**
  128172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128173. * @param scene defines the current scene where to apply this optimization
  128174. * @param optimizer defines the current optimizer
  128175. * @returns true if everything that can be done was applied
  128176. */
  128177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128178. }
  128179. /**
  128180. * Defines an optimization based on user defined callback.
  128181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128182. */
  128183. export class CustomOptimization extends SceneOptimization {
  128184. /**
  128185. * Callback called to apply the custom optimization.
  128186. */
  128187. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  128188. /**
  128189. * Callback called to get custom description
  128190. */
  128191. onGetDescription: () => string;
  128192. /**
  128193. * Gets a string describing the action executed by the current optimization
  128194. * @returns description string
  128195. */
  128196. getDescription(): string;
  128197. /**
  128198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128199. * @param scene defines the current scene where to apply this optimization
  128200. * @param optimizer defines the current optimizer
  128201. * @returns true if everything that can be done was applied
  128202. */
  128203. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128204. }
  128205. /**
  128206. * Defines an optimization used to turn particles off
  128207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128208. */
  128209. export class ParticlesOptimization extends SceneOptimization {
  128210. /**
  128211. * Gets a string describing the action executed by the current optimization
  128212. * @return description string
  128213. */
  128214. getDescription(): string;
  128215. /**
  128216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128217. * @param scene defines the current scene where to apply this optimization
  128218. * @param optimizer defines the current optimizer
  128219. * @returns true if everything that can be done was applied
  128220. */
  128221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128222. }
  128223. /**
  128224. * Defines an optimization used to turn render targets off
  128225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128226. */
  128227. export class RenderTargetsOptimization extends SceneOptimization {
  128228. /**
  128229. * Gets a string describing the action executed by the current optimization
  128230. * @return description string
  128231. */
  128232. getDescription(): string;
  128233. /**
  128234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128235. * @param scene defines the current scene where to apply this optimization
  128236. * @param optimizer defines the current optimizer
  128237. * @returns true if everything that can be done was applied
  128238. */
  128239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128240. }
  128241. /**
  128242. * Defines an optimization used to merge meshes with compatible materials
  128243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128244. */
  128245. export class MergeMeshesOptimization extends SceneOptimization {
  128246. private static _UpdateSelectionTree;
  128247. /**
  128248. * Gets or sets a boolean which defines if optimization octree has to be updated
  128249. */
  128250. /**
  128251. * Gets or sets a boolean which defines if optimization octree has to be updated
  128252. */
  128253. static UpdateSelectionTree: boolean;
  128254. /**
  128255. * Gets a string describing the action executed by the current optimization
  128256. * @return description string
  128257. */
  128258. getDescription(): string;
  128259. private _canBeMerged;
  128260. /**
  128261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128262. * @param scene defines the current scene where to apply this optimization
  128263. * @param optimizer defines the current optimizer
  128264. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  128265. * @returns true if everything that can be done was applied
  128266. */
  128267. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  128268. }
  128269. /**
  128270. * Defines a list of options used by SceneOptimizer
  128271. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128272. */
  128273. export class SceneOptimizerOptions {
  128274. /**
  128275. * Defines the target frame rate to reach (60 by default)
  128276. */
  128277. targetFrameRate: number;
  128278. /**
  128279. * Defines the interval between two checkes (2000ms by default)
  128280. */
  128281. trackerDuration: number;
  128282. /**
  128283. * Gets the list of optimizations to apply
  128284. */
  128285. optimizations: SceneOptimization[];
  128286. /**
  128287. * Creates a new list of options used by SceneOptimizer
  128288. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  128289. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  128290. */
  128291. constructor(
  128292. /**
  128293. * Defines the target frame rate to reach (60 by default)
  128294. */
  128295. targetFrameRate?: number,
  128296. /**
  128297. * Defines the interval between two checkes (2000ms by default)
  128298. */
  128299. trackerDuration?: number);
  128300. /**
  128301. * Add a new optimization
  128302. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  128303. * @returns the current SceneOptimizerOptions
  128304. */
  128305. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  128306. /**
  128307. * Add a new custom optimization
  128308. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  128309. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  128310. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128311. * @returns the current SceneOptimizerOptions
  128312. */
  128313. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  128314. /**
  128315. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  128316. * @param targetFrameRate defines the target frame rate (60 by default)
  128317. * @returns a SceneOptimizerOptions object
  128318. */
  128319. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128320. /**
  128321. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  128322. * @param targetFrameRate defines the target frame rate (60 by default)
  128323. * @returns a SceneOptimizerOptions object
  128324. */
  128325. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128326. /**
  128327. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  128328. * @param targetFrameRate defines the target frame rate (60 by default)
  128329. * @returns a SceneOptimizerOptions object
  128330. */
  128331. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128332. }
  128333. /**
  128334. * Class used to run optimizations in order to reach a target frame rate
  128335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128336. */
  128337. export class SceneOptimizer implements IDisposable {
  128338. private _isRunning;
  128339. private _options;
  128340. private _scene;
  128341. private _currentPriorityLevel;
  128342. private _targetFrameRate;
  128343. private _trackerDuration;
  128344. private _currentFrameRate;
  128345. private _sceneDisposeObserver;
  128346. private _improvementMode;
  128347. /**
  128348. * Defines an observable called when the optimizer reaches the target frame rate
  128349. */
  128350. onSuccessObservable: Observable<SceneOptimizer>;
  128351. /**
  128352. * Defines an observable called when the optimizer enables an optimization
  128353. */
  128354. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  128355. /**
  128356. * Defines an observable called when the optimizer is not able to reach the target frame rate
  128357. */
  128358. onFailureObservable: Observable<SceneOptimizer>;
  128359. /**
  128360. * Gets a boolean indicating if the optimizer is in improvement mode
  128361. */
  128362. readonly isInImprovementMode: boolean;
  128363. /**
  128364. * Gets the current priority level (0 at start)
  128365. */
  128366. readonly currentPriorityLevel: number;
  128367. /**
  128368. * Gets the current frame rate checked by the SceneOptimizer
  128369. */
  128370. readonly currentFrameRate: number;
  128371. /**
  128372. * Gets or sets the current target frame rate (60 by default)
  128373. */
  128374. /**
  128375. * Gets or sets the current target frame rate (60 by default)
  128376. */
  128377. targetFrameRate: number;
  128378. /**
  128379. * Gets or sets the current interval between two checks (every 2000ms by default)
  128380. */
  128381. /**
  128382. * Gets or sets the current interval between two checks (every 2000ms by default)
  128383. */
  128384. trackerDuration: number;
  128385. /**
  128386. * Gets the list of active optimizations
  128387. */
  128388. readonly optimizations: SceneOptimization[];
  128389. /**
  128390. * Creates a new SceneOptimizer
  128391. * @param scene defines the scene to work on
  128392. * @param options defines the options to use with the SceneOptimizer
  128393. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  128394. * @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)
  128395. */
  128396. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  128397. /**
  128398. * Stops the current optimizer
  128399. */
  128400. stop(): void;
  128401. /**
  128402. * Reset the optimizer to initial step (current priority level = 0)
  128403. */
  128404. reset(): void;
  128405. /**
  128406. * Start the optimizer. By default it will try to reach a specific framerate
  128407. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  128408. */
  128409. start(): void;
  128410. private _checkCurrentState;
  128411. /**
  128412. * Release all resources
  128413. */
  128414. dispose(): void;
  128415. /**
  128416. * Helper function to create a SceneOptimizer with one single line of code
  128417. * @param scene defines the scene to work on
  128418. * @param options defines the options to use with the SceneOptimizer
  128419. * @param onSuccess defines a callback to call on success
  128420. * @param onFailure defines a callback to call on failure
  128421. * @returns the new SceneOptimizer object
  128422. */
  128423. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  128424. }
  128425. }
  128426. declare module BABYLON {
  128427. /**
  128428. * Class used to serialize a scene into a string
  128429. */
  128430. export class SceneSerializer {
  128431. /**
  128432. * Clear cache used by a previous serialization
  128433. */
  128434. static ClearCache(): void;
  128435. /**
  128436. * Serialize a scene into a JSON compatible object
  128437. * @param scene defines the scene to serialize
  128438. * @returns a JSON compatible object
  128439. */
  128440. static Serialize(scene: Scene): any;
  128441. /**
  128442. * Serialize a mesh into a JSON compatible object
  128443. * @param toSerialize defines the mesh to serialize
  128444. * @param withParents defines if parents must be serialized as well
  128445. * @param withChildren defines if children must be serialized as well
  128446. * @returns a JSON compatible object
  128447. */
  128448. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  128449. }
  128450. }
  128451. declare module BABYLON {
  128452. /**
  128453. * Class used to host texture specific utilities
  128454. */
  128455. export class TextureTools {
  128456. /**
  128457. * Uses the GPU to create a copy texture rescaled at a given size
  128458. * @param texture Texture to copy from
  128459. * @param width defines the desired width
  128460. * @param height defines the desired height
  128461. * @param useBilinearMode defines if bilinear mode has to be used
  128462. * @return the generated texture
  128463. */
  128464. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  128465. }
  128466. }
  128467. declare module BABYLON {
  128468. /**
  128469. * This represents the different options available for the video capture.
  128470. */
  128471. export interface VideoRecorderOptions {
  128472. /** Defines the mime type of the video. */
  128473. mimeType: string;
  128474. /** Defines the FPS the video should be recorded at. */
  128475. fps: number;
  128476. /** Defines the chunk size for the recording data. */
  128477. recordChunckSize: number;
  128478. /** The audio tracks to attach to the recording. */
  128479. audioTracks?: MediaStreamTrack[];
  128480. }
  128481. /**
  128482. * This can help with recording videos from BabylonJS.
  128483. * This is based on the available WebRTC functionalities of the browser.
  128484. *
  128485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  128486. */
  128487. export class VideoRecorder {
  128488. private static readonly _defaultOptions;
  128489. /**
  128490. * Returns whether or not the VideoRecorder is available in your browser.
  128491. * @param engine Defines the Babylon Engine.
  128492. * @returns true if supported otherwise false.
  128493. */
  128494. static IsSupported(engine: Engine): boolean;
  128495. private readonly _options;
  128496. private _canvas;
  128497. private _mediaRecorder;
  128498. private _recordedChunks;
  128499. private _fileName;
  128500. private _resolve;
  128501. private _reject;
  128502. /**
  128503. * True when a recording is already in progress.
  128504. */
  128505. readonly isRecording: boolean;
  128506. /**
  128507. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  128508. * @param engine Defines the BabylonJS Engine you wish to record.
  128509. * @param options Defines options that can be used to customize the capture.
  128510. */
  128511. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  128512. /**
  128513. * Stops the current recording before the default capture timeout passed in the startRecording function.
  128514. */
  128515. stopRecording(): void;
  128516. /**
  128517. * Starts recording the canvas for a max duration specified in parameters.
  128518. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  128519. * If null no automatic download will start and you can rely on the promise to get the data back.
  128520. * @param maxDuration Defines the maximum recording time in seconds.
  128521. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  128522. * @return A promise callback at the end of the recording with the video data in Blob.
  128523. */
  128524. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  128525. /**
  128526. * Releases internal resources used during the recording.
  128527. */
  128528. dispose(): void;
  128529. private _handleDataAvailable;
  128530. private _handleError;
  128531. private _handleStop;
  128532. }
  128533. }
  128534. declare module BABYLON {
  128535. /**
  128536. * Class containing a set of static utilities functions for screenshots
  128537. */
  128538. export class ScreenshotTools {
  128539. /**
  128540. * Captures a screenshot of the current rendering
  128541. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128542. * @param engine defines the rendering engine
  128543. * @param camera defines the source camera
  128544. * @param size This parameter can be set to a single number or to an object with the
  128545. * following (optional) properties: precision, width, height. If a single number is passed,
  128546. * it will be used for both width and height. If an object is passed, the screenshot size
  128547. * will be derived from the parameters. The precision property is a multiplier allowing
  128548. * rendering at a higher or lower resolution
  128549. * @param successCallback defines the callback receives a single parameter which contains the
  128550. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128551. * src parameter of an <img> to display it
  128552. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128553. * Check your browser for supported MIME types
  128554. */
  128555. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  128556. /**
  128557. * Captures a screenshot of the current rendering
  128558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128559. * @param engine defines the rendering engine
  128560. * @param camera defines the source camera
  128561. * @param size This parameter can be set to a single number or to an object with the
  128562. * following (optional) properties: precision, width, height. If a single number is passed,
  128563. * it will be used for both width and height. If an object is passed, the screenshot size
  128564. * will be derived from the parameters. The precision property is a multiplier allowing
  128565. * rendering at a higher or lower resolution
  128566. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128567. * Check your browser for supported MIME types
  128568. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128569. * to the src parameter of an <img> to display it
  128570. */
  128571. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  128572. /**
  128573. * Generates an image screenshot from the specified camera.
  128574. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128575. * @param engine The engine to use for rendering
  128576. * @param camera The camera to use for rendering
  128577. * @param size This parameter can be set to a single number or to an object with the
  128578. * following (optional) properties: precision, width, height. If a single number is passed,
  128579. * it will be used for both width and height. If an object is passed, the screenshot size
  128580. * will be derived from the parameters. The precision property is a multiplier allowing
  128581. * rendering at a higher or lower resolution
  128582. * @param successCallback The callback receives a single parameter which contains the
  128583. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128584. * src parameter of an <img> to display it
  128585. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128586. * Check your browser for supported MIME types
  128587. * @param samples Texture samples (default: 1)
  128588. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128589. * @param fileName A name for for the downloaded file.
  128590. */
  128591. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128592. /**
  128593. * Generates an image screenshot from the specified camera.
  128594. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128595. * @param engine The engine to use for rendering
  128596. * @param camera The camera to use for rendering
  128597. * @param size This parameter can be set to a single number or to an object with the
  128598. * following (optional) properties: precision, width, height. If a single number is passed,
  128599. * it will be used for both width and height. If an object is passed, the screenshot size
  128600. * will be derived from the parameters. The precision property is a multiplier allowing
  128601. * rendering at a higher or lower resolution
  128602. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128603. * Check your browser for supported MIME types
  128604. * @param samples Texture samples (default: 1)
  128605. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128606. * @param fileName A name for for the downloaded file.
  128607. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128608. * to the src parameter of an <img> to display it
  128609. */
  128610. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128611. /**
  128612. * Gets height and width for screenshot size
  128613. * @private
  128614. */
  128615. private static _getScreenshotSize;
  128616. }
  128617. }
  128618. declare module BABYLON {
  128619. /**
  128620. * A cursor which tracks a point on a path
  128621. */
  128622. export class PathCursor {
  128623. private path;
  128624. /**
  128625. * Stores path cursor callbacks for when an onchange event is triggered
  128626. */
  128627. private _onchange;
  128628. /**
  128629. * The value of the path cursor
  128630. */
  128631. value: number;
  128632. /**
  128633. * The animation array of the path cursor
  128634. */
  128635. animations: Animation[];
  128636. /**
  128637. * Initializes the path cursor
  128638. * @param path The path to track
  128639. */
  128640. constructor(path: Path2);
  128641. /**
  128642. * Gets the cursor point on the path
  128643. * @returns A point on the path cursor at the cursor location
  128644. */
  128645. getPoint(): Vector3;
  128646. /**
  128647. * Moves the cursor ahead by the step amount
  128648. * @param step The amount to move the cursor forward
  128649. * @returns This path cursor
  128650. */
  128651. moveAhead(step?: number): PathCursor;
  128652. /**
  128653. * Moves the cursor behind by the step amount
  128654. * @param step The amount to move the cursor back
  128655. * @returns This path cursor
  128656. */
  128657. moveBack(step?: number): PathCursor;
  128658. /**
  128659. * Moves the cursor by the step amount
  128660. * If the step amount is greater than one, an exception is thrown
  128661. * @param step The amount to move the cursor
  128662. * @returns This path cursor
  128663. */
  128664. move(step: number): PathCursor;
  128665. /**
  128666. * Ensures that the value is limited between zero and one
  128667. * @returns This path cursor
  128668. */
  128669. private ensureLimits;
  128670. /**
  128671. * Runs onchange callbacks on change (used by the animation engine)
  128672. * @returns This path cursor
  128673. */
  128674. private raiseOnChange;
  128675. /**
  128676. * Executes a function on change
  128677. * @param f A path cursor onchange callback
  128678. * @returns This path cursor
  128679. */
  128680. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128681. }
  128682. }
  128683. declare module BABYLON {
  128684. /** @hidden */
  128685. export var blurPixelShader: {
  128686. name: string;
  128687. shader: string;
  128688. };
  128689. }
  128690. declare module BABYLON {
  128691. /** @hidden */
  128692. export var pointCloudVertexDeclaration: {
  128693. name: string;
  128694. shader: string;
  128695. };
  128696. }
  128697. // Mixins
  128698. interface Window {
  128699. mozIndexedDB: IDBFactory;
  128700. webkitIndexedDB: IDBFactory;
  128701. msIndexedDB: IDBFactory;
  128702. webkitURL: typeof URL;
  128703. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128704. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128705. WebGLRenderingContext: WebGLRenderingContext;
  128706. MSGesture: MSGesture;
  128707. CANNON: any;
  128708. AudioContext: AudioContext;
  128709. webkitAudioContext: AudioContext;
  128710. PointerEvent: any;
  128711. Math: Math;
  128712. Uint8Array: Uint8ArrayConstructor;
  128713. Float32Array: Float32ArrayConstructor;
  128714. mozURL: typeof URL;
  128715. msURL: typeof URL;
  128716. VRFrameData: any; // WebVR, from specs 1.1
  128717. DracoDecoderModule: any;
  128718. setImmediate(handler: (...args: any[]) => void): number;
  128719. }
  128720. interface HTMLCanvasElement {
  128721. requestPointerLock(): void;
  128722. msRequestPointerLock?(): void;
  128723. mozRequestPointerLock?(): void;
  128724. webkitRequestPointerLock?(): void;
  128725. /** Track wether a record is in progress */
  128726. isRecording: boolean;
  128727. /** Capture Stream method defined by some browsers */
  128728. captureStream(fps?: number): MediaStream;
  128729. }
  128730. interface CanvasRenderingContext2D {
  128731. msImageSmoothingEnabled: boolean;
  128732. }
  128733. interface MouseEvent {
  128734. mozMovementX: number;
  128735. mozMovementY: number;
  128736. webkitMovementX: number;
  128737. webkitMovementY: number;
  128738. msMovementX: number;
  128739. msMovementY: number;
  128740. }
  128741. interface Navigator {
  128742. mozGetVRDevices: (any: any) => any;
  128743. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128744. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128745. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128746. webkitGetGamepads(): Gamepad[];
  128747. msGetGamepads(): Gamepad[];
  128748. webkitGamepads(): Gamepad[];
  128749. }
  128750. interface HTMLVideoElement {
  128751. mozSrcObject: any;
  128752. }
  128753. interface Math {
  128754. fround(x: number): number;
  128755. imul(a: number, b: number): number;
  128756. }
  128757. interface WebGLRenderingContext {
  128758. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128759. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128760. vertexAttribDivisor(index: number, divisor: number): void;
  128761. createVertexArray(): any;
  128762. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128763. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128764. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128765. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128766. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128767. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128768. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128769. // Queries
  128770. createQuery(): WebGLQuery;
  128771. deleteQuery(query: WebGLQuery): void;
  128772. beginQuery(target: number, query: WebGLQuery): void;
  128773. endQuery(target: number): void;
  128774. getQueryParameter(query: WebGLQuery, pname: number): any;
  128775. getQuery(target: number, pname: number): any;
  128776. MAX_SAMPLES: number;
  128777. RGBA8: number;
  128778. READ_FRAMEBUFFER: number;
  128779. DRAW_FRAMEBUFFER: number;
  128780. UNIFORM_BUFFER: number;
  128781. HALF_FLOAT_OES: number;
  128782. RGBA16F: number;
  128783. RGBA32F: number;
  128784. R32F: number;
  128785. RG32F: number;
  128786. RGB32F: number;
  128787. R16F: number;
  128788. RG16F: number;
  128789. RGB16F: number;
  128790. RED: number;
  128791. RG: number;
  128792. R8: number;
  128793. RG8: number;
  128794. UNSIGNED_INT_24_8: number;
  128795. DEPTH24_STENCIL8: number;
  128796. MIN: number;
  128797. MAX: number;
  128798. /* Multiple Render Targets */
  128799. drawBuffers(buffers: number[]): void;
  128800. readBuffer(src: number): void;
  128801. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128802. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128803. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128804. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128805. // Occlusion Query
  128806. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128807. ANY_SAMPLES_PASSED: number;
  128808. QUERY_RESULT_AVAILABLE: number;
  128809. QUERY_RESULT: number;
  128810. }
  128811. interface WebGLProgram {
  128812. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128813. }
  128814. interface EXT_disjoint_timer_query {
  128815. QUERY_COUNTER_BITS_EXT: number;
  128816. TIME_ELAPSED_EXT: number;
  128817. TIMESTAMP_EXT: number;
  128818. GPU_DISJOINT_EXT: number;
  128819. QUERY_RESULT_EXT: number;
  128820. QUERY_RESULT_AVAILABLE_EXT: number;
  128821. queryCounterEXT(query: WebGLQuery, target: number): void;
  128822. createQueryEXT(): WebGLQuery;
  128823. beginQueryEXT(target: number, query: WebGLQuery): void;
  128824. endQueryEXT(target: number): void;
  128825. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128826. deleteQueryEXT(query: WebGLQuery): void;
  128827. }
  128828. interface WebGLUniformLocation {
  128829. _currentState: any;
  128830. }
  128831. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128832. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128833. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128834. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128835. interface WebGLRenderingContext {
  128836. readonly RASTERIZER_DISCARD: number;
  128837. readonly DEPTH_COMPONENT24: number;
  128838. readonly TEXTURE_3D: number;
  128839. readonly TEXTURE_2D_ARRAY: number;
  128840. readonly TEXTURE_COMPARE_FUNC: number;
  128841. readonly TEXTURE_COMPARE_MODE: number;
  128842. readonly COMPARE_REF_TO_TEXTURE: number;
  128843. readonly TEXTURE_WRAP_R: number;
  128844. readonly HALF_FLOAT: number;
  128845. readonly RGB8: number;
  128846. readonly RED_INTEGER: number;
  128847. readonly RG_INTEGER: number;
  128848. readonly RGB_INTEGER: number;
  128849. readonly RGBA_INTEGER: number;
  128850. readonly R8_SNORM: number;
  128851. readonly RG8_SNORM: number;
  128852. readonly RGB8_SNORM: number;
  128853. readonly RGBA8_SNORM: number;
  128854. readonly R8I: number;
  128855. readonly RG8I: number;
  128856. readonly RGB8I: number;
  128857. readonly RGBA8I: number;
  128858. readonly R8UI: number;
  128859. readonly RG8UI: number;
  128860. readonly RGB8UI: number;
  128861. readonly RGBA8UI: number;
  128862. readonly R16I: number;
  128863. readonly RG16I: number;
  128864. readonly RGB16I: number;
  128865. readonly RGBA16I: number;
  128866. readonly R16UI: number;
  128867. readonly RG16UI: number;
  128868. readonly RGB16UI: number;
  128869. readonly RGBA16UI: number;
  128870. readonly R32I: number;
  128871. readonly RG32I: number;
  128872. readonly RGB32I: number;
  128873. readonly RGBA32I: number;
  128874. readonly R32UI: number;
  128875. readonly RG32UI: number;
  128876. readonly RGB32UI: number;
  128877. readonly RGBA32UI: number;
  128878. readonly RGB10_A2UI: number;
  128879. readonly R11F_G11F_B10F: number;
  128880. readonly RGB9_E5: number;
  128881. readonly RGB10_A2: number;
  128882. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128883. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128884. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128885. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128886. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128887. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128888. 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;
  128889. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128890. readonly TRANSFORM_FEEDBACK: number;
  128891. readonly INTERLEAVED_ATTRIBS: number;
  128892. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128893. createTransformFeedback(): WebGLTransformFeedback;
  128894. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128895. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128896. beginTransformFeedback(primitiveMode: number): void;
  128897. endTransformFeedback(): void;
  128898. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128899. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128900. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128901. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128902. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128903. }
  128904. interface ImageBitmap {
  128905. readonly width: number;
  128906. readonly height: number;
  128907. close(): void;
  128908. }
  128909. interface WebGLQuery extends WebGLObject {
  128910. }
  128911. declare var WebGLQuery: {
  128912. prototype: WebGLQuery;
  128913. new(): WebGLQuery;
  128914. };
  128915. interface WebGLSampler extends WebGLObject {
  128916. }
  128917. declare var WebGLSampler: {
  128918. prototype: WebGLSampler;
  128919. new(): WebGLSampler;
  128920. };
  128921. interface WebGLSync extends WebGLObject {
  128922. }
  128923. declare var WebGLSync: {
  128924. prototype: WebGLSync;
  128925. new(): WebGLSync;
  128926. };
  128927. interface WebGLTransformFeedback extends WebGLObject {
  128928. }
  128929. declare var WebGLTransformFeedback: {
  128930. prototype: WebGLTransformFeedback;
  128931. new(): WebGLTransformFeedback;
  128932. };
  128933. interface WebGLVertexArrayObject extends WebGLObject {
  128934. }
  128935. declare var WebGLVertexArrayObject: {
  128936. prototype: WebGLVertexArrayObject;
  128937. new(): WebGLVertexArrayObject;
  128938. };
  128939. // Type definitions for WebVR API
  128940. // Project: https://w3c.github.io/webvr/
  128941. // Definitions by: six a <https://github.com/lostfictions>
  128942. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128943. interface VRDisplay extends EventTarget {
  128944. /**
  128945. * Dictionary of capabilities describing the VRDisplay.
  128946. */
  128947. readonly capabilities: VRDisplayCapabilities;
  128948. /**
  128949. * z-depth defining the far plane of the eye view frustum
  128950. * enables mapping of values in the render target depth
  128951. * attachment to scene coordinates. Initially set to 10000.0.
  128952. */
  128953. depthFar: number;
  128954. /**
  128955. * z-depth defining the near plane of the eye view frustum
  128956. * enables mapping of values in the render target depth
  128957. * attachment to scene coordinates. Initially set to 0.01.
  128958. */
  128959. depthNear: number;
  128960. /**
  128961. * An identifier for this distinct VRDisplay. Used as an
  128962. * association point in the Gamepad API.
  128963. */
  128964. readonly displayId: number;
  128965. /**
  128966. * A display name, a user-readable name identifying it.
  128967. */
  128968. readonly displayName: string;
  128969. readonly isConnected: boolean;
  128970. readonly isPresenting: boolean;
  128971. /**
  128972. * If this VRDisplay supports room-scale experiences, the optional
  128973. * stage attribute contains details on the room-scale parameters.
  128974. */
  128975. readonly stageParameters: VRStageParameters | null;
  128976. /**
  128977. * Passing the value returned by `requestAnimationFrame` to
  128978. * `cancelAnimationFrame` will unregister the callback.
  128979. * @param handle Define the hanle of the request to cancel
  128980. */
  128981. cancelAnimationFrame(handle: number): void;
  128982. /**
  128983. * Stops presenting to the VRDisplay.
  128984. * @returns a promise to know when it stopped
  128985. */
  128986. exitPresent(): Promise<void>;
  128987. /**
  128988. * Return the current VREyeParameters for the given eye.
  128989. * @param whichEye Define the eye we want the parameter for
  128990. * @returns the eye parameters
  128991. */
  128992. getEyeParameters(whichEye: string): VREyeParameters;
  128993. /**
  128994. * Populates the passed VRFrameData with the information required to render
  128995. * the current frame.
  128996. * @param frameData Define the data structure to populate
  128997. * @returns true if ok otherwise false
  128998. */
  128999. getFrameData(frameData: VRFrameData): boolean;
  129000. /**
  129001. * Get the layers currently being presented.
  129002. * @returns the list of VR layers
  129003. */
  129004. getLayers(): VRLayer[];
  129005. /**
  129006. * Return a VRPose containing the future predicted pose of the VRDisplay
  129007. * when the current frame will be presented. The value returned will not
  129008. * change until JavaScript has returned control to the browser.
  129009. *
  129010. * The VRPose will contain the position, orientation, velocity,
  129011. * and acceleration of each of these properties.
  129012. * @returns the pose object
  129013. */
  129014. getPose(): VRPose;
  129015. /**
  129016. * Return the current instantaneous pose of the VRDisplay, with no
  129017. * prediction applied.
  129018. * @returns the current instantaneous pose
  129019. */
  129020. getImmediatePose(): VRPose;
  129021. /**
  129022. * The callback passed to `requestAnimationFrame` will be called
  129023. * any time a new frame should be rendered. When the VRDisplay is
  129024. * presenting the callback will be called at the native refresh
  129025. * rate of the HMD. When not presenting this function acts
  129026. * identically to how window.requestAnimationFrame acts. Content should
  129027. * make no assumptions of frame rate or vsync behavior as the HMD runs
  129028. * asynchronously from other displays and at differing refresh rates.
  129029. * @param callback Define the eaction to run next frame
  129030. * @returns the request handle it
  129031. */
  129032. requestAnimationFrame(callback: FrameRequestCallback): number;
  129033. /**
  129034. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  129035. * Repeat calls while already presenting will update the VRLayers being displayed.
  129036. * @param layers Define the list of layer to present
  129037. * @returns a promise to know when the request has been fulfilled
  129038. */
  129039. requestPresent(layers: VRLayer[]): Promise<void>;
  129040. /**
  129041. * Reset the pose for this display, treating its current position and
  129042. * orientation as the "origin/zero" values. VRPose.position,
  129043. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  129044. * updated when calling resetPose(). This should be called in only
  129045. * sitting-space experiences.
  129046. */
  129047. resetPose(): void;
  129048. /**
  129049. * The VRLayer provided to the VRDisplay will be captured and presented
  129050. * in the HMD. Calling this function has the same effect on the source
  129051. * canvas as any other operation that uses its source image, and canvases
  129052. * created without preserveDrawingBuffer set to true will be cleared.
  129053. * @param pose Define the pose to submit
  129054. */
  129055. submitFrame(pose?: VRPose): void;
  129056. }
  129057. declare var VRDisplay: {
  129058. prototype: VRDisplay;
  129059. new(): VRDisplay;
  129060. };
  129061. interface VRLayer {
  129062. leftBounds?: number[] | Float32Array | null;
  129063. rightBounds?: number[] | Float32Array | null;
  129064. source?: HTMLCanvasElement | null;
  129065. }
  129066. interface VRDisplayCapabilities {
  129067. readonly canPresent: boolean;
  129068. readonly hasExternalDisplay: boolean;
  129069. readonly hasOrientation: boolean;
  129070. readonly hasPosition: boolean;
  129071. readonly maxLayers: number;
  129072. }
  129073. interface VREyeParameters {
  129074. /** @deprecated */
  129075. readonly fieldOfView: VRFieldOfView;
  129076. readonly offset: Float32Array;
  129077. readonly renderHeight: number;
  129078. readonly renderWidth: number;
  129079. }
  129080. interface VRFieldOfView {
  129081. readonly downDegrees: number;
  129082. readonly leftDegrees: number;
  129083. readonly rightDegrees: number;
  129084. readonly upDegrees: number;
  129085. }
  129086. interface VRFrameData {
  129087. readonly leftProjectionMatrix: Float32Array;
  129088. readonly leftViewMatrix: Float32Array;
  129089. readonly pose: VRPose;
  129090. readonly rightProjectionMatrix: Float32Array;
  129091. readonly rightViewMatrix: Float32Array;
  129092. readonly timestamp: number;
  129093. }
  129094. interface VRPose {
  129095. readonly angularAcceleration: Float32Array | null;
  129096. readonly angularVelocity: Float32Array | null;
  129097. readonly linearAcceleration: Float32Array | null;
  129098. readonly linearVelocity: Float32Array | null;
  129099. readonly orientation: Float32Array | null;
  129100. readonly position: Float32Array | null;
  129101. readonly timestamp: number;
  129102. }
  129103. interface VRStageParameters {
  129104. sittingToStandingTransform?: Float32Array;
  129105. sizeX?: number;
  129106. sizeY?: number;
  129107. }
  129108. interface Navigator {
  129109. getVRDisplays(): Promise<VRDisplay[]>;
  129110. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  129111. }
  129112. interface Window {
  129113. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  129114. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  129115. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  129116. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  129117. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  129118. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  129119. }
  129120. interface Gamepad {
  129121. readonly displayId: number;
  129122. }
  129123. type XRSessionMode =
  129124. | "inline"
  129125. | "immersive-vr"
  129126. | "immersive-ar";
  129127. type XRReferenceSpaceType =
  129128. | "viewer"
  129129. | "local"
  129130. | "local-floor"
  129131. | "bounded-floor"
  129132. | "unbounded";
  129133. type XREnvironmentBlendMode =
  129134. | "opaque"
  129135. | "additive"
  129136. | "alpha-blend";
  129137. type XRVisibilityState =
  129138. | "visible"
  129139. | "visible-blurred"
  129140. | "hidden";
  129141. type XRHandedness =
  129142. | "none"
  129143. | "left"
  129144. | "right";
  129145. type XRTargetRayMode =
  129146. | "gaze"
  129147. | "tracked-pointer"
  129148. | "screen";
  129149. type XREye =
  129150. | "none"
  129151. | "left"
  129152. | "right";
  129153. interface XRSpace extends EventTarget {
  129154. }
  129155. interface XRRenderState {
  129156. depthNear?: number;
  129157. depthFar?: number;
  129158. inlineVerticalFieldOfView?: number;
  129159. baseLayer?: XRWebGLLayer;
  129160. }
  129161. interface XRInputSource {
  129162. handedness: XRHandedness;
  129163. targetRayMode: XRTargetRayMode;
  129164. targetRaySpace: XRSpace;
  129165. gripSpace: XRSpace | undefined;
  129166. gamepad: Gamepad | undefined;
  129167. profiles: Array<string>;
  129168. }
  129169. interface XRSession {
  129170. addEventListener: Function;
  129171. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  129172. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  129173. requestAnimationFrame: Function;
  129174. end(): Promise<void>;
  129175. renderState: XRRenderState;
  129176. inputSources: Array<XRInputSource>;
  129177. }
  129178. interface XRReferenceSpace extends XRSpace {
  129179. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  129180. onreset: any;
  129181. }
  129182. interface XRFrame {
  129183. session: XRSession;
  129184. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  129185. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  129186. }
  129187. interface XRViewerPose extends XRPose {
  129188. views: Array<XRView>;
  129189. }
  129190. interface XRPose {
  129191. transform: XRRigidTransform;
  129192. emulatedPosition: boolean;
  129193. }
  129194. declare var XRWebGLLayer: {
  129195. prototype: XRWebGLLayer;
  129196. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  129197. };
  129198. interface XRWebGLLayer {
  129199. framebuffer: WebGLFramebuffer;
  129200. framebufferWidth: number;
  129201. framebufferHeight: number;
  129202. getViewport: Function;
  129203. }
  129204. interface XRRigidTransform {
  129205. position: DOMPointReadOnly;
  129206. orientation: DOMPointReadOnly;
  129207. matrix: Float32Array;
  129208. inverse: XRRigidTransform;
  129209. }
  129210. interface XRView {
  129211. eye: XREye;
  129212. projectionMatrix: Float32Array;
  129213. transform: XRRigidTransform;
  129214. }
  129215. interface XRInputSourceChangeEvent {
  129216. session: XRSession;
  129217. removed: Array<XRInputSource>;
  129218. added: Array<XRInputSource>;
  129219. }